From 9c2212a60adba88c0f9bd93a772c5ea7bb9d8106 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 14 Aug 2021 19:03:23 +0200 Subject: Kernel+LibC: Share definitions for unistd.h --- Kernel/API/POSIX/unistd.h | 57 ++++++++++++++++++++++++++++++++++++++++ Kernel/UnixTypes.h | 47 +-------------------------------- Userland/Libraries/LibC/stdio.h | 4 --- Userland/Libraries/LibC/unistd.h | 38 +-------------------------- 4 files changed, 59 insertions(+), 87 deletions(-) create mode 100644 Kernel/API/POSIX/unistd.h diff --git a/Kernel/API/POSIX/unistd.h b/Kernel/API/POSIX/unistd.h new file mode 100644 index 0000000000..2562b923f0 --- /dev/null +++ b/Kernel/API/POSIX/unistd.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018-2021, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_OK 0 + +#define MS_NODEV (1 << 0) +#define MS_NOEXEC (1 << 1) +#define MS_NOSUID (1 << 2) +#define MS_BIND (1 << 3) +#define MS_RDONLY (1 << 4) +#define MS_REMOUNT (1 << 5) + +enum { + _SC_MONOTONIC_CLOCK, + _SC_NPROCESSORS_CONF, + _SC_NPROCESSORS_ONLN, + _SC_OPEN_MAX, + _SC_TTY_NAME_MAX, + _SC_PAGESIZE, + _SC_GETPW_R_SIZE_MAX, + _SC_CLK_TCK, +}; + +#define _SC_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK +#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF +#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN +#define _SC_OPEN_MAX _SC_OPEN_MAX +#define _SC_PAGESIZE _SC_PAGESIZE +#define _SC_TTY_NAME_MAX _SC_TTY_NAME_MAX +#define _SC_GETPW_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX +#define _SC_CLK_TCK _SC_CLK_TCK + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#ifdef __cplusplus +} +#endif diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h index d579ee695a..5866fa4934 100644 --- a/Kernel/UnixTypes.h +++ b/Kernel/UnixTypes.h @@ -26,53 +26,11 @@ #include #include #include +#include // Kernel internal options. #define O_NOFOLLOW_NOERROR (1 << 29) #define O_UNLINK_INTERNAL (1 << 30) - -#define MS_NODEV (1 << 0) -#define MS_NOEXEC (1 << 1) -#define MS_NOSUID (1 << 2) -#define MS_BIND (1 << 3) -#define MS_RDONLY (1 << 4) -#define MS_REMOUNT (1 << 5) - -enum { - _SC_MONOTONIC_CLOCK, - _SC_NPROCESSORS_CONF, - _SC_NPROCESSORS_ONLN, - _SC_OPEN_MAX, - _SC_TTY_NAME_MAX, - _SC_PAGESIZE, - _SC_GETPW_R_SIZE_MAX, - _SC_CLK_TCK, -}; - -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#define F_OK 0 - -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 - -#define MADV_SET_VOLATILE 0x100 -#define MADV_SET_NONVOLATILE 0x200 - -#define F_DUPFD 0 -#define F_GETFD 1 -#define F_SETFD 2 -#define F_GETFL 3 -#define F_SETFL 4 -#define F_ISTTY 5 -#define F_GETLK 6 -#define F_SETLK 7 -#define F_SETLKW 8 - -#define FD_CLOEXEC 1 - // Avoid interference with AK/Types.h and LibC/sys/types.h by defining *separate* names: TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ProcessID); TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ThreadID); @@ -115,9 +73,6 @@ struct sched_param { int sched_priority; }; -#define AT_FDCWD -100 -#define AT_SYMLINK_NOFOLLOW 0x100 - #define PT_TRACE_ME 1 #define PT_ATTACH 2 #define PT_CONTINUE 3 diff --git a/Userland/Libraries/LibC/stdio.h b/Userland/Libraries/LibC/stdio.h index ecd1393fc9..80c6e77eb0 100644 --- a/Userland/Libraries/LibC/stdio.h +++ b/Userland/Libraries/LibC/stdio.h @@ -21,10 +21,6 @@ __BEGIN_DECLS # define EOF (-1) #endif -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 - #define _IOFBF 0 #define _IOLBF 1 #define _IONBF 2 diff --git a/Userland/Libraries/LibC/unistd.h b/Userland/Libraries/LibC/unistd.h index 0f952a9a99..20a856f2e0 100644 --- a/Userland/Libraries/LibC/unistd.h +++ b/Userland/Libraries/LibC/unistd.h @@ -13,17 +13,13 @@ #pragma once +#include #include #include -#include -#include __BEGIN_DECLS #define HZ 1000 -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 /* lseek whence values */ #ifndef _STDIO_H /* also defined in stdio.h */ @@ -130,18 +126,6 @@ enum { _PC_VDISABLE }; -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#define F_OK 0 - -#define MS_NODEV (1 << 0) -#define MS_NOEXEC (1 << 1) -#define MS_NOSUID (1 << 2) -#define MS_BIND (1 << 3) -#define MS_RDONLY (1 << 4) -#define MS_REMOUNT (1 << 5) - #define _POSIX_MONOTONIC_CLOCK 200112L #define _POSIX_SAVED_IDS #define _POSIX_TIMERS 200809L @@ -153,26 +137,6 @@ enum { #define _POSIX_PRIORITY_SCHEDULING #define _POSIX_VDISABLE '\0' -enum { - _SC_MONOTONIC_CLOCK, - _SC_NPROCESSORS_CONF, - _SC_NPROCESSORS_ONLN, - _SC_OPEN_MAX, - _SC_TTY_NAME_MAX, - _SC_PAGESIZE, - _SC_GETPW_R_SIZE_MAX, - _SC_CLK_TCK, -}; - -#define _SC_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK -#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF -#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN -#define _SC_OPEN_MAX _SC_OPEN_MAX -#define _SC_PAGESIZE _SC_PAGESIZE -#define _SC_TTY_NAME_MAX _SC_TTY_NAME_MAX -#define _SC_GETPW_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX -#define _SC_CLK_TCK _SC_CLK_TCK - long sysconf(int name); // If opterr is set (the default), print error messages to stderr. -- cgit v1.2.3