Skip to content

Commit fee614f

Browse files
committed
Export FFI::__BIGGEST_ALIGNMENT__
2 parents ecdaf83 + c45552e commit fee614f

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
@@ -43,6 +43,11 @@
4343
#endif
4444
#endif
4545

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

4853
typedef enum _zend_ffi_tag_kind {
@@ -5035,6 +5040,8 @@ ZEND_MINIT_FUNCTION(ffi)
50355040
zend_ffi_handlers.get_properties = zend_fake_get_properties;
50365041
zend_ffi_handlers.get_gc = zend_fake_get_gc;
50375042

5043+
zend_declare_class_constant_long(zend_ffi_ce, "__BIGGEST_ALIGNMENT__", sizeof("__BIGGEST_ALIGNMENT__")-1, __BIGGEST_ALIGNMENT__);
5044+
50385045
INIT_NS_CLASS_ENTRY(ce, "FFI", "CData", NULL);
50395046
zend_ffi_cdata_ce = zend_register_internal_class(&ce);
50405047
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) /* {{{ */
63666373
}
63676374
/* }}} */
63686375

6369-
#ifndef __BIGGEST_ALIGNMENT__
6370-
/* XXX need something better, perhaps with regard to SIMD, etc. */
6371-
# define __BIGGEST_ALIGNMENT__ sizeof(size_t)
6372-
#endif
6373-
63746376
#define SIMPLE_ATTRIBUTES(_) \
63756377
_(cdecl) \
63766378
_(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)