Implemented malloc, abort, exit

This commit is contained in:
Max Wash
2020-04-17 11:24:05 +01:00
parent bf4e733688
commit 076ace9956
8 changed files with 6317 additions and 4 deletions

View File

@@ -20,14 +20,20 @@ message(STATUS "Target: ${machine}-${platform}")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -ffreestanding -nostdlib -lgcc")
set(malloc_impl dlmalloc)
set(photon_libc_sources "")
set(generic_dirs string stdio)
set(generic_dirs string stdio internal)
message(STATUS "Memory allocator: ${malloc_impl}")
foreach (dir ${generic_dirs})
file(GLOB dir_sources ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/${dir}/*.c)
set(photon_libc_sources ${photon_libc_sources} ${dir_sources})
endforeach (dir)
file(GLOB malloc_sources
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/stdlib/${malloc_impl}/*.c
${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/stdlib/${malloc_impl}/*.h)
file(GLOB_RECURSE photon_libc_headers ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/include/*.h)
file(GLOB photon_libc_crt
@@ -48,7 +54,7 @@ file(GLOB platform_headers
${CMAKE_CURRENT_SOURCE_DIR}/photon/sys/${platform}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/photon/sys/${platform}/machine/${machine}/*.h)
set(photon_libc_sources ${photon_libc_sources} ${platform_sources})
set(photon_libc_sources ${photon_libc_sources} ${malloc_sources} ${platform_sources})
set(photon_libc_headers ${photon_libc_headers} ${platform_headers})
add_library(c SHARED ${photon_libc_sources} ${photon_libc_headers})