diff options
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/threadinitialize.c | 22 | ||||
-rw-r--r-- | cpukit/score/src/threadstackfree.c | 23 |
2 files changed, 26 insertions, 19 deletions
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index c41983fc34..2f7cf370be 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -87,18 +87,26 @@ bool _Thread_Initialize( /* * Allocate and Initialize the stack for this thread. */ - if ( !stack_area ) { + #if !defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API) actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size ); if ( !actual_stack_size || actual_stack_size < stack_size ) return false; /* stack allocation failed */ stack = the_thread->Start.stack; - the_thread->Start.core_allocated_stack = true; - } else { - stack = stack_area; - actual_stack_size = stack_size; - the_thread->Start.core_allocated_stack = false; - } + #else + if ( !stack_area ) { + actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size ); + if ( !actual_stack_size || actual_stack_size < stack_size ) + return false; /* stack allocation failed */ + + stack = the_thread->Start.stack; + the_thread->Start.core_allocated_stack = true; + } else { + stack = stack_area; + actual_stack_size = stack_size; + the_thread->Start.core_allocated_stack = false; + } + #endif _Stack_Initialize( &the_thread->Start.Initial_stack, diff --git a/cpukit/score/src/threadstackfree.c b/cpukit/score/src/threadstackfree.c index ba376b8972..beede76793 100644 --- a/cpukit/score/src/threadstackfree.c +++ b/cpukit/score/src/threadstackfree.c @@ -41,23 +41,22 @@ void _Thread_Stack_Free( Thread_Control *the_thread ) { + #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API) /* * If the API provided the stack space, then don't free it. */ - if ( !the_thread->Start.core_allocated_stack ) return; + #endif - /* - * Call ONLY the CPU table stack free hook, or the - * the RTEMS workspace free. This is so the free - * routine properly matches the allocation of the stack. - */ + /* + * Call ONLY the CPU table stack free hook, or the + * the RTEMS workspace free. This is so the free + * routine properly matches the allocation of the stack. + */ - if ( Configuration.stack_free_hook ) - (*Configuration.stack_free_hook)( - the_thread->Start.Initial_stack.area - ); - else - _Workspace_Free( the_thread->Start.Initial_stack.area ); + if ( Configuration.stack_free_hook ) + (*Configuration.stack_free_hook)( the_thread->Start.Initial_stack.area ); + else + _Workspace_Free( the_thread->Start.Initial_stack.area ); } |