libc: Add ctype.h

This commit is contained in:
apio 2023-01-06 20:48:08 +01:00
parent 80f5c790f8
commit 8891304509
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 63 additions and 0 deletions

View File

@ -8,6 +8,7 @@ set(SOURCES
src/errno.cpp
src/string.cpp
src/atexit.cpp
src/ctype.cpp
)
if(${ARCH} STREQUAL "x86_64")

31
libc/include/ctype.h Normal file
View File

@ -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

31
libc/src/ctype.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <ctype.h>
#include <luna/CType.h>
#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