1 | #ifndef AWS_COMMON_ATOMICS_FALLBACK_INL |
2 | #define AWS_COMMON_ATOMICS_FALLBACK_INL |
3 | |
4 | /* |
5 | * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"). |
8 | * You may not use this file except in compliance with the License. |
9 | * A copy of the License is located at |
10 | * |
11 | * http://aws.amazon.com/apache2.0 |
12 | * |
13 | * or in the "license" file accompanying this file. This file is distributed |
14 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
15 | * express or implied. See the License for the specific language governing |
16 | * permissions and limitations under the License. |
17 | */ |
18 | |
19 | AWS_EXTERN_C_BEGIN |
20 | |
21 | #ifndef AWS_ATOMICS_HAVE_THREAD_FENCE |
22 | |
23 | void aws_atomic_thread_fence(enum aws_memory_order order) { |
24 | struct aws_atomic_var var; |
25 | aws_atomic_int_t expected = 0; |
26 | |
27 | aws_atomic_store_int(&var, expected, aws_memory_order_relaxed); |
28 | aws_atomic_compare_exchange_int(&var, &expected, 1, order, aws_memory_order_relaxed); |
29 | } |
30 | |
31 | #endif /* AWS_ATOMICS_HAVE_THREAD_FENCE */ |
32 | |
33 | AWS_EXTERN_C_END |
34 | #endif /* AWS_COMMON_ATOMICS_FALLBACK_INL */ |
35 | |