comparison packages/language/c/libc/startup/current/src/cstartup.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 // cstartup.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:
38 // Description:
39 // Usage:
40 //
41 //####DESCRIPTIONEND####
42 //
43 //========================================================================
44
45 // CONFIGURATION
46
47 #include <pkgconf/system.h> // CYGPKG_KERNEL
48 #include <pkgconf/libc_startup.h> // Configuration header
49
50 // INCLUDES
51
52 #include <cyg/infra/cyg_type.h> // Common type definitions and support
53 #include <cyg/infra/cyg_trac.h> // Common tracing support
54
55 #ifdef CYGPKG_KERNEL
56 # include <pkgconf/kernel.h> // eCos kernel configuration
57 # include <cyg/kernel/thread.hxx> // eCos thread support
58 # include <cyg/kernel/thread.inl>
59 #endif
60
61
62 // FUNCTION PROTOTYPES
63
64 externC void
65 cyg_libc_invoke_main( CYG_ADDRWORD );
66
67 // EXTERNS
68
69 #ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD
70 extern Cyg_Thread cyg_libc_main_thread;
71
72 // FUNCTIONS
73
74 externC void
75 cyg_iso_c_start( void )
76 {
77 static int initialized=0;
78
79 CYG_REPORT_FUNCNAME( "cyg_iso_c_start" );
80 CYG_REPORT_FUNCARGVOID();
81
82 if (initialized++ == 0) {
83 CYG_TRACE0( true, "Resuming cyg_libc_main_thread" );
84 cyg_libc_main_thread.resume();
85 }
86 CYG_REPORT_RETURN();
87
88 } // cyg_iso_c_start()
89
90 // define an object that will automatically call cyg_iso_c_start()
91
92 class cyg_libc_startup_dummy_constructor_class {
93 public:
94 cyg_libc_startup_dummy_constructor_class() { cyg_iso_c_start(); }
95 };
96
97 static cyg_libc_startup_dummy_constructor_class cyg_libc_startup_obj
98 CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC);
99
100 #elif defined( CYGSEM_LIBC_STARTUP_MAIN_INITCONTEXT )
101
102 // otherwise replace the default cyg_user_start(), but of course keep
103 // it a weak symbol in case the user wants to override
104
105 externC void
106 cyg_user_start(void) CYGBLD_ATTRIB_WEAK;
107
108 externC void
109 cyg_user_start(void)
110 {
111 cyg_libc_invoke_main(0);
112 }
113
114 externC void
115 cyg_iso_c_start( void )
116 {
117 static int initialized=0;
118
119 CYG_REPORT_FUNCNAME( "cyg_iso_c_start" );
120 CYG_REPORT_FUNCARGVOID();
121
122 // In case they want to explicitly invoke the C library from
123 // cyg_user_start() themselves
124 if (initialized++ == 0) {
125 cyg_libc_invoke_main(0);
126 }
127 CYG_REPORT_RETURN();
128 }
129 #else
130
131 externC void
132 cyg_iso_c_start( void ) {}
133
134 #endif
135
136 // EOF cstartup.cxx