summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-03-12 11:43:01 +0300
committerDmitry Stogov <dmitry@zend.com>2020-03-12 11:43:01 +0300
commitfee614f66bfb72384c7c6f316cad0c5c68fa9c0c (patch)
tree0ac865aeaec6483aba05b285b3eefff8e1244a72
parentecdaf83f5f0888332c76eca7fb644c536b70e817 (diff)
parentc45552e32bf03e39560f3fbf6bbca64d32cf7fa6 (diff)
downloadphp-git-fee614f66bfb72384c7c6f316cad0c5c68fa9c0c.tar.gz
Export FFI::__BIGGEST_ALIGNMENT__
-rw-r--r--ext/ffi/ffi.c12
-rw-r--r--ext/ffi/tests/022.phpt4
2 files changed, 9 insertions, 7 deletions
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index ec9cdb17ca..9626c4b374 100644
--- a/ext/ffi/ffi.c
+++ b/ext/ffi/ffi.c
@@ -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 {
@@ -5035,6 +5040,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;
@@ -6366,11 +6373,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 a1c009dce8..3eb28fb214 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;}");