mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-28 19:04:07 +08:00
Static assert for TX queue entry size
This commit is contained in:
parent
366ae6397e
commit
9559a9506a
30
libuavcan/include/uavcan/internal/static_assert.hpp
Normal file
30
libuavcan/include/uavcan/internal/static_assert.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* StaticAssert<expression>::check();
|
||||
*/
|
||||
template <bool VALUE>
|
||||
struct StaticAssert
|
||||
{
|
||||
#if __CDT_PARSER__
|
||||
static void check() { assert(0); }
|
||||
#endif
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StaticAssert<true>
|
||||
{
|
||||
static void check() { }
|
||||
};
|
||||
|
||||
}
|
||||
@ -9,6 +9,7 @@
|
||||
#include <stdint.h>
|
||||
#include <uavcan/internal/linked_list.hpp>
|
||||
#include <uavcan/internal/dynamic_memory.hpp>
|
||||
#include <uavcan/internal/static_assert.hpp>
|
||||
#include <uavcan/can_driver.hpp>
|
||||
#include <uavcan/system_clock.hpp>
|
||||
|
||||
@ -45,6 +46,7 @@ public:
|
||||
, qos(uint8_t(qos))
|
||||
{
|
||||
assert(qos == VOLATILE || qos == PERSISTENT);
|
||||
StaticAssert<sizeof(Entry) <= 32>::check();
|
||||
}
|
||||
|
||||
bool isExpired(uint64_t monotonic_timestamp) const { return monotonic_timestamp > monotonic_deadline; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user