brintos

brintos / llvm-project-archived public Read only

0
0
Text · 726 B · 345e363 Raw
26 lines · cpp
1// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s2#include "test.h"3#include <sanitizer/tsan_interface_atomic.h>4 5#ifndef __ATOMIC_HLE_ACQUIRE6#define __ATOMIC_HLE_ACQUIRE (1 << 16)7#endif8#ifndef __ATOMIC_HLE_RELEASE9#define __ATOMIC_HLE_RELEASE (1 << 17)10#endif11 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: DONE25 26