PHP_MINIT_FUNCTION(ion)
{
- // globals
- php_ion_decimal_ctx_init_max(&g_dec_ctx, DEC_ROUND_HALF_EVEN);
+ // true globals
php_ion_decimal_from_zend_long(&g_ion_dec_zend_max, &g_dec_ctx, ZEND_LONG_MAX);
php_ion_decimal_from_zend_long(&g_ion_dec_zend_min, &g_dec_ctx, ZEND_LONG_MIN);
PHP_GINIT_FUNCTION(ion)
{
memset(ion_globals, 0, sizeof(*ion_globals));
+
+ php_ion_decimal_ctx_init_max(&ion_globals->decimal_ctx, DEC_ROUND_HALF_EVEN);
}
PHP_GSHUTDOWN_FUNCTION(ion)
{
ZEND_BEGIN_MODULE_GLOBALS(ion)
+ decContext decimal_ctx;
+
php_ion_serializer serializer;
php_ion_unserializer unserializer;
}
result = 1;
- ion_decimal_compare(&obj->dec, &g_ion_dec_zend_max, &g_dec_ctx, &result);
+ ion_decimal_compare(&obj->dec, &g_ion_dec_zend_max, &php_ion_globals.decimal_ctx, &result);
if (result == 1) {
return false;
}
result = -1;
- ion_decimal_compare(&obj->dec, &g_ion_dec_zend_min, &g_dec_ctx, &result);
+ ion_decimal_compare(&obj->dec, &g_ion_dec_zend_min, &php_ion_globals.decimal_ctx, &result);
if (result == -1) {
return false;
}
static inline zend_long php_usec_from_ion(const decQuad *frac, decContext *ctx)
{
if (!ctx) {
- ctx = &g_dec_ctx;
+ ctx = &php_ion_globals.decimal_ctx;
}
decQuad microsecs, result;
decQuadMultiply(&result, decQuadFromInt32(µsecs, 1000000), frac, ctx);
static inline decQuad *ion_ts_frac_from_usec(decQuad *frac, zend_long usec, decContext *ctx)
{
if (!ctx) {
- ctx = &g_dec_ctx;
+ ctx = &php_ion_globals.decimal_ctx;
}
decQuad microsecs, us;
return decQuadDivide(frac, decQuadFromInt32(&us, usec), decQuadFromInt32(µsecs, 1000000), ctx);