diff options
author | Anthony Green <green@moxielogic.com> | 2022-09-14 07:07:15 -0400 |
---|---|---|
committer | Anthony Green <green@moxielogic.com> | 2022-09-14 07:07:15 -0400 |
commit | 819b01ced894028d41a34ec0178de9e7637b23de (patch) | |
tree | 1cd926fdef2dfaff890308feeb5849ffa56019a2 /testsuite | |
parent | b577a5b801b1d1aef1aec5920d34fd1fd6597122 (diff) | |
download | libffi-819b01ced894028d41a34ec0178de9e7637b23de.tar.gz |
Add test case
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/libffi.call/bpo-38748.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/testsuite/libffi.call/bpo-38748.c b/testsuite/libffi.call/bpo-38748.c new file mode 100644 index 0000000..26ea270 --- /dev/null +++ b/testsuite/libffi.call/bpo-38748.c @@ -0,0 +1,40 @@ +/* Area: bpo-38748 + Purpose: test for stdcall alignment problem + Source: github.com/python/cpython/pull/26204 */ + +/* { dg-do run } */ + +#include "ffitest.h" +#include "ffi_common.h" + +static long ABI_ATTR align_arguments(long l1, + long long l2) +{ + return l1 + l2; +} + +int main(void) +{ + ffi_cif cif; + ffi_type *args[4] = { + &ffi_type_uint32, + &ffi_type_uint64 + }; + UINT32 lr1, lr2, l1 = 1; + UINT64 l2 = 2; + void *values[2] = {&l1, &l2}; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, + &ffi_type_uint32, args) == FFI_OK); + + lr1 = align_arguments(l1, l2); + + ffi_call(&cif, FFI_FN(align_arguments), &lr2, values); + + if (lr1 == lr2) + printf("bpo-38748 arguments tests ok!\n"); + else + CHECK(0); + exit(0); +} |