1--TEST-- 2FFI 021: packed enums 3--SKIPIF-- 4<?php require_once('skipif.inc'); ?> 5--INI-- 6ffi.enable=1 7--FILE-- 8<?php 9function test($size, $type) { 10 if (FFI::sizeof(FFI::new($type)) !== $size) { 11 echo "FAIL: sizeof($type) != $size\n"; 12 } 13} 14 15test(4, "enum {a1, b1}"); 16test(1, "enum __attribute__((packed)) {a2, b2}"); 17 18test(4, "enum {a3=0, b3=0x80000000}"); 19test(8, "enum {a4=-1, b4=0x80000000}"); 20test(8, "enum {a5=0x80000000, b5=-1}"); 21test(4, "enum {a6=-1, b6=0x7fffffff}"); 22test(8, "enum {a7=-1, b7=0x7fffffff, c7}"); 23 24test(1, "enum __attribute__((packed)) {a8=0, b8=0xff}"); 25test(2, "enum __attribute__((packed)) {a9=0, b9=0x100}"); 26 27test(1, "enum __attribute__((packed)) {a10=-1, b10=0x7f}"); 28test(2, "enum __attribute__((packed)) {a11=-1, b11=0x80}"); 29test(1, "enum __attribute__((packed)) {a12=0x7f, b12=-0x80}"); 30test(2, "enum __attribute__((packed)) {a13=0x7f, b13=-0x81}"); 31 32test(2, "enum __attribute__((packed)) {a8=0, b8=0xffff}"); 33test(4, "enum __attribute__((packed)) {a9=0, b9=0x10000}"); 34 35test(2, "enum __attribute__((packed)) {a10=-1, b10=0x7f00}"); 36test(4, "enum __attribute__((packed)) {a11=-1, b11=0x8000}"); 37test(2, "enum __attribute__((packed)) {a12=0x7f00, b12=-0x8000}"); 38test(4, "enum __attribute__((packed)) {a13=0x7f00, b13=-0x8001}"); 39 40test(4, "enum __attribute__((packed)) {a8=0, b8=0xffffffff}"); 41test(8, "enum __attribute__((packed)) {a9=0, b9=0x100000000}"); 42 43test(4, "enum __attribute__((packed)) {a10=-1, b10=0x7f000000}"); 44test(8, "enum __attribute__((packed)) {a11=-1, b11=0x80000000}"); 45test(4, "enum __attribute__((packed)) {a12=0x7f000000, b12=-0x80000000}"); 46test(8, "enum __attribute__((packed)) {a13=0x7f000000, b13=-0x80000001}"); 47 48test(1, "enum __attribute__((packed)) {a14=-0x80}"); 49test(2, "enum __attribute__((packed)) {a14=-0x81}"); 50test(2, "enum __attribute__((packed)) {a14=-0x8000}"); 51test(4, "enum __attribute__((packed)) {a14=-0x8001}"); 52test(4, "enum __attribute__((packed)) {a14=-0x80000000}"); 53test(8, "enum __attribute__((packed)) {a14=-0x80000001}"); 54?> 55ok 56--EXPECT-- 57ok 58