summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadhandler.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-10 09:09:19 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-13 14:30:22 +0200
commita38ced268314dfe3f61cbba5b982eeb77c2b8de4 (patch)
tree2fa13257e71eb2d5e391d8bc2a95f74a2d6fce74 /cpukit/score/src/threadhandler.c
parentarm/nds: Warning clean up (diff)
downloadrtems-a38ced268314dfe3f61cbba5b982eeb77c2b8de4.tar.bz2
score: Rework global construction
Ensure that the global construction is performed in the context of the first initialization thread. On SMP this was not guaranteed in the previous implementation.
Diffstat (limited to 'cpukit/score/src/threadhandler.c')
-rw-r--r--cpukit/score/src/threadhandler.c84
1 files changed, 2 insertions, 82 deletions
diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c
index 5f6623f11f..f8a9a62429 100644
--- a/cpukit/score/src/threadhandler.c
+++ b/cpukit/score/src/threadhandler.c
@@ -24,76 +24,11 @@
#include <rtems/score/isrlevel.h>
#include <rtems/score/userextimpl.h>
-/*
- * Conditional magic to determine what style of C++ constructor
- * initialization this target and compiler version uses.
- */
-#if defined(__USE_INIT_FINI__)
- #if defined(__M32R__)
- #define INIT_NAME __init
- #elif defined(__ARM_EABI__)
- #define INIT_NAME __libc_init_array
- #else
- #define INIT_NAME _init
- #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
-
-#if defined(EXECUTE_GLOBAL_CONSTRUCTORS)
- static bool _Thread_Handler_is_constructor_execution_required(
- Thread_Control *executing
- )
- {
- static bool doneConstructors;
- bool doCons = false;
-
- #if defined(RTEMS_SMP)
- static SMP_lock_Control constructor_lock =
- SMP_LOCK_INITIALIZER("constructor");
-
- SMP_lock_Context lock_context;
-
- if ( !doneConstructors ) {
- _SMP_lock_Acquire( &constructor_lock, &lock_context );
- #endif
-
- #if defined(RTEMS_MULTIPROCESSING)
- doCons = !doneConstructors
- && _Objects_Get_API( executing->Object.id ) != OBJECTS_INTERNAL_API;
- if (doCons)
- doneConstructors = true;
- #else
- (void) executing;
- doCons = !doneConstructors;
- doneConstructors = true;
- #endif
-
- #if defined(RTEMS_SMP)
- _SMP_lock_Release( &constructor_lock, &lock_context );
- }
- #endif
-
- return doCons;
- }
-#endif
-
void _Thread_Handler( void )
{
- ISR_Level level;
- Thread_Control *executing;
- #if defined(EXECUTE_GLOBAL_CONSTRUCTORS)
- bool doCons;
- #endif
+ Thread_Control *executing = _Thread_Executing;
+ ISR_Level level;
- executing = _Thread_Executing;
/*
* Some CPUs need to tinker with the call frame or registers when the
@@ -111,10 +46,6 @@ void _Thread_Handler( void )
_ISR_Set_level( level );
#endif
- #if defined(EXECUTE_GLOBAL_CONSTRUCTORS)
- doCons = _Thread_Handler_is_constructor_execution_required( executing );
- #endif
-
/*
* Initialize the floating point context because we do not come
* through _Thread_Dispatch on our first invocation. So the normal
@@ -171,17 +102,6 @@ void _Thread_Handler( void )
_Thread_Enable_dispatch();
#endif
- #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 (doCons) /* && (volatile void *)_init) */ {
- INIT_NAME ();
- }
- #endif
-
/*
* RTEMS supports multiple APIs and each API can define a different
* thread/task prototype. The following code supports invoking the