diff options
author | Marvin Borner | 2021-06-02 22:27:59 +0200 |
---|---|---|
committer | Marvin Borner | 2021-06-02 22:27:59 +0200 |
commit | 98e15f73f090c32b5197ecec0845c408d4a54608 (patch) | |
tree | 31490731c74b45e2450de56c0c4ea4abd3f3b54d /libs | |
parent | 91ba8d02037cc27c7b44f1bfd492c42ccd0af042 (diff) |
Huge scheduler rewrite and other things
Diffstat (limited to 'libs')
-rw-r--r-- | libs/libc/alloc.c | 4 | ||||
-rw-r--r-- | libs/libc/inc/assert.h | 6 | ||||
-rw-r--r-- | libs/libc/print.c | 7 | ||||
-rw-r--r-- | libs/libc/sanitize.c | 12 |
4 files changed, 20 insertions, 9 deletions
diff --git a/libs/libc/alloc.c b/libs/libc/alloc.c index 6663a0e..f02b015 100644 --- a/libs/libc/alloc.c +++ b/libs/libc/alloc.c @@ -91,9 +91,9 @@ static struct liballoc_major *allocate_new_page(u32 size) u32 st = size + MAJOR_SIZE + MINOR_SIZE; if ((st % l_page_size) == 0) - st = st / (l_page_size); + st = st / l_page_size; else - st = st / (l_page_size) + 1; + st = st / l_page_size + 1; st = MAX(st, l_page_count); diff --git a/libs/libc/inc/assert.h b/libs/libc/inc/assert.h index 6b35dd3..178a733 100644 --- a/libs/libc/inc/assert.h +++ b/libs/libc/inc/assert.h @@ -12,7 +12,8 @@ if (!(exp)) { \ printf("%s:%d: %s: Kernel assertion '%s' failed\n", __FILE__, __LINE__, \ __func__, #exp); \ - __asm__ volatile("cli\nhlt"); \ + while (1) \ + __asm__ volatile("cli\nhlt"); \ } \ } #elif defined(USER) @@ -25,4 +26,7 @@ } #endif +#define assert_not_reached() \ + panic("%s:%d: %s: Reached code that should not be reached\n", __FILE__, __LINE__, __func__) + #endif diff --git a/libs/libc/print.c b/libs/libc/print.c index 264f893..7c40a8b 100644 --- a/libs/libc/print.c +++ b/libs/libc/print.c @@ -194,9 +194,10 @@ int printf(const char *format, ...) int print_prefix(void) { - serial_print(CYN "[LOG] to "); - serial_print(proc_current()->name); - serial_print(": "); + char buf[64] = { 0 }; + snprintf(buf, sizeof(buf), CYN "[LOG] to %s (%d): ", proc_current()->name, + proc_current()->pid); + serial_print(buf); return 1; } diff --git a/libs/libc/sanitize.c b/libs/libc/sanitize.c index 00c9032..ee3c154 100644 --- a/libs/libc/sanitize.c +++ b/libs/libc/sanitize.c @@ -56,6 +56,10 @@ struct overflow { struct type_descriptor *type; }; +struct pointer_overflow { + struct source_location location; +}; + struct out_of_bounds { struct source_location location; struct type_descriptor *left_type; @@ -224,8 +228,10 @@ void __ubsan_handle_invalid_builtin(void) panic("UBSAN: invalid-builtin\n"); } -void __ubsan_handle_pointer_overflow(void); -void __ubsan_handle_pointer_overflow(void) +void __ubsan_handle_pointer_overflow(struct pointer_overflow *data, void *value); +void __ubsan_handle_pointer_overflow(struct pointer_overflow *data, void *value) { - panic("UBSAN: pointer-overflow\n"); + UNUSED(value); + struct source_location *loc = &data->location; + panic("%s:%d: UBSAN: pointer-overflow\n", loc->file, loc->line); } |