diff mbox

[6/9] linux-generic: packet: add strong typing support

Message ID 1422592065-15875-7-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Jan. 30, 2015, 4:27 a.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/include/odp/plat/packet_types.h | 12 ++++++------
 platform/linux-generic/odp_packet.c                    |  8 ++++----
 2 files changed, 10 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..f29d58a 100644
--- a/platform/linux-generic/include/odp/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/plat/packet_types.h
@@ -18,23 +18,23 @@ 
 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_BUFFER_INVALID
+#define ODP_PACKET_SEG_INVALID _odp_cast_scalar(odp_packet_seg_t, 0xffffffff)
 
 /**
  * @}
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index fbe375c..93af7de 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)