Commit 9653c63b by Marcus Winter

Merge branch 'development' into embb517_mutex_based_atomics

parents 4c569201 418d0143
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause
language: cpp
......
Embedded Multicore Building Blocks (EMB²)
Embedded Multicore Building Blocks (EMB²)
=========================================
Version 0.3.2
-------------
### Features:
- Added central spinlock implementation for C/C++ and removed existing (decentral) ones
### Changes and improvements:
- Reworked and optimized hazard pointer implementation
- Adjusted interfaces of value pool and object pool
- Replaced C style casts
### Bug fixes:
- Fixed ordering of destruction and deallocation in value pool
- Fixed potential use of uninitialized memory in WaitFreeArrayValuePool and LockFreeTreeValuePool
### Build system:
- Given user the ability to append compiler flags
- Let Cmake return an error on Doxygen warnings when WARNINGS_ARE_ERRORS is enabled
- Fixed cpplint warnings
### Documentation:
- Added mutex concept
- Corrected library ordering/names in README (section "Using the Library")
- Improved exception messages
- Fixed typos in condition_var_test.cc
Version 0.3.1
-------------
......
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......@@ -40,13 +40,30 @@ function (CreateDoxygenDocumentationTarget)
if (TARGET doxygen)
# Do nothing, since the repeated adding causes an error
else()
add_custom_target (
doxygen
#ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
# IF you do NOT want the documentation to be generated EVERY time you build the project
# then leave out the 'ALL' keyword from the above command.
FILE(WRITE ${CMAKE_BINARY_DIR}/doxygen_makefile.cmake "
MESSAGE(STATUS \"Running Doxygen\")
EXECUTE_PROCESS(
COMMAND \${EXE} \${IN}
ERROR_VARIABLE DOXYGEN_OUT_ERR
RESULT_VARIABLE DOXYGEN_OUT_RESULT)
STRING(LENGTH \"\${DOXYGEN_OUT_ERR}\" LENGTH_ERR)
IF ( NOT \${LENGTH_ERR} STREQUAL \"0\" )
MESSAGE (WARNING \"Doxygen produced following warnings and or/errors: \${DOXYGEN_OUT_ERR}\")
IF ( \${WARNINGS_ARE_ERRORS} STREQUAL ON OR NOT \${DOXYGEN_OUT_RESULT} STREQUAL \"0\" )
MESSAGE (FATAL_ERROR \"Exiting doxygen generation due to errors (or warnings, if WARNINGS_ARE_ERRORS is enabled)\")
ENDIF ()
ENDIF ()
")
add_custom_target(doxygen)
add_custom_command(
TARGET doxygen
COMMAND ${CMAKE_COMMAND}
-DEXE=${DOXYGEN_EXECUTABLE}
-DIN=${PROJECT_BINARY_DIR}/Doxyfile
-DWARNINGS_ARE_ERRORS=${WARNINGS_ARE_ERRORS}
-P ${CMAKE_BINARY_DIR}/doxygen_makefile.cmake)
endif()
endif()
endfunction()
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......@@ -90,10 +90,19 @@ function(SetVisualStudioCompilerFlags)
# Locally suppressed warnings (should not be globally suppressed):
# 4640 -> Information that local static variable initialization is not
# thread-safe.
#
# VS 2015 specific warnings:
# 5026 -> Move constructor was implicitly defined as deleted
# 5027 -> Move assignment operator was implicitly defined as deleted
#
set(warning_flags "/Wall /wd4820 /wd4514 /wd4668 /wd4710 /wd4350 /wd4571 /wd4625 /wd4626 /wd4711 /wd4255")
if (WARNINGS_ARE_ERRORS STREQUAL ON)
if (WARNINGS_ARE_ERRORS STREQUAL ON)
set(warning_flags "${warning_flags} /WX")
endif()
endif()
string(FIND "${CMAKE_GENERATOR}" "Visual Studio 14 2015" vs2015_state)
if (vs2015_state EQUAL 0)
set(warning_flags "${warning_flags} /wd5026 /wd5027")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${warning_flags}" PARENT_SCOPE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${warning_flags}" PARENT_SCOPE)
endif()
......
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......
# Copyright (c) 2014-2015, Siemens AG. All rights reserved.
# Copyright (c) 2014-2016, Siemens AG. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
......@@ -28,7 +28,7 @@ cmake_minimum_required (VERSION 2.8.9)
# Version number
set (EMBB_BASE_VERSION_MAJOR 0)
set (EMBB_BASE_VERSION_MINOR 3)
set (EMBB_BASE_VERSION_PATCH 1)
set (EMBB_BASE_VERSION_PATCH 2)
# Fix compilation for CMake versions >= 3.1
#
......@@ -53,13 +53,9 @@ if(POLICY CMP0053)
cmake_policy(SET CMP0053 OLD)
endif(POLICY CMP0053)
include(CMakeCommon/FindOpenCL.cmake)
IF(NOT OpenCL_FOUND)
MESSAGE( STATUS "OpenCL is not there, will build without MTAPI OpenCL Plugin." )
ENDIF()
# give the user the possibility, to append compiler flags
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CMAKE_CXX_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CMAKE_C_FLAGS}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
......@@ -86,6 +82,7 @@ option(USE_EXCEPTIONS "Specify whether exceptions should be activated in C++" ON
option(INSTALL_DOCS "Specify whether Doxygen docs should be installed" ON)
option(WARNINGS_ARE_ERRORS "Specify whether warnings should be treated as errors" OFF)
option(USE_AUTOMATIC_INITIALIZATION "Specify whether the MTAPI C++ interface, algorithms and dataflow should automatically intialize the MTAPI node if no explicit initialization is present" ON)
option(BUILD_OPENCL_PLUGIN "Specify whether the MTAPI OpenCL plugin should be built" OFF)
## LOCAL INSTALLATION OF SUBPROJECT BINARIES
#
......@@ -144,7 +141,7 @@ set(EXPECTED_EMBB_TEST_EXECUTABLES "embb_algorithms_cpp_test"
)
# if opencl is there, we also expect the mtapi opencl test to be generated
if(OpenCL_FOUND)
if(BUILD_OPENCL_PLUGIN STREQUAL ON)
list(APPEND EXPECTED_EMBB_TEST_EXECUTABLES "embb_mtapi_opencl_c_test")
endif()
......@@ -179,9 +176,9 @@ CheckPartestInstall(${BUILD_TESTS} partest_includepath partest_libpath)
add_subdirectory(base_c)
add_subdirectory(base_cpp)
add_subdirectory(mtapi_c)
add_subdirectory(mtapi_network_c)
if(OpenCL_FOUND)
add_subdirectory(mtapi_opencl_c)
add_subdirectory(mtapi_plugins_c/mtapi_network_c)
if(BUILD_OPENCL_PLUGIN STREQUAL ON)
add_subdirectory(mtapi_plugins_c/mtapi_opencl_c)
endif()
add_subdirectory(tasks_cpp)
add_subdirectory(mtapi_cpp)
......
Embedded Multicore Building Blocks (EMB²)
Embedded Multicore Building Blocks (EMB²)
=========================================
Overview
......@@ -13,7 +13,7 @@ license (see file include\embb\mtapi\c\mtapi.h).
License
-------
Copyright (c) 2014-2015, Siemens AG. All rights reserved.
Copyright (c) 2014-2016, Siemens AG. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
......
......@@ -98,7 +98,8 @@ postfixed with either "_cpp" or "_c" for the C++ and C versions, respectively.
Currently, EMB² contains the following components:
- base: base_c, base_cpp
- mtapi: mtapi_c, mtapi_network_c, mtapi_opencl_c, mtapi_cpp
- mtapi: mtapi_c, mtapi_cpp and
mtapi_plugins_c (mtapi_network_c and mtapi_opencl_c)
- tasks: tasks_cpp
- algorithms: algorithms_cpp
- dataflow: dataflow_cpp
......@@ -270,8 +271,8 @@ If you want to use the C++ functionalities of EMB², you have to link the
following libraries (names will be different on Windows and on Linux) in the
given order:
embb_base, embb_base_cpp, embb_mtapi_c, embb_mtapi_cpp, embb_containers_cpp,
embb_algorithms_cpp, embb_dataflow_cpp
embb_dataflow_cpp, embb_algorithms_cpp, embb_containers_cpp,
embb_mtapi_cpp, embb_mtapi_c, embb_base_cpp, embb_base_c
The C++ header files can be included as follows:
......@@ -284,7 +285,7 @@ The C++ header files can be included as follows:
The following libraries have to be linked in the given order:
embb_base_c, mtapi_c
embb_mtapi_c, embb_base_c
The C header files can be included as follows:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......@@ -39,7 +39,7 @@
EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX) \
typedef struct \
{ \
EMBB_ATOMIC_PARAMETER_TYPE_NATIVE internal_variable; \
volatile EMBB_ATOMIC_PARAMETER_TYPE_NATIVE internal_variable; \
} EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX);
EMBB_ATOMIC_INTERNAL_DEFINE_VARIABLE(char, char)
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......@@ -28,6 +28,7 @@
#define EMBB_BASE_C_LOG_H_
#include <embb/base/c/internal/config.h>
#include <stdarg.h>
/**
* \defgroup C_LOG Logging
......@@ -197,6 +198,13 @@ void embb_log_error(
\c message */
);
/* function for internal use only */
void embb_log_write_internal(
char const * channel,
embb_log_level_t log_level,
char const * message,
va_list argp);
#ifdef __cplusplus
}
#endif
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......@@ -46,12 +46,25 @@ extern "C" {
#include <embb/base/c/internal/platform.h>
#include <embb/base/c/errors.h>
#include <embb/base/c/atomic.h>
#ifdef DOXYGEN
/**
* Opaque type representing a mutex.
*/
typedef opaque_type embb_mutex_t;
/**
* Opaque type representing a spinlock.
*/
typedef opaque_type embb_spinlock_t;
#else
/**
* Spinlock type, treat as opaque.
*/
typedef struct {
embb_atomic_int atomic_spin_variable_;
} embb_spinlock_t;
#endif /* DOXYGEN */
/**
......@@ -147,6 +160,89 @@ void embb_mutex_destroy(
/**< [IN/OUT] Pointer to mutex */
);
/**
* Initializes a spinlock
*
* \pre \c spinlock is uninitialized
* \post \c spinlock is initialized
* \return EMBB_SUCCESS if spinlock could be initialized \n
* EMBB_ERROR otherwise
* \memory (Potentially) allocates dynamic memory
* \notthreadsafe
* \see embb_spinlock_destroy()
*/
int embb_spin_init(
embb_spinlock_t* spinlock
/**< [OUT] Pointer to spinlock */
);
/**
* Spins until the spinlock can be locked and locks it.
*
* \note This method yields the current thread in regular,
* implementation-defined intervals.
*
* \pre \c spinlock is initialized \n
* \post If successful, \c spinlock is locked.
* \return EMBB_SUCCESS if spinlock could be locked. \n
* EMBB_ERROR if an error occurred.
* \threadsafe
* \see embb_spinlock_try_lock(), embb_mutex_unlock()
*/
int embb_spin_lock(
embb_spinlock_t* spinlock
/**< [IN/OUT] Pointer to spinlock */
);
/**
* Tries to lock the spinlock and returns if not successful.
*
* \pre \c spinlock is initialized
* \post If successful, \c spinlock is locked
*
* \return EMBB_SUCCESS if spinlock could be locked \n
* EMBB_BUSY if spinlock could not be locked \n
* EMBB_ERROR if an error occurred
* \threadsafe
* \see embb_spin_lock(), embb_spin_unlock()
*/
int embb_spin_try_lock(
embb_spinlock_t* spinlock,
/**< [IN/OUT] Pointer to spinlock */
unsigned int max_number_spins
/**< [IN] Maximal count of spins to perform, trying to acquire lock. Note that
* passing 0 here results in not trying to obtain the lock at all.
*/
);
/**
* Unlocks a locked spinlock.
*
* \pre \c spinlock has been locked by the current thread.
* \post If successful, \c spinlock is unlocked.
* \return EMBB_SUCCESS if the operation was successful \n
* EMBB_ERROR otherwise
* \threadsafe
* \see embb_spin_lock(), embb_spin_try_lock()
*/
int embb_spin_unlock(
embb_spinlock_t* spinlock
/**< [IN/OUT] Pointer to spinlock */
);
/**
* Destroys a spinlock and frees its resources.
*
* \pre \c spinlock has been initialized
* \post \c spinlock is uninitialized
* \notthreadsafe
* \see embb_spin_init()
*/
void embb_spin_destroy(
embb_spinlock_t* spinlock
/**< [IN/OUT] Pointer to spinlock */
);
#ifdef __cplusplus
} /* Close extern "C" { */
#endif
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......@@ -128,6 +128,20 @@ void embb_internal_thread_index_set_max(unsigned int max) {
*embb_max_number_thread_indices() = max;
}
/**
* \pre the calling thread is the only active thread
*
* \post the thread indices count and calling thread index is reset
*/
void embb_internal_thread_index_reset() {
/** This function is only called in tests, usually when all other threads
* except the main thread have terminated. However, the main thread still has
* potentially stored its old index value in its thread local storage,
* which might be assigned additionally to another thread (as the counter is
* reset), which may lead to hard to detect bugs. Therefore, reset the thread
* local thread id here.
*/
embb_internal_thread_index_var = UINT_MAX;
embb_counter_init(embb_thread_index_counter());
}
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......@@ -59,7 +59,7 @@ void embb_log_set_log_function(
embb_log_global_log_function = func;
}
static void embb_log_write_internal(
void embb_log_write_internal(
char const * channel,
embb_log_level_t log_level,
char const * message,
......@@ -75,18 +75,20 @@ static void embb_log_write_internal(
log_context = (void*)stdout;
}
switch (log_level) {
case EMBB_LOG_LEVEL_INFO:
log_level_str = "INFO ";
break;
case EMBB_LOG_LEVEL_ERROR:
log_level_str = "ERROR";
break;
case EMBB_LOG_LEVEL_WARNING:
log_level_str = "WARN ";
break;
case EMBB_LOG_LEVEL_INFO:
log_level_str = "INFO ";
break;
case EMBB_LOG_LEVEL_TRACE:
log_level_str = "TRACE";
break;
case EMBB_LOG_LEVEL_NONE:
case EMBB_LOG_LEVEL_WARNING:
default:
log_level_str = " ";
break;
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......@@ -25,6 +25,7 @@
*/
#include <embb/base/c/mutex.h>
#include <embb/base/c/thread.h>
#include <assert.h>
#include <embb/base/c/internal/unused.h>
......@@ -115,3 +116,59 @@ void embb_mutex_destroy(embb_mutex_t* mutex) {
}
#endif /* EMBB_PLATFORM_THREADING_POSIXTHREADS */
int embb_spin_init(embb_spinlock_t* spinlock) {
// For now, store the initial value. In the future will use atomic init
// function (as soon as available).
embb_atomic_store_int(&spinlock->atomic_spin_variable_, 0);
return EMBB_SUCCESS;
}
int embb_spin_lock(embb_spinlock_t* spinlock) {
int expected = 0;
int spins = 1;
// try to swap the
while (0 == embb_atomic_compare_and_swap_int(
&spinlock->atomic_spin_variable_, &expected, 1)) {
if (0 == (spins & 1023)) {
embb_thread_yield();
}
spins++;
// reset expected, as CAS might change it...
expected = 0;
}
return EMBB_SUCCESS;
}
int embb_spin_try_lock(embb_spinlock_t* spinlock,
unsigned int max_number_spins) {
if (max_number_spins == 0)
return EMBB_BUSY;
int expected = 0;
while (0 == embb_atomic_compare_and_swap_int(
&spinlock->atomic_spin_variable_,
&expected, 1)) {
max_number_spins--;
if (0 == max_number_spins) {
return EMBB_BUSY;
}
expected = 0;
}
return EMBB_SUCCESS;
}
int embb_spin_unlock(embb_spinlock_t* spinlock) {
int expected = 1;
return embb_atomic_compare_and_swap_int(&spinlock->atomic_spin_variable_,
&expected, 0) ?
EMBB_SUCCESS : EMBB_ERROR;
}
void embb_spin_destroy(embb_spinlock_t* spinlock) {
// for now, doing nothing here... in future, will call the respective
// destroy function for atomics...
EMBB_UNUSED(spinlock);
}
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
/*
* Copyright (c) 2014-2015, Siemens AG. All rights reserved.
* Copyright (c) 2014-2016, Siemens AG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
......
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 sign in to comment