sanitizer_common_libcdep.cc revision 650c7d44b659ddfb4af471dc2ad79a727b7de939
1//===-- sanitizer_common_libcdep.cc ---------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is shared between AddressSanitizer and ThreadSanitizer
11// run-time libraries.
12//===----------------------------------------------------------------------===//
13
14#include "sanitizer_common.h"
15
16namespace __sanitizer {
17
18bool PrintsToTty() {
19  MaybeOpenReportFile();
20  return internal_isatty(report_fd) != 0;
21}
22
23bool PrintsToTtyCached() {
24  // FIXME: Add proper Windows support to AnsiColorDecorator and re-enable color
25  // printing on Windows.
26  if (SANITIZER_WINDOWS)
27    return 0;
28
29  static int cached = 0;
30  static bool prints_to_tty;
31  if (!cached) {  // Not thread-safe.
32    prints_to_tty = PrintsToTty();
33    cached = 1;
34  }
35  return prints_to_tty;
36}
37}  // namespace __sanitizer
38