|
92 | 92 | # define ARG_UNUSED |
93 | 93 | #endif |
94 | 94 |
|
95 | | -#if SIZEOF_LONG == 4 |
96 | | -# define ADD_INDEX_INT64(zval, index, value) \ |
97 | | - if (value > LONG_MAX || value < LONG_MIN) { \ |
98 | | - char *tmp; \ |
99 | | - int tmp_len; \ |
100 | | - mongoc_log(MONGOC_LOG_LEVEL_WARNING, MONGOC_LOG_DOMAIN, "Integer overflow detected on your platform: %lld", value); \ |
101 | | - tmp_len = spprintf(&tmp, 0, "%lld", value); \ |
102 | | - ADD_INDEX_STRINGL(zval, index, tmp, tmp_len); \ |
103 | | - efree(tmp); \ |
104 | | - } else { \ |
105 | | - add_index_long(zval, index, val); \ |
106 | | - } |
107 | | -# define ADD_ASSOC_INT64(zval, key, value) \ |
108 | | - if (value > LONG_MAX || value < LONG_MIN) { \ |
109 | | - char *tmp; \ |
110 | | - int tmp_len; \ |
111 | | - mongoc_log(MONGOC_LOG_LEVEL_WARNING, MONGOC_LOG_DOMAIN, "Integer overflow detected on your platform: %lld", value); \ |
112 | | - tmp_len = spprintf(&tmp, 0, "%lld", value); \ |
113 | | - ADD_ASSOC_STRINGL(zval, key, tmp, tmp_len); \ |
114 | | - efree(tmp); \ |
115 | | - } else { \ |
116 | | - add_assoc_long(zval, key, value); \ |
117 | | - } |
118 | | -#else |
119 | | -# define ADD_INDEX_INT64(zval, index, value) add_index_long(zval, index, value) |
120 | | -# define ADD_ASSOC_INT64(zval, key, value) add_assoc_long(zval, key, value); |
121 | | -#endif |
122 | | - |
123 | 95 | #ifdef HAVE_ATOLL |
124 | 96 | # define STRTOLL(s) atoll(s) |
125 | 97 | #else |
|
151 | 123 | # define phongo_char zend_string |
152 | 124 | # define phongo_char_pdup(str) pestrdup(filename->val, 1) |
153 | 125 | # define phongo_char_free(str) zend_string_release(str) |
| 126 | +# define phongo_long zend_long |
| 127 | +# define SIZEOF_PHONGO_LONG SIZEOF_ZEND_LONG |
154 | 128 | # define phongo_str(str) str->val |
155 | 129 | # define phongo_create_object_retval zend_object* |
156 | 130 | # define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t)+zend_object_properties_size(_class_type)) |
|
178 | 152 | # define phongo_char char |
179 | 153 | # define phongo_char_pdup(str) pestrdup(filename, 1) |
180 | 154 | # define phongo_char_free(str) _efree(str ZEND_FILE_LINE_CC ZEND_FILE_LINE_CC) |
| 155 | +# define phongo_long long |
| 156 | +# define SIZEOF_PHONGO_LONG SIZEOF_LONG |
181 | 157 | # define phongo_str(str) str |
182 | 158 | # define phongo_create_object_retval zend_object_value |
183 | 159 | # define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t)) |
|
206 | 182 | # define PHP_STREAM_CONTEXT(stream) ((php_stream_context*) (stream)->context) |
207 | 183 | #endif |
208 | 184 |
|
| 185 | +#if SIZEOF_PHONGO_LONG == 8 |
| 186 | +# define ADD_INDEX_INT64(zval, index, value) add_index_long(zval, index, value) |
| 187 | +# define ADD_ASSOC_INT64(zval, key, value) add_assoc_long(zval, key, value) |
| 188 | +#elif SIZEOF_PHONGO_LONG == 4 |
| 189 | +# define ADD_INDEX_INT64(zval, index, value) \ |
| 190 | + if (value > INT32_MAX || value < INT32_MIN) { \ |
| 191 | + char *tmp; \ |
| 192 | + int tmp_len; \ |
| 193 | + mongoc_log(MONGOC_LOG_LEVEL_WARNING, MONGOC_LOG_DOMAIN, "Integer overflow detected on your platform: %lld", value); \ |
| 194 | + tmp_len = spprintf(&tmp, 0, "%lld", value); \ |
| 195 | + ADD_INDEX_STRINGL(zval, index, tmp, tmp_len); \ |
| 196 | + efree(tmp); \ |
| 197 | + } else { \ |
| 198 | + add_index_long(zval, index, val); \ |
| 199 | + } |
| 200 | +# define ADD_ASSOC_INT64(zval, key, value) \ |
| 201 | + if (value > INT32_MAX || value < INT32_MIN) { \ |
| 202 | + char *tmp; \ |
| 203 | + int tmp_len; \ |
| 204 | + mongoc_log(MONGOC_LOG_LEVEL_WARNING, MONGOC_LOG_DOMAIN, "Integer overflow detected on your platform: %lld", value); \ |
| 205 | + tmp_len = spprintf(&tmp, 0, "%lld", value); \ |
| 206 | + ADD_ASSOC_STRING_EX(zval, key, strlen(key), tmp, tmp_len); \ |
| 207 | + efree(tmp); \ |
| 208 | + } else { \ |
| 209 | + add_assoc_long(zval, key, value); \ |
| 210 | + } |
| 211 | +#else |
| 212 | +# error Unsupported architecture (integers are neither 32-bit nor 64-bit) |
| 213 | +#endif |
209 | 214 |
|
210 | 215 | void *x509_from_zval(zval *zval TSRMLS_DC); |
211 | 216 | void phongo_add_exception_prop(const char *prop, int prop_len, zval *value TSRMLS_DC); |
|
0 commit comments