On ARM platforms, `__dso_handle` is used for dynamic shared objects. But it is also required if global static objects are used. To avoid that `sys/cpp11_compat` is required only for using the (re)defined `new`/`delete` operators, `__dso_handle` is moved to module `sys/cpp_new_delete`
The `new` and `delete` operators that don't need `libtsdc++` are also provided by module `sys/cpp_new_delete` for platforms that don't have the `libstdc++`. Since these operators in `sys/cpp11-compat` are just wrappers for standard `malloc`/`free` functions like in `sys/cpp_new_delete`, the `new`/`delete` operators that don't need `libstdc++` are used from `sys/cpp_new_delete`. Only the `new`/`delete` operators that require the `libstd++` are left in `sys/cpp11-compat`.
So it is sufficient for the use of the (re)defined `new`/`delete` operators that an application uses the module `sys/cpp_new_delete` instead of `sys/cpp11-compat` and thus also works on platforms without `libstdc++`.
Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:
1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
functions
- Introduced enum type `thread_state_t` to replace preprocessor macros
- Moved thread states to `sched.h` for two reasons:
a) Because of the interdependencies of `sched.h` and `thread.h` keeping it in
`thread.h` would result in ugly code.
b) Theses thread states are defined from the schedulers point of view, so it
actually makes senses to have it defined there
Fixes Clang warning/error:
In file included from .../riot/sys/cpp11-compat/thread.cpp:26:
In file included from .../riot/sys/cpp11-compat/include/riot/thread.hpp:39:
.../riot/sys/cpp11-compat/include/riot/mutex.hpp:47:45: error:
suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
inline constexpr mutex() noexcept : m_mtx{0} {}
^
{}
1 error generated.
cppsupport.cpp contains functions which are necessary in order to use
some features of the C++ language, e.g. calling static constructors or
virtual functions.
TODO/Not implemented yet:
- Test virtual functions
- Handle exceptions (stack unwinding)
- Run time type identification (RTTI)
As discussed in #2725, this commit renames a number of stacksize constants to
better convey their intended usage. In addition, constants for thread priority
are given a `THREAD_` prefix. Changes are:
* KERNEL_CONF_STACKSIZE_PRINTF renamed to THREAD_EXTRA_STACKSIZE_PRINTF
* KERNEL_CONF_STACKSIZE_DEFAULT renamed to THREAD_STACKSIZE_DEFAULT
* KERNEL_CONF_STACKSIZE_IDLE renamed to THREAD_STACKSIZE_IDLE
* KERNEL_CONF_STACKSIZE_MAIN renamed to THREAD_STACKSIZE_MAIN
* Move thread stacksizes from kernel.h to thread.h, since the prefix changed
* PRIORITY_MIN renamed to THREAD_PRIORITY_MIN
* PRIORITY_IDLE renamed to THREAD_PRIORITY_IDLE
* PRIORITY_MAIN renamed to THREAD_PRIORITY_MAIN
* Move thread priorities from kernel.h to thread.h since the prefix has changed
* MINIMUM_STACK_SIZE renamed to THREAD_STACKSIZE_MINIMUM for consistency
These headers do not provide full stl functionality,
but a small subset:
* thread and this_thread
* condition_variable (some timed functions are missing)
* mutex, lock_guard and unique_lock