dllmain.c 2.8 KB

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