From fca80df9e638a7d68147d91cbffda95aed96ab5c Mon Sep 17 00:00:00 2001
From: dzwdz
Date: Thu, 23 Feb 2023 20:07:59 +0100
Subject: build: don't -Isrc/ in user code

---
 src/user/lib/_start2.c            |  2 +-
 src/user/lib/draw/draw.c          |  2 +-
 src/user/lib/draw/draw.h          | 24 ------------------------
 src/user/lib/draw/flush.c         |  2 +-
 src/user/lib/elfload.c            |  4 ++--
 src/user/lib/elfload.h            | 14 --------------
 src/user/lib/elfreloc.c           |  2 +-
 src/user/lib/esemaphore.c         |  2 +-
 src/user/lib/esemaphore.h         | 12 ------------
 src/user/lib/include/bits/panic.h |  5 +++++
 src/user/lib/include/draw.h       | 24 ++++++++++++++++++++++++
 src/user/lib/include/elfload.h    | 14 ++++++++++++++
 src/user/lib/include/esemaphore.h | 12 ++++++++++++
 src/user/lib/include/getopt.h     |  1 +
 src/user/lib/include/malloc.h     |  1 +
 src/user/lib/include/setjmp.h     |  2 +-
 src/user/lib/include/stdlib.h     |  2 +-
 src/user/lib/include/thread.h     |  9 +++++++++
 src/user/lib/include/unistd.h     |  2 +-
 src/user/lib/math.c               |  2 +-
 src/user/lib/panic.h              |  5 -----
 src/user/lib/stdio/file.c         |  2 +-
 src/user/lib/stdlib.c             |  2 +-
 src/user/lib/string/string.c      |  2 +-
 src/user/lib/thread.h             |  9 ---------
 src/user/lib/unistd.c             |  2 +-
 26 files changed, 81 insertions(+), 79 deletions(-)
 delete mode 100644 src/user/lib/draw/draw.h
 delete mode 100644 src/user/lib/elfload.h
 delete mode 100644 src/user/lib/esemaphore.h
 create mode 100644 src/user/lib/include/bits/panic.h
 create mode 100644 src/user/lib/include/draw.h
 create mode 100644 src/user/lib/include/elfload.h
 create mode 100644 src/user/lib/include/esemaphore.h
 create mode 120000 src/user/lib/include/getopt.h
 create mode 120000 src/user/lib/include/malloc.h
 create mode 100644 src/user/lib/include/thread.h
 delete mode 100644 src/user/lib/panic.h
 delete mode 100644 src/user/lib/thread.h

(limited to 'src/user/lib')

diff --git a/src/user/lib/_start2.c b/src/user/lib/_start2.c
index 648c0c6..954fcb4 100644
--- a/src/user/lib/_start2.c
+++ b/src/user/lib/_start2.c
@@ -5,7 +5,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <user/lib/elfload.h>
+#include <elfload.h>
 
 int main(int argc, char **argv, char **envp);
 
diff --git a/src/user/lib/draw/draw.c b/src/user/lib/draw/draw.c
index 3fb6a99..1c2a371 100644
--- a/src/user/lib/draw/draw.c
+++ b/src/user/lib/draw/draw.c
@@ -4,7 +4,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <user/lib/draw/draw.h>
+#include <draw.h>
 
 void dirty_reset(struct rect *d) {
 	d->x1 = ~0; d->y1 = ~0;
diff --git a/src/user/lib/draw/draw.h b/src/user/lib/draw/draw.h
deleted file mode 100644
index 5e614be..0000000
--- a/src/user/lib/draw/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/draw/flush.c b/src/user/lib/draw/flush.c
index 3b4a978..88bf3d6 100644
--- a/src/user/lib/draw/flush.c
+++ b/src/user/lib/draw/flush.c
@@ -1,6 +1,6 @@
 #include <camellia/execbuf.h>
 #include <camellia/syscalls.h>
-#include <user/lib/draw/draw.h>
+#include <draw.h>
 
 static void flush_combined(struct rect pix, struct framebuf *fb) {
 	size_t low  = fb->pitch * pix.y1 + 4 * pix.x1;
diff --git a/src/user/lib/elfload.c b/src/user/lib/elfload.c
index 3862534..7b92d35 100644
--- a/src/user/lib/elfload.c
+++ b/src/user/lib/elfload.c
@@ -6,8 +6,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <user/lib/elf.h>
-#include <user/lib/elfload.h>
+#include "elf.h"
+#include <elfload.h>
 
 void elf_execf(FILE *f, char **argv, char **envp) {
 	void *buf;
diff --git a/src/user/lib/elfload.h b/src/user/lib/elfload.h
deleted file mode 100644
index 825f765..0000000
--- a/src/user/lib/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/elfreloc.c b/src/user/lib/elfreloc.c
index b6e3844..cf740f5 100644
--- a/src/user/lib/elfreloc.c
+++ b/src/user/lib/elfreloc.c
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include <user/lib/elf.h>
+#include "elf.h"
 
 __attribute__((visibility("hidden")))
 extern struct Elf64_Dyn _DYNAMIC[];
diff --git a/src/user/lib/esemaphore.c b/src/user/lib/esemaphore.c
index 3a3aa7f..2707d11 100644
--- a/src/user/lib/esemaphore.c
+++ b/src/user/lib/esemaphore.c
@@ -2,7 +2,7 @@
 #include <camellia/syscalls.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <user/lib/esemaphore.h>
+#include <esemaphore.h>
 
 void esem_signal(struct evil_sem *sem) {
 	_sys_write(sem->signal, NULL, 0, 0, 0);
diff --git a/src/user/lib/esemaphore.h b/src/user/lib/esemaphore.h
deleted file mode 100644
index 9cc85e0..0000000
--- a/src/user/lib/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/bits/panic.h b/src/user/lib/include/bits/panic.h
new file mode 100644
index 0000000..91aec5f
--- /dev/null
+++ b/src/user/lib/include/bits/panic.h
@@ -0,0 +1,5 @@
+#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/draw.h b/src/user/lib/include/draw.h
new file mode 100644
index 0000000..5e614be
--- /dev/null
+++ b/src/user/lib/include/draw.h
@@ -0,0 +1,24 @@
+#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
new file mode 100644
index 0000000..825f765
--- /dev/null
+++ b/src/user/lib/include/elfload.h
@@ -0,0 +1,14 @@
+#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/esemaphore.h b/src/user/lib/include/esemaphore.h
new file mode 100644
index 0000000..9cc85e0
--- /dev/null
+++ b/src/user/lib/include/esemaphore.h
@@ -0,0 +1,12 @@
+#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/getopt.h b/src/user/lib/include/getopt.h
new file mode 120000
index 0000000..4890ceb
--- /dev/null
+++ b/src/user/lib/include/getopt.h
@@ -0,0 +1 @@
+../vendor/getopt/getopt.h
\ No newline at end of file
diff --git a/src/user/lib/include/malloc.h b/src/user/lib/include/malloc.h
new file mode 120000
index 0000000..80b9bf5
--- /dev/null
+++ b/src/user/lib/include/malloc.h
@@ -0,0 +1 @@
+../vendor/dlmalloc/malloc.h
\ No newline at end of file
diff --git a/src/user/lib/include/setjmp.h b/src/user/lib/include/setjmp.h
index 298939c..6d05d79 100644
--- a/src/user/lib/include/setjmp.h
+++ b/src/user/lib/include/setjmp.h
@@ -1,5 +1,5 @@
 #pragma once
-#include <user/lib/panic.h>
+#include <bits/panic.h>
 
 typedef uint64_t jmp_buf[8]; /* rbx, rsp, rbp, r12, r13, r14, r15, rip */
 typedef char sigjmp_buf[1];
diff --git a/src/user/lib/include/stdlib.h b/src/user/lib/include/stdlib.h
index 050ca80..4a44bf6 100644
--- a/src/user/lib/include/stdlib.h
+++ b/src/user/lib/include/stdlib.h
@@ -3,7 +3,7 @@
 #include <stdlib.h>
 
 #ifndef NO_MALLOC_H
-#include <user/lib/vendor/dlmalloc/malloc.h>
+#include <malloc.h>
 #endif
 
 #define EXIT_SUCCESS 0
diff --git a/src/user/lib/include/thread.h b/src/user/lib/include/thread.h
new file mode 100644
index 0000000..5a5ddc0
--- /dev/null
+++ b/src/user/lib/include/thread.h
@@ -0,0 +1,9 @@
+#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/unistd.h b/src/user/lib/include/unistd.h
index c55cd29..a1c18e8 100644
--- a/src/user/lib/include/unistd.h
+++ b/src/user/lib/include/unistd.h
@@ -1,6 +1,6 @@
 #pragma once
 #include <camellia/types.h> // TODO only needed because of hid_t
-#include <user/lib/vendor/getopt/getopt.h>
+#include <getopt.h>
 
 int fork(void);
 int close(hid_t h);
diff --git a/src/user/lib/math.c b/src/user/lib/math.c
index bf7c039..4f8eda4 100644
--- a/src/user/lib/math.c
+++ b/src/user/lib/math.c
@@ -1,5 +1,5 @@
 #include <math.h>
-#include <user/lib/panic.h>
+#include <bits/panic.h>
 
 // TODO port a libm
 #pragma GCC diagnostic ignored "-Wunused-parameter"
diff --git a/src/user/lib/panic.h b/src/user/lib/panic.h
deleted file mode 100644
index 91aec5f..0000000
--- a/src/user/lib/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/stdio/file.c b/src/user/lib/stdio/file.c
index 49ff861..cbacfdd 100644
--- a/src/user/lib/stdio/file.c
+++ b/src/user/lib/stdio/file.c
@@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <user/lib/panic.h>
+#include <bits/panic.h>
 
 static FILE _stdin_null  = { .fd = STDIN_FILENO };
 static FILE _stdout_null = { .fd = STDOUT_FILENO };
diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c
index 85afb25..2d1f224 100644
--- a/src/user/lib/stdlib.c
+++ b/src/user/lib/stdlib.c
@@ -3,7 +3,7 @@
 #include <camellia/syscalls.h>
 #include <errno.h>
 #include <string.h>
-#include <user/lib/panic.h>
+#include <bits/panic.h>
 
 _Noreturn void abort(void) {
 	_sys_exit(1);
diff --git a/src/user/lib/string/string.c b/src/user/lib/string/string.c
index 126d175..8fdc7c7 100644
--- a/src/user/lib/string/string.c
+++ b/src/user/lib/string/string.c
@@ -48,7 +48,7 @@ long strtol(const char *restrict s, char **restrict end, int base) {
 	return res * sign;
 }
 
-#include <user/lib/panic.h>
+#include <bits/panic.h>
 double strtod(const char *restrict s, char **restrict end) {
 	(void)s; (void)end;
 	__libc_panic("unimplemented");
diff --git a/src/user/lib/thread.h b/src/user/lib/thread.h
deleted file mode 100644
index 5a5ddc0..0000000
--- a/src/user/lib/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/unistd.c b/src/user/lib/unistd.c
index f8edd25..f81e7d8 100644
--- a/src/user/lib/unistd.c
+++ b/src/user/lib/unistd.c
@@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <user/lib/elfload.h>
+#include <elfload.h>
 
 int errno = 0;
 
-- 
cgit v1.2.3