diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-07-06 22:11:12 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-09-08 21:10:27 +0200 |
| commit | c849930b5319373978180569506180570320e978 (patch) | |
| tree | 4c286b988540ec1156ac7fc9756f690f7dc8c4a9 /src/libc/include | |
| parent | c8f9dbd494732c43d5b3626ba7010bf27d1f7664 (diff) | |
Setup libc skeleton
Diffstat (limited to 'src/libc/include')
| -rw-r--r-- | src/libc/include/errno.h | 43 | ||||
| -rw-r--r-- | src/libc/include/stddef.h | 8 | ||||
| -rw-r--r-- | src/libc/include/stdio.h | 35 | ||||
| -rw-r--r-- | src/libc/include/stdlib.h | 24 | ||||
| -rw-r--r-- | src/libc/include/string.h | 1 |
5 files changed, 103 insertions, 8 deletions
diff --git a/src/libc/include/errno.h b/src/libc/include/errno.h new file mode 100644 index 0000000..0456645 --- /dev/null +++ b/src/libc/include/errno.h @@ -0,0 +1,43 @@ +#ifndef _ERRNO_H +#define _ERRNO_H + +extern int errno; + +enum +{ + OK, + EPERM, + ENOENT, + ESRCH, + EINTR, + EIO, + ENXIO, + E2BIG, + ENOEXEC, + EBADF, + ECHILD, + EAGAIN, + ENOMEM, + EACCES, + EFAULT, + ENOTBLK, + EBUSY, + EEXIST, + EXDEV, + ENODEV, + ENOTDIR, + EISDIR, + EINVAL, + ENFILE, + EMFILE, + ENOTTY, + ETXTBSY, + EFBIG, + ENOSPC, + ESPIPE, + EROFS, + EMLINK, + EPIPE, +}; + +#endif diff --git a/src/libc/include/stddef.h b/src/libc/include/stddef.h deleted file mode 100644 index 123e46f..0000000 --- a/src/libc/include/stddef.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _STDDEF_H -#define _STDDEF_H - -#define NULL ((void *)0) - -typedef unsigned long size_t; - -#endif diff --git a/src/libc/include/stdio.h b/src/libc/include/stdio.h new file mode 100644 index 0000000..1d0e27c --- /dev/null +++ b/src/libc/include/stdio.h @@ -0,0 +1,35 @@ +/* + * wanix, a Unix-like operating system for WebAssembly + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef _STDIO_H +#define _STDIO_H + +enum +{ + EOF = -1 +}; + +typedef struct __file FILE; + +FILE *fopen(const char *__path, const char *__mode); +int printf(const char *__fmt, ...); +int fprintf(FILE *__stream, const char *__fmt, ...); + +extern FILE *stdin, *stdout, *stderr; + +#endif diff --git a/src/libc/include/stdlib.h b/src/libc/include/stdlib.h index 79d3122..4065f1c 100644 --- a/src/libc/include/stdlib.h +++ b/src/libc/include/stdlib.h @@ -1,7 +1,31 @@ +/* + * wanix, a Unix-like operating system for WebAssembly + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + #ifndef _STDLIB_H #define _STDLIB_H +#include <stddef.h> + #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 +void *malloc(size_t __n); +void *calloc(size_t __nemb, size_t __size); +void free(void *__p); + #endif diff --git a/src/libc/include/string.h b/src/libc/include/string.h index 7efda4e..20c9cf3 100644 --- a/src/libc/include/string.h +++ b/src/libc/include/string.h @@ -7,6 +7,7 @@ int memcmp(const void *__s1, const void *__s2, size_t __n); void *memcpy(void *__dst, const void *__src, size_t __n); void *memset(void *__dst, int __c, size_t __n); char *strchr(const char *__s, int __n); +char *strerror(int errnum); size_t strlen(const char *__s); #endif |
