brintos

brintos / llvm-project-archived public Read only

0
0
Text · 898 B · 8468fed Raw
33 lines · c
1// RUN: %clangxx_msan -DGETC -O0 -g -xc++ %s -o %t && %run %t2// RUN: %clangxx_msan -DGETC -O3 -g -xc++ %s -o %t && %run %t3// RUN: %clang_msan -DGETC -O0 -g %s -o %t && %run %t4// RUN: %clang_msan -DGETC -O3 -g %s -o %t && %run %t5 6// RUN: %clangxx_msan -DGETCHAR -O0 -g -xc++ %s -o %t && %run %t7// RUN: %clangxx_msan -DGETCHAR -O3 -g -xc++ %s -o %t && %run %t8// RUN: %clang_msan -DGETCHAR -O0 -g %s -o %t && %run %t9// RUN: %clang_msan -DGETCHAR -O3 -g %s -o %t && %run %t10 11#include <assert.h>12#include <stdio.h>13#include <unistd.h>14 15int 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#endif26  funlockfile (stream);27  if (c == EOF)28    return 1;29  printf("%c\n", (char)c);30  fclose(stream);31  return 0;32}33