Skip to content

Commit 92f9fde

Browse files
committed
Macrify the common operation
1 parent 4aa864c commit 92f9fde

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Zend/zend_portability.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
540540
# define ZEND_SET_ALIGNED(alignment, decl) decl
541541
#endif
542542

543+
#define ZEND_SLIDE_TO_ALIGNED(alignment, ptr) (((zend_uintptr_t)(ptr) + ((alignment)-1)) & ~((alignment)-1))
544+
#define ZEND_SLIDE_TO_ALIGNED16(ptr) ZEND_SLIDE_TO_ALIGNED(Z_UL(16), ptr)
545+
543546
#endif /* ZEND_PORTABILITY_H */
544547

545548
/*

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,7 +3922,7 @@ zend_string *php_addslashes_sse42(zend_string *str, int should_free)
39223922
end = source + ZSTR_LEN(str);
39233923

39243924
if (ZSTR_LEN(str) > 15) {
3925-
char *aligned = (char*)(((zend_uintptr_t)source + 15) & ~15);
3925+
char *aligned = (char*) ZEND_SLIDE_TO_ALIGNED16(source);
39263926

39273927
if (UNEXPECTED(source != aligned)) {
39283928
do {
@@ -3997,7 +3997,7 @@ zend_string *php_addslashes_sse42(zend_string *str, int should_free)
39973997
}
39983998
source += 16;
39993999
} else if (end - source > 15) {
4000-
char *aligned = (char*)(((zend_uintptr_t)source + 15) & ~15);
4000+
char *aligned = (char*) ZEND_SLIDE_TO_ALIGNED16(source);
40014001

40024002
if (source != aligned) {
40034003
do {

0 commit comments

Comments
 (0)