-# define JSON_POST_LAST_ERROR() json_post_last_error(TSRMLS_C)
-static inline int json_post_last_error(TSRMLS_D)
-{
- zend_long l;
- zval *zv, **zv_ptr = &zv;
-
- ALLOC_ZVAL(zv);
- JSON_POST_G(json_last_error)->internal_function.handler(0, zv, zv_ptr, NULL, 1);
- l = Z_LVAL_P(zv);
- FREE_ZVAL(zv);
-
- return l;
-}
-#else
-# define JSON_POST_LAST_ERROR() JSON_G(error_code)
+# undef JSON_G
+# ifdef ZTS
+# define JSON_G(v) TSRMG(JSON_POST_G(json_module)->globals_id_ptr, zend_json_globals *, v)
+# else
+# define JSON_G(v) ((zend_json_globals *) JSON_POST_G(json_module)->globals_ptr)->v
+# endif