diff mbox

api: odp_align: move internal macros

Message ID 1417724715-21477-1-git-send-email-mike.holmes@linaro.org
State Accepted
Commit 724a13aabdb129adbca5aa94a48607ed52ad07c0
Headers show

Commit Message

Mike Holmes Dec. 4, 2014, 8:25 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/include/api/odp_align.h     |  50 -----------
 .../linux-generic/include/odp_align_internal.h     | 100 +++++++++++++++++++++
 .../linux-generic/include/odp_packet_io_internal.h |   1 +
 .../linux-generic/include/odp_queue_internal.h     |   1 +
 platform/linux-generic/odp_buffer_pool.c           |   1 +
 platform/linux-generic/odp_packet_socket.c         |   1 +
 platform/linux-generic/odp_ring.c                  |   1 +
 platform/linux-generic/odp_shared_memory.c         |   1 +
 8 files changed, 106 insertions(+), 50 deletions(-)
 create mode 100644 platform/linux-generic/include/odp_align_internal.h

Comments

Bill Fischofer Dec. 4, 2014, 10:11 p.m. UTC | #1
Looks good.  Please get this merged soon as it will cause a number of other
patches to need to be rebased, including my buffer pool stuff that I'm
reworking for resubmission.  Thanks.

On Thu, Dec 4, 2014 at 2:25 PM, Mike Holmes <mike.holmes@linaro.org> wrote:

> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>

Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>


> ---
>  platform/linux-generic/include/api/odp_align.h     |  50 -----------
>  .../linux-generic/include/odp_align_internal.h     | 100
> +++++++++++++++++++++
>  .../linux-generic/include/odp_packet_io_internal.h |   1 +
>  .../linux-generic/include/odp_queue_internal.h     |   1 +
>  platform/linux-generic/odp_buffer_pool.c           |   1 +
>  platform/linux-generic/odp_packet_socket.c         |   1 +
>  platform/linux-generic/odp_ring.c                  |   1 +
>  platform/linux-generic/odp_shared_memory.c         |   1 +
>  8 files changed, 106 insertions(+), 50 deletions(-)
>  create mode 100644 platform/linux-generic/include/odp_align_internal.h
>
> diff --git a/platform/linux-generic/include/api/odp_align.h
> b/platform/linux-generic/include/api/odp_align.h
> index eb5f724..6ec5a0a 100644
> --- a/platform/linux-generic/include/api/odp_align.h
> +++ b/platform/linux-generic/include/api/odp_align.h
> @@ -84,12 +84,6 @@ extern "C" {
>   * Round up
>   */
>
> -/**
> - * @internal
> - * Round up 'x' to alignment 'align'
> - */
> -#define ODP_ALIGN_ROUNDUP(x, align)\
> -       ((align) * (((x) + align - 1) / (align)))
>
>  /**
>   * @internal
> @@ -98,12 +92,6 @@ extern "C" {
>  #define ODP_ALIGN_ROUNDUP_PTR(x, align)\
>         ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align)))
>
> -/**
> - * @internal
> - * Round up 'x' to cache line size alignment
> - */
> -#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\
> -       ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE)
>
>  /**
>   * @internal
> @@ -112,24 +100,12 @@ extern "C" {
>  #define ODP_CACHE_LINE_SIZE_ROUNDUP_PTR(x)\
>         ((void *)ODP_CACHE_LINE_SIZE_ROUNDUP((uintptr_t)(x)))
>
> -/**
> - * @internal
> - * Round up 'x' to page size alignment
> - */
> -#define ODP_PAGE_SIZE_ROUNDUP(x)\
> -       ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE)
>
>
>  /*
>   * Round down
>   */
>
> -/**
> - * @internal
> - * Round down 'x' to 'align' alignment, which is a power of two
> - */
> -#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\
> -       ((x) & (~((align) - 1)))
>
>  /**
>   * @internal
> @@ -138,12 +114,6 @@ extern "C" {
>  #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
>  ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x), (uintptr_t)(align)))
>
> -/**
> - * @internal
> - * Round down 'x' to cache line size alignment
> - */
> -#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\
> -       ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE)
>
>  /**
>   * @internal
> @@ -159,26 +129,6 @@ extern "C" {
>  /** Defines type/struct/variable to be page size aligned */
>  #define ODP_ALIGNED_PAGE    ODP_ALIGNED(ODP_PAGE_SIZE)
>
> -
> -
> -/*
> - * Check align
> - */
> -
> -/**
> - * @internal
> - * Check if pointer 'x' is aligned to 'align', which is a power of two
> - */
> -#define ODP_ALIGNED_CHECK_POWER_2(x, align)\
> -       ((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0)
> -
> -/**
> - * @internal
> - * Check if value is a power of two
> - */
> -#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0)
> -
> -
>  /**
>   * @}
>   */
> diff --git a/platform/linux-generic/include/odp_align_internal.h
> b/platform/linux-generic/include/odp_align_internal.h
> new file mode 100644
> index 0000000..498a7a9
> --- /dev/null
> +++ b/platform/linux-generic/include/odp_align_internal.h
> @@ -0,0 +1,100 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:    BSD-3-Clause
> + */
> +
> +/**
> + * @file
> + *
> + * ODP internal alignments
> + */
> +
> +#ifndef ODP_ALIGN_INTERNAL_H_
> +#define ODP_ALIGN_INTERNAL_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include <odp_align.h>
> +
> +/** @addtogroup odp_compiler_optim
> + *  @{
> + */
> +
> +/*
> + * Round up
> + */
> +
> +/**
> + * @internal
> + * Round up 'x' to alignment 'align'
> + */
> +#define ODP_ALIGN_ROUNDUP(x, align)\
> +       ((align) * (((x) + align - 1) / (align)))
> +
> +/**
> + * @internal
> + * Round up pointer 'x' to alignment 'align'
> + */
> +#define ODP_ALIGN_ROUNDUP_PTR(x, align)\
> +       ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align)))
> +
> +/**
> + * @internal
> + * Round up 'x' to cache line size alignment
> + */
> +#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\
> +       ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE)
> +
> +/**
> + * @internal
> + * Round up 'x' to page size alignment
> + */
> +#define ODP_PAGE_SIZE_ROUNDUP(x)\
> +       ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE)
> +
> +/*
> + * Round down
> + */
> +
> +/**
> + * @internal
> + * Round down 'x' to 'align' alignment, which is a power of two
> + */
> +#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\
> +       ((x) & (~((align) - 1)))
> +/**
> + * @internal
> + * Round down 'x' to cache line size alignment
> + */
> +#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\
> +       ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE)
> +
> +/*
> + * Check align
> + */
> +
> +/**
> + * @internal
> + * Check if pointer 'x' is aligned to 'align', which is a power of two
> + */
> +#define ODP_ALIGNED_CHECK_POWER_2(x, align)\
> +       ((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0)
> +
> +/**
> + * @internal
> + * Check if value is a power of two
> + */
> +#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0)
> +
> +/**
> + * @}
> + */
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/platform/linux-generic/include/odp_packet_io_internal.h
> b/platform/linux-generic/include/odp_packet_io_internal.h
> index 0bc1e21..7819dc7 100644
> --- a/platform/linux-generic/include/odp_packet_io_internal.h
> +++ b/platform/linux-generic/include/odp_packet_io_internal.h
> @@ -20,6 +20,7 @@ extern "C" {
>
>  #include <odp_spinlock.h>
>  #include <odp_packet_socket.h>
> +#include <odp_align_internal.h>
>
>  #include <linux/if.h>
>
> diff --git a/platform/linux-generic/include/odp_queue_internal.h
> b/platform/linux-generic/include/odp_queue_internal.h
> index 8b6c517..1254763 100644
> --- a/platform/linux-generic/include/odp_queue_internal.h
> +++ b/platform/linux-generic/include/odp_queue_internal.h
> @@ -20,6 +20,7 @@ extern "C" {
>
>  #include <odp_queue.h>
>  #include <odp_buffer_internal.h>
> +#include <odp_align_internal.h>
>  #include <odp_packet_io.h>
>  #include <odp_align.h>
>
> diff --git a/platform/linux-generic/odp_buffer_pool.c
> b/platform/linux-generic/odp_buffer_pool.c
> index 6a0a6b2..250da81 100644
> --- a/platform/linux-generic/odp_buffer_pool.c
> +++ b/platform/linux-generic/odp_buffer_pool.c
> @@ -10,6 +10,7 @@
>  #include <odp_buffer_internal.h>
>  #include <odp_packet_internal.h>
>  #include <odp_timer_internal.h>
> +#include <odp_align_internal.h>
>  #include <odp_shared_memory.h>
>  #include <odp_align.h>
>  #include <odp_internal.h>
> diff --git a/platform/linux-generic/odp_packet_socket.c
> b/platform/linux-generic/odp_packet_socket.c
> index 68983eb..1468340 100644
> --- a/platform/linux-generic/odp_packet_socket.c
> +++ b/platform/linux-generic/odp_packet_socket.c
> @@ -36,6 +36,7 @@
>
>  #include <odp_packet_socket.h>
>  #include <odp_packet_internal.h>
> +#include <odp_align_internal.h>
>  #include <odp_hints.h>
>
>  #include <odph_eth.h>
> diff --git a/platform/linux-generic/odp_ring.c
> b/platform/linux-generic/odp_ring.c
> index 1d3130a..2b4e0a6 100644
> --- a/platform/linux-generic/odp_ring.c
> +++ b/platform/linux-generic/odp_ring.c
> @@ -72,6 +72,7 @@
>  #include <odp_shared_memory.h>
>  #include <odp_internal.h>
>  #include <odp_spin_internal.h>
> +#include <odp_align_internal.h>
>  #include <odp_spinlock.h>
>  #include <odp_align.h>
>  #include <sys/mman.h>
> diff --git a/platform/linux-generic/odp_shared_memory.c
> b/platform/linux-generic/odp_shared_memory.c
> index 4bcf73e..abf6da3 100644
> --- a/platform/linux-generic/odp_shared_memory.c
> +++ b/platform/linux-generic/odp_shared_memory.c
> @@ -11,6 +11,7 @@
>  #include <odp_system_info.h>
>  #include <odp_debug.h>
>  #include <odp_debug_internal.h>
> +#include <odp_align_internal.h>
>
>  #include <unistd.h>
>  #include <sys/mman.h>
> --
> 2.1.0
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Dec. 5, 2014, 7:20 a.m. UTC | #2
Merged,
Maxim.

On 12/05/2014 01:11 AM, Bill Fischofer wrote:
> Looks good.  Please get this merged soon as it will cause a number of 
> other patches to need to be rebased, including my buffer pool stuff 
> that I'm reworking for resubmission. Thanks.
>
> On Thu, Dec 4, 2014 at 2:25 PM, Mike Holmes <mike.holmes@linaro.org 
> <mailto:mike.holmes@linaro.org>> wrote:
>
>     Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>     <mailto:mike.holmes@linaro.org>>
>
>
> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>>
>
>     ---
>      platform/linux-generic/include/api/odp_align.h     |  50 -----------
>      .../linux-generic/include/odp_align_internal.h     | 100
>     +++++++++++++++++++++
>      .../linux-generic/include/odp_packet_io_internal.h |   1 +
>      .../linux-generic/include/odp_queue_internal.h     |   1 +
>      platform/linux-generic/odp_buffer_pool.c           |   1 +
>      platform/linux-generic/odp_packet_socket.c         |   1 +
>      platform/linux-generic/odp_ring.c                  |   1 +
>      platform/linux-generic/odp_shared_memory.c         |   1 +
>      8 files changed, 106 insertions(+), 50 deletions(-)
>      create mode 100644
>     platform/linux-generic/include/odp_align_internal.h
>
>     diff --git a/platform/linux-generic/include/api/odp_align.h
>     b/platform/linux-generic/include/api/odp_align.h
>     index eb5f724..6ec5a0a 100644
>     --- a/platform/linux-generic/include/api/odp_align.h
>     +++ b/platform/linux-generic/include/api/odp_align.h
>     @@ -84,12 +84,6 @@ extern "C" {
>       * Round up
>       */
>
>     -/**
>     - * @internal
>     - * Round up 'x' to alignment 'align'
>     - */
>     -#define ODP_ALIGN_ROUNDUP(x, align)\
>     -       ((align) * (((x) + align - 1) / (align)))
>
>      /**
>       * @internal
>     @@ -98,12 +92,6 @@ extern "C" {
>      #define ODP_ALIGN_ROUNDUP_PTR(x, align)\
>             ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x),
>     (uintptr_t)(align)))
>
>     -/**
>     - * @internal
>     - * Round up 'x' to cache line size alignment
>     - */
>     -#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\
>     -       ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE)
>
>      /**
>       * @internal
>     @@ -112,24 +100,12 @@ extern "C" {
>      #define ODP_CACHE_LINE_SIZE_ROUNDUP_PTR(x)\
>             ((void *)ODP_CACHE_LINE_SIZE_ROUNDUP((uintptr_t)(x)))
>
>     -/**
>     - * @internal
>     - * Round up 'x' to page size alignment
>     - */
>     -#define ODP_PAGE_SIZE_ROUNDUP(x)\
>     -       ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE)
>
>
>      /*
>       * Round down
>       */
>
>     -/**
>     - * @internal
>     - * Round down 'x' to 'align' alignment, which is a power of two
>     - */
>     -#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\
>     -       ((x) & (~((align) - 1)))
>
>      /**
>       * @internal
>     @@ -138,12 +114,6 @@ extern "C" {
>      #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
>      ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x),
>     (uintptr_t)(align)))
>
>     -/**
>     - * @internal
>     - * Round down 'x' to cache line size alignment
>     - */
>     -#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\
>     -       ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE)
>
>      /**
>       * @internal
>     @@ -159,26 +129,6 @@ extern "C" {
>      /** Defines type/struct/variable to be page size aligned */
>      #define ODP_ALIGNED_PAGE    ODP_ALIGNED(ODP_PAGE_SIZE)
>
>     -
>     -
>     -/*
>     - * Check align
>     - */
>     -
>     -/**
>     - * @internal
>     - * Check if pointer 'x' is aligned to 'align', which is a power
>     of two
>     - */
>     -#define ODP_ALIGNED_CHECK_POWER_2(x, align)\
>     -       ((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0)
>     -
>     -/**
>     - * @internal
>     - * Check if value is a power of two
>     - */
>     -#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0)
>     -
>     -
>      /**
>       * @}
>       */
>     diff --git a/platform/linux-generic/include/odp_align_internal.h
>     b/platform/linux-generic/include/odp_align_internal.h
>     new file mode 100644
>     index 0000000..498a7a9
>     --- /dev/null
>     +++ b/platform/linux-generic/include/odp_align_internal.h
>     @@ -0,0 +1,100 @@
>     +/* Copyright (c) 2014, Linaro Limited
>     + * All rights reserved.
>     + *
>     + * SPDX-License-Identifier:    BSD-3-Clause
>     + */
>     +
>     +/**
>     + * @file
>     + *
>     + * ODP internal alignments
>     + */
>     +
>     +#ifndef ODP_ALIGN_INTERNAL_H_
>     +#define ODP_ALIGN_INTERNAL_H_
>     +
>     +#ifdef __cplusplus
>     +extern "C" {
>     +#endif
>     +
>     +#include <odp_align.h>
>     +
>     +/** @addtogroup odp_compiler_optim
>     + *  @{
>     + */
>     +
>     +/*
>     + * Round up
>     + */
>     +
>     +/**
>     + * @internal
>     + * Round up 'x' to alignment 'align'
>     + */
>     +#define ODP_ALIGN_ROUNDUP(x, align)\
>     +       ((align) * (((x) + align - 1) / (align)))
>     +
>     +/**
>     + * @internal
>     + * Round up pointer 'x' to alignment 'align'
>     + */
>     +#define ODP_ALIGN_ROUNDUP_PTR(x, align)\
>     +       ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x),
>     (uintptr_t)(align)))
>     +
>     +/**
>     + * @internal
>     + * Round up 'x' to cache line size alignment
>     + */
>     +#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\
>     +       ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE)
>     +
>     +/**
>     + * @internal
>     + * Round up 'x' to page size alignment
>     + */
>     +#define ODP_PAGE_SIZE_ROUNDUP(x)\
>     +       ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE)
>     +
>     +/*
>     + * Round down
>     + */
>     +
>     +/**
>     + * @internal
>     + * Round down 'x' to 'align' alignment, which is a power of two
>     + */
>     +#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\
>     +       ((x) & (~((align) - 1)))
>     +/**
>     + * @internal
>     + * Round down 'x' to cache line size alignment
>     + */
>     +#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\
>     +       ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE)
>     +
>     +/*
>     + * Check align
>     + */
>     +
>     +/**
>     + * @internal
>     + * Check if pointer 'x' is aligned to 'align', which is a power
>     of two
>     + */
>     +#define ODP_ALIGNED_CHECK_POWER_2(x, align)\
>     +       ((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0)
>     +
>     +/**
>     + * @internal
>     + * Check if value is a power of two
>     + */
>     +#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0)
>     +
>     +/**
>     + * @}
>     + */
>     +
>     +#ifdef __cplusplus
>     +}
>     +#endif
>     +
>     +#endif
>     diff --git
>     a/platform/linux-generic/include/odp_packet_io_internal.h
>     b/platform/linux-generic/include/odp_packet_io_internal.h
>     index 0bc1e21..7819dc7 100644
>     --- a/platform/linux-generic/include/odp_packet_io_internal.h
>     +++ b/platform/linux-generic/include/odp_packet_io_internal.h
>     @@ -20,6 +20,7 @@ extern "C" {
>
>      #include <odp_spinlock.h>
>      #include <odp_packet_socket.h>
>     +#include <odp_align_internal.h>
>
>      #include <linux/if.h>
>
>     diff --git a/platform/linux-generic/include/odp_queue_internal.h
>     b/platform/linux-generic/include/odp_queue_internal.h
>     index 8b6c517..1254763 100644
>     --- a/platform/linux-generic/include/odp_queue_internal.h
>     +++ b/platform/linux-generic/include/odp_queue_internal.h
>     @@ -20,6 +20,7 @@ extern "C" {
>
>      #include <odp_queue.h>
>      #include <odp_buffer_internal.h>
>     +#include <odp_align_internal.h>
>      #include <odp_packet_io.h>
>      #include <odp_align.h>
>
>     diff --git a/platform/linux-generic/odp_buffer_pool.c
>     b/platform/linux-generic/odp_buffer_pool.c
>     index 6a0a6b2..250da81 100644
>     --- a/platform/linux-generic/odp_buffer_pool.c
>     +++ b/platform/linux-generic/odp_buffer_pool.c
>     @@ -10,6 +10,7 @@
>      #include <odp_buffer_internal.h>
>      #include <odp_packet_internal.h>
>      #include <odp_timer_internal.h>
>     +#include <odp_align_internal.h>
>      #include <odp_shared_memory.h>
>      #include <odp_align.h>
>      #include <odp_internal.h>
>     diff --git a/platform/linux-generic/odp_packet_socket.c
>     b/platform/linux-generic/odp_packet_socket.c
>     index 68983eb..1468340 100644
>     --- a/platform/linux-generic/odp_packet_socket.c
>     +++ b/platform/linux-generic/odp_packet_socket.c
>     @@ -36,6 +36,7 @@
>
>      #include <odp_packet_socket.h>
>      #include <odp_packet_internal.h>
>     +#include <odp_align_internal.h>
>      #include <odp_hints.h>
>
>      #include <odph_eth.h>
>     diff --git a/platform/linux-generic/odp_ring.c
>     b/platform/linux-generic/odp_ring.c
>     index 1d3130a..2b4e0a6 100644
>     --- a/platform/linux-generic/odp_ring.c
>     +++ b/platform/linux-generic/odp_ring.c
>     @@ -72,6 +72,7 @@
>      #include <odp_shared_memory.h>
>      #include <odp_internal.h>
>      #include <odp_spin_internal.h>
>     +#include <odp_align_internal.h>
>      #include <odp_spinlock.h>
>      #include <odp_align.h>
>      #include <sys/mman.h>
>     diff --git a/platform/linux-generic/odp_shared_memory.c
>     b/platform/linux-generic/odp_shared_memory.c
>     index 4bcf73e..abf6da3 100644
>     --- a/platform/linux-generic/odp_shared_memory.c
>     +++ b/platform/linux-generic/odp_shared_memory.c
>     @@ -11,6 +11,7 @@
>      #include <odp_system_info.h>
>      #include <odp_debug.h>
>      #include <odp_debug_internal.h>
>     +#include <odp_align_internal.h>
>
>      #include <unistd.h>
>      #include <sys/mman.h>
>     --
>     2.1.0
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Taras Kondratiuk Dec. 5, 2014, 9:04 a.m. UTC | #3
On 12/04/2014 10:25 PM, Mike Holmes wrote:
> @@ -138,12 +114,6 @@ extern "C" {
>   #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
>   ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x), (uintptr_t)(align)))

Only part of internal macros were moved. For example why
ODP_ALIGN_ROUNDDOWN_PTR_POWER_2() is still in public header?
What was the criteria to choose which function to move?
Ola Liljedahl Dec. 5, 2014, 10:39 a.m. UTC | #4
On 5 December 2014 at 10:04, Taras Kondratiuk
<taras.kondratiuk@linaro.org> wrote:
> On 12/04/2014 10:25 PM, Mike Holmes wrote:
>>
>> @@ -138,12 +114,6 @@ extern "C" {
>>   #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
>>   ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x),
>> (uintptr_t)(align)))
>
>
> Only part of internal macros were moved. For example why
> ODP_ALIGN_ROUNDDOWN_PTR_POWER_2() is still in public header?
> What was the criteria to choose which function to move?

I haven't had a look at what remains public after the patch but ODP
applications have a legitimate interest in making their data
structures cache line (and even page) aligned etc.

So I would expect the following macros (or some subset) to remain public:
ODP_ALIGNED
ODP_ALIGNED_CACHE
ODP_ALIGNED_PAGE
ODP_PACKED
ODP_CACHE_LINE_SIZE
ODP_ALIGN_ROUNDUP or ODP_CACHE_LINE_SIZE_ROUNDUP (why so long names?)
ODP_PAGE_SIZE_ROUNDUP

I also recommend that we use the shorter term "LINE" instead of
"CACHE_LINE". PAGE and LINE, short and nice.


>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Mike Holmes Dec. 5, 2014, 2:24 p.m. UTC | #5
I  addressed only what was in the 1.0 API  doc
<https://docs.google.com/a/linaro.org/document/d/1BRVyW8IIVMTq4nhB_vUz5y-te6TEdu5g1XgolujjY6c/edit#heading=h.iwjfgdfj3au0>
we
need Petri to approve more, but suctions in the doc welcome.

On 5 December 2014 at 04:04, Taras Kondratiuk <taras.kondratiuk@linaro.org>
wrote:

> On 12/04/2014 10:25 PM, Mike Holmes wrote:
>
>> @@ -138,12 +114,6 @@ extern "C" {
>>   #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
>>   ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x),
>> (uintptr_t)(align)))
>>
>
> Only part of internal macros were moved. For example why
> ODP_ALIGN_ROUNDDOWN_PTR_POWER_2() is still in public header?
> What was the criteria to choose which function to move?
>
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_align.h b/platform/linux-generic/include/api/odp_align.h
index eb5f724..6ec5a0a 100644
--- a/platform/linux-generic/include/api/odp_align.h
+++ b/platform/linux-generic/include/api/odp_align.h
@@ -84,12 +84,6 @@  extern "C" {
  * Round up
  */
 
-/**
- * @internal
- * Round up 'x' to alignment 'align'
- */
-#define ODP_ALIGN_ROUNDUP(x, align)\
-	((align) * (((x) + align - 1) / (align)))
 
 /**
  * @internal
@@ -98,12 +92,6 @@  extern "C" {
 #define ODP_ALIGN_ROUNDUP_PTR(x, align)\
 	((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align)))
 
-/**
- * @internal
- * Round up 'x' to cache line size alignment
- */
-#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\
-	ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE)
 
 /**
  * @internal
@@ -112,24 +100,12 @@  extern "C" {
 #define ODP_CACHE_LINE_SIZE_ROUNDUP_PTR(x)\
 	((void *)ODP_CACHE_LINE_SIZE_ROUNDUP((uintptr_t)(x)))
 
-/**
- * @internal
- * Round up 'x' to page size alignment
- */
-#define ODP_PAGE_SIZE_ROUNDUP(x)\
-	ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE)
 
 
 /*
  * Round down
  */
 
-/**
- * @internal
- * Round down 'x' to 'align' alignment, which is a power of two
- */
-#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\
-	((x) & (~((align) - 1)))
 
 /**
  * @internal
@@ -138,12 +114,6 @@  extern "C" {
 #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\
 ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x), (uintptr_t)(align)))
 
-/**
- * @internal
- * Round down 'x' to cache line size alignment
- */
-#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\
-	ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE)
 
 /**
  * @internal
@@ -159,26 +129,6 @@  extern "C" {
 /** Defines type/struct/variable to be page size aligned */
 #define ODP_ALIGNED_PAGE    ODP_ALIGNED(ODP_PAGE_SIZE)
 
-
-
-/*
- * Check align
- */
-
-/**
- * @internal
- * Check if pointer 'x' is aligned to 'align', which is a power of two
- */
-#define ODP_ALIGNED_CHECK_POWER_2(x, align)\
-	((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0)
-
-/**
- * @internal
- * Check if value is a power of two
- */
-#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0)
-
-
 /**
  * @}
  */
diff --git a/platform/linux-generic/include/odp_align_internal.h b/platform/linux-generic/include/odp_align_internal.h
new file mode 100644
index 0000000..498a7a9
--- /dev/null
+++ b/platform/linux-generic/include/odp_align_internal.h
@@ -0,0 +1,100 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:	BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP internal alignments
+ */
+
+#ifndef ODP_ALIGN_INTERNAL_H_
+#define ODP_ALIGN_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_align.h>
+
+/** @addtogroup odp_compiler_optim
+ *  @{
+ */
+
+/*
+ * Round up
+ */
+
+/**
+ * @internal
+ * Round up 'x' to alignment 'align'
+ */
+#define ODP_ALIGN_ROUNDUP(x, align)\
+	((align) * (((x) + align - 1) / (align)))
+
+/**
+ * @internal
+ * Round up pointer 'x' to alignment 'align'
+ */
+#define ODP_ALIGN_ROUNDUP_PTR(x, align)\
+	((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align)))
+
+/**
+ * @internal
+ * Round up 'x' to cache line size alignment
+ */
+#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\
+	ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE)
+
+/**
+ * @internal
+ * Round up 'x' to page size alignment
+ */
+#define ODP_PAGE_SIZE_ROUNDUP(x)\
+	ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE)
+
+/*
+ * Round down
+ */
+
+/**
+ * @internal
+ * Round down 'x' to 'align' alignment, which is a power of two
+ */
+#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\
+	((x) & (~((align) - 1)))
+/**
+ * @internal
+ * Round down 'x' to cache line size alignment
+ */
+#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\
+	ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE)
+
+/*
+ * Check align
+ */
+
+/**
+ * @internal
+ * Check if pointer 'x' is aligned to 'align', which is a power of two
+ */
+#define ODP_ALIGNED_CHECK_POWER_2(x, align)\
+	((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0)
+
+/**
+ * @internal
+ * Check if value is a power of two
+ */
+#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0)
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 0bc1e21..7819dc7 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -20,6 +20,7 @@  extern "C" {
 
 #include <odp_spinlock.h>
 #include <odp_packet_socket.h>
+#include <odp_align_internal.h>
 
 #include <linux/if.h>
 
diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h
index 8b6c517..1254763 100644
--- a/platform/linux-generic/include/odp_queue_internal.h
+++ b/platform/linux-generic/include/odp_queue_internal.h
@@ -20,6 +20,7 @@  extern "C" {
 
 #include <odp_queue.h>
 #include <odp_buffer_internal.h>
+#include <odp_align_internal.h>
 #include <odp_packet_io.h>
 #include <odp_align.h>
 
diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c
index 6a0a6b2..250da81 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -10,6 +10,7 @@ 
 #include <odp_buffer_internal.h>
 #include <odp_packet_internal.h>
 #include <odp_timer_internal.h>
+#include <odp_align_internal.h>
 #include <odp_shared_memory.h>
 #include <odp_align.h>
 #include <odp_internal.h>
diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c
index 68983eb..1468340 100644
--- a/platform/linux-generic/odp_packet_socket.c
+++ b/platform/linux-generic/odp_packet_socket.c
@@ -36,6 +36,7 @@ 
 
 #include <odp_packet_socket.h>
 #include <odp_packet_internal.h>
+#include <odp_align_internal.h>
 #include <odp_hints.h>
 
 #include <odph_eth.h>
diff --git a/platform/linux-generic/odp_ring.c b/platform/linux-generic/odp_ring.c
index 1d3130a..2b4e0a6 100644
--- a/platform/linux-generic/odp_ring.c
+++ b/platform/linux-generic/odp_ring.c
@@ -72,6 +72,7 @@ 
 #include <odp_shared_memory.h>
 #include <odp_internal.h>
 #include <odp_spin_internal.h>
+#include <odp_align_internal.h>
 #include <odp_spinlock.h>
 #include <odp_align.h>
 #include <sys/mman.h>
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index 4bcf73e..abf6da3 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -11,6 +11,7 @@ 
 #include <odp_system_info.h>
 #include <odp_debug.h>
 #include <odp_debug_internal.h>
+#include <odp_align_internal.h>
 
 #include <unistd.h>
 #include <sys/mman.h>