diff options
author | Marvin Borner | 2021-04-02 16:17:50 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-02 16:17:50 +0200 |
commit | b62b9d1f33a4911feb9f318ece0c1565f27abf8d (patch) | |
tree | aecea9f7b5bf651b584911cf90c61258b9564556 /libs | |
parent | d055495f3dbb62f74809d31a84621d6e86d61d0a (diff) |
Replaced target macros
Diffstat (limited to 'libs')
-rw-r--r-- | libs/libc/Makefile | 4 | ||||
-rw-r--r-- | libs/libc/alloc.c | 4 | ||||
-rw-r--r-- | libs/libc/cpu.c | 2 | ||||
-rw-r--r-- | libs/libc/errno.c | 2 | ||||
-rw-r--r-- | libs/libc/inc/assert.h | 6 | ||||
-rw-r--r-- | libs/libc/inc/cpu.h | 2 | ||||
-rw-r--r-- | libs/libc/inc/def.h | 6 | ||||
-rw-r--r-- | libs/libc/inc/errno.h | 2 | ||||
-rw-r--r-- | libs/libc/inc/mem.h | 6 | ||||
-rw-r--r-- | libs/libc/inc/print.h | 2 | ||||
-rw-r--r-- | libs/libc/inc/sys.h | 2 | ||||
-rw-r--r-- | libs/libc/mem.c | 2 | ||||
-rw-r--r-- | libs/libc/print.c | 4 | ||||
-rw-r--r-- | libs/libc/random.c | 4 | ||||
-rw-r--r-- | libs/libc/sys.c | 2 | ||||
-rw-r--r-- | libs/libgui/Makefile | 2 | ||||
-rw-r--r-- | libs/libnet/Makefile | 2 | ||||
-rw-r--r-- | libs/libtxt/Makefile | 2 |
18 files changed, 26 insertions, 30 deletions
diff --git a/libs/libc/Makefile b/libs/libc/Makefile index 1c66f43..d8d58ff 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -27,13 +27,13 @@ ASFLAGS = -f elf32 %.o: %.c @$(CC) -c $(CFLAGS) $< -o $@ -libc: CFLAGS += -Duserspace +libc: CFLAGS += -DUSER libc: $(COBJS) @$(AS) $(ASFLAGS) crt/crt0.asm -o crt0.o @mkdir -p ../../build/ @$(AR) rcs ../../build/libc.a crt0.o $+ -libk: CFLAGS += -Dkernel -ffreestanding -I../../kernel/inc/ $(CFLAGS_EXTRA) +libk: CFLAGS += -DKERNEL -ffreestanding -I../../kernel/inc/ $(CFLAGS_EXTRA) libk: $(COBJS) @mkdir -p ../../build/ @$(AR) rcs ../../build/libk.a $+ diff --git a/libs/libc/alloc.c b/libs/libc/alloc.c index 928a519..02e30eb 100644 --- a/libs/libc/alloc.c +++ b/libs/libc/alloc.c @@ -5,7 +5,7 @@ #include <cpu.h> #include <mem.h> -#ifdef kernel +#ifdef KERNEL #include <mm.h> @@ -379,7 +379,7 @@ static void *_realloc(void *ptr, u32 size) return new_ptr; } -#ifdef kernel +#ifdef KERNEL #define PREFIX "K" #define FUNC printf #else diff --git a/libs/libc/cpu.c b/libs/libc/cpu.c index 37bdb4d..7fbb66a 100644 --- a/libs/libc/cpu.c +++ b/libs/libc/cpu.c @@ -48,7 +48,7 @@ void outl(u16 port, u32 data) __asm__ volatile("outl %0, %1" ::"a"(data), "Nd"(port)); } -#ifdef kernel +#ifdef KERNEL static void cpuid(int code, u32 *a, u32 *b, u32 *c, u32 *d) { diff --git a/libs/libc/errno.c b/libs/libc/errno.c index 7204f5b..06d2b33 100644 --- a/libs/libc/errno.c +++ b/libs/libc/errno.c @@ -2,7 +2,7 @@ #include <def.h> #include <errno.h> -#ifdef userspace +#ifdef USER static u32 error = 0; diff --git a/libs/libc/inc/assert.h b/libs/libc/inc/assert.h index ed835c5..9621e36 100644 --- a/libs/libc/inc/assert.h +++ b/libs/libc/inc/assert.h @@ -5,7 +5,7 @@ #include <print.h> -#ifdef kernel +#ifdef KERNEL #include <proc.h> #define assert(exp) \ if (!(exp)) { \ @@ -13,12 +13,10 @@ #exp); \ __asm__ volatile("cli\nhlt"); \ } -#elif defined(userspace) +#elif defined(USER) #define assert(exp) \ if (!(exp)) \ err(1, "%s:%d: %s: Assertion '%s' failed\n", __FILE__, __LINE__, __func__, #exp); -#else -#error "No lib target specified. Please use -Dkernel or -Duserspace" #endif #endif diff --git a/libs/libc/inc/cpu.h b/libs/libc/inc/cpu.h index 4c6e721..0410125 100644 --- a/libs/libc/inc/cpu.h +++ b/libs/libc/inc/cpu.h @@ -22,7 +22,7 @@ static inline void spinlock(u32 *ptr) while (prev); } -#ifdef kernel +#ifdef KERNEL void cpu_print(void); void cpu_enable_features(void); void fpu_restore(void); diff --git a/libs/libc/inc/def.h b/libs/libc/inc/def.h index 2bf50b1..583a351 100644 --- a/libs/libc/inc/def.h +++ b/libs/libc/inc/def.h @@ -25,10 +25,10 @@ typedef unsigned long long u64; #define UNUSED(__a) ((void)(__a)) -#define MIN(__a, __b) (((__a) < (__b)) ? (__a) : (__b)) -#define MAX(__a, __b) (((__a) > (__b)) ? (__a) : (__b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define ABS(__a) ((u32)(((s32)(__a) < 0) ? (-__a) : (__a))) +#define ABS(a) ((u32)(((s32)(a) < 0) ? -(a) : (a))) #define ATTR __attribute__ #define NORETURN ATTR((noreturn)) diff --git a/libs/libc/inc/errno.h b/libs/libc/inc/errno.h index 133f543..787aab1 100644 --- a/libs/libc/inc/errno.h +++ b/libs/libc/inc/errno.h @@ -44,7 +44,7 @@ typedef s32 res; #define ERANGE 34 /* Math result not representable */ #define EMAX 35 /* Max errno */ -#ifdef userspace +#ifdef USER #define errno (*__errno()) extern u32 *__errno(void); diff --git a/libs/libc/inc/mem.h b/libs/libc/inc/mem.h index 2d55eff..960ee86 100644 --- a/libs/libc/inc/mem.h +++ b/libs/libc/inc/mem.h @@ -12,12 +12,10 @@ void free_debug(void *ptr, const char *file, int line, const char *func, const c void *realloc(void *ptr, u32 size); void *zalloc(u32 size); -#ifdef kernel +#ifdef KERNEL #define STACK_START 0x00500000 // Defined it bootloader #define STACK_SIZE 0x1000 // idk -#elif defined(userspace) -#else -#error "No lib target specified. Please use -Dkernel or -Duserspace" +#elif defined(USER) #endif void *memcpy(void *dest, const void *src, u32 n) NONNULL; diff --git a/libs/libc/inc/print.h b/libs/libc/inc/print.h index 751a929..c0d864e 100644 --- a/libs/libc/inc/print.h +++ b/libs/libc/inc/print.h @@ -13,7 +13,7 @@ int vsnprintf(char *str, u32 size, const char *format, va_list ap) NONNULL; int print(const char *str) NONNULL; NORETURN void panic(const char *format, ...) NONNULL; -#ifdef userspace +#ifdef USER int vfprintf(const char *path, const char *format, va_list ap) NONNULL; int fprintf(const char *path, const char *format, ...) NONNULL; int log(const char *format, ...) NONNULL; diff --git a/libs/libc/inc/sys.h b/libs/libc/inc/sys.h index 6565e10..81de724 100644 --- a/libs/libc/inc/sys.h +++ b/libs/libc/inc/sys.h @@ -59,7 +59,7 @@ struct stat { u32 size; }; -#if defined(userspace) +#ifdef USER /** * Syscall wrappers diff --git a/libs/libc/mem.c b/libs/libc/mem.c index 2e457ef..ad691ed 100644 --- a/libs/libc/mem.c +++ b/libs/libc/mem.c @@ -7,7 +7,7 @@ void *memcpy(void *dest, const void *src, u32 n) { -#ifdef userspace +#ifdef USER // Inspired by Jeko at osdev u8 *dest_byte = dest; const u8 *src_byte = src; diff --git a/libs/libc/print.c b/libs/libc/print.c index d990985..b77c165 100644 --- a/libs/libc/print.c +++ b/libs/libc/print.c @@ -96,7 +96,7 @@ int snprintf(char *str, u32 size, const char *format, ...) return len; } -#ifdef userspace +#ifdef USER #include <sys.h> #define PATH_OUT "/proc/self/io/out" @@ -247,7 +247,7 @@ NORETURN void panic(const char *format, ...) va_start(ap, format); vsnprintf(buf, sizeof(buf), format, ap); va_end(ap); -#ifdef kernel +#ifdef KERNEL print("--- DON'T PANIC! ---\n"); print(buf); print_trace(5); diff --git a/libs/libc/random.c b/libs/libc/random.c index 2801029..5cbbbb6 100644 --- a/libs/libc/random.c +++ b/libs/libc/random.c @@ -14,7 +14,7 @@ void srand(u32 seed) u32 rdrand(void) { -#ifdef kernel +#ifdef KERNEL if (!cpu_has_cfeature(CPUID_FEAT_ECX_RDRND)) return rand(); @@ -31,7 +31,7 @@ u32 rdrand(void) u32 rdseed(void) { -#ifdef kernel +#ifdef KERNEL if (!cpu_has_cfeature(CPUID_FEAT_ECX_RDRND)) return rand(); diff --git a/libs/libc/sys.c b/libs/libc/sys.c index 491c37c..15a9669 100644 --- a/libs/libc/sys.c +++ b/libs/libc/sys.c @@ -6,7 +6,7 @@ #include <errno.h> #include <sys.h> -#if defined(userspace) +#ifdef USER /** * Definitions diff --git a/libs/libgui/Makefile b/libs/libgui/Makefile index 3e2b0b2..e04b703 100644 --- a/libs/libgui/Makefile +++ b/libs/libgui/Makefile @@ -10,7 +10,7 @@ CC = ccache ../../cross/opt/bin/i686-elf-gcc LD = ccache ../../cross/opt/bin/i686-elf-ld AR = ccache ../../cross/opt/bin/i686-elf-ar -CFLAGS = $(CFLAGS_DEFAULT) -I../ -I../libc/inc/ -Duserspace +CFLAGS = $(CFLAGS_DEFAULT) -I../ -I../libc/inc/ -DUSER all: libgui diff --git a/libs/libnet/Makefile b/libs/libnet/Makefile index 85c8fab..69c899d 100644 --- a/libs/libnet/Makefile +++ b/libs/libnet/Makefile @@ -5,7 +5,7 @@ CC = ccache ../../cross/opt/bin/i686-elf-gcc LD = ccache ../../cross/opt/bin/i686-elf-ld AR = ccache ../../cross/opt/bin/i686-elf-ar -CFLAGS = $(CFLAGS_DEFAULT) -I../ -I../libc/inc/ -Duserspace +CFLAGS = $(CFLAGS_DEFAULT) -I../ -I../libc/inc/ -DUSER all: libtxt diff --git a/libs/libtxt/Makefile b/libs/libtxt/Makefile index 93a7993..6d06502 100644 --- a/libs/libtxt/Makefile +++ b/libs/libtxt/Makefile @@ -5,7 +5,7 @@ CC = ccache ../../cross/opt/bin/i686-elf-gcc LD = ccache ../../cross/opt/bin/i686-elf-ld AR = ccache ../../cross/opt/bin/i686-elf-ar -CFLAGS = $(CFLAGS_DEFAULT) -I../ -I../libc/inc/ -Duserspace +CFLAGS = $(CFLAGS_DEFAULT) -I../ -I../libc/inc/ -DUSER all: libtxt |