summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-09-19 23:22:26 +0200
committerNikita Popov <nikic@php.net>2014-09-19 23:39:07 +0200
commit31e842472f46d8aa32e2ef316da245f18806589d (patch)
treee87882472345b757f3b898c441dc9e80e0d4364a /ext
parentad3e1830bafdcbf366f611c8778c5409bd4472d2 (diff)
downloadphp-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 'ext')
-rw-r--r--ext/standard/php_smart_str.h42
-rw-r--r--ext/standard/php_smart_string.h24
-rw-r--r--ext/standard/var.c6
3 files changed, 18 insertions, 54 deletions
diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h
index 25d6fe2db4..1c8c418370 100644
--- a/ext/standard/php_smart_str.h
+++ b/ext/standard/php_smart_str.h
@@ -50,8 +50,6 @@
smart_str_setl((dest), (src), strlen(src));
#define smart_str_append_long(dest, val) \
smart_str_append_long_ex((dest), (val), 0)
-#define smart_str_append_off_t(dest, val) \
- smart_str_append_off_t_ex((dest), (val), 0)
#define smart_str_append_unsigned(dest, val) \
smart_str_append_unsigned_ex((dest), (val), 0)
@@ -106,37 +104,21 @@ static zend_always_inline void smart_str_append_ex(smart_str *dest, const smart_
}
}
-static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) {
- smart_str_free(dest);
- smart_str_appendl(dest, src, len);
-}
-
-static inline char *smart_str_print_long(char *buf, zend_long num) {
- char *r;
- _zend_print_signed_to_buf(buf, num, zend_long, r);
- return r;
+static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_long num, zend_bool persistent) {
+ char buf[32];
+ char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num);
+ smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
-static inline char *smart_str_print_unsigned(char *buf, zend_long num) {
- char *r;
- _zend_print_unsigned_to_buf(buf, num, zend_ulong, r);
- return r;
+static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, zend_bool persistent) {
+ char buf[32];
+ char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num);
+ smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
-#define smart_str_append_generic_ex(dest, num, type, vartype, func) do { \
- char __b[32]; \
- char *__t; \
- _zend_print##func##_to_buf (__b + sizeof(__b) - 1, (num), vartype, __t); \
- smart_str_appendl_ex((dest), __t, __b + sizeof(__b) - 1 - __t, (type)); \
-} while (0)
-
-#define smart_str_append_unsigned_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), zend_ulong, _unsigned)
-
-#define smart_str_append_long_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), zend_ulong, _signed)
-
-#define smart_str_append_off_t_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), zend_off_t, _signed)
+static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) {
+ smart_str_free(dest);
+ smart_str_appendl(dest, src, len);
+}
#endif
diff --git a/ext/standard/php_smart_string.h b/ext/standard/php_smart_string.h
index 36647aa27a..e052574a34 100644
--- a/ext/standard/php_smart_string.h
+++ b/ext/standard/php_smart_string.h
@@ -89,8 +89,6 @@
smart_string_append_ex((dest), (src), 0)
#define smart_string_append_long(dest, val) \
smart_string_append_long_ex((dest), (val), 0)
-#define smart_string_append_off_t(dest, val) \
- smart_string_append_off_t_ex((dest), (val), 0)
#define smart_string_append_unsigned(dest, val) \
smart_string_append_unsigned_ex((dest), (val), 0)
@@ -119,33 +117,17 @@
__dest->len = __nl; \
} while (0)
-static inline char *smart_string_print_long(char *buf, zend_long num) {
- char *r;
- _zend_print_signed_to_buf(buf, num, zend_long, r);
- return r;
-}
-
-static inline char *smart_string_print_unsigned(char *buf, zend_long num) {
- char *r;
- _zend_print_unsigned_to_buf(buf, num, zend_ulong, r);
- return r;
-}
-
#define smart_string_append_generic_ex(dest, num, type, vartype, func) do { \
char __b[32]; \
- char *__t; \
- _zend_print##func##_to_buf(__b + sizeof(__b) - 1, (num), vartype, __t); \
+ char *__t = zend_print##func##_to_buf(__b + sizeof(__b) - 1, (num)); \
smart_string_appendl_ex((dest), __t, __b + sizeof(__b) - 1 - __t, (type)); \
} while (0)
#define smart_string_append_unsigned_ex(dest, num, type) \
- smart_string_append_generic_ex((dest), (num), (type), zend_ulong, _unsigned)
+ smart_string_append_generic_ex((dest), (num), (type), zend_ulong, _ulong)
#define smart_string_append_long_ex(dest, num, type) \
- smart_string_append_generic_ex((dest), (num), (type), zend_ulong, _signed)
-
-#define smart_string_append_off_t_ex(dest, num, type) \
- smart_string_append_generic_ex((dest), (num), (type), zend_off_t, _signed)
+ smart_string_append_generic_ex((dest), (num), (type), zend_ulong, _long)
#define smart_string_append_ex(dest, src, what) \
smart_string_appendl_ex((dest), ((smart_string *)(src))->c, \
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 9d2de3031f..532e53a110 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -611,17 +611,17 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var_ptr, zval *var
var = Z_REFVAL_P(var);
}
if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) {
- p = smart_str_print_long(id + sizeof(id) - 1,
+ p = zend_print_long_to_buf(id + sizeof(id) - 1,
(zend_long) Z_OBJ_P(var));
*(--p) = 'O';
len = id + sizeof(id) - 1 - p;
} else if (var_ptr != var) {
- p = smart_str_print_long(id + sizeof(id) - 1,
+ p = zend_print_long_to_buf(id + sizeof(id) - 1,
(zend_long) Z_REF_P(var_ptr));
*(--p) = 'R';
len = id + sizeof(id) - 1 - p;
} else {
- p = smart_str_print_long(id + sizeof(id) - 1, (zend_long) var);
+ p = zend_print_long_to_buf(id + sizeof(id) - 1, (zend_long) var);
len = id + sizeof(id) - 1 - p;
}