diff options
author | Andrea Fazzi <andrea.fazzi@alcacoop.it> | 2009-10-04 00:44:56 +0200 |
---|---|---|
committer | Andrea Fazzi <andrea.fazzi@alcacoop.it> | 2009-10-04 00:44:56 +0200 |
commit | 3f750078177ddb4bfe749b43f6a8dcc64f99294d (patch) | |
tree | 34a97361983ce6d71f5432d005576e93fe12c82b | |
parent | 3e1b4bab589d51a5790b0b1eea7721b71848ef62 (diff) | |
download | ffi-3f750078177ddb4bfe749b43f6a8dcc64f99294d.tar.gz |
Fix calling convention issues on windows
Fix libtest compilation issues on windows
-rw-r--r-- | ext/ffi_c/FunctionInfo.c | 3 | ||||
-rw-r--r-- | ext/ffi_c/Variadic.c | 3 | ||||
-rw-r--r-- | libtest/FunctionTest.c | 5 | ||||
-rw-r--r-- | libtest/GNUmakefile | 4 |
4 files changed, 11 insertions, 4 deletions
diff --git a/ext/ffi_c/FunctionInfo.c b/ext/ffi_c/FunctionInfo.c index 80ea97b..c8aa892 100644 --- a/ext/ffi_c/FunctionInfo.c +++ b/ext/ffi_c/FunctionInfo.c @@ -158,7 +158,8 @@ fntype_initialize(int argc, VALUE* argv, VALUE self) #if defined(_WIN32) || defined(__WIN32__) - fnInfo->abi = (rbConvention != Qnil && strcmp(StringValueCStr(rbConvention), "stdcall") == 0) + VALUE rbConventionStr = rb_funcall2(rbConvention, rb_intern("to_s"), 0, NULL); + fnInfo->abi = (rbConvention != Qnil && strcmp(StringValueCStr(rbConventionStr), "stdcall") == 0) ? FFI_STDCALL : FFI_DEFAULT_ABI; #else fnInfo->abi = FFI_DEFAULT_ABI; diff --git a/ext/ffi_c/Variadic.c b/ext/ffi_c/Variadic.c index 0395049..16ce7a6 100644 --- a/ext/ffi_c/Variadic.c +++ b/ext/ffi_c/Variadic.c @@ -104,7 +104,8 @@ variadic_initialize(VALUE self, VALUE rbFunction, VALUE rbParameterTypes, VALUE invoker->function = rbffi_AbstractMemory_Cast(rbFunction, rbffi_PointerClass)->address; #if defined(_WIN32) || defined(__WIN32__) - invoker->abi = (RTEST(convention) && strcmp(StringValueCStr(convention), "stdcall") == 0) + VALUE rbConventionStr = rb_funcall2(convention, rb_intern("to_s"), 0, NULL); + invoker->abi = (RTEST(convention) && strcmp(StringValueCStr(rbConventionStr), "stdcall") == 0) ? FFI_STDCALL : FFI_DEFAULT_ABI; #else invoker->abi = FFI_DEFAULT_ABI; diff --git a/libtest/FunctionTest.c b/libtest/FunctionTest.c index fc1040a..730b37c 100644 --- a/libtest/FunctionTest.c +++ b/libtest/FunctionTest.c @@ -27,6 +27,11 @@ #include <unistd.h> +#ifdef __WIN32__ +#include <windows.h> +#define sleep(x) Sleep(x) +#endif + int testAdd(int a, int b) { return a + b; diff --git a/libtest/GNUmakefile b/libtest/GNUmakefile index 9d06df2..0aecfd9 100644 --- a/libtest/GNUmakefile +++ b/libtest/GNUmakefile @@ -31,7 +31,7 @@ CCACHE := $(strip $(realpath $(shell which ccache 2> /dev/null))) TEST_SRCS = $(wildcard $(SRC_DIR)/*.c) TEST_OBJS := $(patsubst $(SRC_DIR)/%.c, $(TEST_BUILD_DIR)/%.o, $(TEST_SRCS)) - + # # Compiler/linker flags from: # http://weblogs.java.net/blog/kellyohair/archive/2006/01/compilation_of_1.html @@ -53,7 +53,7 @@ ifneq ($(strip $(findstring $(OS), win32, mingw, cygwin)),) endif PICFLAGS= LIBEXT=dll - CC ?= gcc + CC = gcc endif ifeq ($(OS), darwin) |