044.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. FFI 044: mode attribute
  3. --EXTENSIONS--
  4. ffi
  5. --INI--
  6. ffi.enable=1
  7. --FILE--
  8. <?php
  9. $ffi = FFI::cdef("
  10. typedef int a __attribute__ ((__mode__ (__QI__)));
  11. typedef unsigned int ua __attribute__ ((__mode__ (__QI__)));
  12. typedef int b __attribute__ ((__mode__ (__HI__)));
  13. typedef unsigned int ub __attribute__ ((__mode__ (__HI__)));
  14. typedef int c __attribute__ ((__mode__ (__SI__)));
  15. typedef unsigned int uc __attribute__ ((__mode__ (__SI__)));
  16. typedef int d __attribute__ ((__mode__ (__DI__)));
  17. typedef unsigned int ud __attribute__ ((__mode__ (__DI__)));
  18. typedef float e __attribute__ ((__mode__ (__SF__)));
  19. typedef float f __attribute__ ((__mode__ (__DF__)));
  20. ");
  21. var_dump(FFI::sizeof($ffi->new("a")));
  22. var_dump(FFI::sizeof($ffi->new("ua")));
  23. var_dump(FFI::sizeof($ffi->new("b")));
  24. var_dump(FFI::sizeof($ffi->new("ub")));
  25. var_dump(FFI::sizeof($ffi->new("c")));
  26. var_dump(FFI::sizeof($ffi->new("uc")));
  27. var_dump(FFI::sizeof($ffi->new("d")));
  28. var_dump(FFI::sizeof($ffi->new("ud")));
  29. var_dump(FFI::sizeof($ffi->new("e")));
  30. var_dump(FFI::sizeof($ffi->new("f")));
  31. ?>
  32. --EXPECT--
  33. int(1)
  34. int(1)
  35. int(2)
  36. int(2)
  37. int(4)
  38. int(4)
  39. int(8)
  40. int(8)
  41. int(4)
  42. int(8)