diff --git a/demos/STM32/RT-STM32F303-DISCOVERY/main.c b/demos/STM32/RT-STM32F303-DISCOVERY/main.c index 1f91e6e63..591f653f9 100644 --- a/demos/STM32/RT-STM32F303-DISCOVERY/main.c +++ b/demos/STM32/RT-STM32F303-DISCOVERY/main.c @@ -21,8 +21,8 @@ /* * Blinker thread #1. */ -static THD_WORKING_AREA(waThread1, 128); -static THD_FUNCTION(Thread1, arg) { +THD_WORKING_AREA(waThread1, 128); +THD_FUNCTION(Thread1, arg) { (void)arg; @@ -50,8 +50,8 @@ static THD_FUNCTION(Thread1, arg) { /* * Blinker thread #2. */ -static THD_WORKING_AREA(waThread2, 128); -static THD_FUNCTION(Thread2, arg) { +THD_WORKING_AREA(waThread2, 128); +THD_FUNCTION(Thread2, arg) { (void)arg; diff --git a/test/rt/configuration.xml b/test/rt/configuration.xml index f934d120d..4289ef051 100644 --- a/test/rt/configuration.xml +++ b/test/rt/configuration.xml @@ -60,23 +60,10 @@ /* * Working Area size of test threads. */ -#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE) +#define WA_SIZE MEM_ALIGN_NEXT(THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), \ + PORT_WORKING_AREA_ALIGN) -/* - * Union of all Working Areas, usable as a single large buffer if required. - */ -union test_buffers { - struct { - THD_WORKING_AREA(T0, THREADS_STACK_SIZE); - THD_WORKING_AREA(T1, THREADS_STACK_SIZE); - THD_WORKING_AREA(T2, THREADS_STACK_SIZE); - THD_WORKING_AREA(T3, THREADS_STACK_SIZE); - THD_WORKING_AREA(T4, THREADS_STACK_SIZE); - } wa; - uint8_t buffer[WA_SIZE * 5]; -}; - -extern union test_buffers test; +extern uint8_t test_buffer[WA_SIZE * 5]; extern thread_t *threads[MAX_THREADS]; extern void * ROMCONST wa[5]; @@ -86,10 +73,9 @@ systime_t test_wait_tick(void);]]> +memory_heap_t test_heap;]]> @@ -3591,7 +3579,7 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);]]> - + @@ -3621,7 +3609,7 @@ size_t n, sz;]]> - @@ -3850,7 +3838,7 @@ The test expects the first two threads to successfully start and the third one t - + diff --git a/test/rt/source/test/test_root.c b/test/rt/source/test/test_root.c index 76aeb05ec..5754813ac 100644 --- a/test/rt/source/test/test_root.c +++ b/test/rt/source/test/test_root.c @@ -91,10 +91,9 @@ const testcase_t * const *test_suite[] = { /*===========================================================================*/ /* - * Static working areas, the following areas can be used for threads or - * used as temporary buffers. + * Global test buffer holding 5 working areas. */ -union test_buffers test; +ALIGNED_VAR(PORT_WORKING_AREA_ALIGN) uint8_t test_buffer[WA_SIZE * 5]; /* * Pointers to the spawned threads. @@ -104,8 +103,11 @@ thread_t *threads[MAX_THREADS]; /* * Pointers to the working areas. */ -void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2, - test.wa.T3, test.wa.T4}; +void * ROMCONST wa[5] = {test_buffer + (WA_SIZE * 0), + test_buffer + (WA_SIZE * 1), + test_buffer + (WA_SIZE * 2), + test_buffer + (WA_SIZE * 3), + test_buffer + (WA_SIZE * 4)}; /* * Sets a termination request in all the test-spawned threads. diff --git a/test/rt/source/test/test_root.h b/test/rt/source/test/test_root.h index e2fdb37f3..4fdc5ec57 100644 --- a/test/rt/source/test/test_root.h +++ b/test/rt/source/test/test_root.h @@ -82,23 +82,10 @@ extern "C" { /* * Working Area size of test threads. */ -#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE) +#define WA_SIZE MEM_ALIGN_NEXT(THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), \ + PORT_WORKING_AREA_ALIGN) -/* - * Union of all Working Areas, usable as a single large buffer if required. - */ -union test_buffers { - struct { - THD_WORKING_AREA(T0, THREADS_STACK_SIZE); - THD_WORKING_AREA(T1, THREADS_STACK_SIZE); - THD_WORKING_AREA(T2, THREADS_STACK_SIZE); - THD_WORKING_AREA(T3, THREADS_STACK_SIZE); - THD_WORKING_AREA(T4, THREADS_STACK_SIZE); - } wa; - uint8_t buffer[WA_SIZE * 5]; -}; - -extern union test_buffers test; +extern uint8_t test_buffer[WA_SIZE * 5]; extern thread_t *threads[MAX_THREADS]; extern void * ROMCONST wa[5]; diff --git a/test/rt/source/test/test_sequence_010.c b/test/rt/source/test/test_sequence_010.c index c4328f7f1..480021eb6 100644 --- a/test/rt/source/test/test_sequence_010.c +++ b/test/rt/source/test/test_sequence_010.c @@ -51,8 +51,7 @@ #define ALLOC_SIZE 16 #define HEAP_SIZE (ALLOC_SIZE * 8) -static memory_heap_t test_heap; -static CH_HEAP_AREA(myheap, HEAP_SIZE); +memory_heap_t test_heap; /**************************************************************************** * Test cases. @@ -89,7 +88,7 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE); */ static void test_010_001_setup(void) { - chHeapObjectInit(&test_heap, myheap, sizeof(myheap)); + chHeapObjectInit(&test_heap, test_buffer, sizeof(test_buffer)); } static void test_010_001_execute(void) { @@ -107,7 +106,7 @@ static void test_010_001_execute(void) { an error is expected.*/ test_set_step(2); { - p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2); + p1 = chHeapAlloc(&test_heap, sizeof test_buffer * 2); test_assert(p1 == NULL, "allocation not failed"); } diff --git a/test/rt/source/test/test_sequence_011.c b/test/rt/source/test/test_sequence_011.c index 71d27433b..14ac5c051 100644 --- a/test/rt/source/test/test_sequence_011.c +++ b/test/rt/source/test/test_sequence_011.c @@ -93,7 +93,7 @@ static THD_FUNCTION(dyn_thread1, p) { */ static void test_011_001_setup(void) { - chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers)); + chHeapObjectInit(&heap1, test_buffer, sizeof test_buffer); } static void test_011_001_execute(void) {