mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Test signed narrow arguments in FFI better.
* test-suite/standalone/test-ffi-lib.c (test_ffi_s16_s8): New function. * test-suite/standalone/test-ffi: Test it. Also test test_ffi_sum with both positive and negative values for the narrower-than-64-bit arguments.
This commit is contained in:
parent
499f3de0d7
commit
8e7cacf139
2 changed files with 16 additions and 2 deletions
|
@ -99,6 +99,10 @@ exec guile -q -s "$0" "$@"
|
|||
(pointer->procedure int16 (dynamic-func "test_ffi_s16_u8" lib) (list uint8)))
|
||||
(test (f-s16-u8 10) -19990)
|
||||
|
||||
(define f-s16-s8
|
||||
(pointer->procedure int16 (dynamic-func "test_ffi_s16_s8" lib) (list int8)))
|
||||
(test (f-s16-s8 -10) -20010)
|
||||
|
||||
(define f-u16-u8
|
||||
(pointer->procedure uint16 (dynamic-func "test_ffi_u16_u8" lib) (list uint8)))
|
||||
(test (f-u16-u8 10) 40010)
|
||||
|
@ -166,8 +170,12 @@ exec guile -q -s "$0" "$@"
|
|||
(define f-sum
|
||||
(pointer->procedure int64 (dynamic-func "test_ffi_sum" lib)
|
||||
(list int8 int16 int32 int64)))
|
||||
(test (f-sum -1 2000 -30000 40000000000)
|
||||
(+ -1 2000 -30000 40000000000))
|
||||
; test sign-extension of narrow arguments
|
||||
(test (f-sum -1 -2000 -30000 40000000000)
|
||||
(+ -1 -2000 -30000 40000000000))
|
||||
; test zero-extension of narrow arguments
|
||||
(test (f-sum 1 2000 30000 40000000000)
|
||||
(+ 1 2000 30000 40000000000))
|
||||
|
||||
;;
|
||||
;; Structs
|
||||
|
|
|
@ -87,6 +87,12 @@ scm_t_int16 test_ffi_s16_u8 (scm_t_uint8 a)
|
|||
return -20000 + a;
|
||||
}
|
||||
|
||||
scm_t_int16 test_ffi_s16_s8 (scm_t_int8 a);
|
||||
scm_t_int16 test_ffi_s16_s8 (scm_t_int8 a)
|
||||
{
|
||||
return -20000 + a;
|
||||
}
|
||||
|
||||
scm_t_int16 test_ffi_s16_s64 (scm_t_int64 a);
|
||||
scm_t_int16 test_ffi_s16_s64 (scm_t_int64 a)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue