Re: [PATCH] samples/cdtest: Test execeptions during system init
On 01/07/2022 12:02, Sebastian Huber wrote: +static void early_exception() +{ +try +{ + throw "early exception"; +} +catch( const char *e ) +{ + rtems_test_assert(strcmp(e, "early exception") == 0); + throw "early exception 2"; +} +} + +static void test_exceptions_during_system_init() +{ +TEST_BEGIN(); + +try +{ + early_exception(); +} +catch( const char *e ) +{ + rtems_test_assert(strcmp(e, "early exception 2") == 0); +} +} + +RTEMS_SYSINIT_ITEM( +test_exceptions_during_system_init, +RTEMS_SYSINIT_IDLE_THREADS, +RTEMS_SYSINIT_ORDER_LAST +); Actually, on targets which use the DWARF2 unwinder (for example sparc), this doesn't work since the exception frames are no yet registered. They are registered during global construction. This also means that C++ exceptions can only be used once the global construction completed on these targets. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[RSB 3/3] 6/7: Use TLS in Newlib
Use the --enable-newlib-reent-thread-local (_REENT_THREAD_LOCAL_STORAGE) Newlib configuration option on all targets which support thread-local storage. Update #4560. --- rtems/config/6/rtems-aarch64.bset| 1 + rtems/config/6/rtems-arm.bset| 1 + rtems/config/6/rtems-i386.bset | 1 + rtems/config/6/rtems-m68k.bset | 1 + rtems/config/6/rtems-microblaze.bset | 1 + rtems/config/6/rtems-nios2.bset | 1 + rtems/config/6/rtems-powerpc.bset| 1 + rtems/config/6/rtems-riscv.bset | 1 + rtems/config/6/rtems-sparc.bset | 1 + rtems/config/6/rtems-x86_64.bset | 1 + rtems/config/7/rtems-aarch64.bset| 1 + rtems/config/7/rtems-arm.bset| 1 + rtems/config/7/rtems-i386.bset | 1 + rtems/config/7/rtems-m68k.bset | 1 + rtems/config/7/rtems-microblaze.bset | 1 + rtems/config/7/rtems-nios2.bset | 1 + rtems/config/7/rtems-powerpc.bset| 1 + rtems/config/7/rtems-riscv.bset | 1 + rtems/config/7/rtems-sparc.bset | 1 + rtems/config/7/rtems-x86_64.bset | 1 + 20 files changed, 20 insertions(+) diff --git a/rtems/config/6/rtems-aarch64.bset b/rtems/config/6/rtems-aarch64.bset index e3c91af..99051eb 100644 --- a/rtems/config/6/rtems-aarch64.bset +++ b/rtems/config/6/rtems-aarch64.bset @@ -1,4 +1,5 @@ %define release 1 %define rtems_arch aarch64 %define with_libgomp +%define with_newlib_tls %include 6/rtems-default.bset diff --git a/rtems/config/6/rtems-arm.bset b/rtems/config/6/rtems-arm.bset index 425d66b..c4e6613 100644 --- a/rtems/config/6/rtems-arm.bset +++ b/rtems/config/6/rtems-arm.bset @@ -1,4 +1,5 @@ %define release 1 %define rtems_arch arm %define with_libgomp +%define with_newlib_tls %include 6/rtems-default.bset diff --git a/rtems/config/6/rtems-i386.bset b/rtems/config/6/rtems-i386.bset index a27319d..99a6d98 100644 --- a/rtems/config/6/rtems-i386.bset +++ b/rtems/config/6/rtems-i386.bset @@ -1,4 +1,5 @@ %define release 1 %define rtems_arch i386 %define with_libgomp +%define with_newlib_tls %include 6/rtems-default.bset diff --git a/rtems/config/6/rtems-m68k.bset b/rtems/config/6/rtems-m68k.bset index 0932d20..a8e758b 100644 --- a/rtems/config/6/rtems-m68k.bset +++ b/rtems/config/6/rtems-m68k.bset @@ -1,3 +1,4 @@ %define release 1 %define rtems_arch m68k +%define with_newlib_tls %include 6/rtems-default.bset diff --git a/rtems/config/6/rtems-microblaze.bset b/rtems/config/6/rtems-microblaze.bset index ea59313..17b674e 100644 --- a/rtems/config/6/rtems-microblaze.bset +++ b/rtems/config/6/rtems-microblaze.bset @@ -1,5 +1,6 @@ %define release 1 %define rtems_arch microblaze +%define with_newlib_tls # # Default tools configuration. diff --git a/rtems/config/6/rtems-nios2.bset b/rtems/config/6/rtems-nios2.bset index 522eff5..d45024d 100644 --- a/rtems/config/6/rtems-nios2.bset +++ b/rtems/config/6/rtems-nios2.bset @@ -1,3 +1,4 @@ %define release 1 %define rtems_arch nios2 +%define with_newlib_tls %include 6/rtems-default.bset diff --git a/rtems/config/6/rtems-powerpc.bset b/rtems/config/6/rtems-powerpc.bset index c19327a..3309057 100644 --- a/rtems/config/6/rtems-powerpc.bset +++ b/rtems/config/6/rtems-powerpc.bset @@ -1,4 +1,5 @@ %define release 1 %define rtems_arch powerpc %define with_libgomp +%define with_newlib_tls %include 6/rtems-default.bset diff --git a/rtems/config/6/rtems-riscv.bset b/rtems/config/6/rtems-riscv.bset index ad7cb5b..ec1ab3a 100644 --- a/rtems/config/6/rtems-riscv.bset +++ b/rtems/config/6/rtems-riscv.bset @@ -1,5 +1,6 @@ %define release 1 %define rtems_arch riscv %define with_libgomp +%define with_newlib_tls %include 6/rtems-default.bset devel/sis-2-1 diff --git a/rtems/config/6/rtems-sparc.bset b/rtems/config/6/rtems-sparc.bset index 48d152d..809d47e 100644 --- a/rtems/config/6/rtems-sparc.bset +++ b/rtems/config/6/rtems-sparc.bset @@ -1,6 +1,7 @@ %define release 1 %define rtems_arch sparc %define with_libgomp +%define with_newlib_tls %define gdb-disable-sim 1 %include 6/rtems-default.bset devel/sis-2-1 diff --git a/rtems/config/6/rtems-x86_64.bset b/rtems/config/6/rtems-x86_64.bset index 088c9f5..1f2cefb 100644 --- a/rtems/config/6/rtems-x86_64.bset +++ b/rtems/config/6/rtems-x86_64.bset @@ -1,6 +1,7 @@ %define release 1 %define rtems_arch x86_64 %define with_libgomp +%define with_newlib_tls %define grub2_platform efi %define grub2_target x86_64 diff --git a/rtems/config/7/rtems-aarch64.bset b/rtems/config/7/rtems-aarch64.bset index fc794aa..d899dc7 100644 --- a/rtems/config/7/rtems-aarch64.bset +++ b/rtems/config/7/rtems-aarch64.bset @@ -1,4 +1,5 @@ %define release 1 %define rtems_arch aarch64 %define with_libgomp +%define with_newlib_tls %include 7/rtems-default.bset diff --git a/rtems/config/7/rtems-arm.bset b/rtems/config/7/rtems-arm.bset index 7518812..a9bd612 100644 --- a/rtems/config/7/rtems-arm.bset +++ b/rtems/config/7/rtems-arm.bset @@ -1,4 +1,5 @@ %define release 1 %define rtems_arch arm %define with_libgomp +%define with_newlib
[RSB 2/3] newlib: Support "with_newlib_tls"
Update #4560. --- source-builder/config/gcc-common-1.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/source-builder/config/gcc-common-1.cfg b/source-builder/config/gcc-common-1.cfg index 694a1f3..f6ec883 100644 --- a/source-builder/config/gcc-common-1.cfg +++ b/source-builder/config/gcc-common-1.cfg @@ -192,6 +192,7 @@ URL: http://gcc.gnu.org/ --enable-version-specific-runtime-libs \ --enable-newlib-io-c99-formats \ %{?disable_MAKEINFO:MAKEINFO=missing} \ +%{?with_newlib_tls:--enable-newlib-reent-thread-local} \ %{?with_iconv:--enable-newlib-iconv} \ %{?with_iconv:--enable-newlib-iconv-encodings=%{_newlib_iconv_encodings}} \ %{?with_threads:--enable-threads}%{!?with_threads:--disable-threads} \ -- 2.35.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[RSB 1/3] 6/7: Update Newlib
This makes the --enable-newlib-reent-thread-local (_REENT_THREAD_LOCAL_STORAGE) Newlib configuration option available. Update #4560. --- .../config/tools/rtems-gcc-10-newlib-head.cfg | 4 +-- .../tools/rtems-gcc-10.4-newlib-ea99f21.cfg | 27 +++ .../config/tools/rtems-gcc-12-newlib-head.cfg | 4 +-- .../tools/rtems-gcc-head-newlib-head.cfg | 4 +-- 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 rtems/config/tools/rtems-gcc-10.4-newlib-ea99f21.cfg diff --git a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg index 1d08b61..07f92d1 100644 --- a/rtems/config/tools/rtems-gcc-10-newlib-head.cfg +++ b/rtems/config/tools/rtems-gcc-10-newlib-head.cfg @@ -16,11 +16,11 @@ %patch add newlib -p1 https://devel.rtems.org/raw-attachment/ticket/4510/0001-aarch64-Add-ILP32-ABI-support-in-assembly-v2.patch %hash sha512 0001-aarch64-Add-ILP32-ABI-support-in-assembly-v2.patch 7ca237eabfd5b382713186e1fc290dfc999a353315795ecb8dd0d22fcd1ab7f5bf31f4329954adab91ad04c100dcac0e86d406fdbce8f82cf9dc23842c88caf6 -%define newlib_version 27fd806 +%define newlib_version ea99f21 %define newlib_external 1 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version} %source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.gz/%{newlib_version} -%hash sha512 newlib-%{newlib_version}.tar.gz 02fc2a0ffc8bf581f3f98deab582469130cfd6e10983b2be69f9971a326bbc9abedd1e828f990ae69ea984fd5dcad0889345ccab37d83c2f025437f65c53dab6 +%hash sha512 newlib-%{newlib_version}.tar.gz a4216024740c7d5ae6d21a6ab731dcf0bd7a4d70710bc1e79683e7d819812829216df08cd54d0ce7d61c2a959924419ea89367e4c6fb442e59839cacd85d2c52 %define with_threads 1 %define with_plugin 0 diff --git a/rtems/config/tools/rtems-gcc-10.4-newlib-ea99f21.cfg b/rtems/config/tools/rtems-gcc-10.4-newlib-ea99f21.cfg new file mode 100644 index 000..270b5ad --- /dev/null +++ b/rtems/config/tools/rtems-gcc-10.4-newlib-ea99f21.cfg @@ -0,0 +1,27 @@ +%include %{_configdir}/checks.cfg +%include %{_configdir}/base.cfg + +%define gcc_version 10.4.0 +%source set gcc https://ftp.gnu.org/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.xz +%hash sha512 gcc-%{gcc_version}.tar.xz 440c08ca746da450d9a1b35e8fd2305cb27e7e6987cd9d0f7d375f3b1fc9e4b0bd7acb3cd7bf795e72fcbead59cdef5b6c152862f5d35cd9fbfe6902101ce648 + +%patch add gcc -p1 https://devel.rtems.org/raw-attachment/ticket/4196/0001-Back-port-v8-of-gcov-improvements-to-GCC-10.patch +%hash sha512 0001-Back-port-v8-of-gcov-improvements-to-GCC-10.patch c2d1faed68aa0f60bef917365545cc4cc899df428a5d08f178417c06def4fd3cd3a749c1871c8a22552022c29dfae4a3d21161e2b01291e458ea8d670f01887e + +%patch add gcc -p1 https://devel.rtems.org/raw-attachment/ticket/4215/0001-nios2-Remove-custom-instruction-warnings.patch +%hash sha512 0001-nios2-Remove-custom-instruction-warnings.patch afd8a5e6bdcc5b75d5fbbf558bdf56ccac400521a6eec9d88cc95f6be67c481f2dbf8faa0f6ddc1e4ac7c56a84938714d80e46e9cf80ec4b8fcd739986449881 + +%patch add newlib -p1 https://devel.rtems.org/raw-attachment/ticket/4510/0001-aarch64-Add-ILP32-ABI-support-in-assembly-v2.patch +%hash sha512 0001-aarch64-Add-ILP32-ABI-support-in-assembly-v2.patch 7ca237eabfd5b382713186e1fc290dfc999a353315795ecb8dd0d22fcd1ab7f5bf31f4329954adab91ad04c100dcac0e86d406fdbce8f82cf9dc23842c88caf6 + +%define newlib_version ea99f21 +%define newlib_external 1 +%define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version} +%source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.gz/%{newlib_version} +%hash sha512 newlib-%{newlib_version}.tar.gz a4216024740c7d5ae6d21a6ab731dcf0bd7a4d70710bc1e79683e7d819812829216df08cd54d0ce7d61c2a959924419ea89367e4c6fb442e59839cacd85d2c52 + +%define with_threads 1 +%define with_plugin 0 +%define with_iconv 1 + +%include %{_configdir}/gcc-10.cfg diff --git a/rtems/config/tools/rtems-gcc-12-newlib-head.cfg b/rtems/config/tools/rtems-gcc-12-newlib-head.cfg index cec65a8..a15fcf2 100644 --- a/rtems/config/tools/rtems-gcc-12-newlib-head.cfg +++ b/rtems/config/tools/rtems-gcc-12-newlib-head.cfg @@ -27,11 +27,11 @@ %hash sha512 fix-mac-arm64-mpc-config.patch 2849b11e360ea98e0b4d708c67723ad2d6c7bac6d1e469673f408b0111cf0278429e8bc38fd2b7538dc2d5bb0cc430c646a0fa7f0b6b105a0482a5455fadc8b9 # Comment above related to #4657 and patches ends here -%define newlib_version 27fd806 +%define newlib_version ea99f21 %define newlib_external 1 %define newlib_expand_name sourceware-mirror-newlib-cygwin-%{newlib_version} %source set newlib --rsb-file=newlib-%{newlib_version}.tar.gz https://codeload.github.com/RTEMS/sourceware-mirror-newlib-cygwin/tar.gz/%{newlib_version} -%hash sha512 newlib-%{newlib_version}.tar.gz 02fc2a0ffc8bf581f3f98deab582469130cfd6e10983b2be69f9971a326bbc9abedd1e828f990ae69ea984fd5dcad0889345ccab37d83c2f025437
[PATCH 1/2] sptests: Disable Newlib reentrancy
From: Matt Joyce Update #4560. --- testsuites/sptests/sp01/system.h | 7 +++ testsuites/sptests/spstkalloc02/init.c | 7 +++ testsuites/sptests/spstkalloc02/spstkalloc02.doc | 2 +- testsuites/sptests/sptls03/init.c| 7 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/testsuites/sptests/sp01/system.h b/testsuites/sptests/sp01/system.h index 46fa76f1e4..782fd929a7 100644 --- a/testsuites/sptests/sp01/system.h +++ b/testsuites/sptests/sp01/system.h @@ -48,6 +48,13 @@ rtems_task Task_1_through_3( */ #define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM +/* + * This test requires full control over the present thread-local objects. In + * certain Newlib configurations, the Newlib reentrancy support may add + * thread-local objects. + */ +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY + #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/testsuites/sptests/spstkalloc02/init.c b/testsuites/sptests/spstkalloc02/init.c index 5e5db20f0f..3613a6a563 100644 --- a/testsuites/sptests/spstkalloc02/init.c +++ b/testsuites/sptests/spstkalloc02/init.c @@ -138,6 +138,13 @@ static rtems_task Init(rtems_task_argument argument) */ #define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM +/* + * This test requires full control over the present thread-local objects. This + * is necessary for the custom stack allocator below. In certain Newlib + * configurations, the Newlib reentrancy support may add thread-local objects. + */ +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY + #define CONFIGURE_MAXIMUM_TASKS TASK_COUNT #define CONFIGURE_TASK_STACK_ALLOCATOR_INIT task_stack_init diff --git a/testsuites/sptests/spstkalloc02/spstkalloc02.doc b/testsuites/sptests/spstkalloc02/spstkalloc02.doc index a2dd0357ba..f4c09b4558 100644 --- a/testsuites/sptests/spstkalloc02/spstkalloc02.doc +++ b/testsuites/sptests/spstkalloc02/spstkalloc02.doc @@ -26,7 +26,7 @@ This file describes the directives and concepts tested by this test set. -test set name: spstkalloc01 +test set name: spstkalloc02 The test expects that no thread-local object is present. diff --git a/testsuites/sptests/sptls03/init.c b/testsuites/sptests/sptls03/init.c index 2b60828808..6625327f45 100644 --- a/testsuites/sptests/sptls03/init.c +++ b/testsuites/sptests/sptls03/init.c @@ -68,6 +68,13 @@ static void Init(rtems_task_argument arg) */ #define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM +/* + * This test requires full control over the present thread-local objects. In + * certain Newlib configurations, the Newlib reentrancy support may add + * thread-local objects. + */ +#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY + #define CONFIGURE_MAXIMUM_TASKS 1 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION -- 2.35.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 0/2] Add support for using TLS in Newlib
This patch set adds support for the --enable-newlib-reent-thread-local (_REENT_THREAD_LOCAL_STORAGE) Newlib configuration option. By default, Newlib uses a huge object of type struct _reent to store thread-specific data. This object is returned by __getreent() if the __DYNAMIC_REENT__ Newlib configuration option is defined. The reentrancy structure contains for example errno and the standard input, output, and error file streams. This means that if an application only uses errno it has a dependency on the file stream support even if it does not use it. This is an issue for lower end targets and applications which need to qualify the software according to safety standards (for example ECSS-E-ST-40C, ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333). If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct _reent is replaced by dedicated thread-local objects for each struct _reent member. The thread-local objects are defined in translation units which use the corresponding object. Matt Joyce (2): sptests: Disable Newlib reentrancy Support _REENT_THREAD_LOCAL Newlib configuration cpukit/include/rtems/confdefs/newlib.h| 3 +- cpukit/include/rtems/confdefs/threads.h | 6 ++-- cpukit/include/rtems/libcsupport.h| 28 +++ cpukit/include/rtems/score/thread.h | 4 +++ cpukit/libcsupport/src/newlibc_reent.c| 6 testsuites/libtests/newlib01/init.c | 11 +--- testsuites/sptests/sp01/system.h | 7 + testsuites/sptests/spstkalloc02/init.c| 7 + .../sptests/spstkalloc02/spstkalloc02.doc | 2 +- testsuites/sptests/sptls03/init.c | 7 + 10 files changed, 62 insertions(+), 19 deletions(-) -- 2.35.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 2/2] Support _REENT_THREAD_LOCAL Newlib configuration
From: Matt Joyce In case the Newlib _REENT_THREAD_LOCAL configuration option is enabled, the struct _reent is not defined (there is only a forward declaration in ). Instead, the usual members of struct _reent are available as dedicatd thread-local storage objects. Update #4560. --- cpukit/include/rtems/confdefs/newlib.h | 3 ++- cpukit/include/rtems/confdefs/threads.h | 6 -- cpukit/include/rtems/libcsupport.h | 28 +++-- cpukit/include/rtems/score/thread.h | 4 cpukit/libcsupport/src/newlibc_reent.c | 6 ++ testsuites/libtests/newlib01/init.c | 11 ++ 6 files changed, 40 insertions(+), 18 deletions(-) diff --git a/cpukit/include/rtems/confdefs/newlib.h b/cpukit/include/rtems/confdefs/newlib.h index 96bf850163..fef71a8855 100644 --- a/cpukit/include/rtems/confdefs/newlib.h +++ b/cpukit/include/rtems/confdefs/newlib.h @@ -57,7 +57,8 @@ extern "C" { #endif -#ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY +#if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \ + !defined(_REENT_THREAD_LOCAL) struct _reent *__getreent( void ) { return _Thread_Get_executing()->libc_reent; diff --git a/cpukit/include/rtems/confdefs/threads.h b/cpukit/include/rtems/confdefs/threads.h index 503a4b20ec..8e4537f90b 100644 --- a/cpukit/include/rtems/confdefs/threads.h +++ b/cpukit/include/rtems/confdefs/threads.h @@ -159,7 +159,8 @@ struct Thread_Configured_control { #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1 char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ]; #endif - #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY + #if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \ +!defined(_REENT_THREAD_LOCAL) struct _reent Newlib; #endif }; @@ -175,7 +176,8 @@ const Thread_Control_add_on _Thread_Control_add_ons[] = { ), offsetof( Thread_Configured_control, API_RTEMS ) } - #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY + #if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \ +!defined(_REENT_THREAD_LOCAL) , { offsetof( Thread_Configured_control, diff --git a/cpukit/include/rtems/libcsupport.h b/cpukit/include/rtems/libcsupport.h index 212eb16e59..67a09dc2a2 100644 --- a/cpukit/include/rtems/libcsupport.h +++ b/cpukit/include/rtems/libcsupport.h @@ -96,27 +96,33 @@ extern int malloc_info(Heap_Information_block *the_info); /* * Prototypes required to install newlib reentrancy user extension */ + +#ifdef _REENT_THREAD_LOCAL +#define _NEWLIB_CREATE_HOOK NULL +#else bool newlib_create_hook( rtems_tcb *current_task, rtems_tcb *creating_task ); +#define _NEWLIB_CREATE_HOOK newlib_create_hook +#endif void newlib_terminate_hook( rtems_tcb *current_task ); #define RTEMS_NEWLIB_EXTENSION \ -{ \ - newlib_create_hook, /* rtems_task_create */ \ - 0, /* rtems_task_start */ \ - 0, /* rtems_task_restart */ \ - 0, /* rtems_task_delete */ \ - 0, /* task_switch */ \ - 0, /* task_begin */ \ - 0, /* task_exitted */ \ - 0, /* fatal*/ \ - newlib_terminate_hook /* thread terminate */ \ -} + { \ +_NEWLIB_CREATE_HOOK, /* thread_create*/ \ +NULL, /* thread_start */ \ +NULL, /* thread_restart */ \ +NULL, /* thread_delete*/ \ +NULL, /* thread_switch*/ \ +NULL, /* thread_begin */ \ +NULL, /* thread_exitted */ \ +NULL, /* fatal*/ \ +newlib_terminate_hook /* thread_terminate */ \ + } typedef struct { uint32_t active_barriers; diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h index dd32b51a5f..94eab18ea3 100644 --- a/cpukit/include/rtems/score/thread.h +++ b/cpukit/include/rtems/score/thread.h @@ -921,8 +921,12 @@ struct _Thread_Control { */ Context_Control_fp *fp_context; #endif + +#ifndef _REENT_THREAD_LOCAL /** This field points to the newlib reentrancy structure for this thread. */ struct _reent*libc_reent; +#endif + /** This array contains the API extension area pointers. */ void *API_Extensions[ THREAD_API_LAST + 1 ]; diff --git a/cpukit/libcsupport/src/newlibc_reent.c b/cpukit/libcsupport/src/newlibc_reent.c index 2dccfd0375..ee82f00858 100644 --- a/cpukit/libcsupport/src/newlibc_reent.c +++ b/cpukit/libcsupport/src/newlibc_reent.c @@ -29,6 +29,7 @@ #include #include +#ifndef _REENT_THREAD_LOCAL bool newlib_create_hook( rtems_tcb *current_task RTEMS_UNUSED, rtems_tcb *creating_task @@ -38,12 +39,17 @@ bool newlib_create_hook( return true; } +#endif void newlib_terminate_hook( rtems_tcb *current_task ) { +#ifdef _REENT_THREAD_LOCAL + _reclaim_reent(NULL); +#else _reclaim_reent(current_task->
[PATCH] cdtest: Restrict exceptions during sysinit
Exceptions during system initialization work only on targets which do not need a registration of exception frames during the global construction. In particular, targets which use the DWARF2 unwinder cannot use exceptions during system initialization. --- testsuites/samples/cdtest/main.cc | 14 ++ 1 file changed, 14 insertions(+) diff --git a/testsuites/samples/cdtest/main.cc b/testsuites/samples/cdtest/main.cc index 44cdaf84bb..d5530a657d 100644 --- a/testsuites/samples/cdtest/main.cc +++ b/testsuites/samples/cdtest/main.cc @@ -238,6 +238,17 @@ rtems_task main_task( exit(0); } +/* + * Exceptions during system initialization work only on targets which do not + * need a registration of exception frames during the global construction. In + * particular, targets which use the DWARF2 unwinder cannot use exceptions + * during system initialization. + */ +#if defined(__arm__) || defined(__aarch64__) +#define CAN_DO_EXCEPTIONS_DURING_SYSINIT +#endif + +#ifdef CAN_DO_EXCEPTIONS_DURING_SYSINIT static void early_exception() { try @@ -250,11 +261,13 @@ static void early_exception() throw "early exception 2"; } } +#endif static void test_exceptions_during_system_init() { TEST_BEGIN(); +#ifdef CAN_DO_EXCEPTIONS_DURING_SYSINIT try { early_exception(); @@ -263,6 +276,7 @@ static void test_exceptions_during_system_init() { rtems_test_assert(strcmp(e, "early exception 2") == 0); } +#endif } RTEMS_SYSINIT_ITEM( -- 2.35.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/3] score: Fix _Objects_Active_count()
With unlimited objects the object maximum may be larger than the sum of active and inactive objects. --- cpukit/score/src/objectactivecount.c | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cpukit/score/src/objectactivecount.c b/cpukit/score/src/objectactivecount.c index 028058e473..5f0304fead 100644 --- a/cpukit/score/src/objectactivecount.c +++ b/cpukit/score/src/objectactivecount.c @@ -46,14 +46,22 @@ Objects_Maximum _Objects_Active_count( const Objects_Information *information ) { - Objects_Maximum inactive; - Objects_Maximum maximum; + Objects_Maximum active; + Objects_Maximum index; + Objects_Maximum maximum; + Objects_Control **local_table; _Assert( _Objects_Allocator_is_owner() ); - inactive = (Objects_Maximum) -_Chain_Node_count_unprotected( &information->Inactive ); + active = 0; maximum = _Objects_Get_maximum_index( information ); + local_table = information->local_table; - return maximum - inactive; + for ( index = 0; index < maximum; ++index ) { +if ( local_table[ index ] != NULL ) { + ++active; +} + } + + return active; } -- 2.35.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 3/3] score: Fix unlimited objects support
Commit 21275b58a5a69c3c838082ffc8a7a3641f32ea9a ("score: Static Objects_Information initialization") introduced an off-by-one error in the maintenance of inactive objects. Close #4677. --- cpukit/include/rtems/score/objectimpl.h | 29 + cpukit/score/src/objectfree.c | 12 +- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h index 72a5f6b126..7938996df8 100644 --- a/cpukit/include/rtems/score/objectimpl.h +++ b/cpukit/include/rtems/score/objectimpl.h @@ -911,6 +911,25 @@ RTEMS_INLINE_ROUTINE void _Objects_Free( ( *information->deallocate )( information, the_object ); } +/** + * @brief Returns true, if the object associated with the zero-based index is + * contained in an allocated block of objects, otherwise false. + * + * @param index is the zero-based object index. + * @param objects_per_block is the object count per block. + * + * @retval true The object associated with the zero-based index is in an + * allocated block of objects. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Objects_Is_in_allocated_block( + Objects_Maximum index, + Objects_Maximum objects_per_block +) +{ + return index >= objects_per_block; +} + /** * @brief Activate the object. * @@ -926,15 +945,17 @@ RTEMS_INLINE_ROUTINE void _Objects_Activate_unlimited( ) { Objects_Maximum objects_per_block; - Objects_Maximum block; + Objects_Maximum index; _Assert( _Objects_Is_auto_extend( information ) ); objects_per_block = information->objects_per_block; - block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; + index = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; + + if ( _Objects_Is_in_allocated_block( index, objects_per_block ) ) { +Objects_Maximum block; - if ( block > objects_per_block ) { -block /= objects_per_block; +block = index / objects_per_block; information->inactive_per_block[ block ]--; information->inactive--; diff --git a/cpukit/score/src/objectfree.c b/cpukit/score/src/objectfree.c index 45b2ba2c86..06d7d82672 100644 --- a/cpukit/score/src/objectfree.c +++ b/cpukit/score/src/objectfree.c @@ -51,14 +51,16 @@ void _Objects_Free_unlimited( if ( _Objects_Is_auto_extend( information ) ) { Objects_Maximum objects_per_block; -Objects_Maximum block; -Objects_Maximum inactive; +Objects_Maximum index; objects_per_block = information->objects_per_block; -block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; +index = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; -if ( block > objects_per_block ) { - block /= objects_per_block; +if ( _Objects_Is_in_allocated_block( index, objects_per_block ) ) { + Objects_Maximum block; + Objects_Maximum inactive; + + block = index / objects_per_block; ++information->inactive_per_block[ block ]; -- 2.35.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 2/3] spunlimited01: New test
Update #4677. --- spec/build/testsuites/sptests/grp.yml | 2 + .../testsuites/sptests/spunlimited01.yml | 20 +++ testsuites/sptests/spunlimited01/init.c | 125 ++ .../sptests/spunlimited01/spunlimited01.doc | 14 ++ 4 files changed, 161 insertions(+) create mode 100644 spec/build/testsuites/sptests/spunlimited01.yml create mode 100644 testsuites/sptests/spunlimited01/init.c create mode 100644 testsuites/sptests/spunlimited01/spunlimited01.doc diff --git a/spec/build/testsuites/sptests/grp.yml b/spec/build/testsuites/sptests/grp.yml index c6d07b07fd..891a78eb86 100644 --- a/spec/build/testsuites/sptests/grp.yml +++ b/spec/build/testsuites/sptests/grp.yml @@ -448,6 +448,8 @@ links: uid: sptls03 - role: build-dependency uid: sptls04 +- role: build-dependency + uid: spunlimited01 - role: build-dependency uid: spversion01 - role: build-dependency diff --git a/spec/build/testsuites/sptests/spunlimited01.yml b/spec/build/testsuites/sptests/spunlimited01.yml new file mode 100644 index 00..e0f530da74 --- /dev/null +++ b/spec/build/testsuites/sptests/spunlimited01.yml @@ -0,0 +1,20 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: [] +ldflags: +- -Wl,--wrap=_Workspace_Free +links: [] +source: +- testsuites/sptests/spunlimited01/init.c +stlib: [] +target: testsuites/sptests/spunlimited01.exe +type: build +use-after: [] +use-before: [] diff --git a/testsuites/sptests/spunlimited01/init.c b/testsuites/sptests/spunlimited01/init.c new file mode 100644 index 00..ce64324768 --- /dev/null +++ b/testsuites/sptests/spunlimited01/init.c @@ -0,0 +1,125 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include + +#include +#include + +const char rtems_test_name[] = "SPUNLIMITED 1"; + +void __real__Workspace_Free( void * ); +void __wrap__Workspace_Free( void * ); + +void __wrap__Workspace_Free( void *ptr ) +{ + uintptr_t alloc_begin; + uintptr_t block_size; + uintptr_t block_end; + Heap_Block *block; + + if ( ptr == NULL ) { +return; + } + + alloc_begin = (uintptr_t) ptr; + block = _Heap_Block_of_alloc_area( alloc_begin, CPU_HEAP_ALIGNMENT ); + block_size = _Heap_Block_size( block ); + block_end = (uintptr_t) block + block_size; + memset( ptr, 0, block_end - alloc_begin ); + + __real__Workspace_Free( ptr ); +} + +static void delete_mutex( rtems_id id ) +{ + rtems_status_code sc; + + sc = rtems_semaphore_delete( id ); + T_rsc_success( sc ); +} + +T_TEST_CASE( UnlimitedShrink ) +{ + rtems_id ids[ 6 ]; + size_t i; + rtems_status_code sc; + + for ( i = 0; i < RTEMS_ARRAY_SIZE( ids ); ++i ) { +sc = rtems_semaphore_create( + rtems_build_name( 'M', 'U', 'T', 'X' ), + 1, + RTEMS_BINARY_SEMAPHORE, + 0, + &ids[ i ] +); +T_assert_rsc_success( sc ); + } + + sc = rtems_semaphore_obtain( ids[ 2 ], RTEMS_WAIT, RTEMS_NO_TIMEOUT ); + T_rsc_success( sc ); + + delete_mutex( ids[ 5 ] ); + delete_mutex( ids[ 4 ] ); + delete_mutex( ids[ 3 ] ); + + sc = rtems_semaphore_release( ids[ 2 ] ); + T_rsc_success( sc ); + + delete_mutex( ids[ 2 ] ); + delete_mutex( ids[ 1 ] ); + delete_mutex( ids[ 0 ] ); +} + +static rtems_task Init( rtems_task_argument argument ) +{ + rtems_test_run( argument, TEST_STATE ); +} + +#define CONFIGURE_APPLIC
Re: Build Linux: FAILED 6/rtems-m68k on x86_64-linux-gnu (m68k-rtems6-gcc-1ad2ee2-newlib-ea99f21-x86_64-linux-gnu-1)
On 13/07/2022 11:58, sebastian.hu...@embedded-brains.de wrote: RTEMS Source Builder - Set Builder, 6 (53c42b08508f) warning: exe: absolute exe found in path: (__chown) /usr/sbin/chown Host: Linux-5.3.18-150300.59.76-default-x86_64-with-glibc2.3.4 Linux lupus 5.3.18-150300.59.76-default #1 SMP Thu Jun 16 04:23:47 UTC 2022 (2cc2ade) x86_64 x86_64 Build Time: 0:06:49.920595 I added a GCC bug report for this error: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106282 I will disable the configuration option for m68k until this is fixed. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] samples/cdtest: Test execeptions during system init
On 13/7/2022 6:42 pm, Sebastian Huber wrote: > On 01/07/2022 12:02, Sebastian Huber wrote: >> +static void early_exception() >> +{ >> + try >> + { >> + throw "early exception"; >> + } >> + catch( const char *e ) >> + { >> + rtems_test_assert(strcmp(e, "early exception") == 0); >> + throw "early exception 2"; >> + } >> +} >> + >> +static void test_exceptions_during_system_init() >> +{ >> + TEST_BEGIN(); >> + >> + try >> + { >> + early_exception(); >> + } >> + catch( const char *e ) >> + { >> + rtems_test_assert(strcmp(e, "early exception 2") == 0); >> + } >> +} >> + >> +RTEMS_SYSINIT_ITEM( >> + test_exceptions_during_system_init, >> + RTEMS_SYSINIT_IDLE_THREADS, >> + RTEMS_SYSINIT_ORDER_LAST >> +); > > Actually, on targets which use the DWARF2 unwinder (for example sparc), this > doesn't work since the exception frames are no yet registered. Is the result a terminate with an unknown type of exception of something else? Kinsey is reporting an issue with aarch64 and cdtest on discord. What mechanism is being used to initialise the unwinder support? With libdl the unwind tables are registered as part of the loading. > They are > registered during global construction. This also means that C++ exceptions can > only be used once the global construction completed on these targets. Has this always been the case? It is part of the well documented RAII principle so we need this to work. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] cdtest: Restrict exceptions during sysinit
On 13/7/2022 9:41 pm, Sebastian Huber wrote: > Exceptions during system initialization work only on targets which do not need > a registration of exception frames during the global construction. In > particular, targets which use the DWARF2 unwinder cannot use exceptions during > system initialization. I would like to complete the discussion on the other thread about this issue before we work around the issue like this. If this patch masks a failure that the standard expects to work we should not hide it. Thanks Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Time to promote lwip git repo
Am 13.07.22 um 04:51 schrieb Chris Johns: On 13/7/2022 10:08 am, Joel Sherrill wrote: Vijay and Kinsey have made great progress in addressing the issues that were raised about the lwip tcpip stack that needed to be addressed before it became an official top level repository. Thanks to both of them. Well done. Great effort. I think it's time to promote the repo. Hopefully just a couple of core developers agreeing is sufficient to get this moving. I support this happening. It is great to see this networking option for small devices become available. I haven't tested the lwip repository yet, but I agree that a stack for small targets is great. So I would support that too. Christian -- embedded brains GmbH Herr Christian MAUDERER Dornierstr. 4 82178 Puchheim Germany email: christian.maude...@embedded-brains.de phone: +49-89-18 94 741 - 18 mobile: +49-176-152 206 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] samples/cdtest: Test execeptions during system init
On 14/07/2022 02:31, Chris Johns wrote: On 13/7/2022 6:42 pm, Sebastian Huber wrote: On 01/07/2022 12:02, Sebastian Huber wrote: +static void early_exception() +{ + try + { + throw "early exception"; + } + catch( const char *e ) + { + rtems_test_assert(strcmp(e, "early exception") == 0); + throw "early exception 2"; + } +} + +static void test_exceptions_during_system_init() +{ + TEST_BEGIN(); + + try + { + early_exception(); + } + catch( const char *e ) + { + rtems_test_assert(strcmp(e, "early exception 2") == 0); + } +} + +RTEMS_SYSINIT_ITEM( + test_exceptions_during_system_init, + RTEMS_SYSINIT_IDLE_THREADS, + RTEMS_SYSINIT_ORDER_LAST +); Actually, on targets which use the DWARF2 unwinder (for example sparc), this doesn't work since the exception frames are no yet registered. Is the result a terminate with an unknown type of exception of something else? It is a failed gcc_assert() in the unwinder code. Depending on the GCC options, this results in a __builtin_trap(). Kinsey is reporting an issue with aarch64 and cdtest on discord. Yes, it seems ARM changed the exception implementation for aarch64 to use what everyone else uses. So we essentially have: #if defined(__arm__) #define CAN_DO_EXCEPTIONS_DURING_SYSINIT #endif What mechanism is being used to initialise the unwinder support? It is the C runtime initialization done during global construction. With libdl the unwind tables are registered as part of the loading. They are registered during global construction. This also means that C++ exceptions can only be used once the global construction completed on these targets. Has this always been the case? Yes, but there was no test which used the C++ exceptions during system initialization until recently. It is part of the well documented RAII principle so we need this to work. Probably the only thing we can do is to document this constraint somewhere. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] cdtest: Restrict exceptions during sysinit
On 14/07/2022 02:36, Chris Johns wrote: Exceptions during system initialization work only on targets which do not need a registration of exception frames during the global construction. In particular, targets which use the DWARF2 unwinder cannot use exceptions during system initialization. I would like to complete the discussion on the other thread about this issue before we work around the issue like this. If this patch masks a failure that the standard expects to work we should not hide it. Don't shoot the messenger. This is a fundamental limitation of the DWARF2 unwinder. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel