1// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2#include "test.h"
3#include <sanitizer/tsan_interface_atomic.h>
4
5#ifndef __ATOMIC_HLE_ACQUIRE
6#define __ATOMIC_HLE_ACQUIRE (1 << 16)
7#endif
8#ifndef __ATOMIC_HLE_RELEASE
9#define __ATOMIC_HLE_RELEASE (1 << 17)
10#endif
11
12int main() {
13 volatile int x = 0;
14 //__atomic_fetch_add(&x, 1, __ATOMIC_ACQUIRE | __ATOMIC_HLE_ACQUIRE);
15 //__atomic_store_n(&x, 0, __ATOMIC_RELEASE | __ATOMIC_HLE_RELEASE);
16 __tsan_atomic32_fetch_add(&x, 1,
17 (__tsan_memory_order)(__ATOMIC_ACQUIRE | __ATOMIC_HLE_ACQUIRE));
18 __tsan_atomic32_store(&x, 0,
19 (__tsan_memory_order)(__ATOMIC_RELEASE | __ATOMIC_HLE_RELEASE));
20 fprintf(stderr, "DONE\n");
21 return 0;
22}
23
24// CHECK: DONE
25
26