diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 331380c0..11823c69 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -8,6 +8,7 @@ set(SOURCES src/errno.cpp src/string.cpp src/atexit.cpp + src/ctype.cpp ) if(${ARCH} STREQUAL "x86_64") diff --git a/libc/include/ctype.h b/libc/include/ctype.h new file mode 100644 index 00000000..c5a96941 --- /dev/null +++ b/libc/include/ctype.h @@ -0,0 +1,31 @@ +/* ctype.h: Character handling functions. */ + +#ifndef _CTYPE_H +#define _CTYPE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + int isalnum(int c); + int isalpha(int c); + int isascii(int c); + int iscntrl(int c); + int isdigit(int c); + int isxdigit(int c); + int isspace(int c); + int ispunct(int c); + int isprint(int c); + int isgraph(int c); + int islower(int c); + int isupper(int c); + int isblank(int c); + int tolower(int c); + int toupper(int c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libc/src/ctype.cpp b/libc/src/ctype.cpp new file mode 100644 index 00000000..daec56d5 --- /dev/null +++ b/libc/src/ctype.cpp @@ -0,0 +1,31 @@ +#include +#include + +#define ctype_wrapper(a, b) \ + int a(int c) \ + { \ + return b(c); \ + } + +// clang-format off + +extern "C" +{ + ctype_wrapper(isalnum, _isalnum) + ctype_wrapper(isalpha, _isalpha) + ctype_wrapper(isascii, _isascii) + ctype_wrapper(iscntrl, _iscntrl) + ctype_wrapper(isdigit, _isdigit) + ctype_wrapper(isxdigit, _isxdigit) + ctype_wrapper(isspace, _isspace) + ctype_wrapper(ispunct, _ispunct) + ctype_wrapper(isprint, _isprint) + ctype_wrapper(isgraph, _isgraph) + ctype_wrapper(islower, _islower) + ctype_wrapper(isupper, _isupper) + ctype_wrapper(isblank, _isblank) + ctype_wrapper(tolower, _tolower) + ctype_wrapper(toupper, _toupper) +} + +// clang-format on