summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-11-19 08:40:13 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-11-19 17:41:07 +0100
commitc5af8aa0704d52e1d9757b863ed2831282642a56 (patch)
tree6acda4c1d3e99d2b51bc3bcdd501725bcca11891
parentvalidation/ts-performance-0: Add partition tests (diff)
downloadrtems-c5af8aa0704d52e1d9757b863ed2831282642a56.tar.bz2
config: Simplify task stack allocator init
Replace runtime checks with compile time assertions. This makes the INTERNAL_ERROR_BAD_STACK_HOOK obsolete.
-rw-r--r--cpukit/include/rtems/confdefs/wkspace.h18
-rw-r--r--cpukit/include/rtems/score/interr.h2
-rw-r--r--cpukit/score/src/stackallocatorinit.c8
-rw-r--r--spec/build/testsuites/sptests/grp.yml2
-rw-r--r--spec/build/testsuites/sptests/spfatal06.yml19
-rw-r--r--testsuites/sptests/Makefile.am9
-rw-r--r--testsuites/sptests/configure.ac1
-rw-r--r--testsuites/sptests/spfatal06/init.c38
-rw-r--r--testsuites/sptests/spfatal06/spfatal06.doc20
-rw-r--r--testsuites/sptests/spfatal06/spfatal06.scn3
-rw-r--r--testsuites/sptests/spinternalerror01/init.c15
-rw-r--r--testsuites/sptests/sptimecounter01/init.c15
12 files changed, 45 insertions, 105 deletions
diff --git a/cpukit/include/rtems/confdefs/wkspace.h b/cpukit/include/rtems/confdefs/wkspace.h
index d40194cbec..81d172815e 100644
--- a/cpukit/include/rtems/confdefs/wkspace.h
+++ b/cpukit/include/rtems/confdefs/wkspace.h
@@ -137,6 +137,12 @@ const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE;
#if defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
&& defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
+ /* Ignore potential warnings from the static assertions below */
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Waddress"
+ #pragma GCC diagnostic ignored "-Wpragmas"
+ #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
+
#ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE
const bool _Stack_Allocator_avoids_workspace = true;
#else
@@ -150,9 +156,19 @@ const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE;
const Stack_Allocator_initialize _Stack_Allocator_initialize = NULL;
#endif
+ RTEMS_STATIC_ASSERT(
+ CONFIGURE_TASK_STACK_ALLOCATOR != NULL,
+ CONFIGURE_TASK_STACK_ALLOCATOR_MUST_NOT_BE_NULL
+ );
+
const Stack_Allocator_allocate _Stack_Allocator_allocate =
CONFIGURE_TASK_STACK_ALLOCATOR;
+ RTEMS_STATIC_ASSERT(
+ CONFIGURE_TASK_STACK_DEALLOCATOR != NULL,
+ CONFIGURE_TASK_STACK_DEALLOCATOR_MUST_NOT_BE_NULL
+ );
+
const Stack_Allocator_free _Stack_Allocator_free =
CONFIGURE_TASK_STACK_DEALLOCATOR;
@@ -161,6 +177,8 @@ const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE;
RTEMS_SYSINIT_DIRTY_MEMORY,
RTEMS_SYSINIT_ORDER_MIDDLE
);
+
+ #pragma GCC diagnostic pop
#elif defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
|| defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
#error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
diff --git a/cpukit/include/rtems/score/interr.h b/cpukit/include/rtems/score/interr.h
index 85767d0bc5..4b06199ae9 100644
--- a/cpukit/include/rtems/score/interr.h
+++ b/cpukit/include/rtems/score/interr.h
@@ -177,7 +177,7 @@ typedef enum {
INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS = 11,
INTERNAL_ERROR_OUT_OF_PROXIES = 12,
INTERNAL_ERROR_INVALID_GLOBAL_ID = 13,
- INTERNAL_ERROR_BAD_STACK_HOOK = 14,
+ /* INTERNAL_ERROR_BAD_STACK_HOOK = 14, */
/* INTERNAL_ERROR_BAD_ATTRIBUTES = 15, */
/* INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY = 16, */
/* INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL = 17, */
diff --git a/cpukit/score/src/stackallocatorinit.c b/cpukit/score/src/stackallocatorinit.c
index 60d243631f..412e3142b3 100644
--- a/cpukit/score/src/stackallocatorinit.c
+++ b/cpukit/score/src/stackallocatorinit.c
@@ -38,20 +38,12 @@
#endif
#include <rtems/score/stack.h>
-#include <rtems/score/interr.h>
#include <rtems/config.h>
void _Stack_Allocator_do_initialize( void )
{
rtems_stack_allocate_init_hook init_hook;
- if (
- rtems_configuration_get_stack_allocate_hook() == NULL
- || rtems_configuration_get_stack_free_hook() == NULL
- ) {
- _Internal_error( INTERNAL_ERROR_BAD_STACK_HOOK );
- }
-
init_hook = rtems_configuration_get_stack_allocate_init_hook();
if ( init_hook != NULL ) {
diff --git a/spec/build/testsuites/sptests/grp.yml b/spec/build/testsuites/sptests/grp.yml
index 64b0a54b0e..1c865777a7 100644
--- a/spec/build/testsuites/sptests/grp.yml
+++ b/spec/build/testsuites/sptests/grp.yml
@@ -227,8 +227,6 @@ links:
- role: build-dependency
uid: spfatal05
- role: build-dependency
- uid: spfatal06
-- role: build-dependency
uid: spfatal09
- role: build-dependency
uid: spfatal10
diff --git a/spec/build/testsuites/sptests/spfatal06.yml b/spec/build/testsuites/sptests/spfatal06.yml
deleted file mode 100644
index 6e4be90a2a..0000000000
--- a/spec/build/testsuites/sptests/spfatal06.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
-build-type: test-program
-cflags: []
-copyrights:
-- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
-cppflags: []
-cxxflags: []
-enabled-by: true
-features: c cprogram
-includes: []
-ldflags: []
-links: []
-source:
-- testsuites/sptests/spfatal06/init.c
-stlib: []
-target: testsuites/sptests/spfatal06.exe
-type: build
-use-after: []
-use-before: []
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 854ec3daf8..14788f7fb1 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -940,15 +940,6 @@ spfatal05_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spfatal05) \
$(support_includes)
endif
-if TEST_spfatal06
-sp_tests += spfatal06
-sp_screens += spfatal06/spfatal06.scn
-sp_docs += spfatal06/spfatal06.doc
-spfatal06_SOURCES = spfatal06/init.c
-spfatal06_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spfatal06) \
- $(support_includes)
-endif
-
if TEST_spfatal09
sp_tests += spfatal09
sp_screens += spfatal09/spfatal09.scn
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 460917dd04..099ff0412b 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -141,7 +141,6 @@ RTEMS_TEST_CHECK([spfatal02])
RTEMS_TEST_CHECK([spfatal03])
RTEMS_TEST_CHECK([spfatal04])
RTEMS_TEST_CHECK([spfatal05])
-RTEMS_TEST_CHECK([spfatal06])
RTEMS_TEST_CHECK([spfatal09])
RTEMS_TEST_CHECK([spfatal10])
RTEMS_TEST_CHECK([spfatal11])
diff --git a/testsuites/sptests/spfatal06/init.c b/testsuites/sptests/spfatal06/init.c
deleted file mode 100644
index cef38f5fe2..0000000000
--- a/testsuites/sptests/spfatal06/init.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "../spfatal_support/spfatal.h"
-
-/*
- * Classic API Init task create failure
- *
- * COPYRIGHT (c) 1989-2008.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#define FATAL_ERROR_TEST_NAME "6"
-#define FATAL_ERROR_DESCRIPTION \
- "Core initialize with invalid stack hook"
-#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE
-#define FATAL_ERROR_EXPECTED_ERROR INTERNAL_ERROR_BAD_STACK_HOOK
-
-#define CONFIGURE_TASK_STACK_ALLOCATOR New_stack_allocate_hook
-
-#define CONFIGURE_TASK_STACK_DEALLOCATOR NULL
-
-static void *New_stack_allocate_hook(size_t unused)
-{
- return NULL;
-}
-
-static void force_error(void)
-{
- /* we will not run this far */
-}
-
-#include "../spfatal_support/spfatalimpl.h"
diff --git a/testsuites/sptests/spfatal06/spfatal06.doc b/testsuites/sptests/spfatal06/spfatal06.doc
deleted file mode 100644
index 5deaa3267b..0000000000
--- a/testsuites/sptests/spfatal06/spfatal06.doc
+++ /dev/null
@@ -1,20 +0,0 @@
-# COPYRIGHT (c) 1989-2009.
-# On-Line Applications Research Corporation (OAR).
-#
-# The license and distribution terms for this file may be
-# found in the file LICENSE in this distribution or at
-# http://www.rtems.org/license/LICENSE.
-#
-
-This file describes the directives and concepts tested by this test set.
-
-test set name: spfatal06
-
-directives:
-
- None specifically
-
-concepts:
-
-+ Ensure that the error condition when the BSP specific stack allocator
- hook is incorrectly configured is properly treated as a fatal error.
diff --git a/testsuites/sptests/spfatal06/spfatal06.scn b/testsuites/sptests/spfatal06/spfatal06.scn
deleted file mode 100644
index 69d3d52fd4..0000000000
--- a/testsuites/sptests/spfatal06/spfatal06.scn
+++ /dev/null
@@ -1,3 +0,0 @@
-*** TEST FATAL 6 ***
-Fatal error (Core initialize with invalid stack hook) hit
-*** END OF TEST FATAL 6 ***
diff --git a/testsuites/sptests/spinternalerror01/init.c b/testsuites/sptests/spinternalerror01/init.c
index 592cfcfa58..349f9fa1b9 100644
--- a/testsuites/sptests/spinternalerror01/init.c
+++ b/testsuites/sptests/spinternalerror01/init.c
@@ -58,6 +58,17 @@ static void *idle_body(uintptr_t ignored)
return NULL;
}
+static void *stack_allocate(size_t size)
+{
+ (void) size;
+ return NULL;
+}
+
+static void stack_free(void *ptr)
+{
+ (void) ptr;
+}
+
#define CONFIGURE_INITIAL_EXTENSIONS \
{ .fatal = fatal_extension }, \
RTEMS_TEST_INITIAL_EXTENSION
@@ -76,9 +87,9 @@ static void *idle_body(uintptr_t ignored)
#define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER 0
-#define CONFIGURE_TASK_STACK_ALLOCATOR NULL
+#define CONFIGURE_TASK_STACK_ALLOCATOR stack_allocate
-#define CONFIGURE_TASK_STACK_DEALLOCATOR NULL
+#define CONFIGURE_TASK_STACK_DEALLOCATOR stack_free
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
diff --git a/testsuites/sptests/sptimecounter01/init.c b/testsuites/sptests/sptimecounter01/init.c
index 81b705473e..13a00209fa 100644
--- a/testsuites/sptests/sptimecounter01/init.c
+++ b/testsuites/sptests/sptimecounter01/init.c
@@ -210,6 +210,17 @@ void boot_card(const char *cmdline)
_Terminate(RTEMS_FATAL_SOURCE_EXIT, 0);
}
+static void *stack_allocate(size_t size)
+{
+ (void) size;
+ return NULL;
+}
+
+static void stack_free(void *ptr)
+{
+ (void) ptr;
+}
+
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
@@ -224,9 +235,9 @@ void boot_card(const char *cmdline)
#define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER 0
-#define CONFIGURE_TASK_STACK_ALLOCATOR NULL
+#define CONFIGURE_TASK_STACK_ALLOCATOR stack_allocate
-#define CONFIGURE_TASK_STACK_DEALLOCATOR NULL
+#define CONFIGURE_TASK_STACK_DEALLOCATOR stack_free
#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION