From 5f48a6b4e0e2753038a839cb10246ba3a159b3c4 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 16 May 2021 18:10:30 +0200 Subject: [PATCH] errno: add the errno variable and base macros A file will likely by added later on for each target to add more specific values. --- CMakeLists.txt | 1 + include/errno.h | 12 ++++++++++++ src/libc/errno/errno.c | 4 ++++ 3 files changed, 17 insertions(+) create mode 100644 include/errno.h create mode 100644 src/libc/errno/errno.c 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;