API Reference Manual  1.45.0
api/abi-default/atomic.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2015-2018 Linaro Limited
3  * Copyright (c) 2021 ARM Limited
4  */
5 
12 #ifndef ODP_ABI_ATOMIC_H_
13 #define ODP_ABI_ATOMIC_H_
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include <odp/api/std_types.h>
20 #include <odp/api/align.h>
21 
26 typedef struct ODP_ALIGNED(sizeof(uint32_t)) odp_atomic_u32_s {
27  uint32_t v;
29 
30 #if __GCC_ATOMIC_LLONG_LOCK_FREE >= 2
31 
36 typedef struct ODP_ALIGNED(sizeof(uint64_t)) odp_atomic_u64_s {
37  uint64_t v;
39 
40 #else
41 
46 #define ODP_ATOMIC_U64_LOCK 1
47 
52 typedef struct ODP_ALIGNED(sizeof(uint64_t)) odp_atomic_u64_s {
53  uint64_t v;
54  /* Some architectures do not support lock-free operations on 64-bit
55  * data types. We use a spin lock to ensure atomicity. */
56  char lock;
58 
59 #endif
60 
61 #if defined(__SIZEOF_INT128__) || defined(_ODP_LOCK_FREE_128BIT_ATOMICS)
62 
67 typedef struct ODP_ALIGNED(sizeof(odp_u128_t)) odp_atomic_u128_s {
68  odp_u128_t v;
70 
71 #else
72 
77 typedef struct ODP_ALIGNED(sizeof(odp_u128_t)) odp_atomic_u128_s {
79  /* Some architectures do not support lock-free operations on 128-bit
80  * data types. We use a spin lock to ensure atomicity. */
81  char lock;
83 
84 #endif
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif
ODP alignments.
Standard C language types and definitions for ODP.
struct odp_atomic_u32_s odp_atomic_u32_t
Atomic 32-bit unsigned integer.
struct odp_atomic_u64_s odp_atomic_u64_t
Atomic 64-bit unsigned integer.
struct odp_atomic_u128_s odp_atomic_u128_t
Atomic 128-bit unsigned integer.
#define ODP_ALIGNED(x)
Defines type/struct/variable alignment in bytes.
odp_u128_t v
Actual storage for the atomic variable.
char lock
Spin lock (if needed) used to ensure atomic access.
uint32_t v
Actual storage for the atomic variable.
uint64_t v
Actual storage for the atomic variable.
char lock
Spin lock (if needed) used to ensure atomic access.
128-bit unsigned integer structure