1 // 2 // Copyright (c) ZeroC, Inc. All rights reserved. 3 // 4 5 #ifndef ICE_PHP_CONFIG_H 6 #define ICE_PHP_CONFIG_H 7 8 // 9 // We need to define WIN32_LEAN_AND_MEAN to avoid redefinition errors in 10 // winsock2.h. However, we can't define the macro in the Makefile because 11 // a PHP header defines it without a surrounding #ifndef, so we have to 12 // undefine it before including the PHP header files. 13 // 14 #ifdef _WIN32 15 # define WIN32_LEAN_AND_MEAN 16 #endif 17 18 #include <Ice/Ice.h> 19 20 #ifdef _WIN32 21 # undef WIN32_LEAN_AND_MEAN 22 #endif 23 24 #ifdef _WIN32 25 #include <crtdbg.h> 26 #include <math.h> 27 #endif 28 29 #ifdef _WIN32 30 extern "C" 31 { 32 #endif 33 34 #ifdef _WIN32 35 # pragma warning( disable : 4018) // suppress signed/unsigned mismatch in zend_execute.h (PHP 5.3.x) 36 #elif defined(__GNUC__) 37 # pragma GCC diagnostic warning "-Wsign-compare" 38 #endif 39 40 #ifdef _WIN64 41 # pragma warning( disable : 4267) // suppress size_t/uint conversion warnings in zend macros for Windows x64 builds 42 #endif 43 44 #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 45 # pragma GCC diagnostic warning "-Wnarrowing" 46 #endif 47 48 #if defined(__GNUC__) && ((__GNUC__ >= 8)) 49 # pragma GCC diagnostic ignored "-Wignored-qualifiers" 50 #endif 51 52 // 53 // The php.h header defines/undefines NDEBUG based on how the PHP binary was built. 54 // As a result, asserts are always disabled unless building against a php binary 55 // built with --enable-debug. We want to enable asserts for the PHP Ice extension 56 // when it's built without OPTIMIZE=yes. We save NDEBUG in a tmp macro here and 57 // explicitly re-include the assert.h header with the saved NDEBUG macro after 58 // including php.h 59 // 60 #ifndef NDEBUG 61 #define TMPDEBUG 62 #endif 63 64 #include "php.h" 65 66 #ifdef _WIN32 67 # pragma warning( default : 4018) 68 #endif 69 70 #include "php_ini.h" 71 #include "ext/standard/info.h" 72 #include "zend_interfaces.h" 73 #include "zend_exceptions.h" 74 75 #ifdef _WIN32 76 } 77 #endif 78 79 // 80 // Enable asserts if the extension is built with debug. It's fine to include several times 81 // assert.h with a different NDEBUG setting. 82 // 83 #ifdef TMPDEBUG 84 #undef TMPDEBUG 85 #undef NDEBUG 86 #include <assert.h> 87 #endif 88 89 extern zend_module_entry ice_module_entry; 90 #define phpext_ice_ptr &ice_module_entry 91 92 #ifdef PHP_WIN32 93 #define PHP_ICE_API __declspec(dllexport) 94 #else 95 #define PHP_ICE_API 96 #endif 97 98 #ifdef ZTS 99 #include "TSRM.h" 100 #endif 101 102 ZEND_MINIT_FUNCTION(ice); 103 ZEND_MSHUTDOWN_FUNCTION(ice); 104 ZEND_RINIT_FUNCTION(ice); 105 ZEND_RSHUTDOWN_FUNCTION(ice); 106 ZEND_MINFO_FUNCTION(ice); 107 108 ZEND_BEGIN_MODULE_GLOBALS(ice) 109 void* communicatorMap; 110 void* idToClassInfoMap; 111 void* compactIdToClassInfoMap; 112 void* nameToClassInfoMap; 113 void* proxyInfoMap; 114 void* exceptionInfoMap; 115 zval* unset; 116 ZEND_END_MODULE_GLOBALS(ice) 117 118 #ifdef ZTS 119 # define ICE_G(v) TSRMG(ice_globals_id, zend_ice_globals*, v) 120 #else 121 # define ICE_G(v) (ice_globals.v) 122 #endif 123 124 #ifndef Z_ADDREF_P 125 # ifndef ZVAL_ADDREF 126 # error "Unknown PHP version" 127 # endif 128 # define Z_ADDREF_P(zv) ZVAL_ADDREF(zv) 129 #endif 130 131 #ifndef ZEND_MN 132 # define ZEND_MN(name) ZEND_FN(name) 133 #endif 134 135 // 136 // Older versions of PHP use char* instead of const char* in many APIs. 137 // 138 #ifdef STRCAST 139 # error "STRCAST already defined!" 140 #endif 141 #define STRCAST(s) const_cast<char*>(s) 142 143 #endif 144