xref: /PHP-7.4/ext/ffi/tests/bug79532.phpt (revision 67f9b0b7)
1--TEST--
2Bug #79532 (sizeof off_t can be wrong)
3--SKIPIF--
4<?php
5if (!extension_loaded('ffi')) die('skip ffi extension not available');
6if (!extension_loaded('zend-test')) die('skip zend-test extension not available');
7?>
8--FILE--
9<?php
10require_once('utils.inc');
11
12$header = <<<HEADER
13void bug79532(off_t *array, size_t elems);
14HEADER;
15
16if (PHP_OS_FAMILY !== 'Windows') {
17    $ffi = FFI::cdef($header);
18} else {
19    try {
20        $ffi = FFI::cdef($header, 'php_zend_test.dll');
21    } catch (FFI\Exception $ex) {
22        $ffi = FFI::cdef($header, ffi_get_php_dll_name());
23    }
24}
25
26$array = FFI::new("off_t[3]");
27$ffi->bug79532($array, 3);
28var_dump($array);
29?>
30--EXPECTF--
31object(FFI\CData:int%d_t[3])#%d (3) {
32  [0]=>
33  int(0)
34  [1]=>
35  int(1)
36  [2]=>
37  int(2)
38}
39