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 // 49 // Ignore redundant redeclarations from php 5.3 php-output.h header. 50 // 51 #if defined(__GNUC__) && PHP_VERSION_ID < 50400 52 # pragma GCC diagnostic ignored "-Wredundant-decls" 53 #endif 54 55 // 56 // The php.h header defines/undefines NDEBUG based on how the PHP binary was built. 57 // As a result, asserts are always disabled unless building against a php binary 58 // built with --enable-debug. We want to enable asserts for the PHP Ice extension 59 // when it's built without OPTIMIZE=yes. We save NDEBUG in a tmp macro here and 60 // explicitly re-include the assert.h header with the saved NDEBUG macro after 61 // including php.h 62 // 63 #ifndef NDEBUG 64 #define TMPDEBUG 65 #endif 66 67 #include "php.h" 68 69 #ifdef _WIN32 70 # pragma warning( default : 4018) 71 #endif 72 73 #include "php_ini.h" 74 #include "ext/standard/info.h" 75 #include "zend_interfaces.h" 76 #include "zend_exceptions.h" 77 78 #ifdef _WIN32 79 } 80 #endif 81 82 // 83 // Enable asserts if the extension is built with debug. It's fine to include several times 84 // assert.h with a different NDEBUG setting. 85 // 86 #ifdef TMPDEBUG 87 #undef TMPDEBUG 88 #undef NDEBUG 89 #include <assert.h> 90 #endif 91 92 extern zend_module_entry ice_module_entry; 93 #define phpext_ice_ptr &ice_module_entry 94 95 #ifdef PHP_WIN32 96 #define PHP_ICE_API __declspec(dllexport) 97 #else 98 #define PHP_ICE_API 99 #endif 100 101 #ifdef ZTS 102 #include "TSRM.h" 103 #endif 104 105 // 106 // The PHP header files define a macro named "inline". 107 // 108 #ifdef inline 109 # undef inline 110 #endif 111 112 ZEND_MINIT_FUNCTION(ice); 113 ZEND_MSHUTDOWN_FUNCTION(ice); 114 ZEND_RINIT_FUNCTION(ice); 115 ZEND_RSHUTDOWN_FUNCTION(ice); 116 ZEND_MINFO_FUNCTION(ice); 117 118 ZEND_BEGIN_MODULE_GLOBALS(ice) 119 void* communicatorMap; 120 void* idToClassInfoMap; 121 void* compactIdToClassInfoMap; 122 void* nameToClassInfoMap; 123 void* proxyInfoMap; 124 void* exceptionInfoMap; 125 zval* unset; 126 ZEND_END_MODULE_GLOBALS(ice) 127 128 #ifdef ZTS 129 # define ICE_G(v) TSRMG(ice_globals_id, zend_ice_globals*, v) 130 #else 131 # define ICE_G(v) (ice_globals.v) 132 #endif 133 134 #ifndef Z_ADDREF_P 135 # ifndef ZVAL_ADDREF 136 # error "Unknown PHP version" 137 # endif 138 # define Z_ADDREF_P(zv) ZVAL_ADDREF(zv) 139 #endif 140 141 #ifndef ZEND_MN 142 # define ZEND_MN(name) ZEND_FN(name) 143 #endif 144 145 // 146 // Older versions of PHP use char* instead of const char* in many APIs. 147 // 148 #ifdef STRCAST 149 # error "STRCAST already defined!" 150 #endif 151 #define STRCAST(s) const_cast<char*>(s) 152 153 #endif 154