muimaster.library: remove weird check that causes halt when application has to rememb...
[AROS.git] / compiler / startup / startup.c
blob73dee08f72facf7b7202b3bb32f4efaf0a1ff534
2 /*
3 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
4 $Id$
6 Desc: Common startup code
7 Lang: english
8 */
9 #define DEBUG 0
11 #include <aros/config.h>
12 #include <dos/dos.h>
13 #include <exec/memory.h>
14 #include <workbench/startup.h>
15 #include <proto/exec.h>
16 #include <proto/dos.h>
17 #include <aros/asmcall.h>
18 #include <aros/debug.h>
19 #include <aros/symbolsets.h>
20 #include <aros/startup.h>
22 struct DosLibrary *DOSBase;
23 extern const LONG const __aros_libreq_DOSBase __attribute__((weak));
25 THIS_PROGRAM_HANDLES_SYMBOLSET(PROGRAM_ENTRIES)
27 extern int main(int argc, char ** argv);
28 int (*__main_function_ptr)(int argc, char ** argv) __attribute__((__weak__)) = main;
30 /* if the programmer hasn't defined a symbol with the name __nocommandline
31 then the code to handle the commandline will be included from the autoinit.lib
33 extern int __nocommandline;
34 asm(".set __importcommandline, __nocommandline");
36 /* if the programmer hasn't defined a symbol with the name __nostdiowin
37 then the code to open a window for stdio will be included from the autoinit.lib
39 extern int __nostdiowin;
40 asm(".set __importstdiowin, __nostdiowin");
42 /* if the programmer hasn't defined a symbol with the name __nowbsupport
43 then the code to handle support for programs started from WB will be included from
44 the autoinit.lib
46 extern int __nowbsupport;
47 asm(".set __importnowbsupport, __nowbsupport");
49 /* if the programmer hasn't defined a symbol with the name __noinitexitsets
50 then the code to handle support for calling the INIT, EXIT symbolset functions
51 and the autoopening of libraries is called from the autoinit.lib
53 extern int __noinitexitsets;
54 asm(".set __importnoinitexitsets, __noinitexitsets");
56 extern void __startup_entries_init(void);
58 /* Guarantee that __startup_entry is placed at the beginning of the binary */
59 __startup AROS_PROCH(__startup_entry, argstr, argsize, SysBase)
61 AROS_PROCFUNC_INIT
63 D(bug("Entering __startup_entry(\"%s\", %d, %x)\n", argstr, argsize, SysBase));
66 No one program will be able to do anything useful without the dos.library,
67 so we open it here instead of using the automatic opening system
69 DOSBase = (struct DosLibrary *)OpenLibrary(DOSNAME, 0);
70 if (!DOSBase) return RETURN_FAIL;
71 if (((struct Library *)DOSBase)->lib_Version < __aros_libreq_DOSBase)
72 return RETURN_FAIL;
74 __argstr = argstr;
75 __argsize = argsize;
76 __startup_error = RETURN_FAIL;
78 __startup_entries_init();
79 __startup_entries_next();
81 CloseLibrary((struct Library *)DOSBase);
83 D(bug("Leaving __startup_entry\n"));
85 return __startup_error;
87 AROS_PROCFUNC_EXIT
88 } /* entry */
91 static void __startup_main(struct ExecBase *SysBase)
93 D(bug("Entering __startup_main\n"));
95 /* Invoke the main function. A weak symbol is used as function name so that
96 it can be overridden (for *nix stuff, for instance). */
97 __startup_error = (*__main_function_ptr) (__argc, __argv);
99 D(bug("Leaving __startup_main\n"));
102 ADD2SET(__startup_main, PROGRAM_ENTRIES, 127);
106 Stub function for GCC __main().
108 The __main() function is originally used for C++ style constructors
109 and destructors in C. This replacement does nothing and gets rid of
110 linker-errors about references to __main().
112 #ifdef AROS_NEEDS___MAIN
113 void __main(void)
115 /* Do nothing. */
117 #endif