xref: /aosp_15_r20/external/compiler-rt/test/tsan/interface_atomic_test.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // Test that we can include header with TSan atomic interface.
2*7c3d14c8STreehugger Robot // RUN: %clang_tsan %s -o %t && %run %t 2>&1 | FileCheck %s
3*7c3d14c8STreehugger Robot #include <sanitizer/tsan_interface_atomic.h>
4*7c3d14c8STreehugger Robot #include <stdio.h>
5*7c3d14c8STreehugger Robot 
main()6*7c3d14c8STreehugger Robot int main() {
7*7c3d14c8STreehugger Robot   __tsan_atomic32 a;
8*7c3d14c8STreehugger Robot   __tsan_atomic32_store(&a, 100, __tsan_memory_order_release);
9*7c3d14c8STreehugger Robot   int res = __tsan_atomic32_load(&a, __tsan_memory_order_acquire);
10*7c3d14c8STreehugger Robot   if (res == 100) {
11*7c3d14c8STreehugger Robot     // CHECK: PASS
12*7c3d14c8STreehugger Robot     fprintf(stderr, "PASS\n");
13*7c3d14c8STreehugger Robot     return 0;
14*7c3d14c8STreehugger Robot   }
15*7c3d14c8STreehugger Robot   return 1;
16*7c3d14c8STreehugger Robot }
17