1// RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=flush_memory_ms=1:memory_limit_mb=1 %run %t 2>&1 | FileCheck %s
2//
3// setuid(0) hangs on powerpc64 big endian. When this is fixed remove
4// the unsupported flag.
5// https://llvm.org/bugs/show_bug.cgi?id=25799
6//
7// UNSUPPORTED: target=powerpc64-unknown-linux-gnu{{.*}}
8#include "test.h"
9#include <sys/types.h>
10#include <unistd.h>
11#include <time.h>
12
13// Test that setuid call works in presence of stoptheworld.
14
15int main() {
16 unsigned long long tp0, tp1;
17 tp0 = monotonic_clock_ns();
18 tp1 = monotonic_clock_ns();
19 while (tp1 - tp0 < 3 * 1000000000ull) {
20 tp1 = monotonic_clock_ns();
21 setuid(0);
22 }
23 fprintf(stderr, format: "DONE\n");
24 return 0;
25}
26
27// CHECK: DONE
28

source code of compiler-rt/test/tsan/setuid2.c