errno: add the errno variable and base macros

A <bits/errno.h> file will likely by added later on for each target to
add more specific values.
This commit is contained in:
Lephenixnoir 2021-05-16 18:10:30 +02:00
parent c87805ef10
commit 5f48a6b4e0
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 17 additions and 0 deletions

View File

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

12
include/errno.h Normal file
View File

@ -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__*/

4
src/libc/errno/errno.c Normal file
View File

@ -0,0 +1,4 @@
#include <errno.h>
/* The initial value is 0 at program startup */
int errno = 0;