diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index ad6b69b34613e..7f820fcdc27b0 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -362,12 +362,17 @@ void *zend_shared_alloc(size_t size) return NULL; } +static zend_always_inline zend_ulong zend_rotr3(zend_ulong key) +{ + return (key >> 3) | (key << ((sizeof(key) * 8) - 3)); +} + int zend_shared_memdup_size(void *source, size_t size) { void *old_p; zend_ulong key = (zend_ulong)source; - key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/ + key = zend_rotr3(key); if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) != NULL) { /* we already duplicated this pointer */ return 0; @@ -383,7 +388,7 @@ static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, b if (get_xlat) { key = (zend_ulong)source; - key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/ + key = zend_rotr3(key); if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) != NULL) { /* we already duplicated this pointer */ return old_p; @@ -395,7 +400,7 @@ static zend_always_inline void *_zend_shared_memdup(void *source, size_t size, b if (set_xlat) { if (!get_xlat) { key = (zend_ulong)source; - key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/ + key = zend_rotr3(key); } zend_hash_index_add_new_ptr(&ZCG(xlat_table), key, retval); } @@ -535,7 +540,7 @@ void zend_shared_alloc_register_xlat_entry(const void *old, const void *new) { zend_ulong key = (zend_ulong)old; - key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/ + key = zend_rotr3(key); zend_hash_index_add_new_ptr(&ZCG(xlat_table), key, (void*)new); } @@ -544,7 +549,7 @@ void *zend_shared_alloc_get_xlat_entry(const void *old) void *retval; zend_ulong key = (zend_ulong)old; - key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/ + key = zend_rotr3(key); if ((retval = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) == NULL) { return NULL; }