diff --git a/CMakeLists.txt b/CMakeLists.txt index 0af8e42..dd2baa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,7 @@ set(SOURCES src/libc/ctype/isxdigit.c src/libc/ctype/tolower.c src/libc/ctype/toupper.c + src/libc/errno/errno.c src/libc/locale/setlocale.c src/libc/locale/localeconv.c src/libc/stdio/vsnprintf.c diff --git a/include/errno.h b/include/errno.h new file mode 100644 index 0000000..41f0201 --- /dev/null +++ b/include/errno.h @@ -0,0 +1,12 @@ +#ifndef __ERRNO_H__ +# define __ERRNO_H__ + +/* Initialized to 0 at startup. Currently not TLS, maybe in the future if + threads are supported. */ +extern int errno; + +#define EDOM 1 +#define EILSEQ 2 +#define ERANGE 3 + +#endif /*__ERRNO_H__*/ diff --git a/src/libc/errno/errno.c b/src/libc/errno/errno.c new file mode 100644 index 0000000..01c99f8 --- /dev/null +++ b/src/libc/errno/errno.c @@ -0,0 +1,4 @@ +#include + +/* The initial value is 0 at program startup */ +int errno = 0;