diff options
| author | Siva Chandra Reddy <sivachandra@google.com> | 2022-10-17 16:27:45 +0000 |
|---|---|---|
| committer | Siva Chandra Reddy <sivachandra@google.com> | 2022-10-18 20:53:00 +0000 |
| commit | b2a294bcf8e6fd83efe72d6d7432affd65b2309e (patch) | |
| tree | 1e2615e3b9ffdc93118d45e699431ca006aa098e /libc/src/termios/linux/tcgetsid.cpp | |
| parent | bcc4c909544e136ac7198d0acf6768817b702bed (diff) | |
[libc] Add termios.h and the implementation of functions declared in it.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D136143
Diffstat (limited to 'libc/src/termios/linux/tcgetsid.cpp')
| -rw-r--r-- | libc/src/termios/linux/tcgetsid.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libc/src/termios/linux/tcgetsid.cpp b/libc/src/termios/linux/tcgetsid.cpp new file mode 100644 index 000000000000..8f0923431a42 --- /dev/null +++ b/libc/src/termios/linux/tcgetsid.cpp @@ -0,0 +1,31 @@ +//===-- Linux implementation of tcgetsid ----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/termios/tcgetsid.h" + +#include "src/__support/OSUtil/syscall.h" +#include "src/__support/common.h" + +#include <asm/ioctls.h> // Safe to include without the risk of name pollution. +#include <errno.h> +#include <sys/syscall.h> // For syscall numbers +#include <termios.h> + +namespace __llvm_libc { + +LLVM_LIBC_FUNCTION(pid_t, tcgetsid, (int fd)) { + pid_t sid; + long ret = __llvm_libc::syscall_impl(SYS_ioctl, fd, TIOCGSID, &sid); + if (ret < 0) { + errno = -ret; + return -1; + } + return sid; +} + +} // namespace __llvm_libc |
