summaryrefslogtreecommitdiffstats
path: root/Mac/mwerks/macuseshlstart.c
blob: d26a89fd3a15cbf6847bb20affaa7fbfbc24026f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
** mac __start for python-with-shared-library.
**
** Partially stolen from MW Startup.c, which is
**	Copyright © 1993 metrowerks inc. All Rights Reserved.
*/

#include <setjmp.h>

extern jmp_buf __program_exit;			/*	exit() does a longjmp() to here		*/
extern void (*__atexit_hook)(void);		/*	atexit()  sets this up if it is ever called	*/
extern void (*___atexit_hook)(void);	/*	_atexit() sets this up if it is ever called	*/
extern int __aborting;					/*	abort() sets this and longjmps to __program_exit	*/

void __start(void)
{
	char *argv = 0;
	
	if (setjmp(__program_exit) == 0) {	//	set up jmp_buf for exit()
		main(0, &argv);				//	call main(argc, argv)
		if (__atexit_hook)
			__atexit_hook();			//	call atexit() procs
	}
	if (!__aborting) {
		if (___atexit_hook)
			___atexit_hook();			//	call _atexit() procs
	}
//	ExitToShell();
}