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