Skip to content

Commit 731a441

Browse files
committed
use static var to only enableConversion once for stdout/stderr
1 parent 51fdbd3 commit 731a441

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

llvm/lib/Support/raw_ostream.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@
3434

3535
#if defined(HAVE_UNISTD_H)
3636
# include <unistd.h>
37-
#else
38-
#ifndef STDIN_FILENO
39-
#define STDIN_FILENO 0
40-
#endif
41-
#ifndef STDOUT_FILENO
42-
#define STDOUT_FILENO 1
43-
#endif
44-
#ifndef STDERR_FILENO
45-
#define STDERR_FILENO 2
46-
#endif
4737
#endif
4838

4939
#if defined(__CYGWIN__)
@@ -906,21 +896,22 @@ raw_fd_ostream &llvm::outs() {
906896
std::error_code EC;
907897

908898
// On z/OS we need to enable auto conversion
909-
EC = enableAutoConversion(STDOUT_FILENO);
910-
assert(!EC);
899+
static std::error_code EC1 = enableAutoConversion(STDOUT_FILENO);
900+
assert(!EC1);
901+
(void) EC1;
911902

912903
static raw_fd_ostream S("-", EC, sys::fs::OF_None);
913904
assert(!EC);
914905
return S;
915906
}
916907

917908
raw_fd_ostream &llvm::errs() {
918-
// Set standard error to be unbuffered.
919-
920909
// On z/OS we need to enable auto conversion
921-
std::error_code EC = enableAutoConversion(STDERR_FILENO);
910+
static std::error_code EC = enableAutoConversion(STDERR_FILENO);
922911
assert(!EC);
912+
(void) EC;
923913

914+
// Set standard error to be unbuffered.
924915
static raw_fd_ostream S(STDERR_FILENO, false, true);
925916
return S;
926917
}

0 commit comments

Comments
 (0)