For this series:

Reviewed-and-tested-by: Bill Fischofer <bill.fischo...@linaro.org>

On Fri, Jan 29, 2016 at 5:25 AM, Petri Savolainen <
petri.savolai...@nokia.com> wrote:

> Highlight that application must ensure that there's no
> race while calling init functions. Also lock free call
> will never set op.init flag, since init call will not need
> to implement locking or other (lock free) synchronization.
>
> Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
> ---
>  include/odp/api/atomic.h            | 11 +++++++++++
>  platform/linux-generic/odp_atomic.c |  4 +++-
>  2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/include/odp/api/atomic.h b/include/odp/api/atomic.h
> index 8626495..a16d90b 100644
> --- a/include/odp/api/atomic.h
> +++ b/include/odp/api/atomic.h
> @@ -67,6 +67,10 @@ extern "C" {
>  /**
>   * Initialize atomic uint32 variable
>   *
> + * Initializes the atomic variable with 'val'. This operation is not
> atomic.
> + * Application must ensure that there's no race condition while
> initializing
> + * the variable.
> + *
>   * @param atom    Pointer to atomic variable
>   * @param val     Value to initialize the variable with
>   */
> @@ -219,6 +223,10 @@ uint32_t odp_atomic_xchg_u32(odp_atomic_u32_t *atom,
> uint32_t new_val);
>  /**
>   * Initialize atomic uint64 variable
>   *
> + * Initializes the atomic variable with 'val'. This operation is not
> atomic.
> + * Application must ensure that there's no race condition while
> initializing
> + * the variable.
> + *
>   * @param atom    Pointer to atomic variable
>   * @param val     Value to initialize the variable with
>   */
> @@ -600,6 +608,9 @@ typedef union odp_atomic_op_t {
>   * variables instead of uint64 to optimize performance on platforms that
>   * implement a performance critical operation using locks.
>   *
> + * Init operations (e.g. odp_atomic_init_64()) are not atomic. This
> function
> + * clears the op.init bit but will never set it to one.
> + *
>   * @param atomic_op  Pointer to atomic operation structure for storing
>   *                   operation flags. All bits are initialized to zero
> during
>   *                   the operation. The parameter is ignored when NULL.
> diff --git a/platform/linux-generic/odp_atomic.c
> b/platform/linux-generic/odp_atomic.c
> index 996d09a..5b71ecf 100644
> --- a/platform/linux-generic/odp_atomic.c
> +++ b/platform/linux-generic/odp_atomic.c
> @@ -16,8 +16,10 @@ int odp_atomic_lock_free_u64(odp_atomic_op_t *atomic_op)
>         return 0;
>  #else
>         /* All operations are lock-free */
> -       if (atomic_op)
> +       if (atomic_op) {
>                 atomic_op->all_bits = ~((uint32_t)0);
> +               atomic_op->op.init  = 0;
> +       }
>
>         return 2;
>  #endif
> --
> 2.6.3
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to