blob: dbf9c98d003019a6721bde1a617037c337fd3cf7 [file] [log] [blame]
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00001/*
Andrew MacIntyre0c833482003-04-22 03:21:42 +00002 * This is the entry point for the Python 2.3 core DLL.
3 */
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00004
5#define NULL 0
6
Andrew MacIntyre0c833482003-04-22 03:21:42 +00007#define REF(s) extern void s(); void *____ref_##s = &s;
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00008
Andrew MacIntyre0c833482003-04-22 03:21:42 +00009/* Make references to imported symbols to pull them from static library */
10REF(Py_Main);
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000011
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000012#include <signal.h>
13
Andrew MacIntyre0c833482003-04-22 03:21:42 +000014extern int _CRT_init(void);
15extern void _CRT_term(void);
16extern void __ctordtorInit(void);
17extern void __ctordtorTerm(void);
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000018
Andrew MacIntyre0c833482003-04-22 03:21:42 +000019unsigned long _DLL_InitTerm(unsigned long mod_handle, unsigned long flag)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000020{
Andrew MacIntyred65778a2002-12-31 11:23:50 +000021 switch (flag)
22 {
23 case 0:
Andrew MacIntyre0c833482003-04-22 03:21:42 +000024 if (_CRT_init())
Andrew MacIntyred65778a2002-12-31 11:23:50 +000025 return 0;
Andrew MacIntyre0c833482003-04-22 03:21:42 +000026 __ctordtorInit();
Andrew MacIntyred65778a2002-12-31 11:23:50 +000027
28 /* Ignore fatal signals */
Andrew MacIntyre0c833482003-04-22 03:21:42 +000029 signal(SIGSEGV, SIG_IGN);
30 signal(SIGFPE, SIG_IGN);
Andrew MacIntyred65778a2002-12-31 11:23:50 +000031
32 return 1;
33
34 case 1:
Andrew MacIntyre0c833482003-04-22 03:21:42 +000035 __ctordtorTerm();
36 _CRT_term();
Andrew MacIntyred65778a2002-12-31 11:23:50 +000037 return 1;
38
39 default:
40 return 0;
41 }
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000042}