[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / msan / getc_unlocked.c
blob7df958ad657a54b94dac2c374cbbc23177c168bc
1 // RUN: %clangxx_msan -DGETC -m64 -O0 -g -xc++ %s -o %t && %run %t
2 // RUN: %clangxx_msan -DGETC -m64 -O3 -g -xc++ %s -o %t && %run %t
3 // RUN: %clang_msan -DGETC -m64 -O0 -g %s -o %t && %run %t
4 // RUN: %clang_msan -DGETC -m64 -O3 -g %s -o %t && %run %t
6 // RUN: %clangxx_msan -DGETCHAR -m64 -O0 -g -xc++ %s -o %t && %run %t
7 // RUN: %clangxx_msan -DGETCHAR -m64 -O3 -g -xc++ %s -o %t && %run %t
8 // RUN: %clang_msan -DGETCHAR -m64 -O0 -g %s -o %t && %run %t
9 // RUN: %clang_msan -DGETCHAR -m64 -O3 -g %s -o %t && %run %t
11 #include <assert.h>
12 #include <stdio.h>
13 #include <unistd.h>
15 int main() {
16 FILE *stream = fopen("/dev/zero", "r");
17 flockfile (stream);
18 int c;
19 #if defined(GETCHAR)
20 int res = dup2(fileno(stream), 0);
21 assert(res == 0);
22 c = getchar_unlocked();
23 #elif defined(GETC)
24 c = getc_unlocked (stream);
25 #endif
26 funlockfile (stream);
27 if (c == EOF)
28 return 1;
29 printf("%c\n", (char)c);
30 fclose(stream);
31 return 0;