This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop double initialisation of malloc_mutex:
[perl5.git] / win32 / perllib.c
1 /*
2  * "The Road goes ever on and on, down from the door where it began."
3  */
4
5
6 #include "EXTERN.h"
7 #include "perl.h"
8 #include "XSUB.h"
9
10 static void xs_init _((void));
11
12 __declspec(dllexport) int
13 RunPerl(int argc, char **argv, char **env, void *iosubsystem)
14 {
15     int exitstatus;
16     PerlInterpreter *my_perl;
17
18     PERL_SYS_INIT(&argc,&argv);
19
20     perl_init_i18nl10n(1);
21
22     if (!(my_perl = perl_alloc()))
23         return (1);
24     perl_construct( my_perl );
25     perl_destruct_level = 0;
26
27     exitstatus = perl_parse( my_perl, xs_init, argc, argv, env);
28     if (!exitstatus) {
29         exitstatus = perl_run( my_perl );
30     }
31
32     perl_destruct( my_perl );
33     perl_free( my_perl );
34
35     PERL_SYS_TERM();
36
37     return (exitstatus);
38 }
39
40 extern HANDLE PerlDllHandle;
41
42 BOOL APIENTRY
43 DllMain(HANDLE hModule,         /* DLL module handle */
44         DWORD fdwReason,        /* reason called */
45         LPVOID lpvReserved)     /* reserved */
46
47     switch (fdwReason) {
48         /* The DLL is attaching to a process due to process
49          * initialization or a call to LoadLibrary.
50          */
51     case DLL_PROCESS_ATTACH:
52 /* #define DEFAULT_BINMODE */
53 #ifdef DEFAULT_BINMODE
54         setmode( fileno( stdin  ), O_BINARY );
55         setmode( fileno( stdout ), O_BINARY );
56         setmode( fileno( stderr ), O_BINARY );
57         _fmode = O_BINARY;
58 #endif
59         PerlDllHandle = hModule;
60         break;
61
62         /* The DLL is detaching from a process due to
63          * process termination or call to FreeLibrary.
64          */
65     case DLL_PROCESS_DETACH:
66         break;
67
68         /* The attached process creates a new thread. */
69     case DLL_THREAD_ATTACH:
70         break;
71
72         /* The thread of the attached process terminates. */
73     case DLL_THREAD_DETACH:
74         break;
75
76     default:
77         break;
78     }
79     return TRUE;
80 }
81
82 /* Register any extra external extensions */
83
84 char *staticlinkmodules[] = {
85     "DynaLoader",
86     NULL,
87 };
88
89 EXTERN_C void boot_DynaLoader _((CV* cv));
90
91 static void
92 xs_init()
93 {
94     char *file = __FILE__;
95     dXSUB_SYS;
96     newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
97 }
98