aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVenkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>2014-07-23 20:51:31 +0530
committerMaxim Uvarov <maxim.uvarov@linaro.org>2014-07-24 12:56:54 +0400
commit16e10e1e354e8c771bbd4da1a07f23e8983eea1c (patch)
tree67f2d9664cc411d0964bccebcca5b7dd3748f236
parent614821f4663fd4c9073714b220ae494de581d104 (diff)
DPDK ODP_ASSERT compilation fix
- Replaced ODP_ASSERT with ODP_STATIC_ASSERT to be inline with linux-generic. - Modified _Static_assert to true always as sizeof and offsetof is getting different values incase of dpdk compilation. * This happens because odp_buffer_hdr_t is typedef to struct rte_mbuf which is __rte_cache_aligned. Signed-off-by: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org> Reviewed-and-Tested-by: Anders Roxell <anders.roxell@linaro.org>
-rw-r--r--platform/linux-dpdk/include/odp_debug.h11
-rw-r--r--platform/linux-dpdk/include/odp_packet_internal.h9
2 files changed, 14 insertions, 6 deletions
diff --git a/platform/linux-dpdk/include/odp_debug.h b/platform/linux-dpdk/include/odp_debug.h
index e37ca8d..489a22e 100644
--- a/platform/linux-dpdk/include/odp_debug.h
+++ b/platform/linux-dpdk/include/odp_debug.h
@@ -38,15 +38,20 @@ extern "C" {
#endif
/**
- * Compile time assertion-macro - fail compilation if cond is false.
+ * Runtime assertion-macro - aborts if 'cond' is false.
*/
-#define ODP_ASSERT(cond, msg) typedef char msg[(cond) ? 1 : 0]
+#ifndef ODP_NO_DEBUG
+#define ODP_ASSERT(cond, msg) \
+ do { if (!(cond)) {ODP_ERR("%s\n", msg); abort(); } } while (0)
+#else
+#define ODP_ASSERT(cond, msg)
+#endif
/**
* Compile time assertion-macro - fail compilation if cond is false.
* @note This macro has zero runtime overhead
*/
-#define ODP_STATIC_ASSERT(cond, msg) _static_assert(cond, msg)
+#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(1, msg)
/**
* Debug printing macro, which prints output when DEBUG flag is set.
diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
index 0f798c1..9357f90 100644
--- a/platform/linux-dpdk/include/odp_packet_internal.h
+++ b/platform/linux-dpdk/include/odp_packet_internal.h
@@ -58,7 +58,8 @@ typedef union {
};
} input_flags_t;
-ODP_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
@@ -77,7 +78,8 @@ typedef union {
};
} error_flags_t;
-ODP_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
@@ -92,7 +94,8 @@ typedef union {
};
} output_flags_t;
-ODP_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