1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 17:52:16 +01:00

Export FFI::__BIGGEST_ALIGNMENT__

This commit is contained in:
Dmitry Stogov
2020-03-11 15:29:58 +03:00
parent 8657f03084
commit c45552e32b
2 changed files with 9 additions and 7 deletions

View File

@@ -43,6 +43,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 {
@@ -5016,6 +5021,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;
@@ -6347,11 +6354,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) \

View File

@@ -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;}");