diff options
author | Dmitry Stogov <dmitry@zend.com> | 2020-03-12 11:45:05 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2020-03-12 11:45:05 +0300 |
commit | 10726588b119c0401ef9ca81497c59587383d478 (patch) | |
tree | 56d117b86d4263363a436b2ce362a27528e247e0 | |
parent | c774ca8d807320cf3ef95edb4594a7f71e10e917 (diff) | |
parent | fee614f66bfb72384c7c6f316cad0c5c68fa9c0c (diff) | |
download | php-git-10726588b119c0401ef9ca81497c59587383d478.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
Export FFI::__BIGGEST_ALIGNMENT__
-rw-r--r-- | ext/ffi/ffi.c | 12 | ||||
-rw-r--r-- | ext/ffi/tests/022.phpt | 4 |
2 files changed, 9 insertions, 7 deletions
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 9b26406486..7658558ee8 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -42,6 +42,11 @@ #endif #endif +#ifndef __BIGGEST_ALIGNMENT__ +/* XXX need something better, perhaps with regard to SIMD, etc. */ +# define __BIGGEST_ALIGNMENT__ sizeof(size_t) +#endif + ZEND_DECLARE_MODULE_GLOBALS(ffi) typedef enum _zend_ffi_tag_kind { @@ -4912,6 +4917,8 @@ ZEND_MINIT_FUNCTION(ffi) zend_ffi_handlers.get_properties = zend_fake_get_properties; zend_ffi_handlers.get_gc = zend_fake_get_gc; + zend_declare_class_constant_long(zend_ffi_ce, "__BIGGEST_ALIGNMENT__", sizeof("__BIGGEST_ALIGNMENT__")-1, __BIGGEST_ALIGNMENT__); + INIT_NS_CLASS_ENTRY(ce, "FFI", "CData", NULL); zend_ffi_cdata_ce = zend_register_internal_class(&ce); 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) /* {{{ */ } /* }}} */ -#ifndef __BIGGEST_ALIGNMENT__ -/* XXX need something better, perhaps with regard to SIMD, etc. */ -# define __BIGGEST_ALIGNMENT__ sizeof(size_t) -#endif - #define SIMPLE_ATTRIBUTES(_) \ _(cdecl) \ _(fastcall) \ diff --git a/ext/ffi/tests/022.phpt b/ext/ffi/tests/022.phpt index 9e5bb915e1..44ddaeebd2 100644 --- a/ext/ffi/tests/022.phpt +++ b/ext/ffi/tests/022.phpt @@ -61,8 +61,8 @@ test_size(32, "struct {char a; uint32_t b __attribute__((aligned(16)));}"); test_align(16, "struct {char a; uint32_t b __attribute__((aligned(16)));}"); if (substr(PHP_OS, 0, 3) != 'WIN') { - test_size(32, "struct {char a; uint32_t b __attribute__((aligned));}"); - test_align(16, "struct {char a; uint32_t b __attribute__((aligned));}"); + test_size(FFI::__BIGGEST_ALIGNMENT__ * 2, "struct {char a; uint32_t b __attribute__((aligned));}"); + test_align(FFI::__BIGGEST_ALIGNMENT__, "struct {char a; uint32_t b __attribute__((aligned));}"); } test_size(16, "struct __declspec(align(16)) {char a; uint32_t b;}"); |