From 8703becf83c816db5e48519ceebb11ef87fd3344 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Wed, 5 Aug 2015 18:13:13 +0200 Subject: Synchronize changes between libtest and spec/ffi/fixtures directories. --- libtest/VariadicTest.c | 37 +++++++++++++++++++++++++++++++++++++ spec/ffi/fixtures/ClosureTest.c | 15 +++++++++++++++ spec/ffi/fixtures/FunctionTest.c | 16 ++++++++++++++-- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/libtest/VariadicTest.c b/libtest/VariadicTest.c index fea6c3b..2f3d801 100644 --- a/libtest/VariadicTest.c +++ b/libtest/VariadicTest.c @@ -60,3 +60,40 @@ void pack_varargs(s64* buf, const char* fmt, ...) va_end(ap); } +int pack_varargs2(s64* buf, int retval, const char* fmt, ...) +{ + va_list ap; + int c; + double d; + va_start(ap, fmt); + while ((c = *fmt++)) { + switch (c) { + case 'c': + case 's': + case 'i': + *buf++ = va_arg(ap, s32); + break; + case 'l': + *buf++ = va_arg(ap, long); + break; + case 'j': + *buf++ = va_arg(ap, s64); + break; + case 'f': + case 'd': + d = va_arg(ap, double); + memcpy(buf++, &d, sizeof(d)); + break; + case 'C': + case 'S': + case 'I': + *buf++ = va_arg(ap, u32); + break; + case 'L': + *buf++ = va_arg(ap, unsigned long); + break; + } + } + va_end(ap); + return retval + 1; +} diff --git a/spec/ffi/fixtures/ClosureTest.c b/spec/ffi/fixtures/ClosureTest.c index 64ea2b4..dfeabde 100644 --- a/spec/ffi/fixtures/ClosureTest.c +++ b/spec/ffi/fixtures/ClosureTest.c @@ -50,6 +50,21 @@ P(D, double); P(P, const void*); P(UL, unsigned long); +#if defined(_WIN32) && !defined(_WIN64) +bool __stdcall testClosureStdcall(long *a1, void __stdcall(*closure)(void *, long), long a2) { \ + void* sp_pre; + void* sp_post; + + asm volatile (" movl %%esp,%0" : "=g" (sp_pre)); + (*closure)(a1, a2); + asm volatile (" movl %%esp,%0" : "=g" (sp_post)); + + /* %esp before pushing parameters on the stack and after the call returns + * should be equal, if both sides respects the stdcall convention */ + return sp_pre == sp_post; +} +#endif + void testOptionalClosureBrV(void (*closure)(char), char a1) { if (closure) { diff --git a/spec/ffi/fixtures/FunctionTest.c b/spec/ffi/fixtures/FunctionTest.c index b4d45bb..5310ab0 100644 --- a/spec/ffi/fixtures/FunctionTest.c +++ b/spec/ffi/fixtures/FunctionTest.c @@ -6,7 +6,7 @@ #ifdef _WIN32 #include -#define sleep(x) Sleep(x) +#define sleep(x) Sleep((x)*1000) #endif #ifndef _WIN32 @@ -55,4 +55,16 @@ void testAsyncCallback(void (*fn)(int), int value) #else (*fn)(value); #endif -} +} + +#if defined(_WIN32) && !defined(_WIN64) +struct StructUCDP { + unsigned char a1; + double a2; + void *a3; +}; + +void __stdcall testStdcallManyParams(long *a1, char a2, short int a3, int a4, __int64 a5, + struct StructUCDP a6, struct StructUCDP *a7, float a8, double a9) { +} +#endif -- cgit v1.2.1