| 1 |
#ifndef AWS_COMMON_ATOMICS_FALLBACK_INL |
| 2 |
#define AWS_COMMON_ATOMICS_FALLBACK_INL |
| 3 |
|
| 4 |
/** |
| 5 |
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 6 |
* SPDX-License-Identifier: Apache-2.0. |
| 7 |
*/ |
| 8 |
|
| 9 |
AWS_EXTERN_C_BEGIN |
| 10 |
|
| 11 |
#ifndef AWS_ATOMICS_HAVE_THREAD_FENCE |
| 12 |
|
| 13 |
void aws_atomic_thread_fence(enum aws_memory_order order) { |
| 14 |
struct aws_atomic_var var; |
| 15 |
aws_atomic_int_t expected = 0; |
| 16 |
|
| 17 |
aws_atomic_store_int(&var, expected, aws_memory_order_relaxed); |
| 18 |
aws_atomic_compare_exchange_int(&var, &expected, 1, order, aws_memory_order_relaxed); |
| 19 |
} |
| 20 |
|
| 21 |
#endif /* AWS_ATOMICS_HAVE_THREAD_FENCE */ |
| 22 |
|
| 23 |
AWS_EXTERN_C_END |
| 24 |
#endif /* AWS_COMMON_ATOMICS_FALLBACK_INL */ |