Mercurial > ecos
comparison packages/language/c/libc/current/src/support/mainthread.cxx @ 2:443894e2e912 ecos-v1_2_1-release
Block commit of eCos version 1.2.1
| author | jlarmour |
|---|---|
| date | Tue, 11 May 1999 12:24:34 +0000 |
| parents | |
| children | 41bd4f3a90de |
comparison
equal
deleted
inserted
replaced
| 1:72f549f0d891 | 2:443894e2e912 |
|---|---|
| 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 | |
| 96 // override stack size on some platforms | |
| 97 #ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL | |
| 98 # if CYGNUM_LIBC_MAIN_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_TYPICAL | |
| 99 # undef CYGNUM_LIBC_MAIN_STACK_SIZE | |
| 100 # define CYGNUM_LIBC_MAIN_STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL | |
| 101 # endif | |
| 102 #endif | |
| 103 | |
| 104 // Make this weak so that users can override this from their own code | |
| 105 // if they really want. FIXME: but its still allocated | |
| 106 cyg_uint8 cyg_libc_main_stack[ CYGNUM_LIBC_MAIN_STACK_SIZE ] | |
| 107 CYGBLD_ATTRIB_WEAK; | |
| 108 | |
| 109 // GLOBALS | |
| 110 | |
| 111 // let the main thread be global so people can play with it (e.g. suspend | |
| 112 // or resume etc.) if that's what they want to do | |
| 113 Cyg_Thread cyg_libc_main_thread CYGBLD_ATTRIB_WEAK CYG_INIT_PRIORITY(LIBC) = | |
| 114 Cyg_Thread(CYG_SCHED_DEFAULT_INFO, | |
| 115 &cyg_libc_invoke_main, (CYG_ADDRWORD) 0, | |
| 116 "main", | |
| 117 (CYG_ADDRESS) &cyg_libc_main_stack, | |
| 118 CYGNUM_LIBC_MAIN_STACK_SIZE); | |
| 119 | |
| 120 #endif // ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD | |
| 121 | |
| 122 // EOF mainthread.cxx |
