From 8c83e09cf5cdb063228be29993bb662e9ddef512 Mon Sep 17 00:00:00 2001 From: no92 Date: Thu, 4 Jan 2024 16:11:03 +0100 Subject: [PATCH 1/5] options/ansi: implement iswctype --- options/ansi/generic/ctype-stubs.cpp | 31 +++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/options/ansi/generic/ctype-stubs.cpp b/options/ansi/generic/ctype-stubs.cpp index db5dacc9f3..3ce76e9db6 100644 --- a/options/ansi/generic/ctype-stubs.cpp +++ b/options/ansi/generic/ctype-stubs.cpp @@ -254,9 +254,34 @@ wctype_t wctype(const char *cs) { return ct_null; } -int iswctype(wint_t, wctype_t) { - __ensure(!"Not implemented"); - __builtin_unreachable(); +int iswctype(wint_t wc, wctype_t type) { + switch (type) { + case ct_alnum: + return iswalnum(wc); + case ct_alpha: + return iswalpha(wc); + case ct_blank: + return iswblank(wc); + case ct_cntrl: + return iswcntrl(wc); + case ct_digit: + return iswdigit(wc); + case ct_graph: + return iswgraph(wc); + case ct_lower: + return iswlower(wc); + case ct_print: + return iswprint(wc); + case ct_punct: + return iswpunct(wc); + case ct_space: + return iswspace(wc); + case ct_upper: + return iswupper(wc); + case ct_xdigit: + return iswxdigit(wc); + } + return 0; } // -------------------------------------------------------------------------------------- From 42e937680c65655b60e9c61aae737f920df9d29b Mon Sep 17 00:00:00 2001 From: no92 Date: Thu, 4 Jan 2024 16:11:47 +0100 Subject: [PATCH 2/5] options/posix: stub msgsnd and msgrcv --- options/posix/generic/sys-msg.cpp | 10 ++++++++++ options/posix/include/sys/msg.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/options/posix/generic/sys-msg.cpp b/options/posix/generic/sys-msg.cpp index e152ce02c0..95f067e506 100644 --- a/options/posix/generic/sys-msg.cpp +++ b/options/posix/generic/sys-msg.cpp @@ -11,3 +11,13 @@ int msgctl(int, int, struct msqid_ds *) { __ensure(!"Not implemented"); __builtin_unreachable(); } + +ssize_t msgrcv(int, void *, size_t, long, int) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} + +int msgsnd(int, const void *, size_t, int) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} diff --git a/options/posix/include/sys/msg.h b/options/posix/include/sys/msg.h index 2ae32659bc..d602f76444 100644 --- a/options/posix/include/sys/msg.h +++ b/options/posix/include/sys/msg.h @@ -2,6 +2,8 @@ #define _SYS_MSG_H #include +#include +#include #ifdef __cplusplus extern "C" { @@ -13,6 +15,9 @@ int msgget(key_t, int); int msgctl(int msqid, int cmd, struct msqid_ds *buf); +ssize_t msgrcv(int, void *, size_t, long, int); +int msgsnd(int, const void *, size_t, int); + #endif /* !__MLIBC_ABI_ONLY */ #ifdef __cplusplus From b6cb83585bc926468b2b28b4b6f763ec9ddfc6b7 Mon Sep 17 00:00:00 2001 From: no92 Date: Thu, 4 Jan 2024 16:13:04 +0100 Subject: [PATCH 3/5] abis/linux: add missing sigevent members --- abis/linux/signal.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/abis/linux/signal.h b/abis/linux/signal.h index a089ac3e03..3a85e4647c 100644 --- a/abis/linux/signal.h +++ b/abis/linux/signal.h @@ -162,6 +162,7 @@ typedef struct __stack { #define SIGEV_SIGNAL 0 #define SIGEV_NONE 1 #define SIGEV_THREAD 2 +#define SIGEV_THREAD_ID 4 #define SEGV_MAPERR 1 #define SEGV_ACCERR 2 @@ -242,12 +243,15 @@ typedef struct __stack { #define NGREG 23 #endif +#include + struct sigevent { union sigval sigev_value; int sigev_notify; int sigev_signo; void (*sigev_notify_function)(union sigval); - // MISSING: sigev_notify_attributes + struct __mlibc_threadattr *sigev_notify_attributes; + pid_t sigev_notify_thread_id; }; struct sigaction { From d8e73858ec066f541f3bb516247bf014f71e94af Mon Sep 17 00:00:00 2001 From: no92 Date: Thu, 4 Jan 2024 16:14:03 +0100 Subject: [PATCH 4/5] options/glibc: define sighandler_t --- options/glibc/include/bits/glibc/glibc_signal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/options/glibc/include/bits/glibc/glibc_signal.h b/options/glibc/include/bits/glibc/glibc_signal.h index 7b402c0cf9..4d34e204f8 100644 --- a/options/glibc/include/bits/glibc/glibc_signal.h +++ b/options/glibc/include/bits/glibc/glibc_signal.h @@ -9,6 +9,12 @@ extern "C" { int tgkill(int, int, int); +#if defined(_GNU_SOURCE) + +typedef void (*sighandler_t)(int); + +#endif + #endif /* !__MLIBC_ABI_ONLY */ #ifdef __cplusplus From ce4ce72d3d4a58e650f43f00717430ad5b36d483 Mon Sep 17 00:00:00 2001 From: no92 Date: Thu, 4 Jan 2024 16:15:50 +0100 Subject: [PATCH 5/5] abis/linux: define more mman flags --- abis/linux/vm-flags.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/abis/linux/vm-flags.h b/abis/linux/vm-flags.h index bbe9f75ccc..3f8137c667 100644 --- a/abis/linux/vm-flags.h +++ b/abis/linux/vm-flags.h @@ -13,7 +13,16 @@ #define MAP_FIXED 0x10 #define MAP_ANON 0x20 #define MAP_ANONYMOUS 0x20 +#define MAP_GROWSDOWN 0x100 +#define MAP_DENYWRITE 0x800 +#define MAP_EXECUTABLE 0x1000 +#define MAP_LOCKED 0x2000 #define MAP_NORESERVE 0x4000 +#define MAP_POPULATE 0x8000 +#define MAP_NONBLOCK 0x10000 +#define MAP_STACK 0x20000 +#define MAP_HUGETLB 0x40000 +#define MAP_SYNC 0x80000 #define MAP_FIXED_NOREPLACE 0x100000 #define MS_ASYNC 0x01 @@ -35,11 +44,27 @@ #define MADV_WILLNEED 3 #define MADV_DONTNEED 4 #define MADV_FREE 8 +#define MADV_REMOVE 9 +#define MADV_DONTFORK 10 +#define MADV_DOFORK 11 +#define MADV_MERGEABLE 12 +#define MADV_UNMERGEABLE 13 +#define MADV_HUGEPAGE 14 +#define MADV_NOHUGEPAGE 15 +#define MADV_DONTDUMP 16 +#define MADV_DODUMP 17 +#define MADV_WIPEONFORK 18 +#define MADV_KEEPONFORK 19 +#define MADV_COLD 20 +#define MADV_PAGEOUT 21 +#define MADV_HWPOISON 100 +#define MADV_SOFT_OFFLINE 101 #define MREMAP_MAYMOVE 1 #define MREMAP_FIXED 2 #define MFD_CLOEXEC 1U #define MFD_ALLOW_SEALING 2U +#define MFD_HUGETLB 4U #endif // _ABIBITS_VM_FLAGS_H