From 98df498e8e8a07e33cc77a059876b940cb9b3c6a Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 19 May 2021 00:43:40 +0200 Subject: Smashed some bugs --- libs/libc/alloc.c | 2 -- libs/libc/inc/def.h | 3 +++ libs/libc/sys.c | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'libs') diff --git a/libs/libc/alloc.c b/libs/libc/alloc.c index ea01a38..6663a0e 100644 --- a/libs/libc/alloc.c +++ b/libs/libc/alloc.c @@ -50,8 +50,6 @@ static int liballoc_unlock(void) } #define ALIGNMENT 16 -#define ALIGN_UP(__addr, __align) (((__addr) + (__align)-1) & ~((__align)-1)) -#define ALIGN_DOWN(__addr, __align) ((__addr) & ~((__align)-1)) #define USE_CASE1 #define USE_CASE2 diff --git a/libs/libc/inc/def.h b/libs/libc/inc/def.h index 7338242..c9c89fd 100644 --- a/libs/libc/inc/def.h +++ b/libs/libc/inc/def.h @@ -41,6 +41,9 @@ typedef unsigned long long u64; #define __STRINGIFY(a) #a #define STRINGIFY(a) __STRINGIFY(a) +#define ALIGN_UP(addr, align) (((addr) + (align)-1) & ~((align)-1)) +#define ALIGN_DOWN(addr, align) ((addr) & ~((align)-1)) + /** * Compiler attribute wrappers */ diff --git a/libs/libc/sys.c b/libs/libc/sys.c index cf2165a..8d0a9b8 100644 --- a/libs/libc/sys.c +++ b/libs/libc/sys.c @@ -186,6 +186,9 @@ static void (*funcs[ATEXIT_MAX])(void) = { 0 }; static void atexit_trigger(void) { + if (!slot) + return; + while (slot-- > 0) { if (funcs[slot]) { funcs[slot](); -- cgit v1.2.3