comparison packages/language/c/libc/startup/current/src/mainthread.cxx @ 115:6ed91473a1cd ecos-sw-2000-08-21

Merge from eCos master repository on 2000-08-21-22:40:54-BST
author jlarmour
date Fri, 25 Aug 2000 17:32:38 +0000
parents
children e0c0827131d1
comparison
equal deleted inserted replaced
114:5ad2b71d525e 115:6ed91473a1cd
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 Red Hat eCos Public License
12 // Version 1.1 (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://www.redhat.com/
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 Configurable Operating System,
22 // released September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Red Hat.
25 // Portions created by Red Hat are
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
27 // All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //========================================================================
32 //#####DESCRIPTIONBEGIN####
33 //
34 // Author(s): jlarmour
35 // Contributors:
36 // Date: 2000-04-30
37 // Purpose: Provides a thread object to call into a user-supplied
38 // main()
39 // Description: Here we define the thread object that calls
40 // cyg_libc_invoke_main() which in turn will invoke
41 // the user-supplied main() entry point function (or
42 // alternatively the dummy empty one supplied by eCos)
43 // Usage: Both the stack (cyg_libc_main_stack) and the thread
44 // (cyg_libc_main_thread) can be overriden if you provide
45 // your own symbols with those names. In the case of the
46 // stack obviously you need to ensure
47 // CYGNUM_LIBC_MAIN_STACK_SIZE corresponds to your own
48 // stack.
49 // The thread object is also available externally if you
50 // want to control it (suspend/resume/etc.) either by
51 // extern Cyg_Thread cyg_libc_main_thread; from C++, using
52 // the kernel C++ API, or
53 // extern cyg_handle_t cyg_libc_main_thread; from C using
54 // the kernel C API.
55 //
56 //####DESCRIPTIONEND####
57 //
58 //========================================================================
59
60 // CONFIGURATION
61
62 #include <pkgconf/libc_startup.h> // C library configuration
63
64 #ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD
65
66 // INCLUDES
67
68 #include <cyg/infra/cyg_type.h> // Common type definitions and support
69 #include <pkgconf/kernel.h> // eCos kernel configuration
70 #include <cyg/kernel/thread.hxx> // eCos thread support
71 #include <cyg/kernel/thread.inl>
72 #include <cyg/hal/hal_arch.h> // for CYGNUM_HAL_STACK_SIZE_TYPICAL
73
74
75 // EXTERNS
76
77 #ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS
78 extern cyg_bool cyg_hal_stop_constructors;
79 #endif
80
81 // FUNCTION PROTOTYPES
82
83 externC void
84 cyg_libc_invoke_main( CYG_ADDRWORD );
85
86 // STATICS
87
88 #ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
89
90 // override stack size on some platforms
91 #ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL
92 # if CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_TYPICAL
93 # undef CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE
94 # define CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
95 # endif
96 #endif
97
98 static cyg_uint8 cyg_libc_main_stack[ CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE ];
99
100 #else // !ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
101
102 extern char *cyg_libc_main_stack;
103 extern int cyg_libc_main_stack_size;
104
105 #endif // !ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
106
107 // GLOBALS
108
109 // let the main thread be global so people can play with it (e.g. suspend
110 // or resume etc.) if that's what they want to do
111 Cyg_Thread cyg_libc_main_thread CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) =
112 Cyg_Thread(CYGNUM_LIBC_MAIN_THREAD_PRIORITY,
113 &cyg_libc_invoke_main, (CYG_ADDRWORD) 0,
114 "main",
115 (CYG_ADDRESS) &cyg_libc_main_stack[0],
116 #ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
117 CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE
118 #else
119 cyg_libc_main_stack_size
120 #endif
121 );
122
123 #endif // ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD
124
125 // EOF mainthread.cxx