fix UB in ffi tests

This commit is contained in:
Bennet Bleßmann
2025-08-01 19:08:24 +02:00
committed by Bennet Bleßmann
parent e1246f0c83
commit 760e1d2aac
6 changed files with 28 additions and 26 deletions
+3 -1
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),
+3 -1
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).
+3 -1
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)
]).
+3 -1
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),