1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Thread Global Construction |
---|
5 | * |
---|
6 | * @ingroup ScoreThread |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2012. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/score/threadimpl.h> |
---|
23 | #include <rtems/score/assert.h> |
---|
24 | #include <rtems/config.h> |
---|
25 | |
---|
26 | /* |
---|
27 | * Conditional magic to determine what style of C++ constructor |
---|
28 | * initialization this target and compiler version uses. |
---|
29 | */ |
---|
30 | #if defined(__USE_INIT_FINI__) |
---|
31 | #if defined(__M32R__) |
---|
32 | #define INIT_NAME __init |
---|
33 | #elif defined(__ARM_EABI__) |
---|
34 | #define INIT_NAME __libc_init_array |
---|
35 | #else |
---|
36 | #define INIT_NAME _init |
---|
37 | #endif |
---|
38 | |
---|
39 | extern void INIT_NAME(void); |
---|
40 | #define EXECUTE_GLOBAL_CONSTRUCTORS |
---|
41 | #endif |
---|
42 | |
---|
43 | #if defined(__USE__MAIN__) |
---|
44 | extern void __main(void); |
---|
45 | #define INIT_NAME __main |
---|
46 | #define EXECUTE_GLOBAL_CONSTRUCTORS |
---|
47 | #endif |
---|
48 | |
---|
49 | void *_Thread_Global_construction( void ) |
---|
50 | { |
---|
51 | Thread_Control *executing; |
---|
52 | Thread_Entry entry_point; |
---|
53 | |
---|
54 | #if defined(EXECUTE_GLOBAL_CONSTRUCTORS) |
---|
55 | /* |
---|
56 | * _init could be a weak symbol and we SHOULD test it but it isn't |
---|
57 | * in any configuration I know of and it generates a warning on every |
---|
58 | * RTEMS target configuration. --joel (12 May 2007) |
---|
59 | */ |
---|
60 | INIT_NAME(); |
---|
61 | #endif |
---|
62 | |
---|
63 | #if defined(RTEMS_POSIX_API) |
---|
64 | if ( Configuration_RTEMS_API.number_of_initialization_tasks > 0 ) { |
---|
65 | #endif |
---|
66 | entry_point = (Thread_Entry) |
---|
67 | Configuration_RTEMS_API.User_initialization_tasks_table[ 0 ].entry_point; |
---|
68 | #if defined(RTEMS_POSIX_API) |
---|
69 | } else { |
---|
70 | entry_point = (Thread_Entry) |
---|
71 | Configuration_POSIX_API |
---|
72 | .User_initialization_threads_table[ 0 ].thread_entry; |
---|
73 | } |
---|
74 | #endif |
---|
75 | |
---|
76 | _Thread_Disable_dispatch(); |
---|
77 | |
---|
78 | executing = _Thread_Executing; |
---|
79 | executing->Start.entry_point = entry_point; |
---|
80 | |
---|
81 | _Thread_Restart( |
---|
82 | executing, |
---|
83 | executing, |
---|
84 | executing->Start.pointer_argument, |
---|
85 | executing->Start.numeric_argument |
---|
86 | ); |
---|
87 | |
---|
88 | _Thread_Enable_dispatch(); |
---|
89 | |
---|
90 | _Assert_Not_reached(); |
---|
91 | |
---|
92 | return NULL; |
---|
93 | } |
---|