summaryrefslogtreecommitdiffstats
path: root/libsanitizer/sanitizer_common/sanitizer_common_libcdep.cc
blob: 215a61deab632ed0fd60ca7df085f6594a7c23e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//===-- sanitizer_common_libcdep.cc ---------------------------------------===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries.
//===----------------------------------------------------------------------===//

#include "sanitizer_common.h"

namespace __sanitizer {

bool PrintsToTty() {
  MaybeOpenReportFile();
  return internal_isatty(report_fd) != 0;
}

bool PrintsToTtyCached() {
  // FIXME: Add proper Windows support to AnsiColorDecorator and re-enable color
  // printing on Windows.
  if (SANITIZER_WINDOWS)
    return 0;

  static int cached = 0;
  static bool prints_to_tty;
  if (!cached) {  // Not thread-safe.
    prints_to_tty = PrintsToTty();
    cached = 1;
  }
  return prints_to_tty;
}
}  // namespace __sanitizer
OpenPOWER on IntegriCloud