[libc] add isatty
authorMichael Jones <michaelrj@google.com>
Mon, 10 Oct 2022 21:37:21 +0000 (14:37 -0700)
committerMichael Jones <michaelrj@google.com>
Mon, 10 Oct 2022 22:20:46 +0000 (15:20 -0700)
commit7639ba690648fae2b2034aa842942419b2fdcad4
tree0bffba4886cfc6aa1d238a0f3ef0f754e0c7d40c
parent8fc63d14c0e0a8425b7eeedd50bd252132595651
[libc] add isatty

The isatty function uses the side effects of an ioctl call to determine
if a specific file descriptor is a terminal. I chose TIOCGETD (get line
discipline of terminal) because it didn't require any new structs.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D135618
15 files changed:
libc/config/linux/x86_64/entrypoints.txt
libc/config/linux/x86_64/headers.txt
libc/include/CMakeLists.txt
libc/include/llvm-libc-macros/CMakeLists.txt
libc/include/llvm-libc-macros/linux/CMakeLists.txt
libc/include/llvm-libc-macros/linux/sys-ioctl-macros.h [new file with mode: 0644]
libc/include/llvm-libc-macros/sys-ioctl-macros.h [new file with mode: 0644]
libc/include/sys/ioctl.h.def [new file with mode: 0644]
libc/spec/posix.td
libc/src/unistd/CMakeLists.txt
libc/src/unistd/isatty.h [new file with mode: 0644]
libc/src/unistd/linux/CMakeLists.txt
libc/src/unistd/linux/isatty.cpp [new file with mode: 0644]
libc/test/src/unistd/CMakeLists.txt
libc/test/src/unistd/isatty_test.cpp [new file with mode: 0644]