aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic
diff options
context:
space:
mode:
authorOla Liljedahl <ola.liljedahl@linaro.org>2015-03-23 21:56:26 +0100
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-03-25 17:37:16 +0300
commit2a9794106a29b6f7c5bfabe58cb9853f0a238bff (patch)
tree4c92871b8ca8139fcca869bc958a6e910f72af74 /platform/linux-generic
parente6ddf873024e247349189b765a0a265df3d0c5ec (diff)
linux-generic: strongtypes: use named structs for C++
Typedefs to anonymous structs creates problems for C++ programs: GCC: warning: ‘odp_crypto_op_params’ has a field ‘odp_crypto_op_params::pkt’ whose type uses the anonymous namespace error: anonymous type with no linkage used to declare function ‘<anonymous struct>* ppp_packet::get_queue() const’ with linkage CLANG: extern odp_pool_t tmo_pool; warning: variable 'tmo_pool' has internal linkage but is not defined When linking: undefined reference to `tmo_pool' The solution is to add a (unique) name to all structs used by the strong typing typedefs. Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic')
-rw-r--r--platform/linux-generic/include/odp/plat/buffer_types.h4
-rw-r--r--platform/linux-generic/include/odp/plat/classification_types.h8
-rw-r--r--platform/linux-generic/include/odp/plat/crypto_types.h2
-rw-r--r--platform/linux-generic/include/odp/plat/event_types.h2
-rw-r--r--platform/linux-generic/include/odp/plat/packet_io_types.h2
-rw-r--r--platform/linux-generic/include/odp/plat/packet_types.h4
-rw-r--r--platform/linux-generic/include/odp/plat/pool_types.h2
-rw-r--r--platform/linux-generic/include/odp/plat/queue_types.h4
-rw-r--r--platform/linux-generic/include/odp/plat/shared_memory_types.h2
-rw-r--r--platform/linux-generic/include/odp/plat/strong_types.h6
10 files changed, 21 insertions, 15 deletions
diff --git a/platform/linux-generic/include/odp/plat/buffer_types.h b/platform/linux-generic/include/odp/plat/buffer_types.h
index 3e7070e77..0c017ae5d 100644
--- a/platform/linux-generic/include/odp/plat/buffer_types.h
+++ b/platform/linux-generic/include/odp/plat/buffer_types.h
@@ -26,13 +26,13 @@ extern "C" {
*/
/** ODP buffer */
-typedef odp_handle_t odp_buffer_t;
+typedef ODP_HANDLE_T(odp_buffer_t);
/** Invalid buffer */
#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0xffffffff)
/** ODP buffer segment */
-typedef odp_handle_t odp_buffer_seg_t;
+typedef ODP_HANDLE_T(odp_buffer_seg_t);
/** Invalid segment */
#define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)ODP_BUFFER_INVALID)
diff --git a/platform/linux-generic/include/odp/plat/classification_types.h b/platform/linux-generic/include/odp/plat/classification_types.h
index 042d8c804..767da7d7f 100644
--- a/platform/linux-generic/include/odp/plat/classification_types.h
+++ b/platform/linux-generic/include/odp/plat/classification_types.h
@@ -23,18 +23,18 @@ extern "C" {
* @{
*/
-typedef odp_handle_t odp_cos_t;
-typedef odp_handle_t odp_flowsig_t;
+typedef ODP_HANDLE_T(odp_cos_t);
+typedef ODP_HANDLE_T(odp_flowsig_t);
#define ODP_COS_INVALID _odp_cast_scalar(odp_cos_t, ~0)
#define ODP_COS_NAME_LEN 32
typedef uint16_t odp_cos_flow_set_t;
-typedef odp_handle_t odp_pmr_t;
+typedef ODP_HANDLE_T(odp_pmr_t);
#define ODP_PMR_INVAL _odp_cast_scalar(odp_pmr_t, ~0)
-typedef odp_handle_t odp_pmr_set_t;
+typedef ODP_HANDLE_T(odp_pmr_set_t);
#define ODP_PMR_SET_INVAL _odp_cast_scalar(odp_pmr_set_t, ~0)
/** Get printable format of odp_cos_t */
diff --git a/platform/linux-generic/include/odp/plat/crypto_types.h b/platform/linux-generic/include/odp/plat/crypto_types.h
index 1b10a5dde..a91d88e6c 100644
--- a/platform/linux-generic/include/odp/plat/crypto_types.h
+++ b/platform/linux-generic/include/odp/plat/crypto_types.h
@@ -25,7 +25,7 @@ extern "C" {
#define ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL)
typedef uint64_t odp_crypto_session_t;
-typedef odp_handle_t odp_crypto_compl_t;
+typedef ODP_HANDLE_T(odp_crypto_compl_t);
enum odp_crypto_op_mode {
ODP_CRYPTO_SYNC,
diff --git a/platform/linux-generic/include/odp/plat/event_types.h b/platform/linux-generic/include/odp/plat/event_types.h
index 24be22f75..d91937d2e 100644
--- a/platform/linux-generic/include/odp/plat/event_types.h
+++ b/platform/linux-generic/include/odp/plat/event_types.h
@@ -26,7 +26,7 @@ extern "C" {
* @{
*/
-typedef odp_handle_t odp_event_t;
+typedef ODP_HANDLE_T(odp_event_t);
#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0xffffffff)
diff --git a/platform/linux-generic/include/odp/plat/packet_io_types.h b/platform/linux-generic/include/odp/plat/packet_io_types.h
index 60592e35c..3cc64c6d2 100644
--- a/platform/linux-generic/include/odp/plat/packet_io_types.h
+++ b/platform/linux-generic/include/odp/plat/packet_io_types.h
@@ -26,7 +26,7 @@ extern "C" {
* @{
*/
-typedef odp_handle_t odp_pktio_t;
+typedef ODP_HANDLE_T(odp_pktio_t);
#define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0)
diff --git a/platform/linux-generic/include/odp/plat/packet_types.h b/platform/linux-generic/include/odp/plat/packet_types.h
index 57e966218..45cb8010d 100644
--- a/platform/linux-generic/include/odp/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/plat/packet_types.h
@@ -26,13 +26,13 @@ extern "C" {
* @{
*/
-typedef odp_handle_t odp_packet_t;
+typedef ODP_HANDLE_T(odp_packet_t);
#define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0xffffffff)
#define ODP_PACKET_OFFSET_INVALID (0x0fffffff)
-typedef odp_handle_t odp_packet_seg_t;
+typedef ODP_HANDLE_T(odp_packet_seg_t);
#define ODP_PACKET_SEG_INVALID _odp_cast_scalar(odp_packet_seg_t, 0xffffffff)
diff --git a/platform/linux-generic/include/odp/plat/pool_types.h b/platform/linux-generic/include/odp/plat/pool_types.h
index 71c778352..568556fa0 100644
--- a/platform/linux-generic/include/odp/plat/pool_types.h
+++ b/platform/linux-generic/include/odp/plat/pool_types.h
@@ -25,7 +25,7 @@ extern "C" {
* @{
*/
-typedef odp_handle_t odp_pool_t;
+typedef ODP_HANDLE_T(odp_pool_t);
#define ODP_POOL_INVALID _odp_cast_scalar(odp_pool_t, 0xffffffff)
diff --git a/platform/linux-generic/include/odp/plat/queue_types.h b/platform/linux-generic/include/odp/plat/queue_types.h
index 04a0be950..1cecc90c7 100644
--- a/platform/linux-generic/include/odp/plat/queue_types.h
+++ b/platform/linux-generic/include/odp/plat/queue_types.h
@@ -25,9 +25,9 @@ extern "C" {
* @{
*/
-typedef odp_handle_t odp_queue_t;
+typedef ODP_HANDLE_T(odp_queue_t);
-typedef odp_handle_t odp_queue_group_t;
+typedef ODP_HANDLE_T(odp_queue_group_t);
#define ODP_QUEUE_INVALID _odp_cast_scalar(odp_queue_t, 0)
diff --git a/platform/linux-generic/include/odp/plat/shared_memory_types.h b/platform/linux-generic/include/odp/plat/shared_memory_types.h
index d2e92cfc8..4be7356dd 100644
--- a/platform/linux-generic/include/odp/plat/shared_memory_types.h
+++ b/platform/linux-generic/include/odp/plat/shared_memory_types.h
@@ -26,7 +26,7 @@ extern "C" {
* @{
*/
-typedef odp_handle_t odp_shm_t;
+typedef ODP_HANDLE_T(odp_shm_t);
#define ODP_SHM_INVALID _odp_cast_scalar(odp_shm_t, 0)
#define ODP_SHM_NULL ODP_SHM_INVALID
diff --git a/platform/linux-generic/include/odp/plat/strong_types.h b/platform/linux-generic/include/odp/plat/strong_types.h
index cd1585388..a53d76352 100644
--- a/platform/linux-generic/include/odp/plat/strong_types.h
+++ b/platform/linux-generic/include/odp/plat/strong_types.h
@@ -16,7 +16,13 @@
#define STRONG_TYPES_H_
/** Use strong typing for ODP types */
+#ifdef __cplusplus
+#define ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type
+#else
#define odp_handle_t struct { uint8_t unused_dummy_var; } *
+/** C/C++ helper macro for strong typing */
+#define ODP_HANDLE_T(type) odp_handle_t type
+#endif
/** Internal macro to get value of an ODP handle */
#define _odp_typeval(handle) ((uint32_t)(uintptr_t)(handle))