annotate src/build-msvctools/libgfortran-dllinit.c @ 3061:f8299bb6c872

Initial support for native MSVC compilation. * add MSVC support files: compiler wrappers and support libraries * adapt libiconv to work with MSVC * adapt gettext to work with MSVC
author Michael Goffioul <michael.goffioul@gmail.com>
date Mon, 17 Jun 2013 22:43:11 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3061
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
1 #include <stdlib.h>
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
2 #include <stdio.h>
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
3 #define WIN32_LEAN_AND_MEAN
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
4 #include <windows.h>
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
5
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
6 extern void _gfortrani_init_variables (void);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
7 extern void _gfortrani_init_units (void);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
8 extern void _gfortrani_close_units (void);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
9 extern void _gfortrani_set_fpu (void);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
10 extern void _gfortrani_init_compile_options (void);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
11 extern void _gfortran_random_seed_i4 (void *a, void *b, void *c);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
12 extern int _gfortrani_big_endian;
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
13
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
14 extern void __msvc_free_exe_path (void);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
15
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
16 static void __cdecl __msvc_init (void)
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
17 {
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
18 _gfortrani_big_endian = 0;
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
19 _gfortrani_init_variables ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
20 _gfortrani_init_units ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
21 _gfortrani_set_fpu ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
22 _gfortrani_init_compile_options ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
23 _gfortran_random_seed_i4 (NULL, NULL, NULL);
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
24 }
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
25
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
26 static void __cdecl __msvc_cleanup (void)
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
27 {
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
28 _gfortrani_close_units ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
29 __msvc_free_exe_path ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
30 }
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
31
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
32 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwreason, LPVOID lpvReserved)
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
33 {
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
34 switch (fdwreason)
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
35 {
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
36 case DLL_PROCESS_ATTACH:
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
37 __msvc_init ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
38 break;
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
39 case DLL_PROCESS_DETACH:
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
40 __msvc_cleanup ();
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
41 break;
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
42 default:
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
43 break;
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
44 }
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
45
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
46 return TRUE;
f8299bb6c872 Initial support for native MSVC compilation.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
47 }