[PATCH] D75278: Use FileDescriptorIsDisplayed in place of direct call to isatty in support library

Douglas Gliner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 11:35:25 PST 2020


dgg5503 created this revision.
dgg5503 added a reviewer: sunfish.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Currently, when building with the Unix support library and `isatty` does
not exist for the target platform (i.e. `HAVE_ISATTY` is false),
compilation of the file `raw_ostream.cpp` will fail due to direct use of
`isatty` in the function `raw_fd_ostream::preferred_buffer_size()`. This
patch simply replaces the direct use of `isatty` with
`sys::Process::FileDescriptorIsDisplayed` which abstracts away the
potentially target specific function `isatty` by accounting for its
existence and returning a default value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75278

Files:
  llvm/lib/Support/raw_ostream.cpp


Index: llvm/lib/Support/raw_ostream.cpp
===================================================================
--- llvm/lib/Support/raw_ostream.cpp
+++ llvm/lib/Support/raw_ostream.cpp
@@ -792,7 +792,7 @@
   // If this is a terminal, don't use buffering. Line buffering
   // would be a more traditional thing to do, but it's not worth
   // the complexity.
-  if (S_ISCHR(statbuf.st_mode) && isatty(FD))
+  if (S_ISCHR(statbuf.st_mode) && sys::Process::FileDescriptorIsDisplayed(FD))
     return 0;
   // Return the preferred block size.
   return statbuf.st_blksize;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75278.247041.patch
Type: text/x-patch
Size: 566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200227/c5696c7d/attachment.bin>


More information about the llvm-commits mailing list