From patchwork Wed Dec 3 14:17:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 41847 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3472525E88 for ; Wed, 3 Dec 2014 14:18:32 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf9771956wiv.5 for ; Wed, 03 Dec 2014 06:18:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=AwqRffZ69vPhBLDn0hL8izF2vTwswJ6K9YEUGqW+Gds=; b=bV9j3GQsifnz9bI1PmbewUsDOdzfhBd0EUExGJ8WpwzZoGsRdNSTMFoW9e9k3X7bbW 33WeTomV7gpiBhrgK9ZHDQzOTQaNFcW1iSoBLw0GdrOUICkROw8IiwBPWTbJ2SQcHtQw 8n2n5FwkG3p5AWGmMG2pCuUx66IP5nkmxtC/e+2xPFFnDi7PjVvkjsSUkqLuK0hj1jLb XqcqoVEHUtJ7rip/LvijY4J92r6WKFXSsjSKho47FyGDm89Vw5QxCLJ5NaEg9wlTUeAF zvL+Vda57lEfekNGxhvKZUEmIw62sAEONa+1cIeLBLLTndI8nl/A4feKvceJ03mvgbk6 o4zw== X-Gm-Message-State: ALoCoQk4Zv6sm7q/KtT0KacvnCTYicVPqGEQo3ppaCAZkgeC8CSvFLdvYwUtkt4DclNEQGpLOKU4 X-Received: by 10.112.147.131 with SMTP id tk3mr1145774lbb.2.1417616311423; Wed, 03 Dec 2014 06:18:31 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.4.41 with SMTP id cb9ls165754lad.52.gmail; Wed, 03 Dec 2014 06:18:31 -0800 (PST) X-Received: by 10.112.235.135 with SMTP id um7mr4587882lbc.96.1417616311134; Wed, 03 Dec 2014 06:18:31 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id bb5si17333511lab.36.2014.12.03.06.18.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 06:18:31 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id q1so7618225lam.19 for ; Wed, 03 Dec 2014 06:18:31 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr4400307lbc.23.1417616310976; Wed, 03 Dec 2014 06:18:30 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp672031lbc; Wed, 3 Dec 2014 06:18:28 -0800 (PST) X-Received: by 10.140.97.37 with SMTP id l34mr8328032qge.43.1417616308323; Wed, 03 Dec 2014 06:18:28 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id s3si7813175qak.101.2014.12.03.06.18.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 03 Dec 2014 06:18:28 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XwAl6-0003MN-OO; Wed, 03 Dec 2014 14:18:24 +0000 Received: from mail-la0-f43.google.com ([209.85.215.43]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XwAkY-0003DB-Ro for lng-odp@lists.linaro.org; Wed, 03 Dec 2014 14:17:51 +0000 Received: by mail-la0-f43.google.com with SMTP id ge10so7989662lab.16 for ; Wed, 03 Dec 2014 06:17:45 -0800 (PST) X-Received: by 10.152.21.9 with SMTP id r9mr4598149lae.76.1417616265320; Wed, 03 Dec 2014 06:17:45 -0800 (PST) Received: from macmini.lan (84-217-193-77.tn.glocalnet.net. [84.217.193.77]) by mx.google.com with ESMTPSA id or5sm6483330lbb.42.2014.12.03.06.17.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Dec 2014 06:17:44 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Wed, 3 Dec 2014 15:17:34 +0100 Message-Id: <1417616254-31760-7-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417616254-31760-1-git-send-email-ola.liljedahl@linaro.org> References: <1417616254-31760-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 6/6] linux-generic:odp_atomic_internal.h: Update doxygen comments, renaming of function params X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ola.liljedahl@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ola Liljedahl --- Update doxygen comments, renaming of function params. Made _odp_atomic_flag_load() use acquire instead of relaxed memory order. .../linux-generic/include/odp_atomic_internal.h | 378 +++++++++++---------- 1 file changed, 191 insertions(+), 187 deletions(-) diff --git a/platform/linux-generic/include/odp_atomic_internal.h b/platform/linux-generic/include/odp_atomic_internal.h index e0b842b..90cb3aa 100644 --- a/platform/linux-generic/include/odp_atomic_internal.h +++ b/platform/linux-generic/include/odp_atomic_internal.h @@ -16,8 +16,7 @@ #ifndef ODP_ATOMIC_INTERNAL_H_ #define ODP_ATOMIC_INTERNAL_H_ -#include -#include +#include #include #include #include @@ -47,25 +46,25 @@ ODP_ALIGNED(sizeof(void *)); /* Enforce alignement! */ typedef char _odp_atomic_flag_t; /** - * Memory consistency models supported by ODP. + * Memory orderings supported by ODP. */ typedef enum { -/** Relaxed memory model, no ordering of other accesses enforced. - * Atomic operations with relaxed memory model cannot be used for +/** Relaxed memory ordering, no ordering of other accesses enforced. + * Atomic operations with relaxed memory ordering cannot be used for * synchronization */ _ODP_MEMMODEL_RLX = __ATOMIC_RELAXED, -/** Acquire memory model, synchronize with release stores from another +/** Acquire memory ordering, synchronize with release stores from another * thread (later accesses cannot move before acquire operation). - * Use acquire and release memory models for Release Consistency */ + * Use acquire and release memory ordering for Release Consistency */ _ODP_MEMMODEL_ACQ = __ATOMIC_ACQUIRE, -/** Release memory model, synchronize with acquire loads from another +/** Release memory ordering, synchronize with acquire loads from another * thread (earlier accesses cannot move after release operation). - * Use acquire and release memory models for Release Consistency */ + * Use acquire and release memory ordering for Release Consistency */ _ODP_MEMMODEL_RLS = __ATOMIC_RELEASE, -/** Acquire&release memory model, synchronize with acquire loads and release +/** Acquire&release memory ordering, synchronize with acquire loads and release * stores in another (one other) thread */ _ODP_MEMMODEL_ACQ_RLS = __ATOMIC_ACQ_REL, -/** Sequential consistent memory model, synchronize with acquire loads and +/** Sequential consistent memory ordering, synchronize with acquire loads and * release stores in all threads */ _ODP_MEMMODEL_SC = __ATOMIC_SEQ_CST } _odp_memmodel_t; @@ -91,133 +90,134 @@ typedef enum { /** * Atomic load of 32-bit atomic variable * - * @param ptr Pointer to a 32-bit atomic variable - * @param mmodel Memory model associated with the load operation + * @param[in] p_atom Pointer to a 32-bit atomic variable + * @param[in] mmodel Memory ordering associated with the load operation * * @return Value of the variable */ -static inline uint32_t _odp_atomic_u32_load_mm(const odp_atomic_u32_t *ptr, +static inline uint32_t _odp_atomic_u32_load_mm(const odp_atomic_u32_t *p_atom, _odp_memmodel_t mmodel) { - return __atomic_load_n(&ptr->v, mmodel); + return __atomic_load_n(&p_atom->v, mmodel); } /** * Atomic store to 32-bit atomic variable * - * @param ptr Pointer to a 32-bit atomic variable - * @param val Value to store in the atomic variable - * @param mmodel Memory model associated with the store operation + * @param[out] p_atom Pointer to a 32-bit atomic variable + * @param[in] val Value to store in the atomic variable + * @param[in] mmodel Memory order associated with the store operation */ -static inline void _odp_atomic_u32_store_mm(odp_atomic_u32_t *ptr, +static inline void _odp_atomic_u32_store_mm(odp_atomic_u32_t *p_atom, uint32_t val, _odp_memmodel_t mmodel) { - __atomic_store_n(&ptr->v, val, mmodel); + __atomic_store_n(&p_atom->v, val, mmodel); } /** * Atomic exchange (swap) of 32-bit atomic variable * - * @param ptr Pointer to a 32-bit atomic variable - * @param val New value to store in the atomic variable - * @param mmodel Memory model associated with the exchange operation + * @param[in,out] p_atom Pointer to a 32-bit atomic variable + * @param[in] val New value to store in the atomic variable + * @param[in] mmodel Memory order associated with the exchange operation * * @return Old value of the variable */ -static inline uint32_t _odp_atomic_u32_xchg_mm(odp_atomic_u32_t *ptr, +static inline uint32_t _odp_atomic_u32_xchg_mm(odp_atomic_u32_t *p_atom, uint32_t val, _odp_memmodel_t mmodel) { - return __atomic_exchange_n(&ptr->v, val, mmodel); + return __atomic_exchange_n(&p_atom->v, val, mmodel); } /** * Atomic compare and exchange (swap) of 32-bit atomic variable * "Strong" semantics, will not fail spuriously. * - * @param ptr Pointer to a 32-bit atomic variable - * @param exp_p Pointer to expected value (updated on failure) - * @param val New value to write - * @param succ Memory model associated with a successful compare-and-swap + * @param[in,out] p_atom Pointer to a 32-bit atomic variable + * @param[in,out] p_exp Pointer to expected value (updated on failure) + * @param[in] val New value to write + * @param[in] success Memory order associated with a successful compare-and-swap * operation - * @param fail Memory model associated with a failed compare-and-swap + * @param[in] failure Memory order associated with a failed compare-and-swap * operation * - * @return 1 (true) if exchange successful, 0 (false) if not successful (and - * '*exp_p' updated with current value) + * @retval 1 exchange successul + * @retval 0 exchange failed and '*p_exp' updated with current value */ -static inline int _odp_atomic_u32_cmp_xchg_strong_mm(odp_atomic_u32_t *ptr, - uint32_t *exp_p, +static inline int _odp_atomic_u32_cmp_xchg_strong_mm( + odp_atomic_u32_t *p_atom, + uint32_t *p_exp, uint32_t val, - _odp_memmodel_t succ, - _odp_memmodel_t fail) + _odp_memmodel_t success, + _odp_memmodel_t failure) { - return __atomic_compare_exchange_n(&ptr->v, exp_p, val, - false/*strong*/, succ, fail); + return __atomic_compare_exchange_n(&p_atom->v, p_exp, val, + false/*strong*/, success, failure); } /** * Atomic fetch and add of 32-bit atomic variable * - * @param ptr Pointer to a 32-bit atomic variable - * @param val Value to add to the atomic variable - * @param mmodel Memory model associated with the add operation + * @param[in,out] p_atom Pointer to a 32-bit atomic variable + * @param[in] val Value to add to the atomic variable + * @param[in] mmodel Memory order associated with the add operation * * @return Value of the atomic variable before the addition */ -static inline uint32_t _odp_atomic_u32_fetch_add_mm(odp_atomic_u32_t *ptr, +static inline uint32_t _odp_atomic_u32_fetch_add_mm(odp_atomic_u32_t *p_atom, uint32_t val, _odp_memmodel_t mmodel) { - return __atomic_fetch_add(&ptr->v, val, mmodel); + return __atomic_fetch_add(&p_atom->v, val, mmodel); } /** * Atomic add of 32-bit atomic variable * - * @param ptr Pointer to a 32-bit atomic variable - * @param val Value to add to the atomic variable - * @param mmodel Memory model associated with the add operation + * @param[in,out] p_atom Pointer to a 32-bit atomic variable + * @param[in] val Value to add to the atomic variable + * @param[in] mmodel Memory order associated with the add operation */ -static inline void _odp_atomic_u32_add_mm(odp_atomic_u32_t *ptr, +static inline void _odp_atomic_u32_add_mm(odp_atomic_u32_t *p_atom, uint32_t val, _odp_memmodel_t mmodel) { - (void)__atomic_fetch_add(&ptr->v, val, mmodel); + (void)__atomic_fetch_add(&p_atom->v, val, mmodel); } /** * Atomic fetch and subtract of 32-bit atomic variable * - * @param ptr Pointer to a 32-bit atomic variable - * @param val Value to subtract from the atomic variable - * @param mmodel Memory model associated with the subtract operation + * @param[in,out] p_atom Pointer to a 32-bit atomic variable + * @param[in] val Value to subtract from the atomic variable + * @param[in] mmodel Memory order associated with the subtract operation * * @return Value of the atomic variable before the subtraction */ -static inline uint32_t _odp_atomic_u32_fetch_sub_mm(odp_atomic_u32_t *ptr, +static inline uint32_t _odp_atomic_u32_fetch_sub_mm(odp_atomic_u32_t *p_atom, uint32_t val, _odp_memmodel_t mmodel) { - return __atomic_fetch_sub(&ptr->v, val, mmodel); + return __atomic_fetch_sub(&p_atom->v, val, mmodel); } /** * Atomic subtract of 32-bit atomic variable * - * @param ptr Pointer to a 32-bit atomic variable - * @param val Value to subtract from the atomic variable - * @param mmodel Memory model associated with the subtract operation + * @param[in,out] p_atom Pointer to a 32-bit atomic variable + * @param[in] val Value to subtract from the atomic variable + * @param[in] mmodel Memory order associated with the subtract operation */ -static inline void _odp_atomic_u32_sub_mm(odp_atomic_u32_t *ptr, +static inline void _odp_atomic_u32_sub_mm(odp_atomic_u32_t *p_atom, uint32_t val, _odp_memmodel_t mmodel) { - (void)__atomic_fetch_sub(&ptr->v, val, mmodel); + (void)__atomic_fetch_sub(&p_atom->v, val, mmodel); } /***************************************************************************** @@ -237,23 +237,23 @@ static inline void _odp_atomic_u32_sub_mm(odp_atomic_u32_t *ptr, /** * @internal * Helper macro for lock-based atomic operations on 64-bit integers - * @param ptr Pointer to the 64-bit atomic variable - * @param expr Expression used update the variable. - * @param mm Memory model to use. + * @param[in,out] p_atom Pointer to the 64-bit atomic variable + * @param[in] expr Expression used update the variable. + * @param[in] mm Memory order to use. * @return The old value of the variable. */ -#define ATOMIC_OP_MM(ptr, expr, mm) \ +#define ATOMIC_OP_MM(p_atom, expr, mm) \ ({ \ uint64_t old_val; \ /* Loop while lock is already taken, stop when lock becomes clear */ \ - while (__atomic_test_and_set(&(ptr)->lock, \ - (mm) == _ODP_MEMMODELSC ? \ + while (__atomic_test_and_set(&(p_atom)->lock, \ + (mm) == _ODP_MEMMODEL_SC ? \ __ATOMIC_SEQ_CST : __ATOMIC_ACQUIRE)) \ (void)0; \ - old_val = (ptr)->v; \ + old_val = (p_atom)->v; \ (expr); /* Perform whatever update is desired */ \ - __atomic_clear(&(ptr)->lock, \ - (mm) == _ODP_MEMMODELSC ? \ + __atomic_clear(&(p_atom)->lock, \ + (mm) == _ODP_MEMMODEL_SC ? \ __ATOMIC_SEQ_CST : __ATOMIC_RELEASE); \ old_val; /* Return old value */ \ }) @@ -262,57 +262,57 @@ static inline void _odp_atomic_u32_sub_mm(odp_atomic_u32_t *ptr, /** * Atomic load of 64-bit atomic variable * - * @param ptr Pointer to a 64-bit atomic variable - * @param mmodel Memory model associated with the load operation + * @param[in] p_atom Pointer to a 64-bit atomic variable + * @param[in] mmodel Memory order associated with the load operation * * @return Value of the variable */ -static inline uint64_t _odp_atomic_u64_load_mm(odp_atomic_u64_t *ptr, +static inline uint64_t _odp_atomic_u64_load_mm(odp_atomic_u64_t *p_atom, _odp_memmodel_t mmodel) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - return ATOMIC_OP_MM(ptr, (void)0, mmodel); + return ATOMIC_OP_MM(p_atom, (void)0, mmodel); #else - return __atomic_load_n(&ptr->v, mmodel); + return __atomic_load_n(&p_atom->v, mmodel); #endif } /** * Atomic store to 64-bit atomic variable * - * @param ptr Pointer to a 64-bit atomic variable - * @param val Value to write to the atomic variable - * @param mmodel Memory model associated with the store operation + * @param[out] p_atom Pointer to a 64-bit atomic variable + * @param[in] val Value to write to the atomic variable + * @param[in] mmodel Memory order associated with the store operation */ -static inline void _odp_atomic_u64_store_mm(odp_atomic_u64_t *ptr, +static inline void _odp_atomic_u64_store_mm(odp_atomic_u64_t *p_atom, uint64_t val, _odp_memmodel_t mmodel) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - (void)ATOMIC_OP_MM(ptr, ptr->v = val, mmodel); + (void)ATOMIC_OP_MM(p_atom, p_atom->v = val, mmodel); #else - __atomic_store_n(&ptr->v, val, mmodel); + __atomic_store_n(&p_atom->v, val, mmodel); #endif } /** * Atomic exchange (swap) of 64-bit atomic variable * - * @param ptr Pointer to a 64-bit atomic variable - * @param val New value to write to the atomic variable - * @param mmodel Memory model associated with the exchange operation + * @param[in,out] p_atom Pointer to a 64-bit atomic variable + * @param[in] val New value to write to the atomic variable + * @param[in] mmodel Memory order associated with the exchange operation * * @return Old value of variable */ -static inline uint64_t _odp_atomic_u64_xchg_mm(odp_atomic_u64_t *ptr, +static inline uint64_t _odp_atomic_u64_xchg_mm(odp_atomic_u64_t *p_atom, uint64_t val, _odp_memmodel_t mmodel) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - return ATOMIC_OP_MM(ptr, ptr->v = val, mmodel); + return ATOMIC_OP_MM(p_atom, p_atom->v = val, mmodel); #else - return __atomic_exchange_n(&ptr->v, val, mmodel); + return __atomic_exchange_n(&p_atom->v, val, mmodel); #endif } @@ -320,123 +320,123 @@ static inline uint64_t _odp_atomic_u64_xchg_mm(odp_atomic_u64_t *ptr, * Atomic compare and exchange (swap) of 64-bit atomic variable * "Strong" semantics, will not fail spuriously. * - * @param ptr Pointer to a 64-bit atomic variable - * @param exp_p Pointer to expected value (updated on failure) - * @param val New value to write - * @param succ Memory model associated with a successful compare-and-swap + * @param[in,out] p_atom Pointer to a 64-bit atomic variable + * @param[in] p_exp Pointer to expected value (updated on failure) + * @param[in] val New value to write + * @param[in] success Memory order associated with a successful compare-and-swap + * operation + * @param[in] failure Memory order associated with a failed compare-and-swap * operation - * @param fail Memory model associated with a failed compare-and-swap operation * - * @return 1 (true) if exchange successful, 0 (false) if not successful (and - * '*exp_p' updated with current value) + * @retval 1 exchange successful + * @retval 0 exchange failed and '*p_exp' updated with current value */ -static inline int _odp_atomic_u64_cmp_xchg_strong_mm(odp_atomic_u64_t *ptr, - uint64_t *exp_p, +static inline int _odp_atomic_u64_cmp_xchg_strong_mm(odp_atomic_u64_t *p_atom, + uint64_t *p_exp, uint64_t val, - _odp_memmodel_t succ, - _odp_memmodel_t fail) + _odp_memmodel_t success, + _odp_memmodel_t failure) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 /* Possibly we are a bit pessimistic with the memory models */ - int success; + odp_bool_t ret_succ; /* Loop while lock is already taken, stop when lock becomes clear */ - while (__atomic_test_and_set(&(ptr)->lock, - (succ) == _ODP_MEMMODELSC ? + while (__atomic_test_and_set(&(p_atom)->lock, + (success) == _ODP_MEMMODEL_SC ? __ATOMIC_SEQ_CST : __ATOMIC_ACQUIRE)) (void)0; - if (ptr->v == *exp_p) { - ptr->v = val; - success = 1; + if (p_atom->v == *p_exp) { + p_atom->v = val; + ret_succ = 1; } else { - *exp_p = ptr->v; - success = 0; - succ = fail; + *p_exp = p_atom->v; + ret_succ = 0; } - __atomic_clear(&(ptr)->lock, - (succ) == _ODP_MEMMODELSC ? + __atomic_clear(&(p_atom)->lock, + (ret_succ ? success : failure) == _ODP_MEMMODEL_SC ? __ATOMIC_SEQ_CST : __ATOMIC_RELEASE); - return success; + return ret_succ; #else - return __atomic_compare_exchange_n(&ptr->v, exp_p, val, - false, succ, fail); + return __atomic_compare_exchange_n(&p_atom->v, p_exp, val, + false/*strong*/, success, failure); #endif } /** * Atomic fetch and add of 64-bit atomic variable * - * @param ptr Pointer to a 64-bit atomic variable - * @param val Value to add to the atomic variable - * @param mmodel Memory model associated with the add operation + * @param[in,out] p_atom Pointer to a 64-bit atomic variable + * @param[in] val Value to add to the atomic variable + * @param[in] mmodel Memory order associated with the add operation * * @return Value of the atomic variable before the addition */ -static inline uint64_t _odp_atomic_u64_fetch_add_mm(odp_atomic_u64_t *ptr, +static inline uint64_t _odp_atomic_u64_fetch_add_mm(odp_atomic_u64_t *p_atom, uint64_t val, _odp_memmodel_t mmodel) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - return ATOMIC_OP_MM(ptr, ptr->v += val, mmodel); + return ATOMIC_OP_MM(p_atom, p_atom->v += val, mmodel); #else - return __atomic_fetch_add(&ptr->v, val, mmodel); + return __atomic_fetch_add(&p_atom->v, val, mmodel); #endif } /** * Atomic add of 64-bit atomic variable * - * @param ptr Pointer to a 64-bit atomic variable - * @param val Value to add to the atomic variable - * @param mmodel Memory model associated with the add operation. + * @param[in,out] p_atom Pointer to a 64-bit atomic variable + * @param[in] val Value to add to the atomic variable + * @param[in] mmodel Memory order associated with the add operation. */ -static inline void _odp_atomic_u64_add_mm(odp_atomic_u64_t *ptr, +static inline void _odp_atomic_u64_add_mm(odp_atomic_u64_t *p_atom, uint64_t val, _odp_memmodel_t mmodel) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - (void)ATOMIC_OP_MM(ptr, ptr->v += val, mmodel); + (void)ATOMIC_OP_MM(p_atom, p_atom->v += val, mmodel); #else - (void)__atomic_fetch_add(&ptr->v, val, mmodel); + (void)__atomic_fetch_add(&p_atom->v, val, mmodel); #endif } /** * Atomic fetch and subtract of 64-bit atomic variable * - * @param ptr Pointer to a 64-bit atomic variable - * @param val Value to subtract from the atomic variable - * @param mmodel Memory model associated with the subtract operation + * @param[in,out] p_atom Pointer to a 64-bit atomic variable + * @param[in] val Value to subtract from the atomic variable + * @param[in] mmodel Memory order associated with the subtract operation * * @return Value of the atomic variable before the subtraction */ -static inline uint64_t _odp_atomic_u64_fetch_sub_mm(odp_atomic_u64_t *ptr, +static inline uint64_t _odp_atomic_u64_fetch_sub_mm(odp_atomic_u64_t *p_atom, uint64_t val, _odp_memmodel_t mmodel) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - return ATOMIC_OP_MM(ptr, ptr->v -= val, mmodel); + return ATOMIC_OP_MM(p_atom, p_atom->v -= val, mmodel); #else - return __atomic_fetch_sub(&ptr->v, val, mmodel); + return __atomic_fetch_sub(&p_atom->v, val, mmodel); #endif } /** * Atomic subtract of 64-bit atomic variable * - * @param ptr Pointer to a 64-bit atomic variable - * @param val Value to subtract from the atomic variable - * @param mmodel Memory model associated with the subtract operation + * @param[in,out] p_atom Pointer to a 64-bit atomic variable + * @param[in] val Value to subtract from the atomic variable + * @param[in] mmodel Memory order associated with the subtract operation */ -static inline void _odp_atomic_u64_sub_mm(odp_atomic_u64_t *ptr, +static inline void _odp_atomic_u64_sub_mm(odp_atomic_u64_t *p_atom, uint64_t val, _odp_memmodel_t mmodel) { #if !defined __GCC_ATOMIC_LLONG_LOCK_FREE || __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - (void)ATOMIC_OP_MM(ptr, ptr->v -= val, mmodel); + (void)ATOMIC_OP_MM(p_atom, p_atom->v -= val, mmodel); #else - (void)__atomic_fetch_sub(&ptr->v, val, mmodel); + (void)__atomic_fetch_sub(&p_atom->v, val, mmodel); #endif } @@ -455,81 +455,82 @@ static inline void _odp_atomic_u64_sub_mm(odp_atomic_u64_t *ptr, /** * Initialization of pointer atomic variable * - * @param ptr Pointer to a pointer atomic variable - * @param val Value to initialize the variable with + * @param[out] p_atom Pointer to a pointer atomic variable + * @param[in] val Value to initialize the variable with */ -static inline void _odp_atomic_ptr_init(_odp_atomic_ptr_t *ptr, void *val) +static inline void _odp_atomic_ptr_init(_odp_atomic_ptr_t *p_atom, void *val) { - __atomic_store_n(&ptr->v, val, __ATOMIC_RELAXED); + __atomic_store_n(&p_atom->v, val, __ATOMIC_RELAXED); } /** * Atomic load of pointer atomic variable * - * @param ptr Pointer to a pointer atomic variable - * @param mmodel Memory model associated with the load operation + * @param[in] p_atom Pointer to a pointer atomic variable + * @param[in] mmodel Memory order associated with the load operation * * @return Value of the variable */ -static inline void *_odp_atomic_ptr_load(const _odp_atomic_ptr_t *ptr, +static inline void *_odp_atomic_ptr_load(const _odp_atomic_ptr_t *p_atom, _odp_memmodel_t mmodel) { - return __atomic_load_n(&ptr->v, mmodel); + return __atomic_load_n(&p_atom->v, mmodel); } /** * Atomic store to pointer atomic variable * - * @param ptr Pointer to a pointer atomic variable - * @param val Value to write to the atomic variable - * @param mmodel Memory model associated with the store operation + * @param[out] p_atom Pointer to a pointer atomic variable + * @param[in] val Value to write to the atomic variable + * @param[in] mmodel Memory order associated with the store operation */ -static inline void _odp_atomic_ptr_store(_odp_atomic_ptr_t *ptr, +static inline void _odp_atomic_ptr_store(_odp_atomic_ptr_t *p_atom, void *val, _odp_memmodel_t mmodel) { - __atomic_store_n(&ptr->v, val, mmodel); + __atomic_store_n(&p_atom->v, val, mmodel); } /** * Atomic exchange (swap) of pointer atomic variable * - * @param ptr Pointer to a pointer atomic variable - * @param val New value to write - * @param mmodel Memory model associated with the exchange operation + * @param[in,out] p_atom Pointer to a pointer atomic variable + * @param[in] val New value to write + * @param[in] mmodel Memory order associated with the exchange operation * * @return Old value of variable */ -static inline void *_odp_atomic_ptr_xchg(_odp_atomic_ptr_t *ptr, +static inline void *_odp_atomic_ptr_xchg(_odp_atomic_ptr_t *p_atom, void *val, _odp_memmodel_t mmodel) { - return __atomic_exchange_n(&ptr->v, val, mmodel); + return __atomic_exchange_n(&p_atom->v, val, mmodel); } /** * Atomic compare and exchange (swap) of pointer atomic variable * "Strong" semantics, will not fail spuriously. * - * @param ptr Pointer to a pointer atomic variable - * @param exp_p Pointer to expected value (updated on failure) - * @param val New value to write - * @param succ Memory model associated with a successful compare-and-swap + * @param[in,out] p_atom Pointer to a pointer atomic variable + * @param[in,out] p_exp Pointer to expected value (updated on failure) + * @param[in] val New value to write + * @param[in] success Memory order associated with a successful compare-and-swap * operation - * @param fail Memory model associated with a failed compare-and-swap + * @param[in] failure Memory order associated with a failed compare-and-swap * operation * - * @return 1 (true) if exchange successful, 0 (false) if not successful (and - * '*exp_p' updated with current value) + * @retval 1 exchange successful + * @retval 0 exchange failed and '*p_exp' updated with current value */ -static inline int _odp_atomic_ptr_cmp_xchg_strong(_odp_atomic_ptr_t *ptr, - void **exp_p, +static inline int _odp_atomic_ptr_cmp_xchg_strong( + _odp_atomic_ptr_t *p_atom, + void **p_exp, void *val, - _odp_memmodel_t succ, - _odp_memmodel_t fail) + _odp_memmodel_t success, + _odp_memmodel_t failure) { - return __atomic_compare_exchange_n(&ptr->v, exp_p, val, - false/*strong*/, succ, fail); + return __atomic_compare_exchange_n(&p_atom->v, p_exp, val, + false/*strong*/, success, failure); } /***************************************************************************** @@ -540,58 +541,61 @@ static inline int _odp_atomic_ptr_cmp_xchg_strong(_odp_atomic_ptr_t *ptr, * _odp_atomic_flag_clear - no return value * * Flag atomics use Release Consistency memory consistency model, acquire - * model for TAS and release model for clear. + * semantics for load & TAS and release semantics for clear. *****************************************************************************/ /** * Initialize a flag atomic variable * - * @param ptr Pointer to a flag atomic variable - * @param val The initial value (true or false) of the variable + * @param[out] p_flag Pointer to a flag atomic variable + * @param[in] val The initial value of the variable */ -static inline void _odp_atomic_flag_init(_odp_atomic_flag_t *ptr, int val) +static inline void _odp_atomic_flag_init(_odp_atomic_flag_t *p_flag, + odp_bool_t val) { - __atomic_clear(ptr, __ATOMIC_RELAXED); + __atomic_clear(p_flag, __ATOMIC_RELAXED); if (val) - __atomic_test_and_set(ptr, __ATOMIC_RELAXED); + __atomic_test_and_set(p_flag, __ATOMIC_RELAXED); } /** * Load atomic flag variable - * @Note Load operation has relaxed memory model. + * @Note Operation has acquire semantics. It pairs with a release operation. * - * @param ptr Pointer to a flag atomic variable - * @return The current value (true or false) of the variable + * @param[in] p_flag Pointer to a flag atomic variable + * @return The current value of the variable */ -static inline int _odp_atomic_flag_load(_odp_atomic_flag_t *ptr) +static inline int _odp_atomic_flag_load(_odp_atomic_flag_t *p_flag) { - return __atomic_load_n(ptr, __ATOMIC_RELAXED); + return __atomic_load_n(p_flag, __ATOMIC_ACQUIRE); } /** * Test-and-set of atomic flag variable - * @Note Operation has acquire memory model. It pairs with a later - * release operation in some thread. + * @Note Operation has acquire semantics. It pairs with a later + * release operation. + * + * @param[in,out] p_flag Pointer to a flag atomic variable * - * @param ptr Pointer to a flag atomic variable - * @return The old value (true or false) of the variable + * @retval 1 if the flag was already true - lock not taken + * @retval 0 if the flag was false and is now set to true - lock taken */ -static inline int _odp_atomic_flag_tas(_odp_atomic_flag_t *ptr) +static inline int _odp_atomic_flag_tas(_odp_atomic_flag_t *p_flag) { - return __atomic_test_and_set(ptr, __ATOMIC_ACQUIRE); + return __atomic_test_and_set(p_flag, __ATOMIC_ACQUIRE); } /** * Clear atomic flag variable - * The flag variable is cleared (set to the false value). - * @Note Operation has release memory model. It pairs with an earlier - * acquire operation in some thread. + * The flag variable is cleared (set to false). + * @Note Operation has release semantics. It pairs with an earlier + * acquire operation or a later load operation. * - * @param ptr Pointer to a flag atomic variable + * @param[out] p_flag Pointer to a flag atomic variable */ -static inline void _odp_atomic_flag_clear(_odp_atomic_flag_t *ptr) +static inline void _odp_atomic_flag_clear(_odp_atomic_flag_t *p_flag) { - __atomic_clear(ptr, __ATOMIC_RELEASE); + __atomic_clear(p_flag, __ATOMIC_RELEASE); } /**