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