1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -DGETC -O0 -g -xc++ %s -o %t && %run %t 2*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -DGETC -O3 -g -xc++ %s -o %t && %run %t 3*7c3d14c8STreehugger Robot // RUN: %clang_msan -DGETC -O0 -g %s -o %t && %run %t 4*7c3d14c8STreehugger Robot // RUN: %clang_msan -DGETC -O3 -g %s -o %t && %run %t 5*7c3d14c8STreehugger Robot 6*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -DGETCHAR -O0 -g -xc++ %s -o %t && %run %t 7*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -DGETCHAR -O3 -g -xc++ %s -o %t && %run %t 8*7c3d14c8STreehugger Robot // RUN: %clang_msan -DGETCHAR -O0 -g %s -o %t && %run %t 9*7c3d14c8STreehugger Robot // RUN: %clang_msan -DGETCHAR -O3 -g %s -o %t && %run %t 10*7c3d14c8STreehugger Robot 11*7c3d14c8STreehugger Robot #include <assert.h> 12*7c3d14c8STreehugger Robot #include <stdio.h> 13*7c3d14c8STreehugger Robot #include <unistd.h> 14*7c3d14c8STreehugger Robot main()15*7c3d14c8STreehugger Robotint main() { 16*7c3d14c8STreehugger Robot FILE *stream = fopen("/dev/zero", "r"); 17*7c3d14c8STreehugger Robot flockfile (stream); 18*7c3d14c8STreehugger Robot int c; 19*7c3d14c8STreehugger Robot #if defined(GETCHAR) 20*7c3d14c8STreehugger Robot int res = dup2(fileno(stream), 0); 21*7c3d14c8STreehugger Robot assert(res == 0); 22*7c3d14c8STreehugger Robot c = getchar_unlocked(); 23*7c3d14c8STreehugger Robot #elif defined(GETC) 24*7c3d14c8STreehugger Robot c = getc_unlocked (stream); 25*7c3d14c8STreehugger Robot #endif 26*7c3d14c8STreehugger Robot funlockfile (stream); 27*7c3d14c8STreehugger Robot if (c == EOF) 28*7c3d14c8STreehugger Robot return 1; 29*7c3d14c8STreehugger Robot printf("%c\n", (char)c); 30*7c3d14c8STreehugger Robot fclose(stream); 31*7c3d14c8STreehugger Robot return 0; 32*7c3d14c8STreehugger Robot } 33