Commit Graph

160 Commits

Author SHA1 Message Date
Ard Biesheuvel
5b121eb04d Fix #64780 (PHP 5.5 builds are broken with GCC 3)
A recent change (by me) introduced a call to __builtin_offsetof()
into zend_operators.h which is not defined by GCC prior to
version 4.

Changed the code to use offsetof() instead: this is defined in
<stddef.h>, so #include this header conditionally (#ifdef GNUC)
2013-05-07 20:37:04 +02:00
Gustavo Lopes
a86fcfbc1d Fix rounding of zend_dval_to_lval
Now rounding is always towards zero; the rounding can be though as if
occurring on the original double. Only relevant for the 32-bit long
variant.
2013-02-23 16:55:50 +00:00
Gustavo Lopes
77566edbaf Fix zend_dval_to_lval outside 64bit integers range
PHP should preserve the least significant bits when casting from double
to long. Zend.m4 contains this:

AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits])

If ZEND_DVAL_TO_LVAL_CAST_OK is not defined, zend_operators.h had an
inline implementation of zend_dval_to_lval() that would do a cast to an
int64_t (when sizeof(long) == 4), then a cast to unsigned long and
finally the cast to long.

While this works well for doubles inside the range of values of the type
used in the first cast (int64_t in the 32-bit version and unsigned long
in the 64-bit version), if outside the range, it is undefined behavior
that WILL give varying and not particularly useful results.

This commit uses fmod() to first put the double in a range that can
safely be cast to unsigned long and then casts this unsigned long to
long. This last cast is implementation defined, but it's very likely
that this gives the expected result (i.e. the internal 2's complement
representation is unchanged) on all platforms that PHP supports. In any
case, the previous implementationa already had this assumption.

This alternative code path is indeed significantly slower than simply
casting the double (almost an order of magnitude), but that should not
matter because casting doubles with a very high absolute value is a
rare event.
2013-02-23 17:23:49 +01:00
Ard Biesheuvel
aa12cdc361 Improve x86 inline assembler
- added cc annotation to inline asm that clobbers the condition
  flags
- remove hardcoded constants (IS_LONG,IS_DOUBLE)
- remove hardcoded offsets (zval->value, zval->type)
2013-02-11 13:53:27 +01:00
Remi Collet
dc47ec0490 Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  Fixed bug #64142 (dval to lval different behavior on ppc64)
2013-02-11 09:13:27 +01:00
Remi Collet
e67a2b9e47 Fixed bug #64142 (dval to lval different behavior on ppc64)
See discussion on internals
http://marc.info/?t=136042277700003&r=1&w=2
2013-02-11 09:10:51 +01:00
Remi Collet
7b75a941ef Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  revert
2013-02-05 12:29:01 +01:00
Remi Collet
e7ce002c01 revert 2013-02-05 12:28:47 +01:00
Remi Collet
79956330fe Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  Fixed bug #64142 (dval to lval different behavior on ppc64)
2013-02-04 15:27:07 +01:00
Remi Collet
6533094d9e Fixed bug #64142 (dval to lval different behavior on ppc64)
On x86_64:
(long)(double)9223372036854775807+1 = -9223372036854775808
On ppc64
(long)(double)9223372036854775807-1 = 9223372036854775807
2013-02-04 15:19:32 +01:00
Lars Strojny
92965b033a Bug #46408: Fix double formatting for PostgreSQL bound parameters 2013-01-14 21:23:52 +01:00
Xinchen Hui
a666285bc2 Happy New Year 2013-01-01 16:37:09 +08:00
Xinchen Hui
0a7395e009 Happy New Year 2013-01-01 16:28:54 +08:00
Gustavo Lopes
3d0857938d zend_binary_strncasecmp_l used w/out declaration 2012-08-26 19:44:05 +02:00
Stanislav Malyshev
47db8a9aa1 fix bug #54547 2012-05-14 11:03:20 -07:00
Stanislav Malyshev
9344bf193c fix bug #54547 2012-05-13 14:40:44 -07:00
Felipe Pena
8775a37559 - Year++ 2012-01-01 13:15:04 +00:00
Felipe Pena
4e19825281 - Year++ 2012-01-01 13:15:04 +00:00
Dmitry Stogov
16c87163f0 Fixed bug #55644 (Math ops tests fail, diff min int value) 2011-09-16 07:59:34 +00:00
Dmitry Stogov
c3741ad973 Fixed bug #55644 (Math ops tests fail, diff min int value) 2011-09-16 07:59:34 +00:00
Derick Rethans
56a87c2806 - Zend engine part for bug #55158: Add SORT_NATURAL type to array_multisort
(patch by Arpad Ray).
2011-08-29 20:24:09 +00:00
Derick Rethans
b0be274324 - Zend engine part for bug #55158: Add SORT_NATURAL type to array_multisort
(patch by Arpad Ray).
2011-08-29 20:24:09 +00:00
Gwynne Raskind
ef0e34580b For 5.4, fix C++-style comments. For trunk, forward-port build fix. 2011-08-07 16:31:21 +00:00
Gwynne Raskind
9e9c9b3430 For 5.4, fix C++-style comments. For trunk, forward-port build fix. 2011-08-07 16:31:21 +00:00
Gwynne Raskind
0af1e412a4 Fix build under Clang 2.9 - see LLVM bug #9164 (http://llvm.org/bugs/show_bug.cgi?id=9164). Tested with GCC and Clang on Darwin and Ubuntu. 2011-08-07 05:20:49 +00:00
Pierre Joye
f169f6f478 - should not have been applied 2011-07-22 11:42:15 +00:00
Pierre Joye
cc1c7af037 - remove magic quotes support, functions are kept (see the NEWS entry for the details) for BC reasons but do not allow to set enable MQ 2011-07-22 11:25:30 +00:00
Felipe Pena
5f33819f9c - Removed accidental offsetof definition 2011-07-03 01:29:23 +00:00
Felipe Pena
3e6b211935 - Removed accidental offsetof definition 2011-07-03 01:29:23 +00:00
Felipe Pena
6ef38daf0e - Fixed compiler warning (redefinition of offsetof) 2011-06-18 18:11:27 +00:00
Felipe Pena
72c4e72570 - Fixed compiler warning (redefinition of offsetof) 2011-06-18 18:11:27 +00:00
Dmitry Stogov
c270347c0b MFH: Arithmetic speedup. Inlined most probable code-paths for arithmetic operations directly into executor. 2011-05-31 12:05:25 +00:00
Dmitry Stogov
b7eb3c1c5a Arithmetic speedup. Inlined most probable code-paths for arithmetic operations directly into executor. 2011-05-23 08:05:44 +00:00
Felipe Pena
0203cc3d44 - Year++ 2011-01-01 02:17:06 +00:00
Hartmut Holzgraefe
aaa2f1c30b marked char pointer arguments as const in lots of
places where strings pointed to are not modified 
to prevent compiler warnings about discarded qualifiers ...
2010-10-14 21:33:10 +00:00
Sebastian Bergmann
d2281d1dff sed -i "s#1998-2009#1998-2010#g" **/*.c **/*.h **/*.php 2010-01-05 20:46:53 +00:00
Matt Wilmas
b907aa4331 MFH:
Restored double->long conversion behavior to that of PHP 5.2 (on most platforms) and prior:
 * Out-of-range numbers overflow/preserve least significant bits (no LONG_MAX/MIN limit)
 * See bug #42868 (presumably-rare platform with different results in 5.2)
 * On 32-bit platforms with 64-bit long type, a zend_long64 cast has been added,
    otherwise it's the same as 5.2
 * Use this conversion method everywhere instead of some plain (long) casts

Added 'L' parameter parsing specifier to ensure a LONG_MAX/MIN limit:
 * Essentially what 5.3's new conversion was doing in most cases
 * Functions with "limit" or "length" type params could be updated to use this,
    and prevent confusing overflow behavior with huge numbers (*also* in 5.2)
  - See bug #47854, for example; or even #42868 again

# Test updates coming
2009-06-04 18:20:45 +00:00
Jani Taskinen
1338aa26be sync with HEAD 2009-05-10 22:39:33 +00:00
Matt Wilmas
6bb0ac9712 MFH: Fixed bug #45877 (Array key '2147483647' left as string) 2009-03-18 01:08:12 +00:00
Felipe Pena
f8689552a4 MFH:
- Fixed bug #46701 (Creating associative array with long values in the key fails on 32bit linux)
Patch by Shire
2009-01-05 20:31:54 +00:00
Sebastian Bergmann
08659c2dcd MFH: Bump copyright year, 3 of 3. 2008-12-31 11:15:49 +00:00
Felipe Pena
cf7384aa40 - MFH: Constness (Added const qualifier to several function parameters) 2008-08-12 17:20:25 +00:00
Stanislav Malyshev
4bd1aec2f9 fix memnstr bug, by Laurent Gaffie 2008-08-05 20:14:27 +00:00
Moriyoshi Koizumi
023211d8d2 - MFH: Constify read-only arguments 2008-07-24 20:39:48 +00:00
Scott MacVicar
e19f52047c Optimisation for zend_memnstr when the needle is only a single character. (Patch by Michal Dziemianko - GSoC08) 2008-07-21 18:47:02 +00:00
Antony Dovgal
54482745ba MFH 2008-03-19 12:44:13 +00:00
Antony Dovgal
7b1bc753c6 MFH: add zend_atol() 2008-03-19 12:41:23 +00:00
Dmitry Stogov
fb50ef1aab Reverted memrchr() patch, because it is broken on linux 64-bit 2008-02-14 10:25:22 +00:00
Dmitry Stogov
9fdaddc56d Use memrchr() instead of zend_memrchr() if available. (Nuno) 2008-02-13 16:22:01 +00:00
Sebastian Bergmann
d1dded8751 MFH: Bump copyright year, 2 of 2. 2007-12-31 07:17:19 +00:00