]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/tsan/atexit2.cc
Import compiler-rt trunk r224034.
[FreeBSD/FreeBSD.git] / test / tsan / atexit2.cc
1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2
3 #include <stdio.h>
4 #include <stdlib.h>
5
6 int n;
7 const int N = 10000;
8
9 static void atexit1() {
10   n++;
11 }
12
13 static void atexit0() {
14   fprintf(stderr, "run count: %d\n", n);
15 }
16
17 int main() {
18   atexit(atexit0);
19   for (int i = 0; i < N; i++)
20     atexit(atexit1);
21 }
22
23 // CHECK-NOT: FATAL: ThreadSanitizer
24 // CHECK-NOT: WARNING: ThreadSanitizer
25 // CHECK: run count: 10000
26