- rtems/score/threadimpl.h: _Thread_Start_multitasking does return on Scheduler Simulator. Initializing RTEMS returns to the command interpreter.
- rtems/score/smpimpl.h: _SMP_Start_multitasking_on_secondary_processor() is not applicable on the Scheduler Simulator and the no return attribute gives a warning. - rtems/score/assert.h: Scheduler Simulator uses glibc assert.h on GNU/Linux. This will likely need to be adjusted more for other host compilers and C libraries - threadrestart.c: Disable assert on Scheduler Simulator. Restarting self returns to the command interpreter. --- cpukit/score/include/rtems/score/assert.h | 20 ++++++++++++++++---- cpukit/score/include/rtems/score/smpimpl.h | 9 ++++++++- cpukit/score/include/rtems/score/threadimpl.h | 7 +++++++ cpukit/score/src/threadrestart.c | 9 ++++++++- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/cpukit/score/include/rtems/score/assert.h b/cpukit/score/include/rtems/score/assert.h index 41ef1ae..d1971d2 100644 --- a/cpukit/score/include/rtems/score/assert.h +++ b/cpukit/score/include/rtems/score/assert.h @@ -28,12 +28,24 @@ extern "C" { /** * @brief Assertion similar to assert() controlled via RTEMS_DEBUG instead of * NDEBUG. + * + * __ASSERT_FUNC is newlib. __ASSERT_FUNCTION is glibc. */ #if defined( RTEMS_DEBUG ) - #define _Assert( _e ) \ - ( ( _e ) ? \ - ( void ) 0 : \ - __assert_func( __FILE__, __LINE__, __ASSERT_FUNC, #_e ) ) + #if defined(__ASSERT_FUNC) + #define _Assert( _e ) \ + ( ( _e ) ? \ + ( void ) 0 : \ + __assert_func( __FILE__, __LINE__, __ASSERT_FUNC, #_e ) ) + #elif defined(__ASSERT_FUNCTION) + #define _Assert( _e ) \ + ( ( _e ) ? \ + ( void ) 0 : \ + __assert_fail( #_e, __FILE__, __LINE__, __ASSERT_FUNCTION ) ) + #else + #error "What does assert.h use?" + #endif + #else #define _Assert( _e ) ( ( void ) 0 ) #endif diff --git a/cpukit/score/include/rtems/score/smpimpl.h b/cpukit/score/include/rtems/score/smpimpl.h index 70475ba..1ed4a4f 100644 --- a/cpukit/score/include/rtems/score/smpimpl.h +++ b/cpukit/score/include/rtems/score/smpimpl.h @@ -105,10 +105,17 @@ static inline void _SMP_Fatal( SMP_Fatal_code code ) * This function must not be called by the main processor. The main processor * uses _Thread_Start_multitasking() instead. * - * This function does not return to the caller. + * In a "real system", this function does not return to the caller. + * But on the Scheduler Simulator, this method actually returns since + * there are no context switches in that environment. */ +#ifdef RTEMS_SCHEDSIM +void _SMP_Start_multitasking_on_secondary_processor( void ); +#else void _SMP_Start_multitasking_on_secondary_processor( void ) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE; +#endif + typedef void ( *SMP_Test_message_handler )( Per_CPU_Control *cpu_self ); diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 2be5cc5..35257df 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -97,8 +97,15 @@ void _Thread_Create_idle(void); * This routine initiates multitasking. It is invoked only as * part of initialization and its invocation is the last act of * the non-multitasking part of the system initialization. + * + * @note On the Scheduler Simulator, this method actually returns. + * There are no true context switches in that environment. */ +#ifdef RTEMS_SCHEDSIM +void _Thread_Start_multitasking( void ); +#else void _Thread_Start_multitasking( void ) RTEMS_COMPILER_NO_RETURN_ATTRIBUTE; +#endif /** * @brief Allocate the requested stack space for the thread. diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index 5c527d8..7c1f77e 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -189,7 +189,14 @@ void _Thread_Life_action_handler( _Thread_Enable_dispatch(); - _Assert_Not_reached(); + /* + * On the Scheduler Simulator, there are real context switches -- only + * the bookkeeping. So the "thread of execution" really does return here. + * We need to return to the invoking environment. + */ + #ifndef RTEMS_SCHEDSIM + _Assert_Not_reached(); + #endif } else { _Assert( _Thread_Is_life_restarting( previous_life_state ) ); -- 1.7.1 _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel