On Fri, Dec 19, 2014 at 9:28 AM, Petri Savolainen <
[email protected]> wrote:
>
> Align buffer and packet APIs to use only _len (instead of
> mixing _len and _size).
>
> Signed-off-by: Petri Savolainen <[email protected]>
> ---
> platform/linux-generic/include/api/odp_buffer.h | 6 +++---
> platform/linux-generic/include/odp_buffer_internal.h | 2 +-
> platform/linux-generic/include/odp_buffer_pool_internal.h | 8 ++++----
> platform/linux-generic/odp_buffer.c | 6 +++---
> platform/linux-generic/odp_buffer_pool.c | 10 +++++-----
> platform/linux-generic/odp_crypto.c | 2 +-
> platform/linux-generic/odp_packet.c | 4 ++--
> 7 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/platform/linux-generic/include/api/odp_buffer.h
> b/platform/linux-generic/include/api/odp_buffer.h
> index 3c23035..47553f7 100644
> --- a/platform/linux-generic/include/api/odp_buffer.h
> +++ b/platform/linux-generic/include/api/odp_buffer.h
> @@ -38,13 +38,13 @@ extern "C" {
> void *odp_buffer_addr(odp_buffer_t buf);
>
> /**
> - * Buffer maximum data size
> + * Buffer length
> *
> * @param buf Buffer handle
> *
> - * @return Buffer maximum data size
> + * @return Buffer length in bytes
> */
> -size_t odp_buffer_size(odp_buffer_t buf);
> +uint32_t odp_buffer_len(odp_buffer_t buf);
>
> /**
> * Buffer type
> diff --git a/platform/linux-generic/include/odp_buffer_internal.h
> b/platform/linux-generic/include/odp_buffer_internal.h
> index 60f06c9..6cc7d5d 100644
> --- a/platform/linux-generic/include/odp_buffer_internal.h
> +++ b/platform/linux-generic/include/odp_buffer_internal.h
> @@ -118,7 +118,7 @@ typedef struct odp_buffer_hdr_t {
> };
> } flags;
> int type; /* buffer type */
> - size_t size; /* max data size */
> + uint32_t len; /* buffer length */
> odp_atomic_u32_t ref_count; /* reference count */
> odp_buffer_pool_t pool_hdl; /* buffer pool handle */
> union {
> diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h
> b/platform/linux-generic/include/odp_buffer_pool_internal.h
> index 2e48ac3..c5f9753 100644
> --- a/platform/linux-generic/include/odp_buffer_pool_internal.h
> +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h
> @@ -246,7 +246,7 @@ static inline void ret_buf(struct pool_entry_s *pool,
> odp_buffer_hdr_t *buf)
> 0, buf->segsize);
> ret_blk(pool, buf->addr[--buf->segcount]);
> }
> - buf->size = 0;
> + buf->len = 0;
> }
>
> oldhead = _odp_atomic_ptr_load(&pool->buf_freelist,
> _ODP_MEMMODEL_ACQ);
> @@ -278,8 +278,8 @@ static inline void *get_local_buf(local_cache_t
> *buf_cache,
> if (odp_likely(buf != NULL)) {
> buf_cache->buf_freelist = buf->next;
>
> - if (odp_unlikely(buf->size < totsize)) {
> - intmax_t needed = totsize - buf->size;
> + if (odp_unlikely(buf->len < totsize)) {
> + intmax_t needed = totsize - buf->len;
>
> do {
> void *blk = get_blk(pool);
> @@ -292,7 +292,7 @@ static inline void *get_local_buf(local_cache_t
> *buf_cache,
> needed -= pool->seg_size;
> } while (needed > 0);
>
> - buf->size = buf->segcount * pool->seg_size;
> + buf->len = buf->segcount * pool->seg_size;
> }
>
> buf_cache->bufallocs++;
> diff --git a/platform/linux-generic/odp_buffer.c
> b/platform/linux-generic/odp_buffer.c
> index dd37ab3..deb46ce 100644
> --- a/platform/linux-generic/odp_buffer.c
> +++ b/platform/linux-generic/odp_buffer.c
> @@ -22,11 +22,11 @@ void *odp_buffer_addr(odp_buffer_t buf)
> }
>
>
> -size_t odp_buffer_size(odp_buffer_t buf)
> +uint32_t odp_buffer_len(odp_buffer_t buf)
> {
> odp_buffer_hdr_t *hdr = odp_buf_to_hdr(buf);
>
> - return hdr->size;
> + return hdr->len;
> }
>
>
> @@ -63,7 +63,7 @@ int odp_buffer_snprint(char *str, uint32_t n,
> odp_buffer_t buf)
> len += snprintf(&str[len], n-len,
> " addr %p\n", hdr->addr);
> len += snprintf(&str[len], n-len,
> - " size %zu\n", hdr->size);
> + " size %u\n", hdr->len);
>
Shouldn't the display text be changed from size to len as well if we're
changing the term on a consistent basis?
> len += snprintf(&str[len], n-len,
> " ref_count %i\n",
> odp_atomic_load_u32(&hdr->ref_count));
> diff --git a/platform/linux-generic/odp_buffer_pool.c
> b/platform/linux-generic/odp_buffer_pool.c
> index 48be24f..021571a 100644
> --- a/platform/linux-generic/odp_buffer_pool.c
> +++ b/platform/linux-generic/odp_buffer_pool.c
> @@ -305,7 +305,7 @@ odp_buffer_pool_t odp_buffer_pool_create(const char
> *name,
> tmp->allocator = ODP_FREEBUF;
> tmp->flags.all = 0;
> tmp->flags.zeroized = zeroized;
> - tmp->size = 0;
> + tmp->len = 0;
> odp_atomic_store_u32(&tmp->ref_count, 0);
> tmp->type = params->buf_type;
> tmp->pool_hdl = pool->s.pool_hdl;
> @@ -324,7 +324,7 @@ odp_buffer_pool_t odp_buffer_pool_create(const char
> *name,
> if (blk_size > 0) {
> tmp->segcount = 1;
> tmp->addr[0] = &tmp->addr[1];
> - tmp->size = blk_size;
> + tmp->len = blk_size;
> }
> }
>
> @@ -473,8 +473,8 @@ odp_buffer_t buffer_alloc(odp_buffer_pool_t pool_hdl,
> size_t size)
> return ODP_BUFFER_INVALID;
>
> /* Get blocks for this buffer, if pool uses application
> data */
> - if (buf->buf.size < totsize) {
> - intmax_t needed = totsize - buf->buf.size;
> + if (buf->buf.len < totsize) {
> + intmax_t needed = totsize - buf->buf.len;
> do {
> uint8_t *blk = get_blk(&pool->s);
> if (blk == NULL) {
> @@ -484,7 +484,7 @@ odp_buffer_t buffer_alloc(odp_buffer_pool_t pool_hdl,
> size_t size)
> buf->buf.addr[buf->buf.segcount++] = blk;
> needed -= pool->s.seg_size;
> } while (needed > 0);
> - buf->buf.size = buf->buf.segcount *
> pool->s.seg_size;
> + buf->buf.len = buf->buf.segcount *
> pool->s.seg_size;
> }
> }
>
> diff --git a/platform/linux-generic/odp_crypto.c
> b/platform/linux-generic/odp_crypto.c
> index 13c5556..8d79aee 100644
> --- a/platform/linux-generic/odp_crypto.c
> +++ b/platform/linux-generic/odp_crypto.c
> @@ -47,7 +47,7 @@ odp_crypto_generic_op_result_t
> *get_op_result_from_buffer(odp_buffer_t buf)
> odp_crypto_generic_op_result_t *result;
>
> temp = odp_buffer_addr(buf);
> - temp += odp_buffer_size(buf);
> + temp += odp_buffer_len(buf);
> temp -= sizeof(*result);
> result = (odp_crypto_generic_op_result_t *)(void *)temp;
> return result;
> diff --git a/platform/linux-generic/odp_packet.c
> b/platform/linux-generic/odp_packet.c
> index 0ab9866..5bf7b60 100644
> --- a/platform/linux-generic/odp_packet.c
> +++ b/platform/linux-generic/odp_packet.c
> @@ -58,7 +58,7 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len)
> pool_entry_t *pool = odp_buf_to_pool(&pkt_hdr->buf_hdr);
> uint32_t totsize = pool->s.headroom + len + pool->s.tailroom;
>
> - if (totsize > pkt_hdr->buf_hdr.size)
> + if (totsize > pkt_hdr->buf_hdr.len)
> return -1;
>
> packet_init(pool, pkt_hdr, len);
> @@ -90,7 +90,7 @@ void *odp_packet_head(odp_packet_t pkt)
>
> uint32_t odp_packet_buf_len(odp_packet_t pkt)
> {
> - return odp_packet_hdr(pkt)->buf_hdr.size;
> + return odp_packet_hdr(pkt)->buf_hdr.len;
> }
>
> void *odp_packet_data(odp_packet_t pkt)
> --
> 2.2.1
>
>
> _______________________________________________
> lng-odp mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp