summaryrefslogtreecommitdiff
path: root/src/user/lib/include
diff options
context:
space:
mode:
authordzwdz2023-08-14 18:51:07 +0200
committerdzwdz2023-08-14 18:51:07 +0200
commit642b5fb0007b64c77d186fcb018d571152ee1d47 (patch)
tree1c466461f3602d306be309a053edae558ef2568e /src/user/lib/include
parent8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff)
reorganization: first steps
Diffstat (limited to 'src/user/lib/include')
-rw-r--r--src/user/lib/include/__errno.h26
-rw-r--r--src/user/lib/include/__errno.h.awk20
-rw-r--r--src/user/lib/include/_proc.h14
-rw-r--r--src/user/lib/include/alloca.h3
-rw-r--r--src/user/lib/include/bits/file.h2
-rw-r--r--src/user/lib/include/bits/panic.h5
-rw-r--r--src/user/lib/include/camellia.h5
-rw-r--r--src/user/lib/include/camellia/compat.h6
-rw-r--r--src/user/lib/include/camellia/fs/dir.h17
-rw-r--r--src/user/lib/include/camellia/fs/misc.h22
-rw-r--r--src/user/lib/include/ctype.h16
-rw-r--r--src/user/lib/include/dirent.h16
-rw-r--r--src/user/lib/include/draw.h24
-rw-r--r--src/user/lib/include/elfload.h14
-rw-r--r--src/user/lib/include/err.h10
-rw-r--r--src/user/lib/include/errno.h3
-rw-r--r--src/user/lib/include/esemaphore.h12
-rw-r--r--src/user/lib/include/fcntl.h25
-rw-r--r--src/user/lib/include/ftw.h6
l---------src/user/lib/include/getopt.h1
-rw-r--r--src/user/lib/include/grp.h11
-rw-r--r--src/user/lib/include/inttypes.h1
-rw-r--r--src/user/lib/include/limits.h6
-rw-r--r--src/user/lib/include/locale.h73
l---------src/user/lib/include/malloc.h1
-rw-r--r--src/user/lib/include/math.h27
-rw-r--r--src/user/lib/include/pwd.h14
-rw-r--r--src/user/lib/include/setjmp.h18
-rw-r--r--src/user/lib/include/signal.h54
-rw-r--r--src/user/lib/include/stdio.h84
-rw-r--r--src/user/lib/include/stdlib.h34
-rw-r--r--src/user/lib/include/string.h25
-rw-r--r--src/user/lib/include/strings.h5
-rw-r--r--src/user/lib/include/sys/ioctl.h13
-rw-r--r--src/user/lib/include/sys/mman.h18
-rw-r--r--src/user/lib/include/sys/param.h2
-rw-r--r--src/user/lib/include/sys/resource.h2
-rw-r--r--src/user/lib/include/sys/stat.h70
-rw-r--r--src/user/lib/include/sys/sysmacros.h3
-rw-r--r--src/user/lib/include/sys/time.h0
-rw-r--r--src/user/lib/include/sys/times.h13
-rw-r--r--src/user/lib/include/sys/types.h18
-rw-r--r--src/user/lib/include/sys/wait.h13
-rw-r--r--src/user/lib/include/termios.h0
-rw-r--r--src/user/lib/include/thread.h9
-rw-r--r--src/user/lib/include/time.h34
-rw-r--r--src/user/lib/include/unistd.h64
47 files changed, 0 insertions, 859 deletions
diff --git a/src/user/lib/include/__errno.h b/src/user/lib/include/__errno.h
deleted file mode 100644
index 7551ce0..0000000
--- a/src/user/lib/include/__errno.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* generated by awk */
-#ifdef E
-E( 1, "EGENERIC unknown error")
-E( 2, "EFAULT")
-E( 3, "EBADF bad file descriptor")
-E( 4, "EINVAL")
-E( 5, "ENOSYS unsupported")
-E( 6, "ERANGE")
-E( 7, "ENOMEM")
-E( 8, "ENOENT")
-E( 9, "ENOTEMPTY")
-E( 10, "EACCES")
-E( 11, "EMFILE all file descriptors taken")
-E( 12, "ECONNRESET")
-E( 13, "EPIPE")
-E( 14, "ECHILD")
-E(200, "EISDIR")
-E(201, "ENAMETOOLONG")
-E(202, "ENOTDIR")
-E(203, "ELOOP")
-E(204, "ENOEXEC")
-E(205, "EINTR")
-E(206, "EWOULDBLOCK")
-E(207, "EEXIST")
-E(208, "EAGAIN")
-#endif
diff --git a/src/user/lib/include/__errno.h.awk b/src/user/lib/include/__errno.h.awk
deleted file mode 100644
index 6232835..0000000
--- a/src/user/lib/include/__errno.h.awk
+++ /dev/null
@@ -1,20 +0,0 @@
-BEGIN {
- print "/* generated by awk */";
- print "#ifdef E";
-}
-
-END {
- print "#endif";
-}
-
-/#define/ {
- comment = $2;
- num = $3;
- # extract the comment, if present
- if (index($0, "/*")) {
- sub(/[^/]*\/\*/, "");
- sub(/ *\*\//, "");
- comment = comment $0;
- }
- printf "E(%3s, \"%s\")\n", num, comment;
-}
diff --git a/src/user/lib/include/_proc.h b/src/user/lib/include/_proc.h
deleted file mode 100644
index 5f9c321..0000000
--- a/src/user/lib/include/_proc.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-struct _psdata {
- /* Description of the process, see setprogname.
- * Assumed to be null terminated. */
- char desc[1024];
-
- /* Base offset where the executable was loaded. */
- void *base;
-};
-
-/* First allocated in bootstrap.
- * Freed on every exec(), just to be immediately reallocated by _start2(). */
-static struct _psdata *const _psdata_loc = (void*)0x10000;
diff --git a/src/user/lib/include/alloca.h b/src/user/lib/include/alloca.h
deleted file mode 100644
index 9c7641c..0000000
--- a/src/user/lib/include/alloca.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-#include <stddef.h>
-void *alloca(size_t size);
diff --git a/src/user/lib/include/bits/file.h b/src/user/lib/include/bits/file.h
deleted file mode 100644
index 63a31c4..0000000
--- a/src/user/lib/include/bits/file.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma once
-typedef struct _LIBC_FILE FILE;
diff --git a/src/user/lib/include/bits/panic.h b/src/user/lib/include/bits/panic.h
deleted file mode 100644
index 91aec5f..0000000
--- a/src/user/lib/include/bits/panic.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-#include <stdio.h>
-#include <stdlib.h>
-
-#define __libc_panic(...) do { fprintf(stderr, "__libc_panic @ %s:", __func__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); abort(); } while (0)
diff --git a/src/user/lib/include/camellia.h b/src/user/lib/include/camellia.h
deleted file mode 100644
index 2e4998b..0000000
--- a/src/user/lib/include/camellia.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-#include <camellia/flags.h>
-#include <camellia/types.h>
-
-hid_t camellia_open(const char *path, int flags);
diff --git a/src/user/lib/include/camellia/compat.h b/src/user/lib/include/camellia/compat.h
deleted file mode 100644
index a7c6f1f..0000000
--- a/src/user/lib/include/camellia/compat.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-#include <camellia/types.h>
-
-/* c0 - fs_wait returning a handle */
-long c0_fs_wait(char *buf, long len, struct ufs_request *res);
-long c0_fs_respond(void *buf, long ret, int flags);
diff --git a/src/user/lib/include/camellia/fs/dir.h b/src/user/lib/include/camellia/fs/dir.h
deleted file mode 100644
index d34a652..0000000
--- a/src/user/lib/include/camellia/fs/dir.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-#include <camellia/types.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-struct dirbuild {
- long offset;
- char *buf;
- long bpos, blen;
- long error;
-};
-
-void dir_start(struct dirbuild *db, long offset, char *buf, size_t buflen);
-bool dir_append(struct dirbuild *db, const char *name);
-bool dir_appendl(struct dirbuild *db, const char *name, size_t len);
-bool dir_append_from(struct dirbuild *db, hid_t h);
-long dir_finish(struct dirbuild *db);
diff --git a/src/user/lib/include/camellia/fs/misc.h b/src/user/lib/include/camellia/fs/misc.h
deleted file mode 100644
index 301c604..0000000
--- a/src/user/lib/include/camellia/fs/misc.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma once
-#include <stdbool.h>
-#include <stdlib.h>
-
-void forward_open(hid_t reqh, const char *path, long len, int flags);
-
-void fs_passthru(const char *prefix);
-void fs_whitelist(const char **list);
-void fs_union(const char **list);
-
-void fs_dirinject(const char *path);
-void fs_dirinject2(const char *injects[]);
-
-int mount_at(const char *path);
-
-// TODO separate fs drivers and wrappers around syscalls
-
-/** like _sys_fs_wait, but ensures *buf is a null terminated string on VFSOP_OPEN */
-hid_t ufs_wait(char *buf, size_t len, struct ufs_request *req);
-
-/** Mounts something and injects its path into the fs */
-#define MOUNT_AT(path) for (; mount_at(path) == 0; exit(1))
diff --git a/src/user/lib/include/ctype.h b/src/user/lib/include/ctype.h
deleted file mode 100644
index 1ebb111..0000000
--- a/src/user/lib/include/ctype.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-
-int isalnum(int c);
-int isalpha(int c);
-int iscntrl(int c);
-int isdigit(int c);
-int isgraph(int c);
-int islower(int c);
-int isprint(int c);
-int ispunct(int c);
-int isspace(int c);
-int isupper(int c);
-int isxdigit(int c);
-
-int tolower(int c);
-int toupper(int c);
diff --git a/src/user/lib/include/dirent.h b/src/user/lib/include/dirent.h
deleted file mode 100644
index 7c419d7..0000000
--- a/src/user/lib/include/dirent.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-#include <stdio.h>
-
-struct dirent {
- ino_t d_ino;
- char d_name[256]; /* NAME_MAX + 1 */
-};
-
-typedef struct {
- FILE *fp;
- struct dirent dent;
-} DIR;
-
-DIR *opendir(const char *name);
-int closedir(DIR *dir);
-struct dirent *readdir(DIR *dir);
diff --git a/src/user/lib/include/draw.h b/src/user/lib/include/draw.h
deleted file mode 100644
index 5e614be..0000000
--- a/src/user/lib/include/draw.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-#include <camellia/types.h>
-#include <stddef.h>
-#include <stdint.h>
-
-struct framebuf {
- size_t len, width, height, pitch;
- uint8_t bpp;
- char *b;
-
- hid_t fd;
-};
-
-struct rect { uint32_t x1, y1, x2, y2; };
-void dirty_reset(struct rect *d);
-void dirty_mark(struct rect *d, uint32_t x, uint32_t y);
-void dirty_flush(struct rect *d, struct framebuf *fb);
-
-int fb_setup(struct framebuf *fb, const char *base);
-int fb_anon(struct framebuf *fb, size_t w, size_t h);
-uint32_t *fb_pixel(struct framebuf *fb, uint32_t x, uint32_t y);
-void fb_cpy(
- struct framebuf *dest, const struct framebuf *src,
- size_t xd, size_t yd, size_t xs, size_t ys, size_t w, size_t h);
diff --git a/src/user/lib/include/elfload.h b/src/user/lib/include/elfload.h
deleted file mode 100644
index 825f765..0000000
--- a/src/user/lib/include/elfload.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-#include <bits/file.h>
-
-struct execdata {
- int argc;
- char **argv, **envp;
- char *cwd;
-};
-
-void elf_execf(FILE *f, char **argv, char **envp);
-void elf_exec(void *base, char **argv, char **envp);
-void *elf_partialexec(void *elf); /* returns pointer to entry point */
-
-void elf_selfreloc(void); // elfreloc.c
diff --git a/src/user/lib/include/err.h b/src/user/lib/include/err.h
deleted file mode 100644
index 6b63c6c..0000000
--- a/src/user/lib/include/err.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-#include <stdarg.h>
-
-_Noreturn void err(int ret, const char *fmt, ...);
-_Noreturn void errx(int ret, const char *fmt, ...);
-void warn(const char *fmt, ...);
-void warnx(const char *fmt, ...);
-
-void vwarn(const char *fmt, va_list args);
-void vwarnx(const char *fmt, va_list args);
diff --git a/src/user/lib/include/errno.h b/src/user/lib/include/errno.h
deleted file mode 100644
index 6686a01..0000000
--- a/src/user/lib/include/errno.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-#include <camellia/errno.h>
-extern int errno;
diff --git a/src/user/lib/include/esemaphore.h b/src/user/lib/include/esemaphore.h
deleted file mode 100644
index 9cc85e0..0000000
--- a/src/user/lib/include/esemaphore.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-#include <camellia/types.h>
-
-struct evil_sem {
- hid_t wait, signal;
-};
-
-void esem_signal(struct evil_sem *sem);
-void esem_wait(struct evil_sem *sem);
-
-struct evil_sem *esem_new(int value);
-void esem_free(struct evil_sem *sem);
diff --git a/src/user/lib/include/fcntl.h b/src/user/lib/include/fcntl.h
deleted file mode 100644
index 6338d1f..0000000
--- a/src/user/lib/include/fcntl.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-#define F_SETFL 1
-#define F_GETFL 2
-#define F_DUPFD 3
-#define F_SETFD 4
-
-#define FD_CLOEXEC 1
-
-#define O_APPEND 0
-#define O_CREAT 0
-#define O_EXCL 0
-#define O_NONBLOCK 0
-#define O_RDONLY 0
-#define O_RDWR 0
-#define O_TRUNC 0
-#define O_WRONLY 0
-
-#define R_OK 1
-#define W_OK 2
-#define X_OK 4
-
-/* it can either take an additonal mode_t argument or none */
-int open(const char *path, int flags, ...);
-int fcntl(int fd, int cmd, ...);
diff --git a/src/user/lib/include/ftw.h b/src/user/lib/include/ftw.h
deleted file mode 100644
index 6dc8132..0000000
--- a/src/user/lib/include/ftw.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-#include <sys/stat.h>
-
-int ftw(const char *dirpath,
- int (*fn)(const char *fpath, const struct stat *sb, int typeflag),
- int nopenfd);
diff --git a/src/user/lib/include/getopt.h b/src/user/lib/include/getopt.h
deleted file mode 120000
index 4890ceb..0000000
--- a/src/user/lib/include/getopt.h
+++ /dev/null
@@ -1 +0,0 @@
-../vendor/getopt/getopt.h \ No newline at end of file
diff --git a/src/user/lib/include/grp.h b/src/user/lib/include/grp.h
deleted file mode 100644
index e7b99c9..0000000
--- a/src/user/lib/include/grp.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-#include <sys/types.h>
-
-struct group {
- char *gr_name;
- char *gr_passwd;
- gid_t gr_gid;
- char **gr_mem;
-};
-
-struct group *getgrgid(gid_t gid);
diff --git a/src/user/lib/include/inttypes.h b/src/user/lib/include/inttypes.h
deleted file mode 100644
index 9a6118b..0000000
--- a/src/user/lib/include/inttypes.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <stdint.h>
diff --git a/src/user/lib/include/limits.h b/src/user/lib/include/limits.h
deleted file mode 100644
index 972553f..0000000
--- a/src/user/lib/include/limits.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-#include <camellia/path.h> // just for PATH_MAX
-// #include_next <limits.h>
-
-#define _POSIX2_RE_DUP_MAX 255
-#define NAME_MAX 255
diff --git a/src/user/lib/include/locale.h b/src/user/lib/include/locale.h
deleted file mode 100644
index 1221375..0000000
--- a/src/user/lib/include/locale.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-#include <limits.h>
-
-#define LC_ALL 0
-#define LC_COLLATE 1
-#define LC_CTYPE 2
-#define LC_MESSAGES 3
-#define LC_MONETARY 4
-#define LC_NUMERIC 5
-#define LC_TIME 6
-
-struct lconv {
- char *decimal_point;
- char *thousands_sep;
- char *grouping;
- char *mon_decimal_point;
- char *mon_thousands_sep;
- char *mon_grouping;
- char *positive_sign;
- char *negative_sign;
- char *currency_symbol;
- char frac_digits;
- char p_cs_precedes;
- char n_cs_precedes;
- char p_sep_by_space;
- char n_sep_by_space;
- char p_sign_posn;
- char n_sign_posn;
- char *int_curr_symbol;
- char int_frac_digits;
- char int_p_cs_precedes;
- char int_n_cs_precedes;
- char int_p_sep_by_space;
- char int_n_sep_by_space;
- char int_p_sign_posn;
- char int_n_sign_posn;
-};
-
-static inline struct lconv *localeconv(void) {
- /* per Linux's lconv(3) */
- static struct lconv locale = (struct lconv){
- .decimal_point = ".",
- .thousands_sep = "",
- .grouping = "",
- .mon_decimal_point = "",
- .mon_thousands_sep = "",
- .mon_grouping = "",
- .positive_sign = "",
- .negative_sign = "",
- .currency_symbol = "",
- .frac_digits = CHAR_MAX,
- .p_cs_precedes = CHAR_MAX,
- .n_cs_precedes = CHAR_MAX,
- .p_sep_by_space = CHAR_MAX,
- .n_sep_by_space = CHAR_MAX,
- .p_sign_posn = CHAR_MAX,
- .n_sign_posn = CHAR_MAX,
- .int_curr_symbol = "",
- .int_frac_digits = CHAR_MAX,
- .int_p_cs_precedes = CHAR_MAX,
- .int_n_cs_precedes = CHAR_MAX,
- .int_p_sep_by_space = CHAR_MAX,
- .int_n_sep_by_space = CHAR_MAX,
- .int_p_sign_posn = CHAR_MAX,
- .int_n_sign_posn = CHAR_MAX,
- };
- return &locale;
-}
-
-static inline char *setlocale(int category, const char *locale) {
- (void)category; (void)locale;
- return NULL;
-}
diff --git a/src/user/lib/include/malloc.h b/src/user/lib/include/malloc.h
deleted file mode 120000
index 80b9bf5..0000000
--- a/src/user/lib/include/malloc.h
+++ /dev/null
@@ -1 +0,0 @@
-../vendor/dlmalloc/malloc.h \ No newline at end of file
diff --git a/src/user/lib/include/math.h b/src/user/lib/include/math.h
deleted file mode 100644
index 1aec564..0000000
--- a/src/user/lib/include/math.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#define INFINITY __builtin_inff()
-#define HUGE_VAL ((double)INFINITY)
-
-double acos(double x);
-double asin(double x);
-double atan2(double x, double y);
-double cos(double x);
-double cosh(double x);
-double sin(double x);
-double sinh(double x);
-double tan(double x);
-double tanh(double x);
-
-double fabs(double x);
-double floor(double x);
-double ceil(double x);
-double log(double x);
-double log2(double x);
-double log10(double x);
-double exp(double x);
-double fmod(double x, double y);
-double frexp(double num, int *exp);
-double ldexp(double x, int exp);
-double pow(double x, double y);
-double sqrt(double x);
diff --git a/src/user/lib/include/pwd.h b/src/user/lib/include/pwd.h
deleted file mode 100644
index 6721ca2..0000000
--- a/src/user/lib/include/pwd.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-#include <sys/types.h>
-
-struct passwd {
- char *pw_name;
- char *pw_passwd;
- uid_t pw_uid;
- gid_t pw_gid;
- char *pw_gecos;
- char *pw_dir;
- char *pw_shell;
-};
-
-struct passwd *getpwuid(uid_t uid);
diff --git a/src/user/lib/include/setjmp.h b/src/user/lib/include/setjmp.h
deleted file mode 100644
index 6d05d79..0000000
--- a/src/user/lib/include/setjmp.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-#include <bits/panic.h>
-
-typedef uint64_t jmp_buf[8]; /* rbx, rsp, rbp, r12, r13, r14, r15, rip */
-typedef char sigjmp_buf[1];
-
-int setjmp(jmp_buf env);
-_Noreturn void longjmp(jmp_buf env, int val);
-
-static inline int sigsetjmp(sigjmp_buf env, int savemask) {
- (void)env; (void)savemask;
- return 0;
-}
-
-static inline _Noreturn void siglongjmp(sigjmp_buf env, int val) {
- (void)env; (void)val;
- __libc_panic("unimplemented");
-}
diff --git a/src/user/lib/include/signal.h b/src/user/lib/include/signal.h
deleted file mode 100644
index 012481e..0000000
--- a/src/user/lib/include/signal.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#pragma once
-#include <bits/panic.h>
-#include <sys/types.h>
-#include <errno.h> // only for ENOSYS
-
-#define SIGHUP 1
-#define SIGINT 2
-#define SIGQUIT 3
-#define SIGILL 4
-#define SIGTRAP 5
-#define SIGABRT 6
-#define SIGFPE 8
-#define SIGKILL 9
-#define SIGSEGV 11
-#define SIGPIPE 13
-#define SIGALRM 14
-#define SIGTERM 15
-
-#define SIGCONT 16
-#define SIGPIPE 17
-#define SIGTSTP 18
-#define SIGTTIN 19
-#define SIGTTOU 20
-#define SIGWINCH 21
-#define SIGCHLD 22
-
-#define NSIG 32
-
-#define SIG_DFL 0
-#define SIG_ERR 0
-#define SIG_IGN 0
-#define SIG_SETMASK 0
-
-typedef int sig_atomic_t;
-typedef struct {} sigset_t;
-typedef struct {} siginfo_t;
-extern const char *const sys_siglist[];
-
-struct sigaction {
- void (*sa_handler)(int);
- void (*sa_sigaction)(int, siginfo_t *, void *);
- sigset_t sa_mask;
- int sa_flags;
- void (*sa_restorer)(void);
-};
-
-int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact);
-int sigemptyset(sigset_t *set);
-int sigfillset(sigset_t *set);
-int sigprocmask(int how, const sigset_t *set, const sigset_t *oldset);
-int sigsuspend(const sigset_t *mask);
-int signal(int sig, void (*func)(int));
-int kill(pid_t pid, int sig);
-int raise(int sig);
diff --git a/src/user/lib/include/stdio.h b/src/user/lib/include/stdio.h
deleted file mode 100644
index 48d5058..0000000
--- a/src/user/lib/include/stdio.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#pragma once
-#include <bits/file.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <sys/types.h>
-
-#define EOF (-1)
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-
-#define SEEK_SET 1
-#define SEEK_CUR 2
-#define SEEK_END 3
-
-#define _IONBF 0
-#define _IOFBF 1
-#define _IOLBF 2
-
-#define BUFSIZ 4096
-
-/* stop fread() from trying to fill the entire buffer before returning
- * i.e. it will call _sys_read() exactly once */
-#define FEXT_NOFILL 1
-
-int printf(const char *restrict fmt, ...);
-int fprintf(FILE *restrict f, const char *restrict fmt, ...);
-
-int sprintf(char *restrict s, const char *restrict fmt, ...);
-
-int vprintf(const char *restrict fmt, va_list ap);
-int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap);
-
-int _klogf(const char *fmt, ...); // for kernel debugging only
-
-
-extern FILE *const stdin, *const stdout, *const stderr;
-
-FILE *fopen(const char *path, const char *mode);
-FILE *freopen(const char *path, const char *mode, FILE *);
-FILE *fdopen(int fd, const char *mode);
-FILE *file_clone(const FILE *, const char *mode);
-FILE *popen(const char *cmd, const char *mode);
-int pclose(FILE *f);
-FILE *tmpfile(void);
-
-int fextflags(FILE *, int extflags);
-int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size);
-int fclose(FILE *);
-int fflush(FILE *f);
-
-size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict);
-size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict);
-int fputs(const char *s, FILE *f);
-char *fgets(char *buf, int size, FILE *f);
-int fgetc(FILE *f);
-int getc(FILE *f);
-int fputc(int c, FILE *f);
-int putc(int c, FILE *f);
-int ungetc(int c, FILE *f);
-
-int fseek(FILE *f, long offset, int whence);
-int fseeko(FILE *f, off_t offset, int whence);
-long ftell(FILE *f);
-off_t ftello(FILE *f);
-
-int feof(FILE *);
-int ferror(FILE *);
-void clearerr(FILE *f);
-
-void perror(const char *s);
-int puts(const char *s);
-int getchar(void);
-int putchar(int c);
-
-off_t lseek(int fd, off_t off, int whence);
-
-int remove(const char *path);
-int rename(const char *old, const char *new);
-
-#define L_tmpnam (5 + 16 + 1)
-char *tmpnam(char *s);
-
-int sscanf(const char *restrict s, const char *restrict format, ...);
diff --git a/src/user/lib/include/stdlib.h b/src/user/lib/include/stdlib.h
deleted file mode 100644
index ee9d179..0000000
--- a/src/user/lib/include/stdlib.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-#include <stddef.h>
-#include <stdlib.h>
-
-#ifndef NO_MALLOC_H
-#include <malloc.h>
-#endif
-
-#define EXIT_SUCCESS 0
-#define EXIT_FAILURE 1
-
-_Noreturn void abort(void);
-_Noreturn void exit(int);
-
-const char *getprogname(void);
-void setprogname(const char *progname);
-void setproctitle(const char *fmt, ...);
-
-int mkstemp(char *template);
-char *getenv(const char *name);
-int system(const char *cmd);
-
-int abs(int i);
-
-int atoi(const char *s);
-double atof(const char *s);
-
-long strtol(const char *restrict s, char **restrict end, int base);
-long long strtoll(const char *restrict s, char **restrict end, int base);
-unsigned long strtoul(const char *restrict s, char **restrict end, int base);
-unsigned long long strtoull(const char *restrict s, char **restrict end, int base);
-double strtod(const char *restrict s, char **restrict end);
-
-void qsort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *a, const void *b));
diff --git a/src/user/lib/include/string.h b/src/user/lib/include/string.h
deleted file mode 100644
index 78bed9b..0000000
--- a/src/user/lib/include/string.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-#include <shared/mem.h>
-#include <strings.h> /* work around bad include in dash */
-
-char *strchr(const char *s, int c);
-char *strrchr(const char *s, int c);
-
-size_t strspn(const char *s, const char *accept);
-size_t strcspn(const char *s, const char *reject);
-char *strpbrk(const char *s1, const char *s2);
-
-char *strtok(char *restrict s, const char *restrict sep);
-char *strtok_r(char *restrict s, const char *restrict sep, char **restrict state);
-
-int strncmp(const char *s1, const char *s2, size_t n);
-int strcoll(const char *s1, const char *s2);
-
-char *strstr(const char *s1, const char *s2);
-
-char *strcpy(char *restrict s1, const char *restrict s2);
-char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
-char *stpncpy(char *restrict dst, const char *restrict src, size_t n);
-char *strdup(const char *s);
-
-char *strerror(int errnum);
diff --git a/src/user/lib/include/strings.h b/src/user/lib/include/strings.h
deleted file mode 100644
index d0abc47..0000000
--- a/src/user/lib/include/strings.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-#include <stddef.h>
-
-int strcasecmp(const char *s1, const char *s2);
-int strncasecmp(const char *s1, const char *s2, size_t n);
diff --git a/src/user/lib/include/sys/ioctl.h b/src/user/lib/include/sys/ioctl.h
deleted file mode 100644
index 708bc3f..0000000
--- a/src/user/lib/include/sys/ioctl.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-#include <errno.h> // only for ENOSYS
-
-#define TIOCGWINSZ 0
-struct winsize {
- int ws_row, ws_col;
-};
-
-static inline int ioctl(int fd, int req, ...) {
- (void)fd; (void)req;
- errno = ENOSYS;
- return -1;
-}
diff --git a/src/user/lib/include/sys/mman.h b/src/user/lib/include/sys/mman.h
deleted file mode 100644
index 074ebe2..0000000
--- a/src/user/lib/include/sys/mman.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-#include <camellia/flags.h>
-#include <sys/types.h>
-
-#define MMAP_UNSUPPORTED 0xFFFF
-
-#define PROT_EXEC 1
-#define PROT_NONE MMAP_UNSUPPORTED
-#define PROT_READ 1
-#define PROT_WRITE 1
-
-#define MAP_FIXED MMAP_UNSUPPORTED
-#define MAP_PRIVATE 0
-#define MAP_SHARED MMAP_UNSUPPORTED
-#define MAP_ANONYMOUS 1
-
-void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off);
-int munmap(void *addr, size_t len);
diff --git a/src/user/lib/include/sys/param.h b/src/user/lib/include/sys/param.h
deleted file mode 100644
index e6c9d6f..0000000
--- a/src/user/lib/include/sys/param.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#define MIN(a, b) ((a)<(b) ? (a):(b))
-#define MAX(a, b) ((a)<(b) ? (b):(a))
diff --git a/src/user/lib/include/sys/resource.h b/src/user/lib/include/sys/resource.h
deleted file mode 100644
index 4582ce0..0000000
--- a/src/user/lib/include/sys/resource.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma once
-struct rusage {};
diff --git a/src/user/lib/include/sys/stat.h b/src/user/lib/include/sys/stat.h
deleted file mode 100644
index 343db55..0000000
--- a/src/user/lib/include/sys/stat.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#pragma once
-#include <bits/panic.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <time.h> // struct timespec
-#include <errno.h> // only for ENOSYS
-
-struct stat {
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- dev_t st_rdev;
- off_t st_size;
- blksize_t st_blksize;
- blkcnt_t st_blocks;
-
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
-
-#define st_atime st_atim.tv_sec
-#define st_mtime st_mtim.tv_sec
-#define st_ctime st_ctim.tv_sec
-};
-
-#define S_IFMT 0170000
-#define S_IFSOCK 0140000
-#define S_IFLNK 0120000
-#define S_IFREG 0100000
-#define S_IFBLK 0060000
-#define S_IFDIR 0040000
-#define S_IFCHR 0020000
-#define S_IFIFO 0010000
-#define S_ISUID 04000
-#define S_ISGID 02000
-#define S_ISVTX 01000
-
-/* inode(7) */
-#define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
-#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
-#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
-#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
-#define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
-#define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
-#define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
-
-int fstat(int fd, struct stat *sb);
-int stat(const char *restrict path, struct stat *restrict sb);
-int lstat(const char *restrict path, struct stat *restrict sb);
-int mkdir(const char *path, mode_t mode);
-
-static inline mode_t umask(mode_t mask) {
- (void)mask;
- __libc_panic("unimplemented");
-}
-
-static inline int chmod(const char *path, mode_t mode) {
- (void)path; (void)mode;
- errno = ENOSYS;
- return -1;
-}
-
-static inline int mknod(const char *path, mode_t mode, dev_t dev) {
- (void)path; (void)mode; (void)dev;
- errno = ENOSYS;
- return -1;
-}
diff --git a/src/user/lib/include/sys/sysmacros.h b/src/user/lib/include/sys/sysmacros.h
deleted file mode 100644
index 30e0efd..0000000
--- a/src/user/lib/include/sys/sysmacros.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#define makedev(maj, min) 0
-#define major(x) 0
-#define minor(x) 0
diff --git a/src/user/lib/include/sys/time.h b/src/user/lib/include/sys/time.h
deleted file mode 100644
index e69de29..0000000
--- a/src/user/lib/include/sys/time.h
+++ /dev/null
diff --git a/src/user/lib/include/sys/times.h b/src/user/lib/include/sys/times.h
deleted file mode 100644
index 4a8d3ef..0000000
--- a/src/user/lib/include/sys/times.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-#include <bits/panic.h>
-
-struct tms {
- clock_t tms_utime;
- clock_t tms_stime;
- clock_t tms_cutime;
- clock_t tms_cstime;
-};
-
-static inline clock_t times(struct tms *buf) {
- __libc_panic("unimplemented");
-}
diff --git a/src/user/lib/include/sys/types.h b/src/user/lib/include/sys/types.h
deleted file mode 100644
index faf656a..0000000
--- a/src/user/lib/include/sys/types.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-#include <stddef.h>
-#include <stdint.h>
-
-typedef long long off_t;
-typedef int64_t time_t;
-typedef uint64_t clock_t;
-typedef int mode_t;
-
-typedef int dev_t;
-typedef int ino_t;
-typedef int mode_t;
-typedef int nlink_t;
-typedef int uid_t;
-typedef int gid_t;
-typedef int blksize_t;
-typedef int blkcnt_t;
-typedef int pid_t;
diff --git a/src/user/lib/include/sys/wait.h b/src/user/lib/include/sys/wait.h
deleted file mode 100644
index cff407e..0000000
--- a/src/user/lib/include/sys/wait.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-#include <sys/types.h>
-
-#define WIFSTOPPED(x) 0
-#define WEXITSTATUS(x) ((x)&0xFF)
-#define WIFEXITED(x) 1
-#define WSTOPSIG(x) 0
-#define WTERMSIG(x) 0
-
-#define WNOHANG 0
-#define WUNTRACED 0
-
-pid_t wait3(int *wstatus, int opts, struct rusage *rusage);
diff --git a/src/user/lib/include/termios.h b/src/user/lib/include/termios.h
deleted file mode 100644
index e69de29..0000000
--- a/src/user/lib/include/termios.h
+++ /dev/null
diff --git a/src/user/lib/include/thread.h b/src/user/lib/include/thread.h
deleted file mode 100644
index 5a5ddc0..0000000
--- a/src/user/lib/include/thread.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-#include <stdlib.h>
-
-void thread_creates(int flags, void (*fn)(void*), void *arg, void *stack);
-
-static inline void thread_create(int flags, void (*fn)(void*), void *arg) {
- /* error checking is for WIMPS. */
- thread_creates(flags, fn, arg, malloc(4096) + 4096);
-}
diff --git a/src/user/lib/include/time.h b/src/user/lib/include/time.h
deleted file mode 100644
index 5d03664..0000000
--- a/src/user/lib/include/time.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-#include <sys/types.h>
-
-#define CLOCKS_PER_SEC 1000000
-
-struct tm {
- int tm_sec; /* Seconds [0,60]. */
- int tm_min; /* Minutes [0,59]. */
- int tm_hour; /* Hour [0,23]. */
- int tm_mday; /* Day of month [1,31]. */
- int tm_mon; /* Month of year [0,11]. */
- int tm_year; /* Years since 1900. */
- int tm_wday; /* Day of week [0,6] (Sunday =0). */
- int tm_yday; /* Day of year [0,365]. */
- int tm_isdst; /* Daylight Savings flag. */
-};
-
-struct timespec {
- time_t tv_sec;
- long long tv_nsec;
-};
-
-time_t time(time_t *tloc);
-clock_t clock(void);
-
-struct tm *gmtime(const time_t *timer);
-struct tm *localtime(const time_t *timer);
-time_t mktime(struct tm *timeptr);
-
-double difftime(time_t time1, time_t time0);
-
-size_t strftime(
- char *restrict s, size_t maxsize,
- const char *restrict format, const struct tm *restrict timeptr);
diff --git a/src/user/lib/include/unistd.h b/src/user/lib/include/unistd.h
deleted file mode 100644
index 005e79c..0000000
--- a/src/user/lib/include/unistd.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#pragma once
-#include <camellia/types.h> // TODO only needed because of hid_t
-#include <sys/types.h>
-#include <getopt.h>
-
-// TODO custom stdint.h, ssize_t doesn't belong here
-typedef long long ssize_t;
-
-extern char **environ;
-
-int fork(void);
-pid_t vfork(void);
-int close(hid_t h);
-_Noreturn void _exit(int);
-
-ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
-int link(const char *path1, const char *path2);
-int unlink(const char *path);
-int symlink(const char *path1, const char *path2);
-int isatty(int fd);
-
-int execv(const char *path, char *const argv[]);
-int execve(const char *path, char *const argv[], char *const envp[]);
-
-int chdir(const char *path);
-char *getcwd(char *buf, size_t size);
-
-uid_t getuid(void);
-uid_t geteuid(void);
-gid_t getgid(void);
-gid_t getegid(void);
-
-int chown(const char *path, uid_t owner, gid_t group);
-
-int setpgid(pid_t pid, pid_t pgid);
-pid_t tcgetpgrp(int fd);
-int tcsetpgrp(int fd, pid_t pgrp);
-pid_t getpgrp(void);
-pid_t getpid(void);
-pid_t getppid(void);
-
-int getgroups(int size, gid_t list[]);
-
-ssize_t read(int fd, void *buf, size_t count);
-ssize_t write(int fd, const void *buf, size_t count);
-int pipe(int pipefd[2]);
-int dup2(int oldfd, int newfd);
-
-/* Converts a relative path to an absolute one, simplifying it if possible.
- * If in == NULL - return the length of cwd. Doesn't include the trailing slash,
- * except for the root dir. Includes the null byte.
- * If size isn't enough to fit the path, returns the amount of bytes needed to fit
- * it, including the null byte.
- *
- * Note that some errors are only detected if *out != NULL, so you must check the return
- * value twice.
- * @return 0 on failure, length of the path otherwise */
-size_t absolutepath(char *out, const char *in, size_t size);
-
-// TODO put in an internal libc header
-void __setinitialcwd(const char *c);
-
-void intr_set(void (*fn)(void));
-void intr_default(void);