diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-08-11 11:38:41 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-08-11 11:38:41 +0400 |
commit | 4c716e8b516146f0a10b0b89078ccd096a8b4b7b (patch) | |
tree | f1bf735d4233ce2bf87763f5acc51ae1f1a3d489 /ext/standard/math.c | |
parent | 0ae305e62dad7542f7917823dac967488bcaffe2 (diff) | |
parent | 97bb078bddef9ad0921d886c75ce6a77206145e3 (diff) | |
download | php-git-4c716e8b516146f0a10b0b89078ccd096a8b4b7b.tar.gz |
Merge branch 'master' into test
* master: (39 commits)
Add __debugInfo() to UPGRADING.
fix TS build
Update NEWS
Update NEWS
Update NEWS
Small tidy ups and raise visibility of GitHub PR process
Bug #41631: Observe socket read timeouts in SSL streams
wrap int8_t and int16_t with #ifdef to avoid possible clashes
- Updated to version 2014.6 (2014f)
Removed Countable::count() change info from UPGRADE.INTERNALS too
NEWS and UPGRADING for intdiv()
Revert "Add SO_REUSEPORT + SO_BROADCAST support via socket stream context option"
Fixed skip case for intdiv 64-bit test
Use callback structure
Add EXPECTF
Fix handling of multi-result sets with PS...used to clean not only the result set but the whole PS.
5.5.17 now
5.4.33-dev now
Add SO_REUSEPORT + SO_BROADCAST support via socket stream context option
Add SO_REUSEPORT + SO_BROADCAST support via socket stream context option
...
Conflicts:
ext/fileinfo/libmagic/softmagic.c
main/streams/xp_socket.c
Diffstat (limited to 'ext/standard/math.c')
-rw-r--r-- | ext/standard/math.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/ext/standard/math.c b/ext/standard/math.c index 06723216c6..74ebb83379 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -1406,7 +1406,28 @@ PHP_FUNCTION(fmod) } /* }}} */ - +/* {{{ proto int intdiv(int numerator, int divisor) + Returns the integer division of the numerator by the divisor */ +PHP_FUNCTION(intdiv) +{ + long numerator, divisor; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &numerator, &divisor) == FAILURE) { + return; + } + + if (divisor == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero"); + RETURN_BOOL(0); + } else if (divisor == -1 && numerator == LONG_MIN) { + /* Prevent overflow error/crash + We don't return a float here as that violates function contract */ + RETURN_LONG(0); + } + + RETURN_LONG(numerator/divisor); +} +/* }}} */ /* * Local variables: |