mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Kernel: Move TYPEDEF_* TTY macros to API/ttydefaults.h file
This allows us to get rid of an include to LibC/sys/ttydefaults.h in the Kernel TTY implementation. Also, move ttydefchars static const struct to another file called Kernel/API/ttydefaultschars.h, so it could be used too in the Kernel TTY implementation without the need to include anything from LibC.
This commit is contained in:
parent
800e244ed9
commit
6b849fc8b1
Notes:
sideshowbarker
2024-07-17 00:49:59 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/6b849fc8b1 Pull-request: https://github.com/SerenityOS/serenity/pull/17634 Reviewed-by: https://github.com/ADKaster
39
Kernel/API/ttydefaults.h
Normal file
39
Kernel/API/ttydefaults.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Daniel Bertalan <dani@danielbertalan.dev>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define TTYDEF_IFLAG (ICRNL)
|
||||||
|
#define TTYDEF_OFLAG (OPOST | ONLCR)
|
||||||
|
#define TTYDEF_LFLAG_NOECHO (ISIG | ICANON)
|
||||||
|
#define TTYDEF_LFLAG_ECHO (TTYDEF_LFLAG_NOECHO | ECHO | ECHOE | ECHOK | ECHONL)
|
||||||
|
#define TTYDEF_LFLAG TTYDEF_LFLAG_ECHO
|
||||||
|
#define TTYDEF_CFLAG (CS8)
|
||||||
|
#define TTYDEF_SPEED (B9600)
|
||||||
|
|
||||||
|
#define CTRL(c) (c & 0x1F)
|
||||||
|
#define CINTR CTRL('c')
|
||||||
|
#define CQUIT 034
|
||||||
|
#define CERASE 010
|
||||||
|
#define CKILL CTRL('u')
|
||||||
|
#define CEOF CTRL('d')
|
||||||
|
#define CTIME 0
|
||||||
|
#define CMIN 1
|
||||||
|
#define CSWTC 0
|
||||||
|
#define CSTART CTRL('q')
|
||||||
|
#define CSTOP CTRL('s')
|
||||||
|
#define CSUSP CTRL('z')
|
||||||
|
#define CEOL 0
|
||||||
|
#define CREPRINT CTRL('r')
|
||||||
|
#define CDISCARD CTRL('o')
|
||||||
|
#define CWERASE CTRL('w')
|
||||||
|
#define CLNEXT CTRL('v')
|
||||||
|
#define CEOL2 CEOL
|
||||||
|
|
||||||
|
#define CEOT CEOF
|
||||||
|
#define CBRK CEOL
|
||||||
|
#define CRPRNT CREPRINT
|
||||||
|
#define CFLUSH CDISCARD
|
47
Kernel/API/ttydefaultschars.h
Normal file
47
Kernel/API/ttydefaultschars.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Daniel Bertalan <dani@danielbertalan.dev>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Kernel/API/POSIX/termios.h>
|
||||||
|
#include <Kernel/API/ttydefaults.h>
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wc99-designator"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const cc_t ttydefchars[NCCS] = {
|
||||||
|
[VINTR] = CINTR,
|
||||||
|
[VQUIT] = CQUIT,
|
||||||
|
[VERASE] = CERASE,
|
||||||
|
[VKILL] = CKILL,
|
||||||
|
[VEOF] = CEOF,
|
||||||
|
[VTIME] = CTIME,
|
||||||
|
[VMIN] = CMIN,
|
||||||
|
[VSWTC] = CSWTC,
|
||||||
|
[VSTART] = CSTART,
|
||||||
|
[VSTOP] = CSTOP,
|
||||||
|
[VSUSP] = CSUSP,
|
||||||
|
[VEOL] = CEOL,
|
||||||
|
[VREPRINT] = CREPRINT,
|
||||||
|
[VDISCARD] = CDISCARD,
|
||||||
|
[VWERASE] = CWERASE,
|
||||||
|
[VLNEXT] = CLNEXT,
|
||||||
|
[VEOL2] = CEOL2
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -10,13 +10,13 @@
|
|||||||
#include <Kernel/API/Ioctl.h>
|
#include <Kernel/API/Ioctl.h>
|
||||||
#include <Kernel/API/POSIX/errno.h>
|
#include <Kernel/API/POSIX/errno.h>
|
||||||
#include <Kernel/API/POSIX/signal_numbers.h>
|
#include <Kernel/API/POSIX/signal_numbers.h>
|
||||||
|
#include <Kernel/API/ttydefaults.h>
|
||||||
|
#include <Kernel/API/ttydefaultschars.h>
|
||||||
#include <Kernel/Debug.h>
|
#include <Kernel/Debug.h>
|
||||||
#include <Kernel/InterruptDisabler.h>
|
#include <Kernel/InterruptDisabler.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
#include <Kernel/TTY/TTY.h>
|
#include <Kernel/TTY/TTY.h>
|
||||||
#define TTYDEFCHARS
|
#include <Kernel/UnixTypes.h>
|
||||||
#include <LibC/sys/ttydefaults.h>
|
|
||||||
#undef TTYDEFCHARS
|
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
@ -6,80 +6,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define TTYDEF_IFLAG (ICRNL)
|
#include <Kernel/API/ttydefaults.h>
|
||||||
#define TTYDEF_OFLAG (OPOST | ONLCR)
|
|
||||||
#define TTYDEF_LFLAG_NOECHO (ISIG | ICANON)
|
|
||||||
#define TTYDEF_LFLAG_ECHO (TTYDEF_LFLAG_NOECHO | ECHO | ECHOE | ECHOK | ECHONL)
|
|
||||||
#define TTYDEF_LFLAG TTYDEF_LFLAG_ECHO
|
|
||||||
#define TTYDEF_CFLAG (CS8)
|
|
||||||
#define TTYDEF_SPEED (B9600)
|
|
||||||
|
|
||||||
#define CTRL(c) (c & 0x1F)
|
|
||||||
#define CINTR CTRL('c')
|
|
||||||
#define CQUIT 034
|
|
||||||
#define CERASE 010
|
|
||||||
#define CKILL CTRL('u')
|
|
||||||
#define CEOF CTRL('d')
|
|
||||||
#define CTIME 0
|
|
||||||
#define CMIN 1
|
|
||||||
#define CSWTC 0
|
|
||||||
#define CSTART CTRL('q')
|
|
||||||
#define CSTOP CTRL('s')
|
|
||||||
#define CSUSP CTRL('z')
|
|
||||||
#define CEOL 0
|
|
||||||
#define CREPRINT CTRL('r')
|
|
||||||
#define CDISCARD CTRL('o')
|
|
||||||
#define CWERASE CTRL('w')
|
|
||||||
#define CLNEXT CTRL('v')
|
|
||||||
#define CEOL2 CEOL
|
|
||||||
|
|
||||||
#define CEOT CEOF
|
|
||||||
#define CBRK CEOL
|
|
||||||
#define CRPRNT CREPRINT
|
|
||||||
#define CFLUSH CDISCARD
|
|
||||||
|
|
||||||
#ifdef TTYDEFCHARS
|
#ifdef TTYDEFCHARS
|
||||||
# ifdef KERNEL
|
# include <termios.h>
|
||||||
# include <Kernel/UnixTypes.h>
|
|
||||||
# else
|
|
||||||
# include <termios.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __clang__
|
|
||||||
# pragma clang diagnostic push
|
|
||||||
# pragma clang diagnostic ignored "-Wc99-designator"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
# endif
|
|
||||||
|
|
||||||
static const cc_t ttydefchars[NCCS] = {
|
|
||||||
[VINTR] = CINTR,
|
|
||||||
[VQUIT] = CQUIT,
|
|
||||||
[VERASE] = CERASE,
|
|
||||||
[VKILL] = CKILL,
|
|
||||||
[VEOF] = CEOF,
|
|
||||||
[VTIME] = CTIME,
|
|
||||||
[VMIN] = CMIN,
|
|
||||||
[VSWTC] = CSWTC,
|
|
||||||
[VSTART] = CSTART,
|
|
||||||
[VSTOP] = CSTOP,
|
|
||||||
[VSUSP] = CSUSP,
|
|
||||||
[VEOL] = CEOL,
|
|
||||||
[VREPRINT] = CREPRINT,
|
|
||||||
[VDISCARD] = CDISCARD,
|
|
||||||
[VWERASE] = CWERASE,
|
|
||||||
[VLNEXT] = CLNEXT,
|
|
||||||
[VEOL2] = CEOL2
|
|
||||||
};
|
|
||||||
|
|
||||||
# ifdef __clang__
|
|
||||||
# pragma clang diagnostic pop
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __cplusplus
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
# include <Kernel/API/ttydefaultschars.h>
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user