summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-03-11 15:29:58 +0300
committerDmitry Stogov <dmitry@zend.com>2020-03-11 15:29:58 +0300
commitc45552e32bf03e39560f3fbf6bbca64d32cf7fa6 (patch)
tree534832ac03b5f14ad9c9cff5ffd9f8f981b1efe9
parent8657f0308481263a87d2dd09b8553d58f543a74a (diff)
downloadphp-git-c45552e32bf03e39560f3fbf6bbca64d32cf7fa6.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 d99448dd69..ffc4f84508 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 {
@@ -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) \
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;}");