Mercurial > ecos
annotate packages/language/c/libc/current/src/support/mainthread.cxx @ 44:41bd4f3a90de ecos-sw-1999-10-08
Merge from eCos master repository on 1999-10-08-07:47:04-BST
| author | jlarmour |
|---|---|
| date | Fri, 08 Oct 1999 13:16:25 +0000 |
| parents | 443894e2e912 |
| children | c38311975d4f |
| rev | line source |
|---|---|
| 2 | 1 //======================================================================= |
| 2 // | |
| 3 // mainthread.cxx | |
| 4 // | |
| 5 // Support for startup of ISO C environment | |
| 6 // | |
| 7 //======================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. | |
| 26 // ------------------------------------------- | |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //======================================================================== | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): jlarmour | |
| 33 // Contributors: jlarmour | |
| 34 // Date: 1999-01-21 | |
| 35 // Purpose: Provides a thread object to call into a user-supplied | |
| 36 // main() | |
| 37 // Description: Here we define the thread object that calls | |
| 38 // cyg_libc_invoke_main() which in turn will invoke | |
| 39 // the user-supplied main() entry point function (or | |
| 40 // alternatively the dummy empty one supplied by eCos) | |
| 41 // Usage: Both the stack (cyg_libc_main_stack) and the thread | |
| 42 // (cyg_libc_main_thread) can be overriden if you provide | |
| 43 // your own symbols with those names. In the case of the | |
| 44 // stack obviously you need to ensure | |
| 45 // CYGNUM_LIBC_MAIN_STACK_SIZE corresponds to your own | |
| 46 // stack. | |
| 47 // The thread object is also available externally if you | |
| 48 // want to control it (suspend/resume/etc.) either by | |
| 49 // extern Cyg_Thread cyg_libc_main_thread; from C++, using | |
| 50 // the kernel C++ API, or | |
| 51 // extern cyg_handle_t cyg_libc_main_thread; from C using | |
| 52 // the kernel C API. | |
| 53 // | |
| 54 //####DESCRIPTIONEND#### | |
| 55 // | |
| 56 //======================================================================== | |
| 57 | |
| 58 // CONFIGURATION | |
| 59 | |
| 60 #include <pkgconf/libc.h> // C library configuration | |
| 61 | |
| 62 #ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD | |
| 63 | |
| 64 // INCLUDES | |
| 65 | |
| 66 #include <cyg/infra/cyg_type.h> // Common type definitions and support | |
| 67 #include <pkgconf/kernel.h> // eCos kernel configuration | |
| 68 #include <cyg/kernel/thread.hxx> // eCos thread support | |
| 69 #include <cyg/kernel/thread.inl> | |
| 70 #include <cyg/hal/hal_arch.h> // for CYGNUM_HAL_STACK_SIZE_TYPICAL | |
| 71 | |
| 72 | |
| 73 // EXTERNS | |
| 74 | |
| 75 #ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS | |
| 76 extern cyg_bool cyg_hal_stop_constructors; | |
| 77 #endif | |
| 78 | |
| 79 // FUNCTION PROTOTYPES | |
| 80 | |
| 81 externC void | |
| 82 cyg_libc_invoke_main( CYG_ADDRWORD ); | |
| 83 | |
| 84 // STATICS | |
| 85 | |
| 86 #ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS | |
| 87 class cyg_libc_dummy_constructor_class { | |
| 88 public: | |
| 89 cyg_libc_dummy_constructor_class(void) { ++cyg_hal_stop_constructors; } | |
| 90 }; | |
| 91 | |
| 92 static cyg_libc_dummy_constructor_class cyg_libc_dummy_constructor_obj | |
| 93 CYG_INIT_PRIORITY(PREDEFAULT); | |
| 94 #endif | |
| 95 | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
96 #ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
97 |
| 2 | 98 // override stack size on some platforms |
| 99 #ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
100 # if CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_TYPICAL |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
101 # undef CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
102 # define CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL |
| 2 | 103 # endif |
| 104 #endif | |
| 105 | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
106 static cyg_uint8 cyg_libc_main_stack[ CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE ]; |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
107 |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
108 #else // !ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
109 |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
110 extern char *cyg_libc_main_stack; |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
111 extern int cyg_libc_main_stack_size; |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
112 |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
113 #endif // !ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM |
| 2 | 114 |
| 115 // GLOBALS | |
| 116 | |
| 117 // let the main thread be global so people can play with it (e.g. suspend | |
| 118 // or resume etc.) if that's what they want to do | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
119 Cyg_Thread cyg_libc_main_thread CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) = |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
120 Cyg_Thread(CYGNUM_LIBC_MAIN_THREAD_PRIORITY, |
| 2 | 121 &cyg_libc_invoke_main, (CYG_ADDRWORD) 0, |
| 122 "main", | |
|
44
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
123 (CYG_ADDRESS) &cyg_libc_main_stack[0], |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
124 #ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
125 CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
126 #else |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
127 cyg_libc_main_stack_size |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
128 #endif |
|
41bd4f3a90de
Merge from eCos master repository on 1999-10-08-07:47:04-BST
jlarmour
parents:
2
diff
changeset
|
129 ); |
| 2 | 130 |
| 131 #endif // ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD | |
| 132 | |
| 133 // EOF mainthread.cxx |
