From fc00c656c96528112d05cf0edf8631bd5eaea446 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 7 Dec 2025 20:10:31 +0100 Subject: Add build system scaffolding and libc headers --- lib/libc/ctype/isalnum.c | 12 ++++++++++++ lib/libc/ctype/isalpha.c | 8 ++++++++ lib/libc/ctype/isblank.c | 8 ++++++++ lib/libc/ctype/iscntrl.c | 8 ++++++++ lib/libc/ctype/isdigit.c | 8 ++++++++ lib/libc/ctype/isgraph.c | 8 ++++++++ lib/libc/ctype/islower.c | 8 ++++++++ lib/libc/ctype/isprint.c | 8 ++++++++ lib/libc/ctype/ispunct.c | 12 ++++++++++++ lib/libc/ctype/isspace.c | 8 ++++++++ lib/libc/ctype/isupper.c | 8 ++++++++ lib/libc/ctype/isxdigit.c | 6 ++++++ lib/libc/ctype/tolower.c | 14 ++++++++++++++ lib/libc/ctype/toupper.c | 14 ++++++++++++++ 14 files changed, 130 insertions(+) create mode 100644 lib/libc/ctype/isalnum.c create mode 100644 lib/libc/ctype/isalpha.c create mode 100644 lib/libc/ctype/isblank.c create mode 100644 lib/libc/ctype/iscntrl.c create mode 100644 lib/libc/ctype/isdigit.c create mode 100644 lib/libc/ctype/isgraph.c create mode 100644 lib/libc/ctype/islower.c create mode 100644 lib/libc/ctype/isprint.c create mode 100644 lib/libc/ctype/ispunct.c create mode 100644 lib/libc/ctype/isspace.c create mode 100644 lib/libc/ctype/isupper.c create mode 100644 lib/libc/ctype/isxdigit.c create mode 100644 lib/libc/ctype/tolower.c create mode 100644 lib/libc/ctype/toupper.c (limited to 'lib/libc/ctype') diff --git a/lib/libc/ctype/isalnum.c b/lib/libc/ctype/isalnum.c new file mode 100644 index 00000000..04e94fc6 --- /dev/null +++ b/lib/libc/ctype/isalnum.c @@ -0,0 +1,12 @@ +#include +#include + +int isalnum(int c) +{ + return isalpha(c) || isdigit(c); +} + +weak int isalnum_l(int c, locale_t unused locale) +{ + return isalnum(c); +} diff --git a/lib/libc/ctype/isalpha.c b/lib/libc/ctype/isalpha.c new file mode 100644 index 00000000..d046c09e --- /dev/null +++ b/lib/libc/ctype/isalpha.c @@ -0,0 +1,8 @@ +#include + +int isalpha(int c) +{ + return ((unsigned)c | 32) - 'a' < 26; +} + +weak_reference(isalpha, isalpha_l); diff --git a/lib/libc/ctype/isblank.c b/lib/libc/ctype/isblank.c new file mode 100644 index 00000000..7ad08709 --- /dev/null +++ b/lib/libc/ctype/isblank.c @@ -0,0 +1,8 @@ +#include + +int isblank(int c) +{ + return (c == ' ' || c == '\t'); +} + +weak_reference(isblank, isblank_l); diff --git a/lib/libc/ctype/iscntrl.c b/lib/libc/ctype/iscntrl.c new file mode 100644 index 00000000..6d4ff5a8 --- /dev/null +++ b/lib/libc/ctype/iscntrl.c @@ -0,0 +1,8 @@ +#include + +int iscntrl(int c) +{ + return (unsigned)c < 0x20 || c == 0x7f; +} + +weak_reference(iscntrl, iscntrl_l); diff --git a/lib/libc/ctype/isdigit.c b/lib/libc/ctype/isdigit.c new file mode 100644 index 00000000..445e1cdc --- /dev/null +++ b/lib/libc/ctype/isdigit.c @@ -0,0 +1,8 @@ +#include + +int isdigit(int c) +{ + return (unsigned)c - '0' < 10; +} + +weak_reference(isdigit, isdigit_l); diff --git a/lib/libc/ctype/isgraph.c b/lib/libc/ctype/isgraph.c new file mode 100644 index 00000000..03919200 --- /dev/null +++ b/lib/libc/ctype/isgraph.c @@ -0,0 +1,8 @@ +#include + +int isgraph(int c) +{ + return (unsigned)c - 0x21 < 0x5e; +} + +weak_reference(isgraph, isgraph_l); diff --git a/lib/libc/ctype/islower.c b/lib/libc/ctype/islower.c new file mode 100644 index 00000000..34980da6 --- /dev/null +++ b/lib/libc/ctype/islower.c @@ -0,0 +1,8 @@ +#include + +int islower(int c) +{ + return (unsigned)c - 'a' < 26; +} + +weak_reference(islower, islower_l); diff --git a/lib/libc/ctype/isprint.c b/lib/libc/ctype/isprint.c new file mode 100644 index 00000000..76524050 --- /dev/null +++ b/lib/libc/ctype/isprint.c @@ -0,0 +1,8 @@ +#include + +int isprint(int c) +{ + return (unsigned)c - 0x20 < 0x5f; +} + +weak_reference(isprint, isprint_l); diff --git a/lib/libc/ctype/ispunct.c b/lib/libc/ctype/ispunct.c new file mode 100644 index 00000000..2bd08c38 --- /dev/null +++ b/lib/libc/ctype/ispunct.c @@ -0,0 +1,12 @@ +#include +#include + +int ispunct(int c) +{ + return isgraph(c) && !isalnum(c); +} + +weak int ispunct_l(int c, locale_t locale) +{ + return ispunct(c); +} diff --git a/lib/libc/ctype/isspace.c b/lib/libc/ctype/isspace.c new file mode 100644 index 00000000..86630c66 --- /dev/null +++ b/lib/libc/ctype/isspace.c @@ -0,0 +1,8 @@ +#include + +int isspace(int c) +{ + return c == ' ' || (unsigned)c - '\t' < 5; +} + +weak_reference(isspace, isspace_l); diff --git a/lib/libc/ctype/isupper.c b/lib/libc/ctype/isupper.c new file mode 100644 index 00000000..458990df --- /dev/null +++ b/lib/libc/ctype/isupper.c @@ -0,0 +1,8 @@ +#include + +int isupper(int c) +{ + return (unsigned)c - 'A' < 26; +} + +weak_reference(isupper, isupper_l); diff --git a/lib/libc/ctype/isxdigit.c b/lib/libc/ctype/isxdigit.c new file mode 100644 index 00000000..588df77a --- /dev/null +++ b/lib/libc/ctype/isxdigit.c @@ -0,0 +1,6 @@ +#include + +int isxdigit(int c) +{ + return isdigit(c) || ((unsigned)c | 32) - 'a' < 6; +} diff --git a/lib/libc/ctype/tolower.c b/lib/libc/ctype/tolower.c new file mode 100644 index 00000000..abeab42a --- /dev/null +++ b/lib/libc/ctype/tolower.c @@ -0,0 +1,14 @@ +#include +#include + +int tolower(int c) +{ + if (isupper(c)) + return c | 32; + return c; +} + +weak int tolower_l(int c, locale_t unused locale) +{ + return tolower(c); +} diff --git a/lib/libc/ctype/toupper.c b/lib/libc/ctype/toupper.c new file mode 100644 index 00000000..e952acd9 --- /dev/null +++ b/lib/libc/ctype/toupper.c @@ -0,0 +1,14 @@ +#include +#include + +int toupper(int c) +{ + if (islower(c)) + return c & 0x5f; + return c; +} + +int toupper_l(int c, locale_t unused locale) +{ + return toupper(c); +} -- cgit v1.2.3