1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 7 |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1997-2018 The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Anatol Belski <ab@php.net> |
16 +----------------------------------------------------------------------+
17 */
18
19 #include <config.w32.h>
20
21 #include <win32/time.h>
22 #include <win32/ioutil.h>
23 #include <php.h>
24
25 #ifdef HAVE_LIBXML
26 #include <libxml/threads.h>
27 #endif
28
29 /* TODO this file, or part of it, could be machine generated, to
30 allow extensions and SAPIs adding their own init stuff.
31 However expected is that MINIT is enough in most cases.
32 This file is only useful for some really internal stuff,
33 eq. initializing something before the DLL even is
34 available to be called. */
35
DllMain(HINSTANCE inst,DWORD reason,LPVOID dummy)36 BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
37 {
38 BOOL ret = TRUE;
39
40 switch (reason)
41 {
42 case DLL_PROCESS_ATTACH:
43 /*
44 * We do not need to check the return value of php_win32_init_gettimeofday()
45 * because the symbol bare minimum symbol we need is always available on our
46 * lowest supported platform.
47 *
48 * On Windows 8 or greater, we use a more precise symbol to obtain the system
49 * time, which is dynamically. The fallback allows us to proper support
50 * Vista/7/Server 2003 R2/Server 2008/Server 2008 R2.
51 *
52 * Instead simply initialize the global in win32/time.c for gettimeofday()
53 * use later on
54 */
55 php_win32_init_gettimeofday();
56
57 ret = ret && php_win32_ioutil_init();
58 if (!ret) {
59 fprintf(stderr, "ioutil initialization failed");
60 return ret;
61 }
62 break;
63 #if 0 /* prepared */
64 case DLL_PROCESS_DETACH:
65 /* pass */
66 break;
67
68 case DLL_THREAD_ATTACH:
69 /* pass */
70 break;
71
72 case DLL_THREAD_DETACH:
73 /* pass */
74 break;
75 #endif
76 }
77
78 #ifdef HAVE_LIBXML
79 /* This imply that only LIBXML_STATIC_FOR_DLL is supported ATM.
80 If that changes, this place will need some rework.
81 TODO Also this should be revisited as no initialization
82 might be needed for TS build (libxml build with TLS
83 support. */
84 ret = ret && xmlDllMain(inst, reason, dummy);
85 #endif
86
87 return ret;
88 }
89
90 /*
91 * Local variables:
92 * tab-width: 4
93 * c-basic-offset: 4
94 * End:
95 * vim600: sw=4 ts=4 fdm=marker
96 * vim<600: sw=4 ts=4
97 */
98