@@ -40,7 +40,8 @@ typedef struct ODP_PACKED {
} odph_ethaddr_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN, "ODPH_ETHADDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_ethaddr_t) == ODPH_ETHADDR_LEN,
+ "ODPH_ETHADDR_T__SIZE_ERROR");
/**
* Ethernet header
@@ -52,7 +53,8 @@ typedef struct ODP_PACKED {
} odph_ethhdr_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN, "ODPH_ETHHDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_ethhdr_t) == ODPH_ETHHDR_LEN,
+ "ODPH_ETHHDR_T__SIZE_ERROR");
/**
* VLAN header
@@ -65,7 +67,8 @@ typedef struct ODP_PACKED {
} odph_vlanhdr_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN, "ODPH_VLANHDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN,
+ "ODPH_VLANHDR_T__SIZE_ERROR");
/* Ethernet header Ether Type ('type') values, a selected few */
@@ -92,7 +92,8 @@ typedef struct ODP_PACKED {
exceeded*/
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN, "ODPH_ICMPHDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_icmphdr_t) == ODPH_ICMPHDR_LEN,
+ "ODPH_ICMPHDR_T__SIZE_ERROR");
/**
* @}
@@ -71,7 +71,8 @@ typedef struct ODP_PACKED {
} odph_ipv4hdr_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, "ODPH_IPV4HDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN,
+ "ODPH_IPV4HDR_T__SIZE_ERROR");
/**
* Check if IPv4 checksum is valid
@@ -146,7 +147,8 @@ typedef struct ODP_PACKED {
} odph_ipv6hdr_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, "ODPH_IPV6HDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN,
+ "ODPH_IPV6HDR_T__SIZE_ERROR");
/**
* IPv6 Header extensions
@@ -38,7 +38,8 @@ typedef struct ODP_PACKED {
} odph_esphdr_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN, "ODPH_ESPHDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_esphdr_t) == ODPH_ESPHDR_LEN,
+ "ODPH_ESPHDR_T__SIZE_ERROR");
/**
* IPSec ESP trailer
@@ -50,7 +51,8 @@ typedef struct ODP_PACKED {
} odph_esptrl_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN, "ODPH_ESPTRL_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_esptrl_t) == ODPH_ESPTRL_LEN,
+ "ODPH_ESPTRL_T__SIZE_ERROR");
/**
* IPSec AH header
@@ -65,7 +67,8 @@ typedef struct ODP_PACKED {
} odph_ahhdr_t;
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN, "ODPH_AHHDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_ahhdr_t) == ODPH_AHHDR_LEN,
+ "ODPH_AHHDR_T__SIZE_ERROR");
/**
* @}
@@ -87,7 +87,8 @@ static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt)
}
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, "ODPH_UDPHDR_T__SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN,
+ "ODPH_UDPHDR_T__SIZE_ERROR");
/**
* @}
@@ -17,31 +17,14 @@
extern "C" {
#endif
-#if defined(__GNUC__) && !defined(__clang__)
-
-
-#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6))
-
-/**
- * @internal _Static_assert was only added in GCC 4.6. Provide a weak replacement
- * for previous versions.
- */
-#define _Static_assert(e, s) (extern int (*static_assert_checker(void)) \
- [sizeof(struct { unsigned int error_if_negative:(e) ? 1 : -1; })])
-
-#endif
-
-
-
-#endif
-
-
/**
- * @internal Compile time assertion-macro - fail compilation if cond is false.
- * This macro has zero runtime overhead
+ * @def ODP_STATIC_ASSERT
+ * Compile time assertion macro - fail compilation if cond if false.
+ *
+ * @param cond Conditional expression to be evaluated at compile time
+ *
+ * @param msg Compile time error message to be displayed if cond is false
*/
-#define _ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
-
#ifdef __cplusplus
}
@@ -19,6 +19,27 @@ extern "C" {
#include <odp/api/spec/debug.h>
+#if defined(__GNUC__) && !defined(__clang__)
+
+#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6))
+
+/**
+ * @internal _Static_assert was only added in GCC 4.6. Provide a weak replacement
+ * for previous versions.
+ */
+#define _Static_assert(e, s) (extern int (*static_assert_checker(void)) \
+ [sizeof(struct { unsigned int error_if_negative:(e) ? 1 : -1; })])
+
+#endif
+
+#endif
+
+/**
+ * @internal Compile time assertion-macro - fail compilation if cond is false.
+ * This macro has zero runtime overhead
+ */
+#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
+
#ifdef __cplusplus
}
#endif
@@ -50,10 +50,10 @@ extern "C" {
((x) <= 65536 ? 16 : \
(0/0)))))))))))))))))
-_ODP_STATIC_ASSERT(ODP_CONFIG_PACKET_SEG_LEN_MIN >= 256,
- "ODP Segment size must be a minimum of 256 bytes");
+ODP_STATIC_ASSERT(ODP_CONFIG_PACKET_SEG_LEN_MIN >= 256,
+ "ODP Segment size must be a minimum of 256 bytes");
-_ODP_STATIC_ASSERT((ODP_CONFIG_PACKET_BUF_LEN_MAX %
+ODP_STATIC_ASSERT((ODP_CONFIG_PACKET_BUF_LEN_MAX %
ODP_CONFIG_PACKET_SEG_LEN_MIN) == 0,
"Packet max size must be a multiple of segment size");
@@ -146,8 +146,8 @@ struct odp_buffer_hdr_t {
/** @internal Compile time assert that the
* allocator field can handle any allocator id*/
-_ODP_STATIC_ASSERT(INT16_MAX >= ODP_THREAD_COUNT_MAX,
- "ODP_BUFFER_HDR_T__ALLOCATOR__SIZE_ERROR");
+ODP_STATIC_ASSERT(INT16_MAX >= ODP_THREAD_COUNT_MAX,
+ "ODP_BUFFER_HDR_T__ALLOCATOR__SIZE_ERROR");
typedef struct odp_buffer_hdr_stride {
uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_buffer_hdr_t))];
@@ -74,8 +74,8 @@ typedef union {
};
} input_flags_t;
-_ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t),
- "INPUT_FLAGS_SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t),
+ "INPUT_FLAGS_SIZE_ERROR");
/**
* Packet error flags
@@ -96,8 +96,8 @@ typedef union {
};
} error_flags_t;
-_ODP_STATIC_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t),
- "ERROR_FLAGS_SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t),
+ "ERROR_FLAGS_SIZE_ERROR");
/**
* Packet output flags
@@ -117,8 +117,8 @@ typedef union {
};
} output_flags_t;
-_ODP_STATIC_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t),
- "OUTPUT_FLAGS_SIZE_ERROR");
+ODP_STATIC_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t),
+ "OUTPUT_FLAGS_SIZE_ERROR");
/**
* Internal Packet header
@@ -24,8 +24,8 @@ extern "C" {
/** Max nbr of pkts to receive in one burst (keep same as QUEUE_MULTI_MAX) */
#define ODP_PKTIN_QUEUE_MAX_BURST 16
/* pktin_deq_multi() depends on the condition: */
-_ODP_STATIC_ASSERT(ODP_PKTIN_QUEUE_MAX_BURST >= QUEUE_MULTI_MAX,
- "ODP_PKTIN_DEQ_MULTI_MAX_ERROR");
+ODP_STATIC_ASSERT(ODP_PKTIN_QUEUE_MAX_BURST >= QUEUE_MULTI_MAX,
+ "ODP_PKTIN_DEQ_MULTI_MAX_ERROR");
int pktin_enqueue(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr, int sustain);
odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *queue);
@@ -65,8 +65,9 @@ struct ring {
struct tpacket_req req;
};
-_ODP_STATIC_ASSERT(offsetof(struct ring, mm_space) <= ODP_CACHE_LINE_SIZE,
- "ERR_STRUCT_RING");
+
+ODP_STATIC_ASSERT(offsetof(struct ring, mm_space) <= ODP_CACHE_LINE_SIZE,
+ "ERR_STRUCT_RING");
/** Packet socket using mmap rings for both Rx and Tx */
typedef struct {
@@ -21,8 +21,8 @@
#include <sys/types.h>
/** @internal Compile time assert */
-_ODP_STATIC_ASSERT(CPU_SETSIZE >= ODP_CPUMASK_SIZE,
- "ODP_CPUMASK_SIZE__SIZE_ERROR");
+ODP_STATIC_ASSERT(CPU_SETSIZE >= ODP_CPUMASK_SIZE,
+ "ODP_CPUMASK_SIZE__SIZE_ERROR");
void odp_cpumask_from_str(odp_cpumask_t *mask, const char *str_in)
{
@@ -45,8 +45,8 @@ odp_thrmask_t sched_mask_all;
/* Mask of queues per priority */
typedef uint8_t pri_mask_t;
-_ODP_STATIC_ASSERT((8*sizeof(pri_mask_t)) >= QUEUES_PER_PRIO,
- "pri_mask_t_is_too_small");
+ODP_STATIC_ASSERT((8 * sizeof(pri_mask_t)) >= QUEUES_PER_PRIO,
+ "pri_mask_t_is_too_small");
/* Internal: Start of named groups in group mask arrays */
#define _ODP_SCHED_GROUP_NAMED (ODP_SCHED_GROUP_CONTROL + 1)
@@ -28,8 +28,8 @@
#include <string.h>
#include <errno.h>
-_ODP_STATIC_ASSERT(ODP_CONFIG_SHM_BLOCKS >= ODP_CONFIG_POOLS,
- "ODP_CONFIG_SHM_BLOCKS < ODP_CONFIG_POOLS");
+ODP_STATIC_ASSERT(ODP_CONFIG_SHM_BLOCKS >= ODP_CONFIG_POOLS,
+ "ODP_CONFIG_SHM_BLOCKS < ODP_CONFIG_POOLS");
typedef struct {
char name[ODP_SHM_NAME_LEN];
@@ -107,7 +107,7 @@ ODP_ALIGNED(16) /* 16-byte atomic operations need properly aligned addresses */
#endif
;
-_ODP_STATIC_ASSERT(sizeof(tick_buf_t) == 16, "sizeof(tick_buf_t) == 16");
+ODP_STATIC_ASSERT(sizeof(tick_buf_t) == 16, "sizeof(tick_buf_t) == 16");
typedef struct odp_timer_s {
void *user_ptr;
@@ -396,8 +396,8 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED,
int ret = -1;
int slave;
- _ODP_STATIC_ASSERT(ODP_POOL_NAME_LEN == _RING_NAMESIZE,
- "mismatch pool and ring name arrays");
+ ODP_STATIC_ASSERT(ODP_POOL_NAME_LEN == _RING_NAMESIZE,
+ "mismatch pool and ring name arrays");
if (strncmp(dev, "ipc", 3))
return -1;
Convert the formerly internal _ODP_STATIC_ASSERT() macro to be a full ODP API named ODP_STATIC_ASSERT(). This provides a wrapper around any platform-specific compile-time assertion macro. Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> --- helper/include/odp/helper/eth.h | 9 ++++--- helper/include/odp/helper/icmp.h | 3 ++- helper/include/odp/helper/ip.h | 6 +++-- helper/include/odp/helper/ipsec.h | 9 ++++--- helper/include/odp/helper/udp.h | 3 ++- include/odp/api/spec/debug.h | 29 +++++----------------- platform/linux-generic/include/odp/api/debug.h | 21 ++++++++++++++++ .../linux-generic/include/odp_buffer_internal.h | 10 ++++---- .../linux-generic/include/odp_packet_internal.h | 12 ++++----- .../linux-generic/include/odp_packet_io_queue.h | 4 +-- platform/linux-generic/include/odp_packet_socket.h | 5 ++-- platform/linux-generic/odp_cpumask.c | 4 +-- platform/linux-generic/odp_schedule.c | 4 +-- platform/linux-generic/odp_shared_memory.c | 4 +-- platform/linux-generic/odp_timer.c | 2 +- platform/linux-generic/pktio/ipc.c | 4 +-- 16 files changed, 72 insertions(+), 57 deletions(-)