diff mbox

[PATCHv5,16/19] linux-generic: packets: add strong typing support

Message ID 1422938699-12877-17-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit d523953de94880bdd3bd388d699008cb657e00fa
Headers show

Commit Message

Bill Fischofer Feb. 3, 2015, 4:44 a.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 .../linux-generic/include/odp/plat/packet_types.h  | 24 ++++++++++++++++------
 platform/linux-generic/odp_packet.c                |  8 ++++----
 2 files changed, 22 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp/plat/packet_types.h b/platform/linux-generic/include/odp/plat/packet_types.h
index 60d6443..57e9662 100644
--- a/platform/linux-generic/include/odp/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/plat/packet_types.h
@@ -18,23 +18,35 @@ 
 extern "C" {
 #endif
 
-
-#include <odp/plat/buffer_types.h>
+#include <odp/std_types.h>
+#include <odp/plat/strong_types.h>
 
 /** @addtogroup odp_packet ODP PACKET
  *  Operations on a packet.
  *  @{
  */
 
-typedef odp_buffer_t odp_packet_t;
+typedef odp_handle_t odp_packet_t;
 
-#define ODP_PACKET_INVALID ODP_BUFFER_INVALID
+#define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0xffffffff)
 
 #define ODP_PACKET_OFFSET_INVALID (0x0fffffff)
 
-typedef odp_buffer_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)
 
-#define ODP_PACKET_SEG_INVALID ODP_BUFFER_INVALID
+/** Get printable format of odp_packet_t */
+static inline uint64_t odp_packet_to_u64(odp_packet_t hdl)
+{
+	return _odp_pri(hdl);
+}
+
+/** Get printable format of odp_packet_seg_t */
+static inline uint64_t odp_packet_seg_to_u64(odp_packet_seg_t hdl)
+{
+	return _odp_pri(hdl);
+}
 
 /**
  * @}
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 599d768..c5a3f7d 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -193,10 +193,10 @@  void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len,
 
 	if (addr != NULL && seg != NULL) {
 		odp_buffer_bits_t seghandle;
-		seghandle.handle = pkt;
+		seghandle.handle = (odp_buffer_t)pkt;
 		seghandle.seg = (pkt_hdr->headroom + offset) /
 			pkt_hdr->buf_hdr.segsize;
-		*seg = seghandle.handle;
+		*seg = (odp_packet_seg_t)seghandle.handle;
 	}
 
 	return addr;
@@ -325,9 +325,9 @@  odp_packet_seg_t odp_packet_last_seg(odp_packet_t pkt)
 	odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
 	odp_buffer_bits_t seghandle;
 
-	seghandle.handle = pkt;
+	seghandle.handle = (odp_buffer_t)pkt;
 	seghandle.seg = pkt_hdr->buf_hdr.segcount - 1;
-	return seghandle.handle;
+	return (odp_packet_seg_t)seghandle.handle;
 }
 
 odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg)