aboutsummaryrefslogtreecommitdiff
path: root/libc/src/termios/linux/kernel_termios.h
blob: 5a3a9722789ebb544353945bff9585ec937a2a0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//===-- Definition of kernel's version of struct termios --------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_TERMIOS_LINUX_KERNEL_TERMIOS_H
#define LLVM_LIBC_SRC_TERMIOS_LINUX_KERNEL_TERMIOS_H

#include "src/__support/macros/config.h"
#include <stddef.h>
#include <termios.h>

namespace LIBC_NAMESPACE_DECL {

// The kernel's struct termios is different from the libc's struct termios. The
// kernel's syscalls expect the size and layout of its definition of struct
// termios. So, we define a flavor of struct termios which matches that of the
// kernel so that we can translate between the libc version and the kernel
// version when passing struct termios objects to syscalls.

// NOTE: The definitions here are generic definitions valid for most target
// architectures including x86_64 and aarch64. Definitions on some architectures
// deviate from these generic definitions. Adjustments have to be made for those
// architectures.

constexpr size_t KERNEL_NCCS = 19;

struct kernel_termios {
  tcflag_t c_iflag;
  tcflag_t c_oflag;
  tcflag_t c_cflag;
  tcflag_t c_lflag;
  cc_t c_line;
  cc_t c_cc[KERNEL_NCCS];
};

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_TERMIOS_LINUX_KERNEL_TERMIOS_H