blob: 32b808a50a7cb3c84bbecb14da13ccb7abce741c [file] [log] [blame]
Jack Jansen7467ce31995-02-13 11:41:40 +00001/*
2** mac __start for python-with-shared-library.
3**
4** Partially stolen from MW Startup.c, which is
5** Copyright © 1993 metrowerks inc. All Rights Reserved.
6*/
7
8#include <setjmp.h>
9
Jack Janseneb263681996-02-20 16:26:19 +000010#ifdef PRE_CW8
Jack Jansen7467ce31995-02-13 11:41:40 +000011extern jmp_buf __program_exit; /* exit() does a longjmp() to here */
12extern void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */
13extern void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */
14extern int __aborting; /* abort() sets this and longjmps to __program_exit */
Jack Janseneb263681996-02-20 16:26:19 +000015#endif
16
17/*
18 * clear_stackframe_backlink - set 0(SP) to 0
19 *
20 */
21
22static asm void clear_stackframe_backlink(void)
23{
24 li r3,0
25 stw r3,0(SP)
26 blr
27}
Jack Jansen7467ce31995-02-13 11:41:40 +000028
29void __start(void)
30{
31 char *argv = 0;
32
Jack Janseneb263681996-02-20 16:26:19 +000033#ifdef PRE_CW8
Jack Jansen7467ce31995-02-13 11:41:40 +000034 if (setjmp(__program_exit) == 0) { // set up jmp_buf for exit()
35 main(0, &argv); // call main(argc, argv)
36 if (__atexit_hook)
37 __atexit_hook(); // call atexit() procs
38 }
39 if (!__aborting) {
40 if (___atexit_hook)
41 ___atexit_hook(); // call _atexit() procs
42 }
43// ExitToShell();
Jack Janseneb263681996-02-20 16:26:19 +000044#else
45 clear_stackframe_backlink();
46 main(0, &argv);
47 exit(0);
48#endif
Jack Jansen7467ce31995-02-13 11:41:40 +000049}