diff options
author | Damjan Marion <damarion@cisco.com> | 2016-11-07 14:57:50 +0100 |
---|---|---|
committer | Chris Luke <chris_luke@comcast.com> | 2016-11-07 14:53:29 +0000 |
commit | cf4789498d077a2733055b0144c5a4ea2e33d95f (patch) | |
tree | 934847846fa334ea0454953e3d8dbed44bb7f4f9 | |
parent | 109cd5026122c4174ef4b2c8a560d24d6eb07626 (diff) |
use STATIC_ASSERT macro instead of calling _Static_assert directly
Change-Id: Iccae655334b6219d22c325108b0e7f37d1dd68cf
Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r-- | vnet/vnet/dpo/dpo.h | 6 | ||||
-rw-r--r-- | vnet/vnet/dpo/load_balance.h | 4 | ||||
-rw-r--r-- | vnet/vnet/fib/fib_entry.h | 8 | ||||
-rw-r--r-- | vnet/vnet/fib/fib_node.h | 4 | ||||
-rw-r--r-- | vnet/vnet/fib/fib_types.h | 4 | ||||
-rw-r--r-- | vnet/vnet/ip/ip4_mtrie.h | 4 | ||||
-rw-r--r-- | vnet/vnet/ip/lookup.h | 10 | ||||
-rw-r--r-- | vnet/vnet/map/map.h | 4 | ||||
-rw-r--r-- | vppinfra/vppinfra/error_bootstrap.h | 4 |
9 files changed, 26 insertions, 22 deletions
diff --git a/vnet/vnet/dpo/dpo.h b/vnet/vnet/dpo/dpo.h index 2ab936e5f00..9065f88daae 100644 --- a/vnet/vnet/dpo/dpo.h +++ b/vnet/vnet/dpo/dpo.h @@ -154,9 +154,9 @@ typedef struct dpo_id_t_ { index_t dpoi_index; } __attribute__ ((aligned(sizeof(u64)))) dpo_id_t; -_Static_assert(sizeof(dpo_id_t) <= sizeof(u64), - "DPO ID is greater than sizeof u64 " - "atomic updates need to be revisited"); +STATIC_ASSERT(sizeof(dpo_id_t) <= sizeof(u64), + "DPO ID is greater than sizeof u64 " + "atomic updates need to be revisited"); /** * @brief An initialiser for DPos declared on the stack. diff --git a/vnet/vnet/dpo/load_balance.h b/vnet/vnet/dpo/load_balance.h index 4bf3ecffc26..dc6485e688a 100644 --- a/vnet/vnet/dpo/load_balance.h +++ b/vnet/vnet/dpo/load_balance.h @@ -135,8 +135,8 @@ typedef struct load_balance_t_ { dpo_id_t lb_buckets_inline[LB_NUM_INLINE_BUCKETS]; } load_balance_t; -_Static_assert(sizeof(load_balance_t) <= CLIB_CACHE_LINE_BYTES, - "A load_balance object size exceeds one cachline"); +STATIC_ASSERT(sizeof(load_balance_t) <= CLIB_CACHE_LINE_BYTES, + "A load_balance object size exceeds one cachline"); /** * Flags controlling load-balance formatting/display diff --git a/vnet/vnet/fib/fib_entry.h b/vnet/vnet/fib/fib_entry.h index 2b7ea636acb..39b2083ea9a 100644 --- a/vnet/vnet/fib/fib_entry.h +++ b/vnet/vnet/fib/fib_entry.h @@ -120,8 +120,8 @@ typedef enum fib_source_t_ { FIB_SOURCE_LAST = FIB_SOURCE_DEFAULT_ROUTE, } __attribute__ ((packed)) fib_source_t; -_Static_assert (sizeof(fib_source_t) == 1, - "FIB too many sources"); +STATIC_ASSERT (sizeof(fib_source_t) == 1, + "FIB too many sources"); /** * The maximum number of sources @@ -260,8 +260,8 @@ typedef enum fib_entry_src_flag_t_ { * Keep the size of the flags field to 2 bytes, so it * can be placed next to the 2 bytes reference count */ -_Static_assert (sizeof(fib_entry_src_flag_t) <= 2, - "FIB entry flags field size too big"); +STATIC_ASSERT (sizeof(fib_entry_src_flag_t) <= 2, + "FIB entry flags field size too big"); /** * Information related to the source of a FIB entry diff --git a/vnet/vnet/fib/fib_node.h b/vnet/vnet/fib/fib_node.h index 253c42dd777..c820546bcc2 100644 --- a/vnet/vnet/fib/fib_node.h +++ b/vnet/vnet/fib/fib_node.h @@ -123,8 +123,8 @@ typedef enum fib_node_bw_reason_flag_t_ { FIB_NODE_BW_REASON_FLAG_ADJ_UPDATE = (1 << FIB_NODE_BW_REASON_ADJ_UPDATE), } __attribute__ ((packed)) fib_node_bw_reason_flag_t; -_Static_assert(sizeof(fib_node_bw_reason_flag_t) < 2, - "BW Reason enum < 2 byte. Consequences for cover_upd_res_t"); +STATIC_ASSERT(sizeof(fib_node_bw_reason_flag_t) < 2, + "BW Reason enum < 2 byte. Consequences for cover_upd_res_t"); /** * Forward eclarations diff --git a/vnet/vnet/fib/fib_types.h b/vnet/vnet/fib/fib_types.h index 0bc17d6006c..ea5a6d8cae1 100644 --- a/vnet/vnet/fib/fib_types.h +++ b/vnet/vnet/fib/fib_types.h @@ -184,8 +184,8 @@ typedef struct fib_prefix_t_ { }; } fib_prefix_t; -_Static_assert(STRUCT_OFFSET_OF(fib_prefix_t, fp_addr) == 4, - "FIB Prefix's address is 4 byte aligned."); +STATIC_ASSERT(STRUCT_OFFSET_OF(fib_prefix_t, fp_addr) == 4, + "FIB Prefix's address is 4 byte aligned."); /** * \brief Compare two prefixes for equality diff --git a/vnet/vnet/ip/ip4_mtrie.h b/vnet/vnet/ip/ip4_mtrie.h index c49937d6814..4771be43e3f 100644 --- a/vnet/vnet/ip/ip4_mtrie.h +++ b/vnet/vnet/ip/ip4_mtrie.h @@ -115,8 +115,8 @@ typedef struct { - 1 * sizeof (i32)]; } ip4_fib_mtrie_ply_t; -_Static_assert(0 == sizeof(ip4_fib_mtrie_ply_t) % CLIB_CACHE_LINE_BYTES, - "IP4 Mtrie ply cache line"); +STATIC_ASSERT(0 == sizeof(ip4_fib_mtrie_ply_t) % CLIB_CACHE_LINE_BYTES, + "IP4 Mtrie ply cache line"); typedef struct { /* Pool of plies. Index zero is root ply. */ diff --git a/vnet/vnet/ip/lookup.h b/vnet/vnet/ip/lookup.h index c1d8d204ef9..239ca6818be 100644 --- a/vnet/vnet/ip/lookup.h +++ b/vnet/vnet/ip/lookup.h @@ -256,11 +256,11 @@ typedef struct ip_adjacency_t_ { fib_node_t ia_node; } ip_adjacency_t; -_Static_assert((STRUCT_OFFSET_OF(ip_adjacency_t, cacheline0) == 0), - "IP adjacency cachline 0 is not offset"); -_Static_assert((STRUCT_OFFSET_OF(ip_adjacency_t, cacheline1) == - CLIB_CACHE_LINE_BYTES), - "IP adjacency cachline 1 is more than one cachline size offset"); +STATIC_ASSERT((STRUCT_OFFSET_OF(ip_adjacency_t, cacheline0) == 0), + "IP adjacency cachline 0 is not offset"); +STATIC_ASSERT((STRUCT_OFFSET_OF(ip_adjacency_t, cacheline1) == + CLIB_CACHE_LINE_BYTES), + "IP adjacency cachline 1 is more than one cachline size offset"); /* An all zeros address */ extern const ip46_address_t zero_addr; diff --git a/vnet/vnet/map/map.h b/vnet/vnet/map/map.h index b76891b69b3..f446b739a93 100644 --- a/vnet/vnet/map/map.h +++ b/vnet/vnet/map/map.h @@ -110,8 +110,8 @@ typedef struct u8 ip4_prefix_len; } map_domain_t; -_Static_assert ((sizeof (map_domain_t) <= CLIB_CACHE_LINE_BYTES), - "MAP domain fits in one cacheline"); +STATIC_ASSERT ((sizeof (map_domain_t) <= CLIB_CACHE_LINE_BYTES), + "MAP domain fits in one cacheline"); #define MAP_REASS_INDEX_NONE ((u16)0xffff) diff --git a/vppinfra/vppinfra/error_bootstrap.h b/vppinfra/vppinfra/error_bootstrap.h index ad600621eae..b03ec88049a 100644 --- a/vppinfra/vppinfra/error_bootstrap.h +++ b/vppinfra/vppinfra/error_bootstrap.h @@ -79,7 +79,11 @@ do { \ } \ } while (0) +#if defined(__clang__) +#define STATIC_ASSERT(truth,...) +#else #define STATIC_ASSERT(truth,...) _Static_assert(truth, __VA_ARGS__) +#endif /* Assert without allocating memory. */ #define ASSERT_AND_PANIC(truth) \ |