Skip to content

Commit 8623d4f

Browse files
committed
Use memcmp() for consistency
1 parent d749db6 commit 8623d4f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

‎ext/opcache/jit/tls/zend_jit_tls_x86.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,23 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
117117
/* Check if the general dynamic code was relaxed by the linker */
118118

119119
// addl any,%ebx
120-
if (code[0] != 0x81 || code[1] != 0xc3) {
120+
if (memcmp(&code[0], "\x81\xc3", 2) != 0) {
121121
uint64_t bytes;
122122
memcpy(&bytes, &code[0], 8);
123123
zend_accel_error(ACCEL_LOG_DEBUG, "addl insn does not match: 0x%16" PRIx64 "\n", bytes);
124124
goto code_changed;
125125
}
126126

127127
// leal any(,%ebx,1),%eax
128-
if (code[6] != 0x8d || code[7] != 0x04 || code[8] != 0x1d) {
128+
if (memcmp(&code[6], "\x8d\x04\x1d", 3) != 0) {
129129
uint64_t bytes;
130130
memcpy(&bytes, &code[6], 8);
131131
zend_accel_error(ACCEL_LOG_DEBUG, "leal insn does not match: 0x%16" PRIx64 "\n", bytes);
132132
goto code_changed;
133133
}
134134

135135
// call any
136-
if (code[13] != 0xe8) {
136+
if (memcmp(&code[13], "\xe8", 1) != 0) {
137137
uint64_t bytes;
138138
memcpy(&bytes, &code[13], 8);
139139
zend_accel_error(ACCEL_LOG_DEBUG, "call insn does not match: 0x%16" PRIx64 "\n", bytes);
@@ -189,7 +189,7 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
189189
}
190190

191191
// subl $any,%eax
192-
if (code[12] != 0x81 || code[13] != 0xe8) {
192+
if (memcmp(&code[12], "\x81\xe8", 2) != 0) {
193193
uint64_t bytes;
194194
memcpy(&bytes, &code[6], 8);
195195
zend_accel_error(ACCEL_LOG_DEBUG, "subl insn does not match: 0x%16" PRIx64 "\n", bytes);

‎ext/opcache/jit/tls/zend_jit_tls_x86_64.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
113113
/* Check if the general dynamic code was relaxed by the linker */
114114

115115
// data16 leaq any(%rip),%rdi
116-
if (code[0] != 0x66 || code[1] != 0x48 || code[2] != 0x8d || code[3] != 0x3d) {
116+
if (memcmp(&code[0], "\x66\x48\x8d\x3d", 4) != 0) {
117117
uint64_t bytes;
118118
memcpy(&bytes, &code[0], 8);
119119
zend_accel_error(ACCEL_LOG_DEBUG, "leaq insn does not match: 0x%016" PRIx64 "\n", bytes);
120120
goto code_changed;
121121
}
122122

123123
// data16 data16 rex.W call any
124-
if (code[8] != 0x66 || code[9] != 0x66 || code[10] != 0x48 || code[11] != 0xe8) {
124+
if (memcmp(&code[8], "\x66\x66\x48\xe8", 4) != 0) {
125125
uint64_t bytes;
126126
memcpy(&bytes, &code[8], 8);
127127
zend_accel_error(ACCEL_LOG_DEBUG, "call insn does not match: 0x%016" PRIx64 "\n", bytes);
@@ -172,7 +172,7 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
172172
}
173173

174174
// leaq any(%rax),$rax
175-
if (code[9] != 0x48 || code[10] != 0x8d || code[11] != 0x80) {
175+
if (memcmp(&code[9], "\x48\x8d\x80", 3) != 0) {
176176
uint64_t bytes;
177177
memcpy(&bytes, &code[10], 8);
178178
zend_accel_error(ACCEL_LOG_DEBUG, "leaq insn does not match: 0x%016" PRIx64 "\n", bytes);

0 commit comments

Comments
 (0)