mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 19:08:21 +08:00
[libc++] Guard fileno() and isatty() usage correctly for Newlib. (#166668)
Including unistd.h does not expose fileno() on Newlib.
This commit is contained in:
@@ -22,6 +22,14 @@
|
||||
# include <windows.h>
|
||||
#elif __has_include(<unistd.h>)
|
||||
# include <unistd.h>
|
||||
# if defined(_NEWLIB_VERSION)
|
||||
# if defined(_POSIX_C_SOURCE) && __has_include(<stdio.h>)
|
||||
# include <stdio.h>
|
||||
# define HAS_FILENO_AND_ISATTY
|
||||
# endif
|
||||
# else
|
||||
# define HAS_FILENO_AND_ISATTY
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
@@ -56,7 +64,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst
|
||||
}
|
||||
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
|
||||
|
||||
#elif __has_include(<unistd.h>) // !_LIBCPP_WIN32API
|
||||
#elif defined(HAS_FILENO_AND_ISATTY) // !_LIBCPP_WIN32API
|
||||
|
||||
_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream) { return isatty(fileno(__stream)); }
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user