From 46a67b19814a4e2a9f303f85849bdbf3b7e5d4b7 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 1 Jun 2009 14:50:31 +0000 Subject: 2009-06-01 Joel Sherrill * score/include/rtems/score/thread.h, score/src/threadhandler.c: Merge conditional code from main and init/fini C++ constructors so the body of this method reads better. Mark thread prototypes which are not currently exercised by any APIs with FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API conditional. --- cpukit/score/include/rtems/score/thread.h | 6 +- cpukit/score/src/threadhandler.c | 110 +++++++++++++++--------------- 2 files changed, 58 insertions(+), 58 deletions(-) (limited to 'cpukit/score') diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index 3eba3bc136..bd63e7a4ae 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -99,8 +99,10 @@ typedef uintptr_t Thread_Entry_numeric_type; typedef enum { THREAD_START_NUMERIC, THREAD_START_POINTER, - THREAD_START_BOTH_POINTER_FIRST, - THREAD_START_BOTH_NUMERIC_FIRST + #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) + THREAD_START_BOTH_POINTER_FIRST, + THREAD_START_BOTH_NUMERIC_FIRST + #endif } Thread_Start_types; /** This type corresponds to a very simple style thread entry point. */ diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c index a1c0ff2e9b..762e26c82b 100644 --- a/cpukit/score/src/threadhandler.c +++ b/cpukit/score/src/threadhandler.c @@ -2,7 +2,7 @@ * Thread Handler * * - * COPYRIGHT (c) 1989-2008. + * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -42,9 +42,13 @@ #endif extern void INIT_NAME(void); + #define EXECUTE_GLOBAL_CONSTRUCTORS #endif + #if defined(__USE__MAIN__) extern void _main(void); + #define INIT_NAME __main + #define EXECUTE_GLOBAL_CONSTRUCTORS #endif /*PAGE @@ -79,10 +83,10 @@ void _Thread_Handler( void ) { ISR_Level level; Thread_Control *executing; -#if defined(__USE_INIT_FINI__) || defined(__USE__MAIN__) - static char doneConstructors; - char doneCons; -#endif + #if defined(EXECUTE_GLOBAL_CONSTRUCTORS) + static char doneConstructors; + char doneCons; + #endif executing = _Thread_Executing; @@ -101,78 +105,72 @@ void _Thread_Handler( void ) level = executing->Start.isr_level; _ISR_Set_level(level); -#if defined(__USE_INIT_FINI__) || defined(__USE__MAIN__) - doneCons = doneConstructors; - doneConstructors = 1; -#endif + #if defined(EXECUTE_GLOBAL_CONSTRUCTORS) + doneCons = doneConstructors; + doneConstructors = 1; + #endif -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) - if ( (executing->fp_context != NULL) && !_Thread_Is_allocated_fp( executing ) ) { - if ( _Thread_Allocated_fp != NULL ) - _Context_Save_fp( &_Thread_Allocated_fp->fp_context ); - _Thread_Allocated_fp = executing; - } -#endif -#endif + #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) + #if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) + if ( (executing->fp_context != NULL) && + !_Thread_Is_allocated_fp( executing ) ) { + if ( _Thread_Allocated_fp != NULL ) + _Context_Save_fp( &_Thread_Allocated_fp->fp_context ); + _Thread_Allocated_fp = executing; + } + #endif + #endif /* * Take care that 'begin' extensions get to complete before * 'switch' extensions can run. This means must keep dispatch * disabled until all 'begin' extensions complete. */ - _User_extensions_Thread_begin( executing ); /* * At this point, the dispatch disable level BETTER be 1. */ - _Thread_Enable_dispatch(); -#if defined(__USE_INIT_FINI__) - /* - * _init could be a weak symbol and we SHOULD test it but it isn't - * in any configuration I know of and it generates a warning on every - * RTEMS target configuration. --joel (12 May 2007) - */ - if (!doneCons) /* && (volatile void *)_init) */ - { - INIT_NAME (); - } -#endif -#if defined(__USE__MAIN__) - if (!doneCons && _main) - __main (); -#endif - switch ( executing->Start.prototype ) { - case THREAD_START_NUMERIC: - executing->Wait.return_argument = - (*(Thread_Entry_numeric) executing->Start.entry_point)( - executing->Start.numeric_argument + #if defined(EXECUTE_GLOBAL_CONSTRUCTORS) + /* + * _init could be a weak symbol and we SHOULD test it but it isn't + * in any configuration I know of and it generates a warning on every + * RTEMS target configuration. --joel (12 May 2007) + */ + if (!doneCons) /* && (volatile void *)_init) */ { + INIT_NAME (); + } + #endif + + if ( executing->Start.prototype == THREAD_START_NUMERIC ) { + executing->Wait.return_argument = + (*(Thread_Entry_numeric) executing->Start.entry_point)( + executing->Start.numeric_argument ); - break; - case THREAD_START_POINTER: - executing->Wait.return_argument = - (*(Thread_Entry_pointer) executing->Start.entry_point)( - executing->Start.pointer_argument - ); - break; - case THREAD_START_BOTH_POINTER_FIRST: + } else if ( executing->Start.prototype == THREAD_START_POINTER ) { + executing->Wait.return_argument = + (*(Thread_Entry_pointer) executing->Start.entry_point)( + executing->Start.pointer_argument + ); + } + #if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) + else if ( executing->Start.prototype == THREAD_START_BOTH_POINTER_FIRST ) { executing->Wait.return_argument = (*(Thread_Entry_both_pointer_first) executing->Start.entry_point)( executing->Start.pointer_argument, executing->Start.numeric_argument ); - break; - case THREAD_START_BOTH_NUMERIC_FIRST: + } + else if ( executing->Start.prototype == THREAD_START_BOTH_NUMERIC_FIRST ) { executing->Wait.return_argument = - (*(Thread_Entry_both_numeric_first) executing->Start.entry_point)( - executing->Start.numeric_argument, - executing->Start.pointer_argument - ); - break; - } + (*(Thread_Entry_both_numeric_first) executing->Start.entry_point)( + executing->Start.numeric_argument, + executing->Start.pointer_argument + ); + } + #endif /* * In the switch above, the return code from the user thread body -- cgit v1.2.3