Harini0924 52ae891036
[compiler-rt][test] Add env command to fix command not found errors in compiler-rt with lit internal shell (#105917)
There are several files in the compiler-rt subproject that have command
not found errors. This patch uses the `env` command to properly set the
environment variables correctly when using the lit internal shell.
fixes: #102395 
[This change is relevant [RFC] Enabling the lit internal shell by
Default](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
2024-08-25 21:36:34 -07:00

25 lines
533 B
C

/// The static TLS block is reused among by threads. The shadow is cleared.
// RUN: %clang_nsan %s -o %t
// RUN: env NSAN_OPTIONS=halt_on_error=1,log2_max_relative_error=19 %run %t
#include <pthread.h>
#include <stdio.h>
__thread float x;
static void *ThreadFn(void *a) {
long i = (long)a;
for (long j = i * 1000; j < (i + 1) * 1000; j++)
x += j;
printf("%f\n", x);
return 0;
}
int main() {
pthread_t t;
for (long i = 0; i < 5; ++i) {
pthread_create(&t, 0, ThreadFn, (void *)i);
pthread_join(t, 0);
}
}