+static inline void php_ion_decimal_from_zend_long(ION_DECIMAL *dec, decContext *ctx, zend_long num)
+{
+ if (num <= INT32_MAX && num >= INT32_MIN) {
+ ION_CHECK(ion_decimal_from_int32(dec, num));
+ } else if (num > 0 && num <= UINT32_MAX) {
+ ION_CHECK(ion_decimal_from_uint32(dec, num));
+ } else {
+ ION_INT *iint;
+ ION_CHECK(ion_int_alloc(NULL, &iint));
+ ION_CHECK(ion_int_from_long(iint, num),
+ ion_int_free(iint));
+ /* WATCH OUT: BS API */
+ dec->type = ION_DECIMAL_TYPE_QUAD;
+ ION_CHECK(ion_decimal_from_ion_int(dec, ctx, iint),
+ ion_int_free(iint));
+ ion_int_free(iint);
+ }
+}
+