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

[fix] Move sys-dependent locking into port

parent 243ae119
......@@ -2,6 +2,7 @@ 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)
option(WITH_PORTS "Enable the build of the ports" ON)
project(
......@@ -22,7 +23,7 @@ find_package(
)
find_package(
freertos-headers 10.0.0
toki-syslog-sys 0.1
REQUIRED
)
......@@ -38,12 +39,18 @@ target_link_libraries(
toki-syslog
PUBLIC toki-syslog-headers
PRIVATE toki-libc-repl
PRIVATE freertos-headers
PRIVATE toki-syslog-sys
)
add_subdirectory(src)
if (WITH_PORTS)
message(STATUS "Building toki-libc-repl with\n\tsystem port = ${TOKI_OS}")
add_subdirectory(ports)
endif()
if (WITH_HEADERS)
add_subdirectory(include)
endif()
......
#ifndef TOKI_SYSLOG_LOCK_H
#define TOKI_SYSLOG_LOCK_H
void lock();
void unlock();
#endif //TOKI_SYSLOG_LOCK_H
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
add_subdirectory(sys)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
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)
project(
toki-syslog-sys
#
VERSION 0.1
LANGUAGES C ASM
)
add_library(
toki-syslog-sys
#
STATIC
"" # The sources are added in the respective sub-folders
)
add_subdirectory(src)
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)
target_sources(
toki-syslog-sys
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/lock.c"
)
#include "toki/syslog/lock.h"
void lock() {
// TODO implement locking if concurrent accesses to syslog routine happen
}
void unlock() {
// TODO implement locking if concurrent accesses to syslog routine happen
}
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-syslog-sys-targets.cmake)
check_required_components(toki-syslog-sys)
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
option(ENABLE_INSTALL "Enable target installation possibility" ON)
project(
toki-syslog-sys
#
VERSION 0.1
LANGUAGES C ASM
)
find_package(
freertos-headers 10.0.0
REQUIRED
)
add_library(
toki-syslog-sys
#
STATIC
""
)
target_link_libraries(
toki-syslog-sys
PRIVATE freertos-headers
)
add_subdirectory(src)
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)
target_sources(
toki-syslog-sys
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/lock.c"
)
#include "toki/syslog/lock.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
extern volatile uint64_t ullPortInterruptNesting;
UBaseType_t was_masked_before;
void lock() {
if (ullPortInterruptNesting > 0) {
was_masked_before = taskENTER_CRITICAL_FROM_ISR();
} else {
taskENTER_CRITICAL();
}
}
void unlock() {
if (ullPortInterruptNesting > 0) {
taskEXIT_CRITICAL_FROM_ISR(was_masked_before);
} else {
taskEXIT_CRITICAL();
}
}
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(freertos-headers)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-syslog-sys-targets.cmake)
check_required_components(toki-syslog-sys)
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
extern volatile uint64_t ullPortInterruptNesting;
#include "toki/syslog/lock.h"
void toki_log(const char* severity, const char* facility, const char* format, ...) {
// TODO print time information - We are currently still missing the syscall for this feature
......@@ -15,12 +12,7 @@ void toki_log(const char* severity, const char* facility, const char* format, ..
* printf(%ld.%06ld\t", (long int) tval.tv_sec, (long int)tval.tv_usec);
*/
UBaseType_t was_masked_before;
if (ullPortInterruptNesting > 0) {
was_masked_before = taskENTER_CRITICAL_FROM_ISR();
} else {
taskENTER_CRITICAL();
}
lock();
// Print the facility and severity
printf("%s\t %s ", facility, severity);
......@@ -46,9 +38,5 @@ void toki_log(const char* severity, const char* facility, const char* format, ..
va_end(va);
if (ullPortInterruptNesting > 0) {
taskEXIT_CRITICAL_FROM_ISR(was_masked_before);
} else {
taskEXIT_CRITICAL();
}
unlock();
}
......@@ -4,7 +4,7 @@ include(CMakeFindDependencyMacro)
find_dependency(toki-syslog-headers)
find_dependency(toki-libc-repl)
find_dependency(freertos-headers)
find_dependency(toki-syslog-sys)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-syslog-targets.cmake)
......
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