1
0
mirror of https://github.com/php/php-src.git synced 2026-04-19 22:11:12 +02:00
Files
archived-php-src/ext/ffi/tests/bug79532.phpt
Christoph M. Becker 67f9b0b754 Fix #79532: sizeof off_t can be wrong
We have to actually determine the proper `SIZEOF_OFF_T`.
Interestingly, it is `4` on Windows x64.

We also have to prevent the redefinition in pg_config.h.  The clean
solution would likely be to not include pg_config.h at all, but that's
out of scope for BC reasons for now.
2020-04-29 10:40:59 +02:00

39 lines
762 B
PHP

--TEST--
Bug #79532 (sizeof off_t can be wrong)
--SKIPIF--
<?php
if (!extension_loaded('ffi')) die('skip ffi extension not available');
if (!extension_loaded('zend-test')) die('skip zend-test extension not available');
?>
--FILE--
<?php
require_once('utils.inc');
$header = <<<HEADER
void bug79532(off_t *array, size_t elems);
HEADER;
if (PHP_OS_FAMILY !== 'Windows') {
$ffi = FFI::cdef($header);
} else {
try {
$ffi = FFI::cdef($header, 'php_zend_test.dll');
} catch (FFI\Exception $ex) {
$ffi = FFI::cdef($header, ffi_get_php_dll_name());
}
}
$array = FFI::new("off_t[3]");
$ffi->bug79532($array, 3);
var_dump($array);
?>
--EXPECTF--
object(FFI\CData:int%d_t[3])#%d (3) {
[0]=>
int(0)
[1]=>
int(1)
[2]=>
int(2)
}