1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 18:53:33 +02:00
Files
archived-php-src/ext/ffi/tests/031.phpt
T
Max Semenik bd9f4fa676 Migrate skip checks to --EXTENSIONS--, p2
For rationale, see https://github.com/php/php-src/pull/6787

Make extension checks lowercase, add a special case for opcache
that has internal name not matching .so filename.

Extensions migrated in part 2:
* dom
* exif
* fileinfo
* ffi
2021-04-01 12:08:24 +01:00

30 lines
830 B
PHP

--TEST--
FFI 031: bit-fields packing
--EXTENSIONS--
ffi
--INI--
ffi.enable=1
--FILE--
<?php
function test_size($expected_size, $type) {
try {
$size = FFI::sizeof(FFI::new($type));
if ($size !== $expected_size) {
echo "FAIL: sizeof($type) != $expected_size ($size)\n";
}
} catch (Throwable $e) {
echo $type . "=>" . get_class($e) . ": " . $e->getMessage()."\n";
}
}
test_size( 4, "struct {int a:2; int b:2;}");
test_size( 1, "struct __attribute__((packed)) {int a:2; int b:2;}");
test_size( 8, "struct {int a:2; unsigned long long :60; int b:2;}");
test_size( 9, "struct __attribute__((packed)) {int a:2; unsigned long long :64; int b:2;}");
test_size( 4, "union {int a:2; int b:8;}");
test_size( 1, "union __attribute__((packed)) {int a:2; int b:8;}");
?>
ok
--EXPECT--
ok