Skip to content

Commit 1072658

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Export FFI::__BIGGEST_ALIGNMENT__
2 parents c774ca8 + fee614f commit 1072658

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

ext/ffi/ffi.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
#endif
4343
#endif
4444

45+
#ifndef __BIGGEST_ALIGNMENT__
46+
/* XXX need something better, perhaps with regard to SIMD, etc. */
47+
# define __BIGGEST_ALIGNMENT__ sizeof(size_t)
48+
#endif
49+
4550
ZEND_DECLARE_MODULE_GLOBALS(ffi)
4651

4752
typedef enum _zend_ffi_tag_kind {
@@ -4912,6 +4917,8 @@ ZEND_MINIT_FUNCTION(ffi)
49124917
zend_ffi_handlers.get_properties = zend_fake_get_properties;
49134918
zend_ffi_handlers.get_gc = zend_fake_get_gc;
49144919

4920+
zend_declare_class_constant_long(zend_ffi_ce, "__BIGGEST_ALIGNMENT__", sizeof("__BIGGEST_ALIGNMENT__")-1, __BIGGEST_ALIGNMENT__);
4921+
49154922
INIT_NS_CLASS_ENTRY(ce, "FFI", "CData", NULL);
49164923
zend_ffi_cdata_ce = zend_register_internal_class(&ce);
49174924
zend_ffi_cdata_ce->ce_flags |= ZEND_ACC_FINAL;
@@ -6242,11 +6249,6 @@ void zend_ffi_set_abi(zend_ffi_dcl *dcl, uint16_t abi) /* {{{ */
62426249
}
62436250
/* }}} */
62446251

6245-
#ifndef __BIGGEST_ALIGNMENT__
6246-
/* XXX need something better, perhaps with regard to SIMD, etc. */
6247-
# define __BIGGEST_ALIGNMENT__ sizeof(size_t)
6248-
#endif
6249-
62506252
#define SIMPLE_ATTRIBUTES(_) \
62516253
_(cdecl) \
62526254
_(fastcall) \

ext/ffi/tests/022.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ test_size(32, "struct {char a; uint32_t b __attribute__((aligned(16)));}");
6161
test_align(16, "struct {char a; uint32_t b __attribute__((aligned(16)));}");
6262

6363
if (substr(PHP_OS, 0, 3) != 'WIN') {
64-
test_size(32, "struct {char a; uint32_t b __attribute__((aligned));}");
65-
test_align(16, "struct {char a; uint32_t b __attribute__((aligned));}");
64+
test_size(FFI::__BIGGEST_ALIGNMENT__ * 2, "struct {char a; uint32_t b __attribute__((aligned));}");
65+
test_align(FFI::__BIGGEST_ALIGNMENT__, "struct {char a; uint32_t b __attribute__((aligned));}");
6666
}
6767

6868
test_size(16, "struct __declspec(align(16)) {char a; uint32_t b;}");

0 commit comments

Comments
 (0)