fix UB in ffi tests

This commit is contained in:
Bennet Bleßmann
2025-01-27 21:55:34 +01:00
committed by Bennet Bleßmann
parent e1246f0c83
commit 760e1d2aac
6 changed files with 28 additions and 26 deletions

View File

@@ -2,7 +2,9 @@
:- use_module(library(ffi)).
test :-
getenv("ffi_f64_minus_zero_LIB", LIB),
read(Body),
term_variables(Body, [LIB]),
Body,
use_foreign_module(LIB, ['ffi_f64_minus_zero'([], f64), 'signum'([f64], f64)]),
ffi:'ffi_f64_minus_zero'(N),
A is max(0.0, N),

View File

@@ -2,7 +2,9 @@
:- use_module(library(ffi)).
test :-
getenv("ffi_f64_nan_LIB", LIB),
read(Body),
term_variables(Body, [LIB]),
Body,
use_foreign_module(LIB, ['ffi_f64_nan'([], f64)]),
ffi:'ffi_f64_nan'(N),
_ is round(N).

View File

@@ -2,7 +2,9 @@
:- use_module(library(ffi)).
test :-
getenv("ffi_invalid_type_LIB", LIB),
read(Body),
term_variables(Body, [LIB]),
Body,
use_foreign_module(LIB, [
'ffi_invalid_type'([], c_void)
]).

View File

@@ -2,7 +2,9 @@
:- use_module(library(ffi)).
test :-
getenv("ffi_return_values_LIB", LIB),
read(Body),
term_variables(Body, [LIB]),
Body,
use_foreign_module(LIB, [
'ffi_return_values_true'([], bool),
'ffi_return_values_false'([], bool),