From f31f7960bd260cb90ffdd766393d51bd85a547d1 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 14 Jul 2017 15:13:02 +0200 Subject: removed stddef.h and limits.h (come with the compiler header files) added a stub stdint.h (only sometimes comes with the compiler) added a guide on cross compiling adapted to cross compilation, for now tcc works --- src/README | 4 ---- src/drivers/video/vga.h | 2 +- src/gui/composite_widget.c | 2 +- src/gui/desktop.c | 2 +- src/gui/text_widget.c | 2 +- src/gui/widget.c | 2 +- src/gui/window.c | 2 +- src/hardware/interrupts.h | 2 +- src/hardware/port.h | 2 +- src/kernel/console.c | 2 +- src/kernel/kernel.c | 2 +- src/kernel/memorymanagement.h | 3 ++- src/kernel/tasks.h | 2 +- src/libc/limits.h | 7 ------- src/libc/setjmp.h | 2 +- src/libc/stddef.h | 10 ---------- src/libc/stdint.h | 15 +++++++++++++++ src/libc/stdio.c | 2 +- src/libc/stdio.h | 2 +- src/libc/stdlib.c | 2 +- src/libc/stdlib.h | 2 +- src/libc/string.h | 2 +- 22 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 src/libc/limits.h delete mode 100644 src/libc/stddef.h create mode 100644 src/libc/stdint.h (limited to 'src') diff --git a/src/README b/src/README index 7b1b51c..a1c75e4 100644 --- a/src/README +++ b/src/README @@ -65,10 +65,6 @@ libc Stub C library implementation. -C library definitions -* stddef.h - definition of NULL, size_t -* limits.h - domain range constants like INT_MAX - C library routines * string.c - string, memory functions * stdlib.c - UNIX standard library functions diff --git a/src/drivers/video/vga.h b/src/drivers/video/vga.h index 0947856..9a637a2 100644 --- a/src/drivers/video/vga.h +++ b/src/drivers/video/vga.h @@ -4,7 +4,7 @@ #include #include "string.h" -#include "stddef.h" +#include #include "interrupts.h" #include "port.h" diff --git a/src/gui/composite_widget.c b/src/gui/composite_widget.c index 743360f..07056c0 100644 --- a/src/gui/composite_widget.c +++ b/src/gui/composite_widget.c @@ -1,7 +1,7 @@ #include "composite_widget.h" #include "string.h" -#include "stddef.h" +#include static composite_widget_vtable_t const composite_widget_vtable = { { diff --git a/src/gui/desktop.c b/src/gui/desktop.c index 98fb900..9851b78 100644 --- a/src/gui/desktop.c +++ b/src/gui/desktop.c @@ -1,7 +1,7 @@ #include "desktop.h" #include "string.h" -#include "stddef.h" +#include static desktop_vtable_t const desktop_vtable = { { diff --git a/src/gui/text_widget.c b/src/gui/text_widget.c index 49c1be7..5e468c7 100644 --- a/src/gui/text_widget.c +++ b/src/gui/text_widget.c @@ -1,7 +1,7 @@ #include "text_widget.h" #include "string.h" -#include "stddef.h" +#include static text_widget_vtable_t const text_widget_vtable = { { diff --git a/src/gui/widget.c b/src/gui/widget.c index 3620761..58b03ef 100644 --- a/src/gui/widget.c +++ b/src/gui/widget.c @@ -1,7 +1,7 @@ #include "widget.h" #include "string.h" -#include "stddef.h" +#include static widget_vtable_t const widget_vtable = { widget_draw, diff --git a/src/gui/window.c b/src/gui/window.c index 80c0b6c..fd53920 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -1,7 +1,7 @@ #include "window.h" #include "string.h" -#include "stddef.h" +#include static window_vtable_t const window_vtable = { { diff --git a/src/hardware/interrupts.h b/src/hardware/interrupts.h index c325d4f..64040cb 100644 --- a/src/hardware/interrupts.h +++ b/src/hardware/interrupts.h @@ -1,7 +1,7 @@ #ifndef INTERRUPTS_H #define INTERRUPTS_H -#include +#include "stdint.h" #include "port.h" #include "tasks.h" diff --git a/src/hardware/port.h b/src/hardware/port.h index ec96d09..8203fea 100644 --- a/src/hardware/port.h +++ b/src/hardware/port.h @@ -1,7 +1,7 @@ #ifndef PORT_H #define PORT_H -#include +#include "stdint.h" typedef struct { uint16_t number; // port number, e.g. 0x3d4 VGA index register diff --git a/src/kernel/console.c b/src/kernel/console.c index 8caefc8..04fb44f 100644 --- a/src/kernel/console.c +++ b/src/kernel/console.c @@ -1,7 +1,7 @@ #include "console.h" #include "string.h" -#include "stddef.h" +#include void console_init( console_t *console ) { diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 3be8758..a472cde 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -1,5 +1,5 @@ #include -#include +#include "stdint.h" #include #include "vgatext.h" diff --git a/src/kernel/memorymanagement.h b/src/kernel/memorymanagement.h index 647c05d..299fa4c 100644 --- a/src/kernel/memorymanagement.h +++ b/src/kernel/memorymanagement.h @@ -1,7 +1,8 @@ #ifndef MEMORYMANAGEMENT_H #define MEMORYMANAGEMENT_H -#include "stddef.h" +#include +#include "stdint.h" typedef struct { size_t offset; diff --git a/src/kernel/tasks.h b/src/kernel/tasks.h index dddf9bb..b982d13 100644 --- a/src/kernel/tasks.h +++ b/src/kernel/tasks.h @@ -1,7 +1,7 @@ #ifndef TASKS_H #define TASKS_H -#include +#include "stdint.h" #define TASK_STACK_SIZE 4096 diff --git a/src/libc/limits.h b/src/libc/limits.h deleted file mode 100644 index 1fc4e37..0000000 --- a/src/libc/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef LIMITS_H -#define LIMITS_H - -#define INT_MAX 2147483647 -#define INT_MIN -2147483648 - -#endif // LIMITS_H diff --git a/src/libc/setjmp.h b/src/libc/setjmp.h index 5f987f1..4322124 100644 --- a/src/libc/setjmp.h +++ b/src/libc/setjmp.h @@ -1,7 +1,7 @@ #ifndef SETJMP_H #define SETJMP_H -#include +#include "stdint.h" // C99 states this should be an array so we can address it without // the & operator, see prototypes of setjmp and longjmp diff --git a/src/libc/stddef.h b/src/libc/stddef.h deleted file mode 100644 index 4333661..0000000 --- a/src/libc/stddef.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef STDDEF_H -#define STDDEF_H - -#include - -#define NULL ( (void *)0 ) - -typedef uint32_t size_t; - -#endif /* STDDEF_H */ diff --git a/src/libc/stdint.h b/src/libc/stdint.h new file mode 100644 index 0000000..e0f35b6 --- /dev/null +++ b/src/libc/stdint.h @@ -0,0 +1,15 @@ +#ifndef STDINT_H +#define STDINT_H + +#if defined( __PCC__ ) || defined( __TINYC__ ) +// TODO: no stdint.h in pcc-libs/pcc or tcc, mock one, but this one is +// most likely very incorrect +typedef unsigned int uint32_t; +typedef signed int int32_t; +typedef unsigned short uint16_t; +typedef signed short int16_t; +typedef unsigned char uint8_t; +typedef signed char int8_t; +#endif + +#endif // STDINT_H diff --git a/src/libc/stdio.c b/src/libc/stdio.c index 631cfbb..87b70ef 100644 --- a/src/libc/stdio.c +++ b/src/libc/stdio.c @@ -1,5 +1,5 @@ #include "stdio.h" -#include "stddef.h" +#include #include "stdlib.h" #include "string.h" diff --git a/src/libc/stdio.h b/src/libc/stdio.h index 33d7946..58c80b1 100644 --- a/src/libc/stdio.h +++ b/src/libc/stdio.h @@ -3,7 +3,7 @@ #include -#include "stddef.h" +#include #ifdef OS_ABAOS #include "console.h" diff --git a/src/libc/stdlib.c b/src/libc/stdlib.c index 07eabd4..4fea56e 100644 --- a/src/libc/stdlib.c +++ b/src/libc/stdlib.c @@ -1,7 +1,7 @@ #include #include "string.h" #include "stdlib.h" -#include "stddef.h" +#include #include "kernel.h" diff --git a/src/libc/stdlib.h b/src/libc/stdlib.h index 5b2521f..f7cfc8c 100644 --- a/src/libc/stdlib.h +++ b/src/libc/stdlib.h @@ -1,7 +1,7 @@ #ifndef STDLIB_H #define STDLIB_H -#include "stddef.h" +#include #include "memorymanagement.h" diff --git a/src/libc/string.h b/src/libc/string.h index 6c0fa01..f078d48 100644 --- a/src/libc/string.h +++ b/src/libc/string.h @@ -1,7 +1,7 @@ #ifndef STRING_H #define STRING_H -#include "stddef.h" +#include void *memset( void *s, int c, size_t n ); void *memmove( void *d, const void *s, size_t n ); -- cgit v1.2.3-54-g00ecf