Skip to content

Commit 7b29f95

Browse files
committed
__builtin_memcpy_inline usage introduction.
for now concealed in few places in zend. builtin producing only a load and store operands and works with compile time lengths.
1 parent 9f06bb3 commit 7b29f95

17 files changed

+66
-38
lines changed

Zend/zend.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ static void function_copy_ctor(zval *zv) /* {{{ */
632632
}
633633
func = pemalloc(sizeof(zend_internal_function), 1);
634634
Z_FUNC_P(zv) = func;
635-
memcpy(func, old_func, sizeof(zend_internal_function));
635+
ZEND_MEMCPY_INLINE(func, old_func, sizeof(zend_internal_function));
636636
function_add_ref(func);
637637
if ((old_func->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS))
638638
&& old_func->common.arg_info) {
@@ -1298,7 +1298,7 @@ ZEND_API zval *zend_get_configuration_directive(zend_string *name) /* {{{ */
12981298

12991299
#define SAVE_STACK(stack) do { \
13001300
if (CG(stack).top) { \
1301-
memcpy(&stack, &CG(stack), sizeof(zend_stack)); \
1301+
ZEND_MEMCPY_INLINE(&stack, &CG(stack), sizeof(zend_stack)); \
13021302
CG(stack).top = CG(stack).max = 0; \
13031303
CG(stack).elements = NULL; \
13041304
} else { \
@@ -1309,7 +1309,7 @@ ZEND_API zval *zend_get_configuration_directive(zend_string *name) /* {{{ */
13091309
#define RESTORE_STACK(stack) do { \
13101310
if (stack.top) { \
13111311
zend_stack_destroy(&CG(stack)); \
1312-
memcpy(&CG(stack), &stack, sizeof(zend_stack)); \
1312+
ZEND_MEMCPY_INLINE(&CG(stack), &stack, sizeof(zend_stack)); \
13131313
} \
13141314
} while (0)
13151315

Zend/zend_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ ZEND_API HashTable *zend_separate_class_constants_table(zend_class_entry *class_
13281328
if (c->ce == class_type) {
13291329
if (Z_TYPE(c->value) == IS_CONSTANT_AST) {
13301330
new_c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
1331-
memcpy(new_c, c, sizeof(zend_class_constant));
1331+
ZEND_MEMCPY_INLINE(new_c, c, sizeof(zend_class_constant));
13321332
c = new_c;
13331333
}
13341334
Z_TRY_ADDREF(c->value);
@@ -2770,7 +2770,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
27702770
lowercase_name = zend_string_tolower_ex(internal_function->function_name, type == MODULE_PERSISTENT);
27712771
lowercase_name = zend_new_interned_string(lowercase_name);
27722772
reg_function = malloc(sizeof(zend_internal_function));
2773-
memcpy(reg_function, &function, sizeof(zend_internal_function));
2773+
ZEND_MEMCPY_INLINE(reg_function, &function, sizeof(zend_internal_function));
27742774
if (zend_hash_add_ptr(target_function_table, lowercase_name, reg_function) == NULL) {
27752775
unload=1;
27762776
free(reg_function);

Zend/zend_alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,7 +3008,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
30083008
zend_mm_chunk *chunk;
30093009
zend_mm_heap *heap;
30103010

3011-
memcpy((zend_mm_handlers*)&tmp_storage.handlers, handlers, sizeof(zend_mm_handlers));
3011+
ZEND_MEMCPY_INLINE((zend_mm_handlers*)&tmp_storage.handlers, handlers, sizeof(zend_mm_handlers));
30123012
tmp_storage.data = data;
30133013
chunk = (zend_mm_chunk*)handlers->chunk_alloc(&tmp_storage, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE);
30143014
if (UNEXPECTED(chunk == NULL)) {
@@ -3068,7 +3068,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
30683068
#endif
30693069
return NULL;
30703070
}
3071-
memcpy(storage, &tmp_storage, sizeof(zend_mm_storage));
3071+
ZEND_MEMCPY_INLINE(storage, &tmp_storage, sizeof(zend_mm_storage));
30723072
if (data) {
30733073
storage->data = (void*)(((char*)storage + sizeof(zend_mm_storage)));
30743074
memcpy(storage->data, data, data_size);

Zend/zend_attributes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ void zend_register_attribute_ce(void)
374374
zend_ce_sensitive_parameter = register_class_SensitiveParameter();
375375
attr = zend_internal_attribute_register(zend_ce_sensitive_parameter, ZEND_ATTRIBUTE_TARGET_PARAMETER);
376376

377-
memcpy(&attributes_object_handlers_sensitive_parameter_value, &std_object_handlers, sizeof(zend_object_handlers));
377+
ZEND_MEMCPY_INLINE(&attributes_object_handlers_sensitive_parameter_value, &std_object_handlers, sizeof(zend_object_handlers));
378378
attributes_object_handlers_sensitive_parameter_value.get_properties_for = attributes_sensitive_parameter_value_get_properties_for;
379379

380380
/* This is not an actual attribute, thus the zend_internal_attribute_register() call is missing. */

Zend/zend_closures.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ void zend_register_closure_ce(void) /* {{{ */
648648
zend_ce_closure = register_class_Closure();
649649
zend_ce_closure->create_object = zend_closure_new;
650650

651-
memcpy(&closure_handlers, &std_object_handlers, sizeof(zend_object_handlers));
651+
ZEND_MEMCPY_INLINE(&closure_handlers, &std_object_handlers, sizeof(zend_object_handlers));
652652
closure_handlers.free_obj = zend_closure_free_storage;
653653
closure_handlers.get_constructor = zend_closure_get_constructor;
654654
closure_handlers.get_method = zend_closure_get_method;
@@ -685,7 +685,7 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
685685
}
686686

687687
if (func->type == ZEND_USER_FUNCTION) {
688-
memcpy(&closure->func, func, sizeof(zend_op_array));
688+
ZEND_MEMCPY_INLINE(&closure->func, func, sizeof(zend_op_array));
689689
closure->func.common.fn_flags |= ZEND_ACC_CLOSURE;
690690
closure->func.common.fn_flags &= ~ZEND_ACC_IMMUTABLE;
691691

@@ -739,7 +739,7 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
739739
(*closure->func.op_array.refcount)++;
740740
}
741741
} else {
742-
memcpy(&closure->func, func, sizeof(zend_internal_function));
742+
ZEND_MEMCPY_INLINE(&closure->func, func, sizeof(zend_internal_function));
743743
closure->func.common.fn_flags |= ZEND_ACC_CLOSURE;
744744
/* wrap internal function handler to avoid memory leak */
745745
if (UNEXPECTED(closure->func.internal_function.handler == zend_closure_internal_handler)) {

Zend/zend_constants.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void copy_zend_constant(zval *zv)
6464

6565
ZEND_ASSERT(ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT);
6666
Z_PTR_P(zv) = pemalloc(sizeof(zend_constant), 1);
67-
memcpy(Z_PTR_P(zv), c, sizeof(zend_constant));
67+
ZEND_MEMCPY_INLINE(Z_PTR_P(zv), c, sizeof(zend_constant));
6868

6969
c = Z_PTR_P(zv);
7070
c->name = zend_string_copy(c->name);
@@ -538,7 +538,7 @@ static void* zend_hash_add_constant(HashTable *ht, zend_string *key, zend_consta
538538
void *ret;
539539
zend_constant *copy = pemalloc(sizeof(zend_constant), ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT);
540540

541-
memcpy(copy, c, sizeof(zend_constant));
541+
ZEND_MEMCPY_INLINE(copy, c, sizeof(zend_constant));
542542
ret = zend_hash_add_ptr(ht, key, copy);
543543
if (!ret) {
544544
pefree(copy, ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT);

Zend/zend_enum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void zend_register_enum_ce(void)
156156
zend_ce_backed_enum = register_class_BackedEnum(zend_ce_unit_enum);
157157
zend_ce_backed_enum->interface_gets_implemented = zend_implement_backed_enum;
158158

159-
memcpy(&enum_handlers, &std_object_handlers, sizeof(zend_object_handlers));
159+
ZEND_MEMCPY_INLINE(&enum_handlers, &std_object_handlers, sizeof(zend_object_handlers));
160160
enum_handlers.clone_obj = NULL;
161161
enum_handlers.compare = zend_objects_not_comparable;
162162
}

Zend/zend_exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ void zend_register_default_exception(void) /* {{{ */
744744
zend_ce_throwable = register_class_Throwable(zend_ce_stringable);
745745
zend_ce_throwable->interface_gets_implemented = zend_implement_throwable;
746746

747-
memcpy(&default_exception_handlers, &std_object_handlers, sizeof(zend_object_handlers));
747+
ZEND_MEMCPY_INLINE(&default_exception_handlers, &std_object_handlers, sizeof(zend_object_handlers));
748748
default_exception_handlers.clone_obj = NULL;
749749

750750
zend_ce_exception = register_class_Exception(zend_ce_throwable);

Zend/zend_generators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ void zend_register_generator_ce(void) /* {{{ */
11331133
/* get_iterator has to be assigned *after* implementing the interface */
11341134
zend_ce_generator->get_iterator = zend_generator_get_iterator;
11351135

1136-
memcpy(&zend_generator_handlers, &std_object_handlers, sizeof(zend_object_handlers));
1136+
ZEND_MEMCPY_INLINE(&zend_generator_handlers, &std_object_handlers, sizeof(zend_object_handlers));
11371137
zend_generator_handlers.free_obj = zend_generator_free_storage;
11381138
zend_generator_handlers.dtor_obj = zend_generator_dtor_storage;
11391139
zend_generator_handlers.get_gc = zend_generator_get_gc;

Zend/zend_inheritance.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ static zend_function *zend_duplicate_internal_function(zend_function *func, zend
8181

8282
if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) {
8383
new_function = pemalloc(sizeof(zend_internal_function), 1);
84-
memcpy(new_function, func, sizeof(zend_internal_function));
84+
ZEND_MEMCPY_INLINE(new_function, func, sizeof(zend_internal_function));
8585
} else {
8686
new_function = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));
87-
memcpy(new_function, func, sizeof(zend_internal_function));
87+
ZEND_MEMCPY_INLINE(new_function, func, sizeof(zend_internal_function));
8888
new_function->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
8989
}
9090
if (EXPECTED(new_function->common.function_name)) {
@@ -1111,7 +1111,7 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
11111111
} else {
11121112
/* op_array wasn't duplicated yet */
11131113
zend_function *new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
1114-
memcpy(new_function, child, sizeof(zend_op_array));
1114+
ZEND_MEMCPY_INLINE(new_function, child, sizeof(zend_op_array));
11151115
Z_PTR_P(child_zv) = child = new_function;
11161116
}
11171117
}
@@ -1352,13 +1352,13 @@ static void do_inherit_class_constant(zend_string *name, zend_class_constant *pa
13521352
ce->ce_flags |= ZEND_ACC_HAS_AST_CONSTANTS;
13531353
if (ce->parent->ce_flags & ZEND_ACC_IMMUTABLE) {
13541354
c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
1355-
memcpy(c, parent_const, sizeof(zend_class_constant));
1355+
ZEND_MEMCPY_INLINE(c, parent_const, sizeof(zend_class_constant));
13561356
parent_const = c;
13571357
}
13581358
}
13591359
if (ce->type & ZEND_INTERNAL_CLASS) {
13601360
c = pemalloc(sizeof(zend_class_constant), 1);
1361-
memcpy(c, parent_const, sizeof(zend_class_constant));
1361+
ZEND_MEMCPY_INLINE(c, parent_const, sizeof(zend_class_constant));
13621362
parent_const = c;
13631363
}
13641364
_zend_hash_append_ptr(&ce->constants_table, name, parent_const);
@@ -1638,14 +1638,14 @@ static void do_inherit_iface_constant(zend_string *name, zend_class_constant *c,
16381638
ce->ce_flags |= ZEND_ACC_HAS_AST_CONSTANTS;
16391639
if (iface->ce_flags & ZEND_ACC_IMMUTABLE) {
16401640
ct = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
1641-
memcpy(ct, c, sizeof(zend_class_constant));
1641+
ZEND_MEMCPY_INLINE(ct, c, sizeof(zend_class_constant));
16421642
c = ct;
16431643
Z_CONSTANT_FLAGS(c->value) |= CONST_OWNED;
16441644
}
16451645
}
16461646
if (ce->type & ZEND_INTERNAL_CLASS) {
16471647
ct = pemalloc(sizeof(zend_class_constant), 1);
1648-
memcpy(ct, c, sizeof(zend_class_constant));
1648+
ZEND_MEMCPY_INLINE(ct, c, sizeof(zend_class_constant));
16491649
c = ct;
16501650
}
16511651
zend_hash_update_ptr(&ce->constants_table, name, c);
@@ -1837,11 +1837,11 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
18371837

18381838
if (UNEXPECTED(fn->type == ZEND_INTERNAL_FUNCTION)) {
18391839
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));
1840-
memcpy(new_fn, fn, sizeof(zend_internal_function));
1840+
ZEND_MEMCPY_INLINE(new_fn, fn, sizeof(zend_internal_function));
18411841
new_fn->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
18421842
} else {
18431843
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
1844-
memcpy(new_fn, fn, sizeof(zend_op_array));
1844+
ZEND_MEMCPY_INLINE(new_fn, fn, sizeof(zend_op_array));
18451845
new_fn->op_array.fn_flags |= ZEND_ACC_TRAIT_CLONE;
18461846
new_fn->op_array.fn_flags &= ~ZEND_ACC_IMMUTABLE;
18471847
}
@@ -2425,14 +2425,14 @@ static void add_compatibility_obligation(
24252425
obligation->type = OBLIGATION_COMPATIBILITY;
24262426
/* Copy functions, because they may be stack-allocated in the case of traits. */
24272427
if (child_fn->common.type == ZEND_INTERNAL_FUNCTION) {
2428-
memcpy(&obligation->child_fn, child_fn, sizeof(zend_internal_function));
2428+
ZEND_MEMCPY_INLINE(&obligation->child_fn, child_fn, sizeof(zend_internal_function));
24292429
} else {
2430-
memcpy(&obligation->child_fn, child_fn, sizeof(zend_op_array));
2430+
ZEND_MEMCPY_INLINE(&obligation->child_fn, child_fn, sizeof(zend_op_array));
24312431
}
24322432
if (parent_fn->common.type == ZEND_INTERNAL_FUNCTION) {
2433-
memcpy(&obligation->parent_fn, parent_fn, sizeof(zend_internal_function));
2433+
ZEND_MEMCPY_INLINE(&obligation->parent_fn, parent_fn, sizeof(zend_internal_function));
24342434
} else {
2435-
memcpy(&obligation->parent_fn, parent_fn, sizeof(zend_op_array));
2435+
ZEND_MEMCPY_INLINE(&obligation->parent_fn, parent_fn, sizeof(zend_op_array));
24362436
}
24372437
obligation->child_scope = child_scope;
24382438
obligation->parent_scope = parent_scope;
@@ -2553,7 +2553,7 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce)
25532553
Bucket *p, *end;
25542554

25552555
ce = zend_arena_alloc(&CG(arena), sizeof(zend_class_entry));
2556-
memcpy(ce, pce, sizeof(zend_class_entry));
2556+
ZEND_MEMCPY_INLINE(ce, pce, sizeof(zend_class_entry));
25572557
ce->ce_flags &= ~ZEND_ACC_IMMUTABLE;
25582558
ce->refcount = 1;
25592559
ce->inheritance_cache = NULL;
@@ -2592,7 +2592,7 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce)
25922592
ZEND_ASSERT(op_array->prototype == NULL);
25932593
new_op_array = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
25942594
Z_PTR(p->val) = new_op_array;
2595-
memcpy(new_op_array, op_array, sizeof(zend_op_array));
2595+
ZEND_MEMCPY_INLINE(new_op_array, op_array, sizeof(zend_op_array));
25962596
new_op_array->fn_flags &= ~ZEND_ACC_IMMUTABLE;
25972597
new_op_array->scope = ce;
25982598
ZEND_MAP_PTR_INIT(new_op_array->run_time_cache, NULL);
@@ -2641,7 +2641,7 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce)
26412641
ZEND_ASSERT(prop_info->ce == pce);
26422642
new_prop_info= zend_arena_alloc(&CG(arena), sizeof(zend_property_info));
26432643
Z_PTR(p->val) = new_prop_info;
2644-
memcpy(new_prop_info, prop_info, sizeof(zend_property_info));
2644+
ZEND_MEMCPY_INLINE(new_prop_info, prop_info, sizeof(zend_property_info));
26452645
new_prop_info->ce = ce;
26462646
if (ZEND_TYPE_HAS_LIST(new_prop_info->type)) {
26472647
zend_type_list *new_list;
@@ -2669,7 +2669,7 @@ static zend_class_entry *zend_lazy_class_load(zend_class_entry *pce)
26692669
ZEND_ASSERT(c->ce == pce);
26702670
new_c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
26712671
Z_PTR(p->val) = new_c;
2672-
memcpy(new_c, c, sizeof(zend_class_constant));
2672+
ZEND_MEMCPY_INLINE(new_c, c, sizeof(zend_class_constant));
26732673
new_c->ce = ce;
26742674
}
26752675
}

Zend/zend_ini.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void copy_ini_entry(zval *zv) /* {{{ */
143143
zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), 1);
144144

145145
Z_PTR_P(zv) = new_entry;
146-
memcpy(new_entry, old_entry, sizeof(zend_ini_entry));
146+
ZEND_MEMCPY_INLINE(new_entry, old_entry, sizeof(zend_ini_entry));
147147
if (old_entry->name) {
148148
new_entry->name = zend_string_dup(old_entry->name, 1);
149149
}

Zend/zend_portability.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ char *alloca();
341341
# define UNEXPECTED(condition) (condition)
342342
#endif
343343

344+
#if PHP_HAVE_BUILTIN_MEMCPY_INLINE
345+
# define ZEND_MEMCPY_INLINE(a, b, s) __builtin_memcpy_inline(a, b, s)
346+
#else
347+
# define ZEND_MEMCPY_INLINE(a, b, s) memcpy(a, b, s)
348+
#endif
349+
344350
#ifndef XtOffsetOf
345351
# define XtOffsetOf(s_type, field) offsetof(s_type, field)
346352
#endif

Zend/zend_signal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void zend_signal_activate(void)
319319
{
320320
size_t x;
321321

322-
memcpy(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers));
322+
ZEND_MEMCPY_INLINE(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers));
323323

324324
if (SIGG(reset)) {
325325
for (x = 0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {

Zend/zend_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static zend_always_inline zend_ulong zend_inline_hash_func(const char *str, size
432432
time and extract each byte with a bit field extract instr. */
433433
uint64_t chunk;
434434

435-
memcpy(&chunk, str, sizeof(chunk));
435+
ZEND_MEMCPY_INLINE(&chunk, str, sizeof(chunk));
436436
hash =
437437
hash * 33 * 33 * 33 * 33 +
438438
((chunk >> (8 * 0)) & 0xff) * 33 * 33 * 33 +

Zend/zend_weakrefs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ void zend_register_weakref_ce(void) /* {{{ */
648648

649649
zend_ce_weakref->create_object = zend_weakref_new;
650650

651-
memcpy(&zend_weakref_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
651+
ZEND_MEMCPY_INLINE(&zend_weakref_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
652652
zend_weakref_handlers.offset = XtOffsetOf(zend_weakref, std);
653653

654654
zend_weakref_handlers.free_obj = zend_weakref_free;
@@ -659,7 +659,7 @@ void zend_register_weakref_ce(void) /* {{{ */
659659
zend_ce_weakmap->create_object = zend_weakmap_create_object;
660660
zend_ce_weakmap->get_iterator = zend_weakmap_get_iterator;
661661

662-
memcpy(&zend_weakmap_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
662+
ZEND_MEMCPY_INLINE(&zend_weakmap_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
663663
zend_weakmap_handlers.offset = XtOffsetOf(zend_weakmap, std);
664664
zend_weakmap_handlers.free_obj = zend_weakmap_free_obj;
665665
zend_weakmap_handlers.read_dimension = zend_weakmap_read_dimension;

build/php.m4

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,26 @@ AC_DEFUN([PHP_CHECK_BUILTIN_CPU_SUPPORTS], [
27332733
[$have_builtin_cpu_supports], [Whether the compiler supports __builtin_cpu_supports])
27342734
])
27352735

2736+
dnl
2737+
dnl PHP_CHECK_BUILTIN_MEMCPY_INLINE
2738+
dnl
2739+
AC_DEFUN([PHP_CHECK_BUILTIN_MEMCPY_INLINE], [
2740+
AC_MSG_CHECKING([for __builtin_memcpy_inline])
2741+
2742+
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
2743+
int d, s = 5;
2744+
__builtin_memcpy_inline(&d,&s,sizeof(d));
2745+
]])], [
2746+
have_builtin_memcpy_inline=1
2747+
AC_MSG_RESULT([yes])
2748+
], [
2749+
have_builtin_memcpy_inline=0
2750+
AC_MSG_RESULT([no])
2751+
])
2752+
2753+
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_MEMCPY_INLINE], [$have_builtin_memcpy_inline], [Whether the compiler supports __builtin_memcpy_inline])
2754+
])
2755+
27362756
dnl
27372757
dnl PHP_PATCH_CONFIG_HEADERS([FILE])
27382758
dnl

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ dnl Check __builtin_cpu_init
507507
PHP_CHECK_BUILTIN_CPU_INIT
508508
dnl Check __builtin_cpu_supports
509509
PHP_CHECK_BUILTIN_CPU_SUPPORTS
510+
dnl Check __builtin_memcpy_inline
511+
PHP_CHECK_BUILTIN_MEMCPY_INLINE
510512

511513
dnl Check for __alignof__ support in the compiler
512514
AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[

0 commit comments

Comments
 (0)