aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/libc/alloc.c4
-rw-r--r--libs/libc/inc/assert.h6
-rw-r--r--libs/libc/print.c7
-rw-r--r--libs/libc/sanitize.c12
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);
}