mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13085 from pea-pod/remove-deprecated-mbed-assert
Change MBED_STATIC_ASSERTs version for built-inpull/13957/head
commit
57bbb4739b
|
@ -141,7 +141,7 @@ struct Duration {
|
||||||
Duration(Duration<OtherRep, OtherTB, OtherRange, OtherF> other) :
|
Duration(Duration<OtherRep, OtherTB, OtherRange, OtherF> other) :
|
||||||
duration(clamp(other.value() * (OtherTB / TB)))
|
duration(clamp(other.value() * (OtherTB / TB)))
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(OtherTB >= TB && (OtherTB % TB) == 0, "Incompatible units");
|
static_assert(OtherTB >= TB && (OtherTB % TB) == 0, "Incompatible units");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -431,7 +431,7 @@ protected:
|
||||||
// Conversion function for network stacks
|
// Conversion function for network stacks
|
||||||
NetworkStack *nsapi_create_stack(nsapi_stack_t *stack)
|
NetworkStack *nsapi_create_stack(nsapi_stack_t *stack)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(sizeof stack->_stack_buffer >= sizeof(NetworkStackWrapper),
|
static_assert(sizeof stack->_stack_buffer >= sizeof(NetworkStackWrapper),
|
||||||
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
|
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
|
||||||
return new (stack->_stack_buffer) NetworkStackWrapper;
|
return new (stack->_stack_buffer) NetworkStackWrapper;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace mbed {
|
||||||
|
|
||||||
SingletonPtr<PlatformMutex> mbed_crc_mutex;
|
SingletonPtr<PlatformMutex> mbed_crc_mutex;
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(MBED_CRC_TABLE_SIZE == 0 || MBED_CRC_TABLE_SIZE == 16 || MBED_CRC_TABLE_SIZE == 256,
|
static_assert(MBED_CRC_TABLE_SIZE == 0 || MBED_CRC_TABLE_SIZE == 16 || MBED_CRC_TABLE_SIZE == 256,
|
||||||
"Configuration setting drivers.crc-table-size must be set to 0, 16 or 256");
|
"Configuration setting drivers.crc-table-size must be set to 0, 16 or 256");
|
||||||
|
|
||||||
#if MBED_CRC_TABLE_SIZE > 0
|
#if MBED_CRC_TABLE_SIZE > 0
|
||||||
|
|
||||||
|
|
|
@ -106,10 +106,10 @@ static void equeue_tick_update()
|
||||||
|
|
||||||
void equeue_tick_init()
|
void equeue_tick_init()
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(sizeof(equeue_timer) >= sizeof(ALIAS_TIMER),
|
static_assert(sizeof(equeue_timer) >= sizeof(ALIAS_TIMER),
|
||||||
"The equeue_timer buffer must fit the class Timer");
|
"The equeue_timer buffer must fit the class Timer");
|
||||||
MBED_STATIC_ASSERT(sizeof(equeue_ticker) >= sizeof(ALIAS_TICKER),
|
static_assert(sizeof(equeue_ticker) >= sizeof(ALIAS_TICKER),
|
||||||
"The equeue_ticker buffer must fit the class Ticker");
|
"The equeue_ticker buffer must fit the class Ticker");
|
||||||
ALIAS_TIMER *timer = new (equeue_timer) ALIAS_TIMER;
|
ALIAS_TIMER *timer = new (equeue_timer) ALIAS_TIMER;
|
||||||
ALIAS_TICKER *ticker = new (equeue_ticker) ALIAS_TICKER;
|
ALIAS_TICKER *ticker = new (equeue_ticker) ALIAS_TICKER;
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void equeue_mutex_unlock(equeue_mutex_t *m)
|
||||||
|
|
||||||
#include "rtos/EventFlags.h"
|
#include "rtos/EventFlags.h"
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(sizeof(equeue_sema_t) == sizeof(rtos::EventFlags), "equeue_sema_t / rtos::EventFlags mismatch");
|
static_assert(sizeof(equeue_sema_t) == sizeof(rtos::EventFlags), "equeue_sema_t / rtos::EventFlags mismatch");
|
||||||
|
|
||||||
int equeue_sema_create(equeue_sema_t *s)
|
int equeue_sema_create(equeue_sema_t *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace v1 {
|
||||||
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
||||||
defaults(defaults)
|
defaults(defaults)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
sizeof(CaseType) == sizeof(Case),
|
sizeof(CaseType) == sizeof(Case),
|
||||||
"CaseType and Case should have the same size"
|
"CaseType and Case should have the same size"
|
||||||
);
|
);
|
||||||
|
@ -69,7 +69,7 @@ namespace v1 {
|
||||||
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
||||||
defaults(defaults)
|
defaults(defaults)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
sizeof(CaseType) == sizeof(Case),
|
sizeof(CaseType) == sizeof(Case),
|
||||||
"CaseType and Case should have the same size"
|
"CaseType and Case should have the same size"
|
||||||
);
|
);
|
||||||
|
@ -83,7 +83,7 @@ namespace v1 {
|
||||||
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
||||||
defaults(defaults)
|
defaults(defaults)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
sizeof(CaseType) == sizeof(Case),
|
sizeof(CaseType) == sizeof(Case),
|
||||||
"CaseType and Case should have the same size"
|
"CaseType and Case should have the same size"
|
||||||
);
|
);
|
||||||
|
@ -98,7 +98,7 @@ namespace v1 {
|
||||||
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
||||||
defaults(defaults)
|
defaults(defaults)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
sizeof(CaseType) == sizeof(Case),
|
sizeof(CaseType) == sizeof(Case),
|
||||||
"CaseType and Case should have the same size"
|
"CaseType and Case should have the same size"
|
||||||
);
|
);
|
||||||
|
@ -122,7 +122,7 @@ namespace v1 {
|
||||||
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
||||||
defaults(defaults)
|
defaults(defaults)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
sizeof(CaseType) == sizeof(Case),
|
sizeof(CaseType) == sizeof(Case),
|
||||||
"CaseType and Case should have the same size"
|
"CaseType and Case should have the same size"
|
||||||
);
|
);
|
||||||
|
@ -137,7 +137,7 @@ namespace v1 {
|
||||||
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
||||||
defaults(defaults)
|
defaults(defaults)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
sizeof(CaseType) == sizeof(Case),
|
sizeof(CaseType) == sizeof(Case),
|
||||||
"CaseType and Case should have the same size"
|
"CaseType and Case should have the same size"
|
||||||
);
|
);
|
||||||
|
@ -153,7 +153,7 @@ namespace v1 {
|
||||||
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
|
||||||
defaults(defaults)
|
defaults(defaults)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
sizeof(CaseType) == sizeof(Case),
|
sizeof(CaseType) == sizeof(Case),
|
||||||
"CaseType and Case should have the same size"
|
"CaseType and Case should have the same size"
|
||||||
);
|
);
|
||||||
|
|
|
@ -42,8 +42,8 @@ static const PinList ff_arduino_list = {
|
||||||
ff_arduino_pins
|
ff_arduino_pins
|
||||||
};
|
};
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]) == sizeof(ff_arduino_names) / sizeof(ff_arduino_names[0]),
|
static_assert(sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]) == sizeof(ff_arduino_names) / sizeof(ff_arduino_names[0]),
|
||||||
"Arrays must have the same length");
|
"Arrays must have the same length");
|
||||||
|
|
||||||
const PinList *pinmap_ff_arduino_pins()
|
const PinList *pinmap_ff_arduino_pins()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#endif
|
#endif
|
||||||
#define MBED_MPU_RAM_START (MBED_MPU_ROM_END + 1)
|
#define MBED_MPU_RAM_START (MBED_MPU_ROM_END + 1)
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
MBED_MPU_ROM_END == 0x04000000 - 1 ||
|
MBED_MPU_ROM_END == 0x04000000 - 1 ||
|
||||||
MBED_MPU_ROM_END == 0x08000000 - 1 ||
|
MBED_MPU_ROM_END == 0x08000000 - 1 ||
|
||||||
MBED_MPU_ROM_END == 0x0C000000 - 1 ||
|
MBED_MPU_ROM_END == 0x0C000000 - 1 ||
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
#endif
|
#endif
|
||||||
#define MBED_MPU_RAM_START (MBED_MPU_ROM_END + 1)
|
#define MBED_MPU_RAM_START (MBED_MPU_ROM_END + 1)
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(MBED_MPU_ROM_END <= 0x20000000 - 1,
|
static_assert(MBED_MPU_ROM_END <= 0x20000000 - 1,
|
||||||
"Unsupported value for MBED_MPU_ROM_END");
|
"Unsupported value for MBED_MPU_ROM_END");
|
||||||
|
|
||||||
void mbed_mpu_init()
|
void mbed_mpu_init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <mstd_memory>
|
#include <mstd_memory>
|
||||||
#include <mstd_type_traits>
|
#include <mstd_type_traits>
|
||||||
#include <mstd_utility>
|
#include <mstd_utility>
|
||||||
#include "platform/mbed_assert.h"
|
|
||||||
#include "platform/mbed_atomic.h"
|
#include "platform/mbed_atomic.h"
|
||||||
#include "platform/mbed_critical.h"
|
#include "platform/mbed_critical.h"
|
||||||
#include "platform/CriticalSectionLock.h"
|
#include "platform/CriticalSectionLock.h"
|
||||||
|
@ -477,7 +476,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
template<typename T, typename A = atomic_container_t<T>>
|
template<typename T, typename A = atomic_container_t<T>>
|
||||||
struct AtomicBaseInt {
|
struct AtomicBaseInt {
|
||||||
MBED_STRUCT_STATIC_ASSERT(sizeof(T) == sizeof(A), "AtomicBaseInt size mismatch");
|
static_assert(sizeof(T) == sizeof(A), "AtomicBaseInt size mismatch");
|
||||||
using value_type = T;
|
using value_type = T;
|
||||||
AtomicBaseInt() noexcept = default;
|
AtomicBaseInt() noexcept = default;
|
||||||
constexpr AtomicBaseInt(T v) noexcept : u(A(v))
|
constexpr AtomicBaseInt(T v) noexcept : u(A(v))
|
||||||
|
|
|
@ -70,12 +70,12 @@ class CircularBuffer {
|
||||||
public:
|
public:
|
||||||
CircularBuffer() : _head(0), _tail(0), _full(false)
|
CircularBuffer() : _head(0), _tail(0), _full(false)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
internal::is_unsigned<CounterType>::value,
|
internal::is_unsigned<CounterType>::value,
|
||||||
"CounterType must be unsigned"
|
"CounterType must be unsigned"
|
||||||
);
|
);
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
(sizeof(CounterType) >= sizeof(uint32_t)) ||
|
(sizeof(CounterType) >= sizeof(uint32_t)) ||
|
||||||
(BufferSize < (((uint64_t) 1) << (sizeof(CounterType) * 8))),
|
(BufferSize < (((uint64_t) 1) << (sizeof(CounterType) * 8))),
|
||||||
"Invalid BufferSize for the CounterType"
|
"Invalid BufferSize for the CounterType"
|
||||||
|
|
|
@ -249,7 +249,7 @@ struct Span {
|
||||||
*/
|
*/
|
||||||
static const index_type extent = Extent;
|
static const index_type extent = Extent;
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(Extent >= 0, "Invalid extent for a Span");
|
static_assert(Extent >= 0, "Invalid extent for a Span");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an empty Span.
|
* Construct an empty Span.
|
||||||
|
@ -262,7 +262,7 @@ struct Span {
|
||||||
Span() :
|
Span() :
|
||||||
_data(NULL)
|
_data(NULL)
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
Extent == 0,
|
Extent == 0,
|
||||||
"Cannot default construct a static-extent Span (unless Extent is 0)"
|
"Cannot default construct a static-extent Span (unless Extent is 0)"
|
||||||
);
|
);
|
||||||
|
@ -333,7 +333,7 @@ struct Span {
|
||||||
Span(const Span<OtherElementType, Extent> &other):
|
Span(const Span<OtherElementType, Extent> &other):
|
||||||
_data(other.data())
|
_data(other.data())
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
(span_detail::is_convertible<OtherElementType (*)[1], ElementType (*)[1]>::value),
|
(span_detail::is_convertible<OtherElementType (*)[1], ElementType (*)[1]>::value),
|
||||||
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
|
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
|
||||||
);
|
);
|
||||||
|
@ -440,7 +440,7 @@ struct Span {
|
||||||
template<ptrdiff_t Count>
|
template<ptrdiff_t Count>
|
||||||
Span<element_type, Count> first() const
|
Span<element_type, Count> first() const
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
(0 <= Count) && (Count <= Extent),
|
(0 <= Count) && (Count <= Extent),
|
||||||
"Invalid subspan extent"
|
"Invalid subspan extent"
|
||||||
);
|
);
|
||||||
|
@ -459,7 +459,7 @@ struct Span {
|
||||||
template<ptrdiff_t Count>
|
template<ptrdiff_t Count>
|
||||||
Span<element_type, Count> last() const
|
Span<element_type, Count> last() const
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
(0 <= Count) && (Count <= Extent),
|
(0 <= Count) && (Count <= Extent),
|
||||||
"Invalid subspan extent"
|
"Invalid subspan extent"
|
||||||
);
|
);
|
||||||
|
@ -484,11 +484,11 @@ struct Span {
|
||||||
Span<element_type, Count == SPAN_DYNAMIC_EXTENT ? Extent - Offset : Count>
|
Span<element_type, Count == SPAN_DYNAMIC_EXTENT ? Extent - Offset : Count>
|
||||||
subspan() const
|
subspan() const
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
0 <= Offset && Offset <= Extent,
|
0 <= Offset && Offset <= Extent,
|
||||||
"Invalid subspan offset"
|
"Invalid subspan offset"
|
||||||
);
|
);
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
(Count == SPAN_DYNAMIC_EXTENT) ||
|
(Count == SPAN_DYNAMIC_EXTENT) ||
|
||||||
(0 <= Count && (Count + Offset) <= Extent),
|
(0 <= Count && (Count + Offset) <= Extent),
|
||||||
"Invalid subspan count"
|
"Invalid subspan count"
|
||||||
|
@ -678,7 +678,7 @@ struct Span<ElementType, SPAN_DYNAMIC_EXTENT> {
|
||||||
Span(const Span<OtherElementType, OtherExtent> &other):
|
Span(const Span<OtherElementType, OtherExtent> &other):
|
||||||
_data(other.data()), _size(other.size())
|
_data(other.data()), _size(other.size())
|
||||||
{
|
{
|
||||||
MBED_STATIC_ASSERT(
|
static_assert(
|
||||||
(span_detail::is_convertible<OtherElementType (*)[1], ElementType (*)[1]>::value),
|
(span_detail::is_convertible<OtherElementType (*)[1], ElementType (*)[1]>::value),
|
||||||
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
|
"OtherElementType(*)[] should be convertible to ElementType (*)[]"
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#ifndef MBED_ASSERT_H
|
#ifndef MBED_ASSERT_H
|
||||||
#define MBED_ASSERT_H
|
#define MBED_ASSERT_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include "platform/mbed_toolchain.h"
|
#include "platform/mbed_toolchain.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -70,6 +71,10 @@ do { \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ARM Compiler 6 currently fails to define `static_assert` in assert.h; correct for this
|
||||||
|
#if !defined __cplusplus && !defined static_assert
|
||||||
|
#define static_assert _Static_assert
|
||||||
|
#endif
|
||||||
|
|
||||||
/** MBED_STATIC_ASSERT
|
/** MBED_STATIC_ASSERT
|
||||||
* Declare compile-time assertions, results in compile-time error if condition is false
|
* Declare compile-time assertions, results in compile-time error if condition is false
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
* master branch code
|
* master branch code
|
||||||
*/
|
*/
|
||||||
#define MBED_VERSION_CHECK(major, minor, patch) do { \
|
#define MBED_VERSION_CHECK(major, minor, patch) do { \
|
||||||
MBED_STATIC_ASSERT((MBED_VERSION >= MBED_ENCODE_VERSION((major),(minor),(patch))), "Incompatible mbed-os version detected!!"); \
|
static_assert((MBED_VERSION >= MBED_ENCODE_VERSION((major),(minor),(patch))), "Incompatible mbed-os version detected!!"); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
#include "platform/internal/CThunkBase.h"
|
#include "platform/internal/CThunkBase.h"
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX < 256, "MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX must be less than 256");
|
static_assert(MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX < 256, "MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX must be less than 256");
|
||||||
MBED_STATIC_ASSERT(MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX > 0, "MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX must be greater than 0");
|
static_assert(MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX > 0, "MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX must be greater than 0");
|
||||||
|
|
||||||
#define ENABLE_N(N) ((MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX & N) ? 1 : 0)
|
#define ENABLE_N(N) ((MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX & N) ? 1 : 0)
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,7 @@ void SysTimer<Period, IRQ>::handler()
|
||||||
|
|
||||||
#if MBED_CONF_RTOS_PRESENT
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
/* Whatever the OS wants (in case it isn't 1ms) */
|
/* Whatever the OS wants (in case it isn't 1ms) */
|
||||||
MBED_STATIC_ASSERT(1000000 % OS_TICK_FREQ == 0, "OS_TICK_FREQ must be a divisor of 1000000 for correct tick calculations");
|
static_assert(1000000 % OS_TICK_FREQ == 0, "OS_TICK_FREQ must be a divisor of 1000000 for correct tick calculations");
|
||||||
#define OS_TICK_US (1000000 / OS_TICK_FREQ)
|
#define OS_TICK_US (1000000 / OS_TICK_FREQ)
|
||||||
#if OS_TICK_US != 1000
|
#if OS_TICK_US != 1000
|
||||||
template class SysTimer<std::ratio_multiply<std::ratio<OS_TICK_US>, std::micro>>;
|
template class SysTimer<std::ratio_multiply<std::ratio<OS_TICK_US>, std::micro>>;
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#include "platform/mbed_critical.h"
|
#include "platform/mbed_critical.h"
|
||||||
|
|
||||||
/* Inline bool implementations in the header use uint8_t versions to manipulate the bool */
|
/* Inline bool implementations in the header use uint8_t versions to manipulate the bool */
|
||||||
MBED_STATIC_ASSERT(sizeof(bool) == sizeof(uint8_t), "Surely bool is a byte");
|
static_assert(sizeof(bool) == sizeof(uint8_t), "Surely bool is a byte");
|
||||||
|
|
||||||
/* Inline implementations in the header use uint32_t versions to manipulate pointers */
|
/* Inline implementations in the header use uint32_t versions to manipulate pointers */
|
||||||
MBED_STATIC_ASSERT(sizeof(void *) == sizeof(uint32_t), "Alas, pointers must be 32-bit");
|
static_assert(sizeof(void *) == sizeof(uint32_t), "Alas, pointers must be 32-bit");
|
||||||
|
|
||||||
|
|
||||||
#define DO_MBED_LOCKED_OP(name, OP, retValue, T, fn_suffix) \
|
#define DO_MBED_LOCKED_OP(name, OP, retValue, T, fn_suffix) \
|
||||||
|
|
|
@ -510,7 +510,7 @@ extern "C" std::FILE *fdopen(int fildes, const char *mode)
|
||||||
{
|
{
|
||||||
// This is to avoid scanf and the bloat it brings.
|
// This is to avoid scanf and the bloat it brings.
|
||||||
char buf[1 + sizeof fildes]; /* @(integer) */
|
char buf[1 + sizeof fildes]; /* @(integer) */
|
||||||
MBED_STATIC_ASSERT(sizeof buf == 5, "Integers should be 4 bytes.");
|
static_assert(sizeof buf == 5, "Integers should be 4 bytes.");
|
||||||
buf[0] = '@';
|
buf[0] = '@';
|
||||||
memcpy(buf + 1, &fildes, sizeof fildes);
|
memcpy(buf + 1, &fildes, sizeof fildes);
|
||||||
|
|
||||||
|
|
|
@ -22,36 +22,36 @@
|
||||||
// multiple asserts are used to guarantee no conflicts occur in generated labels
|
// multiple asserts are used to guarantee no conflicts occur in generated labels
|
||||||
|
|
||||||
// Test for static asserts in global context
|
// Test for static asserts in global context
|
||||||
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
static_assert(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
MBED_STATIC_ASSERT(2 + 2 == 4,
|
static_assert(2 + 2 == 4,
|
||||||
"Hopefully the universe is mathematically consistent");
|
"Hopefully the universe is mathematically consistent");
|
||||||
MBED_STATIC_ASSERT(THE_ANSWER == 42,
|
static_assert(THE_ANSWER == 42,
|
||||||
"Said Deep Thought, with infinite majesty and calm");
|
"Said Deep Thought, with infinite majesty and calm");
|
||||||
|
|
||||||
struct test {
|
struct test {
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
// Test for static asserts in struct context
|
// Test for static asserts in struct context
|
||||||
MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
static_assert(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4,
|
static_assert(2 + 2 == 4,
|
||||||
"Hopefully the universe is mathematically consistent");
|
"Hopefully the universe is mathematically consistent");
|
||||||
MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42,
|
static_assert(THE_ANSWER == 42,
|
||||||
"Said Deep Thought, with infinite majesty and calm");
|
"Said Deep Thought, with infinite majesty and calm");
|
||||||
};
|
};
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
|
static_assert(sizeof(struct test) == sizeof(int),
|
||||||
"Static assertions should not change the size of a struct");
|
"Static assertions should not change the size of a struct");
|
||||||
|
|
||||||
void doit_c(void)
|
void doit_c(void)
|
||||||
{
|
{
|
||||||
// Test for static asserts in function context
|
// Test for static asserts in function context
|
||||||
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
static_assert(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
MBED_STATIC_ASSERT(2 + 2 == 4,
|
static_assert(2 + 2 == 4,
|
||||||
"Hopefully the universe is mathematically consistent");
|
"Hopefully the universe is mathematically consistent");
|
||||||
MBED_STATIC_ASSERT(THE_ANSWER == 42,
|
static_assert(THE_ANSWER == 42,
|
||||||
"Said Deep Thought, with infinite majesty and calm");
|
"Said Deep Thought, with infinite majesty and calm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,43 +22,43 @@
|
||||||
// multiple asserts are used to guarantee no conflicts occur in generated labels
|
// multiple asserts are used to guarantee no conflicts occur in generated labels
|
||||||
|
|
||||||
// Test for static asserts in global context
|
// Test for static asserts in global context
|
||||||
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
static_assert(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
MBED_STATIC_ASSERT(2 + 2 == 4,
|
static_assert(2 + 2 == 4,
|
||||||
"Hopefully the universe is mathematically consistent");
|
"Hopefully the universe is mathematically consistent");
|
||||||
MBED_STATIC_ASSERT(THE_ANSWER == 42,
|
static_assert(THE_ANSWER == 42,
|
||||||
"Said Deep Thought, with infinite majesty and calm");
|
"Said Deep Thought, with infinite majesty and calm");
|
||||||
|
|
||||||
struct test {
|
struct test {
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
// Test for static asserts in struct context
|
// Test for static asserts in struct context
|
||||||
MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
static_assert(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4,
|
static_assert(2 + 2 == 4,
|
||||||
"Hopefully the universe is mathematically consistent");
|
"Hopefully the universe is mathematically consistent");
|
||||||
MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42,
|
static_assert(THE_ANSWER == 42,
|
||||||
"Said Deep Thought, with infinite majesty and calm");
|
"Said Deep Thought, with infinite majesty and calm");
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
static_assert(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
MBED_STATIC_ASSERT(2 + 2 == 4,
|
static_assert(2 + 2 == 4,
|
||||||
"Hopefully the universe is mathematically consistent");
|
"Hopefully the universe is mathematically consistent");
|
||||||
MBED_STATIC_ASSERT(THE_ANSWER == 42,
|
static_assert(THE_ANSWER == 42,
|
||||||
"Said Deep Thought, with infinite majesty and calm");
|
"Said Deep Thought, with infinite majesty and calm");
|
||||||
};
|
};
|
||||||
|
|
||||||
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
|
static_assert(sizeof(struct test) == sizeof(int),
|
||||||
"Static assertions should not change the size of a struct");
|
"Static assertions should not change the size of a struct");
|
||||||
|
|
||||||
void doit_c(void)
|
void doit_c(void)
|
||||||
{
|
{
|
||||||
// Test for static asserts in function context
|
// Test for static asserts in function context
|
||||||
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
static_assert(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
MBED_STATIC_ASSERT(2 + 2 == 4,
|
static_assert(2 + 2 == 4,
|
||||||
"Hopefully the universe is mathematically consistent");
|
"Hopefully the universe is mathematically consistent");
|
||||||
MBED_STATIC_ASSERT(THE_ANSWER == 42,
|
static_assert(THE_ANSWER == 42,
|
||||||
"Said Deep Thought, with infinite majesty and calm");
|
"Said Deep Thought, with infinite majesty and calm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace rtos {
|
||||||
*/
|
*/
|
||||||
template<typename T, uint32_t pool_sz>
|
template<typename T, uint32_t pool_sz>
|
||||||
class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
|
class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
|
||||||
MBED_STATIC_ASSERT(pool_sz > 0, "Invalid memory pool size. Must be greater than 0.");
|
static_assert(pool_sz > 0, "Invalid memory pool size. Must be greater than 0.");
|
||||||
public:
|
public:
|
||||||
/** Create and Initialize a memory pool.
|
/** Create and Initialize a memory pool.
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
#if MBED_CONF_RTOS_PRESENT
|
#if MBED_CONF_RTOS_PRESENT
|
||||||
|
|
||||||
#define ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
|
#define ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos))
|
||||||
MBED_STATIC_ASSERT(ALIGN_UP(0, 8) == 0, "ALIGN_UP macro error");
|
static_assert(ALIGN_UP(0, 8) == 0, "ALIGN_UP macro error");
|
||||||
MBED_STATIC_ASSERT(ALIGN_UP(1, 8) == 8, "ALIGN_UP macro error");
|
static_assert(ALIGN_UP(1, 8) == 8, "ALIGN_UP macro error");
|
||||||
|
|
||||||
#define ALIGN_DOWN(pos, align) ((pos) - ((pos) % (align)))
|
#define ALIGN_DOWN(pos, align) ((pos) - ((pos) % (align)))
|
||||||
MBED_STATIC_ASSERT(ALIGN_DOWN(7, 8) == 0, "ALIGN_DOWN macro error");
|
static_assert(ALIGN_DOWN(7, 8) == 0, "ALIGN_DOWN macro error");
|
||||||
MBED_STATIC_ASSERT(ALIGN_DOWN(8, 8) == 8, "ALIGN_DOWN macro error");
|
static_assert(ALIGN_DOWN(8, 8) == 8, "ALIGN_DOWN macro error");
|
||||||
|
|
||||||
namespace rtos {
|
namespace rtos {
|
||||||
|
|
||||||
|
|
|
@ -264,8 +264,8 @@ SDBlockDevice::SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName c
|
||||||
_card_type = SDCARD_NONE;
|
_card_type = SDCARD_NONE;
|
||||||
|
|
||||||
// Set default to 100kHz for initialisation and 1MHz for data transfer
|
// Set default to 100kHz for initialisation and 1MHz for data transfer
|
||||||
MBED_STATIC_ASSERT(((MBED_CONF_SD_INIT_FREQUENCY >= 100000) && (MBED_CONF_SD_INIT_FREQUENCY <= 400000)),
|
static_assert(((MBED_CONF_SD_INIT_FREQUENCY >= 100000) && (MBED_CONF_SD_INIT_FREQUENCY <= 400000)),
|
||||||
"Initialization frequency should be between 100KHz to 400KHz");
|
"Initialization frequency should be between 100KHz to 400KHz");
|
||||||
_init_sck = MBED_CONF_SD_INIT_FREQUENCY;
|
_init_sck = MBED_CONF_SD_INIT_FREQUENCY;
|
||||||
_transfer_sck = hz;
|
_transfer_sck = hz;
|
||||||
|
|
||||||
|
@ -285,8 +285,8 @@ SDBlockDevice::SDBlockDevice(const spi_pinmap_t &spi_pinmap, PinName cs, uint64_
|
||||||
_card_type = SDCARD_NONE;
|
_card_type = SDCARD_NONE;
|
||||||
|
|
||||||
// Set default to 100kHz for initialisation and 1MHz for data transfer
|
// Set default to 100kHz for initialisation and 1MHz for data transfer
|
||||||
MBED_STATIC_ASSERT(((MBED_CONF_SD_INIT_FREQUENCY >= 100000) && (MBED_CONF_SD_INIT_FREQUENCY <= 400000)),
|
static_assert(((MBED_CONF_SD_INIT_FREQUENCY >= 100000) && (MBED_CONF_SD_INIT_FREQUENCY <= 400000)),
|
||||||
"Initialization frequency should be between 100KHz to 400KHz");
|
"Initialization frequency should be between 100KHz to 400KHz");
|
||||||
_init_sck = MBED_CONF_SD_INIT_FREQUENCY;
|
_init_sck = MBED_CONF_SD_INIT_FREQUENCY;
|
||||||
_transfer_sck = hz;
|
_transfer_sck = hz;
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ const uint32_t gau32ClkSrcTbl[] = {__HXT, __LXT, 0UL, __LIRC, 0UL, __HIRC48, 0UL
|
||||||
/* The configuration of TDB internal storage area defined in "partition_M2351_mem.h"
|
/* The configuration of TDB internal storage area defined in "partition_M2351_mem.h"
|
||||||
* must match "tdb_internal/mbed_lib.json", so it can pass to linker files for
|
* must match "tdb_internal/mbed_lib.json", so it can pass to linker files for
|
||||||
* memory layout check. */
|
* memory layout check. */
|
||||||
MBED_STATIC_ASSERT(NU_TDB_INTERNAL_STORAGE_START == MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS,
|
static_assert(NU_TDB_INTERNAL_STORAGE_START == MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS,
|
||||||
"NU_TDB_INTERNAL_STORAGE_START must be equal to MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS");
|
"NU_TDB_INTERNAL_STORAGE_START must be equal to MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS");
|
||||||
MBED_STATIC_ASSERT(NU_TDB_INTERNAL_STORAGE_SIZE == MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE,
|
static_assert(NU_TDB_INTERNAL_STORAGE_SIZE == MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE,
|
||||||
"NU_TDB_INTERNAL_STORAGE_SIZE must be equal to MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE");
|
"NU_TDB_INTERNAL_STORAGE_SIZE must be equal to MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -161,7 +161,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
||||||
|
|
||||||
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
||||||
MBED_STATIC_ASSERT(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
static_assert(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
||||||
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
||||||
uint32_t irq_type;
|
uint32_t irq_type;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
||||||
|
|
||||||
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
||||||
MBED_STATIC_ASSERT(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
static_assert(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
||||||
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
||||||
uint32_t irq_type;
|
uint32_t irq_type;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
|
@ -158,7 +158,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
||||||
|
|
||||||
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
||||||
MBED_STATIC_ASSERT(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
static_assert(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
||||||
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
||||||
uint32_t irq_type;
|
uint32_t irq_type;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
|
@ -154,7 +154,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
||||||
|
|
||||||
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
||||||
MBED_STATIC_ASSERT(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
static_assert(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
||||||
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
||||||
uint32_t irq_type;
|
uint32_t irq_type;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
|
@ -161,7 +161,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
||||||
|
|
||||||
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
||||||
MBED_STATIC_ASSERT(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
static_assert(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
||||||
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
||||||
uint32_t irq_type;
|
uint32_t irq_type;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
|
@ -176,7 +176,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
||||||
|
|
||||||
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
||||||
MBED_STATIC_ASSERT(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
static_assert(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
||||||
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
||||||
uint32_t irq_type;
|
uint32_t irq_type;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
|
@ -160,7 +160,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
GPIO_T *gpio_base = NU_PORT_BASE(port_index);
|
||||||
|
|
||||||
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
/* We assume BSP has such coding so that we can easily add/remove either irq type. */
|
||||||
MBED_STATIC_ASSERT(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
static_assert(GPIO_INT_BOTH_EDGE == (GPIO_INT_RISING | GPIO_INT_FALLING),
|
||||||
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
"GPIO_INT_BOTH_EDGE must be bitwise OR of GPIO_INT_RISING and GPIO_INT_FALLING");
|
||||||
uint32_t irq_type;
|
uint32_t irq_type;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
Loading…
Reference in New Issue