Re: [lng-odp] [PATCH v2 1/3] linux-gen: buffer: change buffer handle to pointer
Merged with review from v1. Maxim. On 07/13/17 15:58, Petri Savolainen wrote: > Changed buffer, event and timeout handles to be pointers. > Packet handles are already pointers. This enabled code > optimization as some conversions may be removed and remaining > once are just type casts. > > Signed-off-by: Petri Savolainen > --- > include/odp/arch/default/api/abi/buffer.h | 7 +- > include/odp/arch/default/api/abi/event.h | 2 +- > .../include/odp/api/plat/buffer_types.h| 6 +- > .../include/odp/api/plat/event_types.h | 2 +- > .../include/odp/api/plat/timer_types.h | 2 +- > .../linux-generic/include/odp_buffer_inlines.h | 9 +- > .../linux-generic/include/odp_buffer_internal.h| 23 ++-- > .../linux-generic/include/odp_packet_internal.h| 5 +- > platform/linux-generic/include/odp_pool_internal.h | 30 +- > platform/linux-generic/odp_buffer.c| 4 +- > platform/linux-generic/odp_packet.c| 56 +- > platform/linux-generic/odp_pool.c | 120 > +++-- > platform/linux-generic/odp_queue.c | 6 +- > platform/linux-generic/odp_traffic_mngr.c | 2 +- > platform/linux-generic/pktio/ipc.c | 11 +- > 15 files changed, 126 insertions(+), 159 deletions(-) > > diff --git a/include/odp/arch/default/api/abi/buffer.h > b/include/odp/arch/default/api/abi/buffer.h > index eec6f01f..d8bfc913 100644 > --- a/include/odp/arch/default/api/abi/buffer.h > +++ b/include/odp/arch/default/api/abi/buffer.h > @@ -14,18 +14,13 @@ extern "C" { > /** @internal Dummy type for strong typing */ > typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_buffer_t; > > -/** @internal Dummy type for strong typing */ > -typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_buffer_seg_t; > - > /** @ingroup odp_buffer > * @{ > */ > > typedef _odp_abi_buffer_t *odp_buffer_t; > -typedef _odp_abi_buffer_seg_t *odp_buffer_seg_t; > > -#define ODP_BUFFER_INVALID ((odp_buffer_t)0x) > -#define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)0x) > +#define ODP_BUFFER_INVALID ((odp_buffer_t)NULL) > > /** > * @} > diff --git a/include/odp/arch/default/api/abi/event.h > b/include/odp/arch/default/api/abi/event.h > index 4f6596b1..fd86f25c 100644 > --- a/include/odp/arch/default/api/abi/event.h > +++ b/include/odp/arch/default/api/abi/event.h > @@ -22,7 +22,7 @@ typedef struct { char dummy; /**< @internal Dummy */ } > _odp_abi_event_t; > > typedef _odp_abi_event_t *odp_event_t; > > -#define ODP_EVENT_INVALID ((odp_event_t)0x) > +#define ODP_EVENT_INVALID ((odp_event_t)NULL) > > typedef enum odp_event_type_t { > ODP_EVENT_BUFFER = 1, > diff --git a/platform/linux-generic/include/odp/api/plat/buffer_types.h > b/platform/linux-generic/include/odp/api/plat/buffer_types.h > index 809768f3..8b79bb52 100644 > --- a/platform/linux-generic/include/odp/api/plat/buffer_types.h > +++ b/platform/linux-generic/include/odp/api/plat/buffer_types.h > @@ -31,11 +31,7 @@ extern "C" { > > typedef ODP_HANDLE_T(odp_buffer_t); > > -#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0x) > - > -typedef ODP_HANDLE_T(odp_buffer_seg_t); > - > -#define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)ODP_BUFFER_INVALID) > +#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, NULL) > > /** > * @} > diff --git a/platform/linux-generic/include/odp/api/plat/event_types.h > b/platform/linux-generic/include/odp/api/plat/event_types.h > index a1aa0e45..559a2fa0 100644 > --- a/platform/linux-generic/include/odp/api/plat/event_types.h > +++ b/platform/linux-generic/include/odp/api/plat/event_types.h > @@ -32,7 +32,7 @@ extern "C" { > > typedef ODP_HANDLE_T(odp_event_t); > > -#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0x) > +#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, NULL) > > typedef enum odp_event_type_t { > ODP_EVENT_BUFFER = 1, > diff --git a/platform/linux-generic/include/odp/api/plat/timer_types.h > b/platform/linux-generic/include/odp/api/plat/timer_types.h > index 8821bed6..a8891f11 100644 > --- a/platform/linux-generic/include/odp/api/plat/timer_types.h > +++ b/platform/linux-generic/include/odp/api/plat/timer_types.h > @@ -38,7 +38,7 @@ typedef ODP_HANDLE_T(odp_timer_t); > > typedef ODP_HANDLE_T(odp_timeout_t); > > -#define ODP_TIMEOUT_INVALID _odp_cast_scalar(odp_timeout_t, 0x) > +#define ODP_TIMEOUT_INVALID _odp_cast_scalar(odp_timeout_t, NULL) > > /** > * @} > diff --git a/platform/linux-generic/include/odp_buffer_inlines.h > b/platform/linux-generic/include/odp_buffer_inlines.h > index cf817d90..1dbc725b 100644 > --- a/platform/linux-generic/include/odp_buffer_inlines.h > +++ b/platform/linux-generic/include/odp_buffer_inlines.h > @@ -23,9 +23,14 @@ odp_event_type_t _odp_buffer_event_type(odp_buffer_t b
[lng-odp] [PATCH v2 1/3] linux-gen: buffer: change buffer handle to pointer
Changed buffer, event and timeout handles to be pointers. Packet handles are already pointers. This enabled code optimization as some conversions may be removed and remaining once are just type casts. Signed-off-by: Petri Savolainen --- include/odp/arch/default/api/abi/buffer.h | 7 +- include/odp/arch/default/api/abi/event.h | 2 +- .../include/odp/api/plat/buffer_types.h| 6 +- .../include/odp/api/plat/event_types.h | 2 +- .../include/odp/api/plat/timer_types.h | 2 +- .../linux-generic/include/odp_buffer_inlines.h | 9 +- .../linux-generic/include/odp_buffer_internal.h| 23 ++-- .../linux-generic/include/odp_packet_internal.h| 5 +- platform/linux-generic/include/odp_pool_internal.h | 30 +- platform/linux-generic/odp_buffer.c| 4 +- platform/linux-generic/odp_packet.c| 56 +- platform/linux-generic/odp_pool.c | 120 +++-- platform/linux-generic/odp_queue.c | 6 +- platform/linux-generic/odp_traffic_mngr.c | 2 +- platform/linux-generic/pktio/ipc.c | 11 +- 15 files changed, 126 insertions(+), 159 deletions(-) diff --git a/include/odp/arch/default/api/abi/buffer.h b/include/odp/arch/default/api/abi/buffer.h index eec6f01f..d8bfc913 100644 --- a/include/odp/arch/default/api/abi/buffer.h +++ b/include/odp/arch/default/api/abi/buffer.h @@ -14,18 +14,13 @@ extern "C" { /** @internal Dummy type for strong typing */ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_buffer_t; -/** @internal Dummy type for strong typing */ -typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_buffer_seg_t; - /** @ingroup odp_buffer * @{ */ typedef _odp_abi_buffer_t *odp_buffer_t; -typedef _odp_abi_buffer_seg_t *odp_buffer_seg_t; -#define ODP_BUFFER_INVALID ((odp_buffer_t)0x) -#define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)0x) +#define ODP_BUFFER_INVALID ((odp_buffer_t)NULL) /** * @} diff --git a/include/odp/arch/default/api/abi/event.h b/include/odp/arch/default/api/abi/event.h index 4f6596b1..fd86f25c 100644 --- a/include/odp/arch/default/api/abi/event.h +++ b/include/odp/arch/default/api/abi/event.h @@ -22,7 +22,7 @@ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_event_t; typedef _odp_abi_event_t *odp_event_t; -#define ODP_EVENT_INVALID ((odp_event_t)0x) +#define ODP_EVENT_INVALID ((odp_event_t)NULL) typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, diff --git a/platform/linux-generic/include/odp/api/plat/buffer_types.h b/platform/linux-generic/include/odp/api/plat/buffer_types.h index 809768f3..8b79bb52 100644 --- a/platform/linux-generic/include/odp/api/plat/buffer_types.h +++ b/platform/linux-generic/include/odp/api/plat/buffer_types.h @@ -31,11 +31,7 @@ extern "C" { typedef ODP_HANDLE_T(odp_buffer_t); -#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0x) - -typedef ODP_HANDLE_T(odp_buffer_seg_t); - -#define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)ODP_BUFFER_INVALID) +#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, NULL) /** * @} diff --git a/platform/linux-generic/include/odp/api/plat/event_types.h b/platform/linux-generic/include/odp/api/plat/event_types.h index a1aa0e45..559a2fa0 100644 --- a/platform/linux-generic/include/odp/api/plat/event_types.h +++ b/platform/linux-generic/include/odp/api/plat/event_types.h @@ -32,7 +32,7 @@ extern "C" { typedef ODP_HANDLE_T(odp_event_t); -#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0x) +#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, NULL) typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, diff --git a/platform/linux-generic/include/odp/api/plat/timer_types.h b/platform/linux-generic/include/odp/api/plat/timer_types.h index 8821bed6..a8891f11 100644 --- a/platform/linux-generic/include/odp/api/plat/timer_types.h +++ b/platform/linux-generic/include/odp/api/plat/timer_types.h @@ -38,7 +38,7 @@ typedef ODP_HANDLE_T(odp_timer_t); typedef ODP_HANDLE_T(odp_timeout_t); -#define ODP_TIMEOUT_INVALID _odp_cast_scalar(odp_timeout_t, 0x) +#define ODP_TIMEOUT_INVALID _odp_cast_scalar(odp_timeout_t, NULL) /** * @} diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h index cf817d90..1dbc725b 100644 --- a/platform/linux-generic/include/odp_buffer_inlines.h +++ b/platform/linux-generic/include/odp_buffer_inlines.h @@ -23,9 +23,14 @@ odp_event_type_t _odp_buffer_event_type(odp_buffer_t buf); void _odp_buffer_event_type_set(odp_buffer_t buf, int ev); int odp_buffer_snprint(char *str, uint32_t n, odp_buffer_t buf); -static inline odp_buffer_t odp_hdr_to_buf(odp_buffer_hdr_t *hdr) +static inline odp_buffer_t buf_from_buf_hdr(odp_buffer_hdr_t *hdr) { - return hdr->handle.handle; +