mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 07:41:36 +08:00
Static assert for TX queue entry size
This commit is contained in:
@@ -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 <stdint.h>
|
||||||
#include <uavcan/internal/linked_list.hpp>
|
#include <uavcan/internal/linked_list.hpp>
|
||||||
#include <uavcan/internal/dynamic_memory.hpp>
|
#include <uavcan/internal/dynamic_memory.hpp>
|
||||||
|
#include <uavcan/internal/static_assert.hpp>
|
||||||
#include <uavcan/can_driver.hpp>
|
#include <uavcan/can_driver.hpp>
|
||||||
#include <uavcan/system_clock.hpp>
|
#include <uavcan/system_clock.hpp>
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ public:
|
|||||||
, qos(uint8_t(qos))
|
, qos(uint8_t(qos))
|
||||||
{
|
{
|
||||||
assert(qos == VOLATILE || qos == PERSISTENT);
|
assert(qos == VOLATILE || qos == PERSISTENT);
|
||||||
|
StaticAssert<sizeof(Entry) <= 32>::check();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isExpired(uint64_t monotonic_timestamp) const { return monotonic_timestamp > monotonic_deadline; }
|
bool isExpired(uint64_t monotonic_timestamp) const { return monotonic_timestamp > monotonic_deadline; }
|
||||||
|
|||||||
Reference in New Issue
Block a user