|
41 | 41 | #include "php_phongo.h" |
42 | 42 | #include "php_bson.h" |
43 | 43 |
|
44 | | - |
45 | | -#define BSON_APPEND_INT32(b,key,val) \ |
46 | | - bson_append_int32 (b, key, (int) strlen (key), val) |
47 | | - |
48 | | -#if SIZEOF_LONG == 8 |
49 | | -# define BSON_APPEND_INT(b, key, keylen, val) \ |
50 | | - if (val > INT_MAX || val < INT_MIN) { \ |
51 | | - bson_append_int64(b, key, keylen, val); \ |
52 | | - } else { \ |
53 | | - bson_append_int32(b, key, keylen, val); \ |
54 | | - } |
55 | | -#elif SIZEOF_LONG == 4 |
56 | | -# define BSON_APPEND_INT(b, key, keylen, val) \ |
57 | | - bson_append_int32(b, key, keylen, val); |
58 | | -#endif |
59 | | - |
60 | 44 | #undef MONGOC_LOG_DOMAIN |
61 | 45 | #define MONGOC_LOG_DOMAIN "PHONGO-BSON" |
62 | 46 |
|
@@ -1005,7 +989,17 @@ static void phongo_bson_append(bson_t *bson, php_phongo_bson_flags_t flags, cons |
1005 | 989 | #endif |
1006 | 990 |
|
1007 | 991 | case IS_LONG: |
1008 | | - BSON_APPEND_INT(bson, key, key_len, Z_LVAL_P(entry)); |
| 992 | +#if SIZEOF_LONG == 8 || (PHP_VERSION_ID >= 70000 && SIZEOF_ZEND_LONG == 8) |
| 993 | + if (val > INT_MAX || val < INT_MIN) { |
| 994 | + bson_append_int64(bson, key, keylen, Z_LVAL_P(entry)); |
| 995 | + } else { |
| 996 | + bson_append_int32(bson, key, keylen, Z_LVAL_P(entry)); |
| 997 | + } |
| 998 | +#elif SIZEOF_LONG == 4 || (PHP_VERSION_ID >= 70000 && SIZEOF_ZEND_LONG == 4) |
| 999 | + bson_append_int32(bson, key, keylen, Z_LVAL_P(entry)); |
| 1000 | +#else |
| 1001 | +#error Need fix for this architecture |
| 1002 | +#endif |
1009 | 1003 | break; |
1010 | 1004 |
|
1011 | 1005 | case IS_DOUBLE: |
|
0 commit comments