From: Anatol Belski Date: Wed, 24 Jan 2018 17:21:24 +0000 (+0100) Subject: Macrify the common operation X-Git-Tag: php-7.3.0alpha1~548 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92f9fde23af79c2c08005935ed256720e0da3552;p=php Macrify the common operation --- diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index f89258e0d6..6901a75c43 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -540,6 +540,9 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */ # define ZEND_SET_ALIGNED(alignment, decl) decl #endif +#define ZEND_SLIDE_TO_ALIGNED(alignment, ptr) (((zend_uintptr_t)(ptr) + ((alignment)-1)) & ~((alignment)-1)) +#define ZEND_SLIDE_TO_ALIGNED16(ptr) ZEND_SLIDE_TO_ALIGNED(Z_UL(16), ptr) + #endif /* ZEND_PORTABILITY_H */ /* diff --git a/ext/standard/string.c b/ext/standard/string.c index cd2b028741..02f78a4f0e 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3922,7 +3922,7 @@ zend_string *php_addslashes_sse42(zend_string *str, int should_free) end = source + ZSTR_LEN(str); if (ZSTR_LEN(str) > 15) { - char *aligned = (char*)(((zend_uintptr_t)source + 15) & ~15); + char *aligned = (char*) ZEND_SLIDE_TO_ALIGNED16(source); if (UNEXPECTED(source != aligned)) { do { @@ -3997,7 +3997,7 @@ do_escape: } source += 16; } else if (end - source > 15) { - char *aligned = (char*)(((zend_uintptr_t)source + 15) & ~15); + char *aligned = (char*) ZEND_SLIDE_TO_ALIGNED16(source); if (source != aligned) { do {