Commit 59e3e6ce authored by Ulrich Huber's avatar Ulrich Huber Committed by Oliver Horst
Browse files

[chg] Use FreeRTOS implementation for malloc/free if compiled with FreeRTOS

parent 27208c0f
......@@ -18,7 +18,12 @@ find_package(
)
find_package(
toki-libc-repl-port 0.1
toki-libc-repl-sys 0.1
REQUIRED
)
find_package(
toki-libc-repl-machine 0.1
REQUIRED
)
......@@ -38,7 +43,8 @@ add_library(
target_link_libraries(
toki-libc-repl
PUBLIC toki-libc-repl-headers
toki-libc-repl-port
toki-libc-repl-machine
toki-libc-repl-sys
PRIVATE sfmt
)
......@@ -46,7 +52,8 @@ target_link_libraries(
add_subdirectory(src)
if (WITH_PORTS)
message(STATUS "Building toki-libc-repl with\n\tport = ${TOKI_MACHINE}")
message(STATUS "Building toki-libc-repl with\n\tmachine port = ${TOKI_MACHINE}")
message(STATUS "Building toki-libc-repl with\n\tsystem port = ${TOKI_OS}")
add_subdirectory(ports)
endif()
......
......@@ -15,6 +15,11 @@ find_package(
REQUIRED
)
find_package(
toki-libc-repl-sys-headers 0.1
REQUIRED
)
add_library(
toki-libc-repl-headers
......@@ -22,15 +27,11 @@ add_library(
INTERFACE
)
find_package(
sfmt-headers 1.4.1
REQUIRED
)
target_link_libraries(
toki-libc-repl-headers
#
INTERFACE sfmt-headers
INTERFACE sfmt-headers
toki-libc-repl-sys-headers
)
......
......@@ -5,28 +5,12 @@
#include <stddef.h>
#include <sys/types.h>
#include <malloc.h>
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
/**
* Initialize malloc with a memory address and pool size
*/
void malloc_addblock(void *addr, size_t size);
/**
* Free-list malloc implementation
*/
#define malloc fl_malloc
void * fl_malloc(size_t size);
/**
* Corresponding free-list free implementation
*/
#define free fl_free
void fl_free(void * ptr);
/**
* Random routines from C library
*/
......
......@@ -3,6 +3,7 @@
include(CMakeFindDependencyMacro)
find_dependency(sfmt-headers)
find_dependency(toki-libc-repl-sys-headers)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-libc-repl-headers-targets.cmake)
......
add_subdirectory(${TOKI_MACHINE})
add_subdirectory(machine)
add_subdirectory(sys)
add_subdirectory(${TOKI_MACHINE})
......@@ -4,7 +4,7 @@ option(ENABLE_INSTALL "Enable target installation possibility" ON)
project(
toki-libc-repl-port
toki-libc-repl-machine
#
VERSION 0.1
LANGUAGES C ASM
......@@ -22,14 +22,14 @@ find_package(
add_library(
toki-libc-repl-port
toki-libc-repl-machine
#
STATIC
"" # The sources are added in the respective sub-folders
)
target_link_libraries(
toki-libc-repl-port
toki-libc-repl-machine
PRIVATE
toki-libc-repl-headers
xil-headers
......
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
toki-libc-repl-port
toki-libc-repl-machine
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/putchar.c"
......
......@@ -6,6 +6,6 @@ find_dependency(xil-headers 7.0)
find_dependency(toki-libc-repl-headers 0.1)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-libc-repl-port-targets.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/toki-libc-repl-machine-targets.cmake)
check_required_components(toki-libc-repl-port)
check_required_components(toki-libc-repl-machine)
string(TOLOWER ${TOKI_OS} SUB_DIR)
add_subdirectory( ${SUB_DIR} )
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
option(ENABLE_INSTALL "Enable target installation possibility" ON)
option(WITH_HEADERS "Enable the installation of header files" ON)
project(
toki-libc-repl-sys
#
VERSION 0.1
LANGUAGES C ASM
)
find_package(
toki-libc-repl-sys-headers 0.1
REQUIRED
)
add_library(
toki-libc-repl-sys
#
STATIC
"" # The sources are added in the respective sub-folders
)
target_link_libraries(
toki-libc-repl-sys
PUBLIC toki-libc-repl-sys-headers
)
add_subdirectory(src)
if (WITH_HEADERS)
add_subdirectory(include)
endif()
if (ENABLE_INSTALL)
# Configure and install the following files:
# - ${PROJECT_NAME}-config.cmake,
# - ${PROJECT_NAME}-config-version.cmake,
include(CMakePackageConfigHelpers)
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
# ${PROJECT_NAME}-config.cmake
configure_package_config_file(
${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${ConfigPackageLocation}
)
# ${PROJECT_NAME}-config-config-version.cmake
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
COMPATIBILITY SameMajorVersion
)
# Install exported CMake target files
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
)
install(
EXPORT ${PROJECT_NAME}-targets
DESTINATION ${ConfigPackageLocation}
EXPORT_LINK_INTERFACE_LIBRARIES
)
# Install package/module configuration files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${ConfigPackageLocation}
)
endif()
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
option(ENABLE_INSTALL "Enable target installation possibility" ON)
project(
toki-libc-repl-sys-headers
#
VERSION 0.1
LANGUAGES C ASM
)
add_library(
toki-libc-repl-sys-headers
#
INTERFACE
)
target_include_directories(
toki-libc-repl-sys-headers
#
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
INTERFACE $<INSTALL_INTERFACE:include>
)
if (ENABLE_INSTALL)
# Configure and install the following files:
# - ${PROJECT_NAME}-config.cmake,
# - ${PROJECT_NAME}-config-version.cmake,
include(CMakePackageConfigHelpers)
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
# ${PROJECT_NAME}-config.cmake
configure_package_config_file(
${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${ConfigPackageLocation}
)
# ${PROJECT_NAME}-config-config-version.cmake
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
COMPATIBILITY SameMajorVersion
)
# Install exported CMake target files
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
)
install(
EXPORT ${PROJECT_NAME}-targets
DESTINATION ${ConfigPackageLocation}
EXPORT_LINK_INTERFACE_LIBRARIES
)
# Install package/module configuration files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${ConfigPackageLocation}
)
# Install all header files of the current project
get_target_property(PROJECT_INCLUDE_DIRECTORIES ${PROJECT_NAME} INTERFACE_INCLUDE_DIRECTORIES)
foreach(DIR ${PROJECT_INCLUDE_DIRECTORIES})
string(REGEX MATCH "^.<BUILD_INTERFACE:(.*)>$" EXTRACTED_DIR ${DIR})
if (CMAKE_MATCH_1)
set(EXTRACTED_DIR "${CMAKE_MATCH_1}")
file(
GLOB_RECURSE
#
HEADER_FILES
#
FOLLOW_SYMLINKS
LIST_DIRECTORIES FALSE
RELATIVE "${EXTRACTED_DIR}"
#
"${EXTRACTED_DIR}/*.h"
"${EXTRACTED_DIR}/*.hpp"
)
foreach(FILE ${HEADER_FILES})
get_filename_component(INSTALL_PATH ${FILE} DIRECTORY)
install(
FILES ${EXTRACTED_DIR}/${FILE}
DESTINATION include/${INSTALL_PATH}
)
endforeach()
endif()
endforeach()
endif()
//
// Created by huber on 7/13/20.
//
#ifndef TOKI_MALLOC_H
#define TOKI_MALLOC_H
/**
* Initialize malloc with a memory address and pool size
*/
void malloc_addblock(void *addr, size_t size);
/**
* Free-list malloc implementation
*/
#define malloc fl_malloc
void * fl_malloc(size_t size);
/**
* Corresponding free-list free implementation
*/
#define free fl_free
void fl_free(void * ptr);
#endif //TOKI_MALLOC_H
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-libc-repl-sys-headers-targets.cmake)
check_required_components(toki-libc-repl-sys-headers)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
add_subdirectory(malloc)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
toki-libc-repl
toki-libc-repl-sys
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/malloc_freelist.c"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment