OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [language/] [c/] [libc/] [startup/] [v2_0/] [src/] [invokemain.cxx] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//=======================================================================
2
//
3
//      invokemain.cxx
4
//
5
//      Support for startup of ISO C environment
6
//
7
//========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):     jlarmour
44
// Contributors:  
45
// Date:          2000-04-30
46
// Purpose:       Provide entry point for thread which then calls main()
47
// Description:   cyg_libc_invoke_main() is used as the entry point for
48
//                the thread object that is created to call the
49
//                user-supplied main() function. It sets up the arguments
50
//                (if any) and invokes exit() if main() returns
51
// Usage:       
52
//
53
//####DESCRIPTIONEND####
54
//
55
//========================================================================
56
 
57
// CONFIGURATION
58
 
59
#include <pkgconf/libc_startup.h>  // Configuration header
60
#include <pkgconf/isoinfra.h>
61
 
62
// INCLUDES
63
 
64
#include <cyg/infra/cyg_type.h>    // Common type definitions and support
65
#include <cyg/infra/cyg_trac.h>    // Common tracing support
66
#include <cyg/infra/cyg_ass.h>     // Common assertion support
67
#include <stdlib.h>                // exit()
68
 
69
// EXTERNS
70
 
71
externC cyg_bool cyg_hal_stop_constructors;
72
 
73
// FUNCTION PROTOTYPES
74
 
75
externC int
76
main( int argc, char *argv[] );
77
 
78
externC void
79
cyg_hal_invoke_constructors(void);
80
 
81
externC void
82
pthread_exit( void *value_ptr );
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
                                  CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_PREDEFAULT);
94
#endif
95
 
96
// FUNCTIONS
97
 
98
externC void
99
cyg_libc_invoke_main( CYG_ADDRWORD )
100
{
101
    CYG_REPORT_FUNCNAME( "cyg_libc_invoke_main" );
102
    CYG_REPORT_FUNCARG1( "argument is %s", "ignored" );
103
 
104
#ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS
105
    // finish invoking constructors that weren't called by default
106
    cyg_hal_invoke_constructors();
107
#endif
108
 
109
    // argv[argc] must be NULL according to the ISO C standard 5.1.2.2.1
110
    char *temp_argv[] = CYGDAT_LIBC_ARGUMENTS ;
111
    int rc;
112
 
113
    rc = main( (sizeof(temp_argv)/sizeof(char *)) - 1, &temp_argv[0] );
114
 
115
    CYG_TRACE1( true, "main() has returned with code %d. Calling exit()",
116
                rc );
117
 
118
#ifdef CYGINT_ISO_PTHREAD_IMPL
119
    // It is up to pthread_exit() to call exit() if needed
120
    pthread_exit( (void *)rc );
121
    CYG_FAIL( "pthread_exit() returned!!!" );
122
#else
123
    exit(rc);
124
    CYG_FAIL( "exit() returned!!!" );
125
#endif
126
 
127
    CYG_REPORT_RETURN();
128
 
129
} // cyg_libc_invoke_main()
130
 
131
// EOF invokemain.cxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.