dllmain.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include <config.w32.h>
  19. #include <win32/time.h>
  20. #include <win32/ioutil.h>
  21. #include <php.h>
  22. #ifdef HAVE_LIBXML
  23. #include <libxml/threads.h>
  24. #endif
  25. /* TODO this file, or part of it, could be machine generated, to
  26. allow extensions and SAPIs adding their own init stuff.
  27. However expected is that MINIT is enough in most cases.
  28. This file is only useful for some really internal stuff,
  29. eq. initializing something before the DLL even is
  30. available to be called. */
  31. BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
  32. {
  33. BOOL ret = TRUE;
  34. switch (reason)
  35. {
  36. case DLL_PROCESS_ATTACH:
  37. /*
  38. * We do not need to check the return value of php_win32_init_gettimeofday()
  39. * because the symbol bare minimum symbol we need is always available on our
  40. * lowest supported platform.
  41. *
  42. * On Windows 8 or greater, we use a more precise symbol to obtain the system
  43. * time, which is dynamically. The fallback allows us to proper support
  44. * Vista/7/Server 2003 R2/Server 2008/Server 2008 R2.
  45. *
  46. * Instead simply initialize the global in win32/time.c for gettimeofday()
  47. * use later on
  48. */
  49. php_win32_init_gettimeofday();
  50. ret = ret && php_win32_ioutil_init();
  51. if (!ret) {
  52. fprintf(stderr, "ioutil initialization failed");
  53. return ret;
  54. }
  55. break;
  56. #if 0 /* prepared */
  57. case DLL_PROCESS_DETACH:
  58. /* pass */
  59. break;
  60. case DLL_THREAD_ATTACH:
  61. /* pass */
  62. break;
  63. case DLL_THREAD_DETACH:
  64. /* pass */
  65. break;
  66. #endif
  67. }
  68. #ifdef HAVE_LIBXML
  69. /* This imply that only LIBXML_STATIC_FOR_DLL is supported ATM.
  70. If that changes, this place will need some rework.
  71. TODO Also this should be revisited as no initialization
  72. might be needed for TS build (libxml build with TLS
  73. support. */
  74. ret = ret && xmlDllMain(inst, reason, dummy);
  75. #endif
  76. return ret;
  77. }
  78. /*
  79. * Local variables:
  80. * tab-width: 4
  81. * c-basic-offset: 4
  82. * End:
  83. * vim600: sw=4 ts=4 fdm=marker
  84. * vim<600: sw=4 ts=4
  85. */