comparison packages/language/c/libc/current/src/support/invokemain.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 c38311975d4f
comparison
equal deleted inserted replaced
1:72f549f0d891 2:443894e2e912
1 //=======================================================================
2 //
3 // invokemain.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: Provide entry point for thread which then calls main()
36 // Description: cyg_libc_invoke_main() is used as the entry point for
37 // the thread object that is created to call the
38 // user-supplied main() function. It sets up the arguments
39 // (if any) and invokes exit() if main() returns
40 // Usage:
41 //
42 //####DESCRIPTIONEND####
43 //
44 //========================================================================
45
46 // CONFIGURATION
47
48 #include <pkgconf/libc.h> // C library configuration
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 #include <cyg/infra/cyg_ass.h> // Common assertion support
55 #include "clibincl/stdlibsupp.hxx" // __libc_exit() ( i.e. exit() )
56
57 // FUNCTION PROTOTYPES
58
59 externC int
60 main( int argc, char *argv[] );
61
62 externC void
63 cyg_hal_invoke_constructors(void);
64
65 // FUNCTIONS
66
67 externC void
68 cyg_libc_invoke_main( CYG_ADDRWORD )
69 {
70 CYG_REPORT_FUNCNAME( "cyg_libc_invoke_main" );
71 CYG_REPORT_FUNCARG1( "argument is %s", "ignored" );
72
73 #ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS
74 // finish invoking constructors that weren't called by default
75 cyg_hal_invoke_constructors();
76 #endif
77
78 // argv[argc] must be NULL according to the ISO C standard 5.1.2.2.1
79 char *temp_argv[] = CYGDAT_LIBC_ARGUMENTS ;
80 int rc;
81
82 rc = main( (sizeof(temp_argv)/sizeof(char *)) - 1, &temp_argv[0] );
83
84 CYG_TRACE1( true, "main() has returned with code %d. Calling exit()",
85 rc );
86
87 __libc_exit(rc);
88
89 CYG_FAIL( "__libc_exit() returned!!!" );
90
91 CYG_REPORT_RETURN();
92
93 } // invoke_main();
94
95 // EOF invokemain.cxx