Skip to content

Commit c45552e

Browse files
committed
Export FFI::__BIGGEST_ALIGNMENT__
1 parent 8657f03 commit c45552e

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 {
@@ -5016,6 +5021,8 @@ ZEND_MINIT_FUNCTION(ffi)
50165021
zend_ffi_handlers.get_properties = zend_fake_get_properties;
50175022
zend_ffi_handlers.get_gc = zend_fake_get_gc;
50185023

5024+
zend_declare_class_constant_long(zend_ffi_ce, "__BIGGEST_ALIGNMENT__", sizeof("__BIGGEST_ALIGNMENT__")-1, __BIGGEST_ALIGNMENT__);
5025+
50195026
INIT_NS_CLASS_ENTRY(ce, "FFI", "CData", NULL);
50205027
zend_ffi_cdata_ce = zend_register_internal_class(&ce);
50215028
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) /* {{{ */
63476354
}
63486355
/* }}} */
63496356

6350-
#ifndef __BIGGEST_ALIGNMENT__
6351-
/* XXX need something better, perhaps with regard to SIMD, etc. */
6352-
# define __BIGGEST_ALIGNMENT__ sizeof(size_t)
6353-
#endif
6354-
63556357
#define SIMPLE_ATTRIBUTES(_) \
63566358
_(cdecl) \
63576359
_(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)