1 | //===-- Definition of kernel's version of struct termios --------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLVM_LIBC_SRC_TERMIOS_LINUX_KERNEL_TERMIOS_H |
10 | #define LLVM_LIBC_SRC_TERMIOS_LINUX_KERNEL_TERMIOS_H |
11 | |
12 | #include <stddef.h> |
13 | #include <termios.h> |
14 | |
15 | namespace LIBC_NAMESPACE { |
16 | |
17 | // The kernel's struct termios is different from the libc's struct termios. The |
18 | // kernel's syscalls expect the size and layout of its definition of struct |
19 | // termios. So, we define a flavor of struct termios which matches that of the |
20 | // kernel so that we can translate between the libc version and the kernel |
21 | // version when passing struct termios objects to syscalls. |
22 | |
23 | // NOTE: The definitions here are generic definitions valid for most target |
24 | // architectures including x86_64 and aarch64. Definitions on some architectures |
25 | // deviate from these generic definitions. Adjustments have to be made for those |
26 | // architectures. |
27 | |
28 | constexpr size_t KERNEL_NCCS = 19; |
29 | |
30 | struct kernel_termios { |
31 | tcflag_t c_iflag; |
32 | tcflag_t c_oflag; |
33 | tcflag_t c_cflag; |
34 | tcflag_t c_lflag; |
35 | cc_t c_line; |
36 | cc_t c_cc[KERNEL_NCCS]; |
37 | }; |
38 | |
39 | } // namespace LIBC_NAMESPACE |
40 | |
41 | #endif // LLVM_LIBC_SRC_TERMIOS_LINUX_KERNEL_TERMIOS_H |
42 | |