diff options
| author | Nikita Popov <nikic@php.net> | 2014-09-19 23:22:26 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2014-09-19 23:39:07 +0200 |
| commit | 31e842472f46d8aa32e2ef316da245f18806589d (patch) | |
| tree | e87882472345b757f3b898c441dc9e80e0d4364a /Zend/zend_operators.h | |
| parent | ad3e1830bafdcbf366f611c8778c5409bd4472d2 (diff) | |
| download | php-git-31e842472f46d8aa32e2ef316da245f18806589d.tar.gz | |
Make number printing functions less generic
Now that zend_ulong is 64bit on 64bit platforms, it should be
sufficient to always use it, rather than supporting multiple
types.
API changes:
* _zend_print_unsigned_to_buf and _zend_print_signed_to_buf
no longer exist.
* smart_str(ing)_print_long and smart_str(ing)_print_unsigned
no longer exist.
* Instead of all these, zend_print_ulong_to_buf and
zend_print_long_to_buf should be used.
* smart_str_append_generic_ex no longer exists.
* smart_str(ing)_append_off_t(_ex) no longer exists, use
smart_str(ing)_append_long(_ex) instead.
Diffstat (limited to 'Zend/zend_operators.h')
| -rw-r--r-- | Zend/zend_operators.h | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index ece77936eb..ddec162174 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -894,27 +894,26 @@ static zend_always_inline void fast_is_not_identical_function(zval *result, zval return SUCCESS; \ } -/* input: buf points to the END of the buffer */ -#define _zend_print_unsigned_to_buf(buf, num, vartype, result) do { \ - char *__p = (buf); \ - vartype __num = (num); \ - *__p = '\0'; \ - do { \ - *--__p = (char) (__num % 10) + '0'; \ - __num /= 10; \ - } while (__num > 0); \ - result = __p; \ -} while (0) +/* buf points to the END of the buffer */ +static zend_always_inline char *zend_print_ulong_to_buf(char *buf, zend_ulong num) { + *buf = '\0'; + do { + *--buf = (char) (num % 10) + '0'; + num /= 10; + } while (num > 0); + return buf; +} /* buf points to the END of the buffer */ -#define _zend_print_signed_to_buf(buf, num, vartype, result) do { \ - if (num < 0) { \ - _zend_print_unsigned_to_buf((buf), (~((vartype)(num)) + 1), vartype, (result)); \ - *--(result) = '-'; \ - } else { \ - _zend_print_unsigned_to_buf((buf), (num), vartype, (result)); \ - } \ -} while (0) +static zend_always_inline char *zend_print_long_to_buf(char *buf, zend_long num) { + if (num < 0) { + char *result = zend_print_ulong_to_buf(buf, ~((zend_ulong) num) + 1); + *--result = '-'; + return result; + } else { + return zend_print_ulong_to_buf(buf, num); + } +} ZEND_API zend_string *zend_long_to_str(zend_long num); |
