blob: e8811d39ef253eb03a6adfe21af21bb1a94c2eae [file] [log] [blame]
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -07001/*===-- atomic_flag_test_and_set.c ------------------------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
7 *
8 *===------------------------------------------------------------------------===
9 *
10 * This file implements atomic_flag_test_and_set from C11's stdatomic.h.
11 *
12 *===------------------------------------------------------------------------===
13 */
14
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080015#ifndef __has_include
16#define __has_include(inc) 0
17#endif
18
19#if __has_include(<stdatomic.h>)
20
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070021#include <stdatomic.h>
22#undef atomic_flag_test_and_set
23_Bool atomic_flag_test_and_set(volatile atomic_flag *object) {
24 return __c11_atomic_exchange(&(object)->_Value, 1, __ATOMIC_SEQ_CST);
25}
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080026
27#endif