diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-07-13 11:23:03 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-07-13 11:23:03 +0200 |
commit | ebb0e5f9fe6707133dacbe70f80831cd1aa5c974 (patch) | |
tree | 23ccd04644fcab179812a093545213dec9907943 /src/libc | |
parent | ed869aa3867d134fb37f586f1db029006677cebb (diff) | |
download | abaos-ebb0e5f9fe6707133dacbe70f80831cd1aa5c974.tar.gz abaos-ebb0e5f9fe6707133dacbe70f80831cd1aa5c974.tar.bz2 |
added a simple test for malloc/free
added a memorymanager initilializer which works on a buffer instead on an offset
(thus we can but the heap area also onto the stack for testing)
added a kernel_stub module to test modules using kernel_panic (for now, maybe
have a callback later)
Diffstat (limited to 'src/libc')
-rw-r--r-- | src/libc/stdlib.c | 17 | ||||
-rw-r--r-- | src/libc/stdlib.h | 6 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/libc/stdlib.c b/src/libc/stdlib.c index d6bb8b2..d7d4331 100644 --- a/src/libc/stdlib.c +++ b/src/libc/stdlib.c @@ -3,6 +3,8 @@ #include "stdlib.h" #include "stddef.h" +#include "kernel.h" + static void strreverse( char *s ) { char *end = s + strlen( s ) - 1; @@ -46,29 +48,28 @@ char *itoa( int v, char *s, int base ) return s; } -#ifdef OS_ABAOS +void abort( void ) +{ + // TODO: this should be done on process level, terminating + // the process (by signalling SIGABRT for instance) + kernel_panic( "aborted" ); +} + // TODO: we should have a global memory manager and one per // user process later static memory_manager_t *stdlib_memory_manager = NULL; -#endif void *malloc( size_t size ) { -#ifdef OS_ABAOS return memory_manager_allocate( stdlib_memory_manager, size ); -#endif } void free( void *p ) { -#ifdef OS_ABAOS memory_manager_deallocate( stdlib_memory_manager, &p ); -#endif } -#ifdef OS_ABAOS void __stdlib_set_memory_manager( memory_manager_t *memory_manager ) { stdlib_memory_manager = memory_manager; } -#endif diff --git a/src/libc/stdlib.h b/src/libc/stdlib.h index 9507fa3..9ff28a3 100644 --- a/src/libc/stdlib.h +++ b/src/libc/stdlib.h @@ -3,17 +3,15 @@ #include "stddef.h" -#ifdef OS_ABAOS #include "memorymanagement.h" -#endif char *itoa( int v, char *s, int base ); +void abort( void ); + void *malloc( size_t size ); void free( void *p ); -#ifdef OS_ABAOS void __stdlib_set_memory_manager( memory_manager_t *memory_manager ); -#endif #endif // STDLIB_H |