]> granicus.if.org Git - php/commitdiff
Don't inline slow path
authorDmitry Stogov <dmitry@zend.com>
Wed, 25 Feb 2015 22:28:47 +0000 (01:28 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 25 Feb 2015 22:28:47 +0000 (01:28 +0300)
Zend/zend_operators.c
Zend/zend_operators.h

index 0a084036b8c94c698a32b023fc09c49ce874266b..d8be615c162f0587dfeb276b6c64e04ca92a62df 100644 (file)
@@ -2870,6 +2870,38 @@ ZEND_API const char* zend_memnrstr_ex(const char *haystack, const char *needle,
 }
 /* }}} */
 
+#if !ZEND_DVAL_TO_LVAL_CAST_OK
+# if SIZEOF_ZEND_LONG == 4
+ZEND_API zend_long zend_dval_to_lval_slow(double d)
+{
+       double  two_pow_32 = pow(2., 32.),
+                       dmod;
+
+       dmod = fmod(d, two_pow_32);
+       if (dmod < 0) {
+               /* we're going to make this number positive; call ceil()
+                * to simulate rounding towards 0 of the negative number */
+               dmod = ceil(dmod);// + two_pow_32;
+       }
+       return (zend_long)(zend_ulong)dmod;
+}
+#else
+ZEND_API zend_long zend_dval_to_lval_slow(double d)
+{
+       double  two_pow_64 = pow(2., 64.),
+                       dmod;
+
+       dmod = fmod(d, two_pow_64);
+       if (dmod < 0) {
+               /* no need to call ceil; original double must have had no
+                * fractional part, hence dmod does not have one either */
+               dmod += two_pow_64;
+       }
+       return (zend_long)(zend_ulong)dmod;
+}
+#endif
+#endif
+
 /*
  * Local variables:
  * tab-width: 4
index d66f82d3645d241a3a8f4ea547229d1cd871f386..31d84fc5b1fa73a238d61153c2953471b32a4d4d 100644 (file)
@@ -108,41 +108,15 @@ static zend_always_inline zend_long zend_dval_to_lval(double d)
         return 0;
     }
 }
-#elif SIZEOF_ZEND_LONG == 4
-static zend_always_inline zend_long zend_dval_to_lval(double d)
-{
-       if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
-               return 0;
-       } else if (!ZEND_DOUBLE_FITS_LONG(d)) {
-               double  two_pow_32 = pow(2., 32.),
-                               dmod;
-
-               dmod = fmod(d, two_pow_32);
-               if (dmod < 0) {
-                       /* we're going to make this number positive; call ceil()
-                        * to simulate rounding towards 0 of the negative number */
-                       dmod = ceil(dmod) + two_pow_32;
-               }
-               return (zend_long)(zend_ulong)dmod;
-       }
-       return (zend_long)d;
-}
 #else
+ZEND_API zend_long zend_dval_to_lval_slow(double d);
+
 static zend_always_inline zend_long zend_dval_to_lval(double d)
 {
        if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
                return 0;
        } else if (!ZEND_DOUBLE_FITS_LONG(d)) {
-               double  two_pow_64 = pow(2., 64.),
-                               dmod;
-
-               dmod = fmod(d, two_pow_64);
-               if (dmod < 0) {
-                       /* no need to call ceil; original double must have had no
-                        * fractional part, hence dmod does not have one either */
-                       dmod += two_pow_64;
-               }
-               return (zend_long)(zend_ulong)dmod;
+               return zend_dval_to_lval_slow(d);
        }
        return (zend_long)d;
 }