diff options
author | Wayne Meissner <wmeissner@gmail.com> | 2009-11-06 05:38:48 +1000 |
---|---|---|
committer | Wayne Meissner <wmeissner@gmail.com> | 2009-11-06 05:52:50 +1000 |
commit | 3d0e391509c2931c74eca9185c863463e3e3236e (patch) | |
tree | 74fe4fba19904d75c32b4ee3154d5421d9b083a1 | |
parent | 94ac817d1fc6cf490fd892489e9a4c2a8a87fd47 (diff) | |
download | ffi-3d0e391509c2931c74eca9185c863463e3e3236e.tar.gz |
Apply cygwin patches from Joe Khoobyar <joe@ankhcraft.com>
-rw-r--r-- | ext/ffi_c/ClosurePool.c | 12 | ||||
-rw-r--r-- | ext/ffi_c/endian.h | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/ext/ffi_c/ClosurePool.c b/ext/ffi_c/ClosurePool.c index 1a7d6c4..7190f1a 100644 --- a/ext/ffi_c/ClosurePool.c +++ b/ext/ffi_c/ClosurePool.c @@ -35,6 +35,8 @@ #include <stdbool.h> #ifndef _WIN32 # include <unistd.h> +#else +# include <windows.h> #endif #include <errno.h> #include <ruby.h> @@ -111,7 +113,7 @@ rbffi_ClosurePool_New(int closureSize, pool->prep = prep; pool->refcnt = 1; -#if defined(HAVE_NATIVETHREAD) && !defined(_WIN32) && !defined(__WIN32__) +#if defined(HAVE_NATIVETHREAD) && !defined(_WIN32) pthread_mutex_init(&pool->mutex, NULL); #endif @@ -253,7 +255,7 @@ rbffi_Closure_CodeAddress(Closure* handle) static int getPageSize() { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__WIN32__) SYSTEM_INFO si; GetSystemInfo(&si); return si.dwPageSize; @@ -265,7 +267,7 @@ getPageSize() static void* allocatePage(void) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__WIN32__) return VirtualAlloc(NULL, pageSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #else caddr_t page = mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -276,7 +278,7 @@ allocatePage(void) static bool freePage(void *addr) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__WIN32__) return VirtualFree(addr, 0, MEM_RELEASE); #else return munmap(addr, pageSize) == 0; @@ -286,7 +288,7 @@ freePage(void *addr) static bool protectPage(void* page) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__WIN32__) DWORD oldProtect; return VirtualProtect(page, pageSize, PAGE_EXECUTE_READ, &oldProtect); #else diff --git a/ext/ffi_c/endian.h b/ext/ffi_c/endian.h index 1d1c981..db506d5 100644 --- a/ext/ffi_c/endian.h +++ b/ext/ffi_c/endian.h @@ -4,7 +4,7 @@ #include <sys/param.h> #include <sys/types.h> -#ifdef __linux__ +#if defined(__linux__) || defined(__CYGWIN__) # include_next <endian.h> #endif |