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 "src/__support/macros/config.h" |
13 | #include <stddef.h> |
14 | #include <termios.h> |
15 | |
16 | namespace LIBC_NAMESPACE_DECL { |
17 | |
18 | // The kernel's struct termios is different from the libc's struct termios. The |
19 | // kernel's syscalls expect the size and layout of its definition of struct |
20 | // termios. So, we define a flavor of struct termios which matches that of the |
21 | // kernel so that we can translate between the libc version and the kernel |
22 | // version when passing struct termios objects to syscalls. |
23 | |
24 | // NOTE: The definitions here are generic definitions valid for most target |
25 | // architectures including x86_64 and aarch64. Definitions on some architectures |
26 | // deviate from these generic definitions. Adjustments have to be made for those |
27 | // architectures. |
28 | |
29 | constexpr size_t KERNEL_NCCS = 19; |
30 | |
31 | struct kernel_termios { |
32 | tcflag_t c_iflag; |
33 | tcflag_t c_oflag; |
34 | tcflag_t c_cflag; |
35 | tcflag_t c_lflag; |
36 | cc_t c_line; |
37 | cc_t c_cc[KERNEL_NCCS]; |
38 | }; |
39 | |
40 | } // namespace LIBC_NAMESPACE_DECL |
41 | |
42 | #endif // LLVM_LIBC_SRC_TERMIOS_LINUX_KERNEL_TERMIOS_H |
43 |