summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKUWASHIMA yuichiro <ykuwashima@gmail.com>2013-05-05 02:04:39 +0900
committerKUWASHIMA yuichiro <ykuwashima@gmail.com>2013-05-05 02:04:39 +0900
commitfbffb4d15d10ae84464aecb844834fcb80be1ae3 (patch)
tree1f32a6942b7c6be1d7be96a1b84e45f26fc2b6f2
parent840e359f766776ba696b3360c8383536f3d2a8bb (diff)
downloadffi-fbffb4d15d10ae84464aecb844834fcb80be1ae3.tar.gz
Fix compile error for cygwin1.7.18, add check __CYGWIN_ macro.
-rw-r--r--ext/ffi_c/ClosurePool.c12
-rw-r--r--ext/ffi_c/Thread.c2
2 files changed, 7 insertions, 7 deletions
diff --git a/ext/ffi_c/ClosurePool.c b/ext/ffi_c/ClosurePool.c
index bcc2051..4e6637b 100644
--- a/ext/ffi_c/ClosurePool.c
+++ b/ext/ffi_c/ClosurePool.c
@@ -21,7 +21,7 @@
#include <sys/param.h>
#endif
#include <sys/types.h>
-#ifndef _WIN32
+#if defined(__CYGWIN__) || !defined(_WIN32)
# include <sys/mman.h>
#endif
#include <stdio.h>
@@ -32,7 +32,7 @@
# include "win32/stdbool.h"
# include "win32/stdint.h"
#endif
-#ifndef _WIN32
+#if defined(__CYGWIN__) || !defined(_WIN32)
# include <unistd.h>
#else
# include <winsock2.h>
@@ -225,7 +225,7 @@ rbffi_Closure_CodeAddress(Closure* handle)
static long
getPageSize()
{
-#if defined(_WIN32) || defined(__WIN32__)
+#if !defined(__CYGWIN__) && (defined(_WIN32) || defined(__WIN32__))
SYSTEM_INFO si;
GetSystemInfo(&si);
return si.dwPageSize;
@@ -237,7 +237,7 @@ getPageSize()
static void*
allocatePage(void)
{
-#if defined(_WIN32) || defined(__WIN32__)
+#if !defined(__CYGWIN__) && (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);
@@ -248,7 +248,7 @@ allocatePage(void)
static bool
freePage(void *addr)
{
-#if defined(_WIN32) || defined(__WIN32__)
+#if !defined(__CYGWIN__) && (defined(_WIN32) || defined(__WIN32__))
return VirtualFree(addr, 0, MEM_RELEASE);
#else
return munmap(addr, pageSize) == 0;
@@ -258,7 +258,7 @@ freePage(void *addr)
static bool
protectPage(void* page)
{
-#if defined(_WIN32) || defined(__WIN32__)
+#if !defined(__CYGWIN__) && (defined(_WIN32) || defined(__WIN32__))
DWORD oldProtect;
return VirtualProtect(page, pageSize, PAGE_EXECUTE_READ, &oldProtect);
#else
diff --git a/ext/ffi_c/Thread.c b/ext/ffi_c/Thread.c
index a67a6ed..20c8a3d 100644
--- a/ext/ffi_c/Thread.c
+++ b/ext/ffi_c/Thread.c
@@ -25,7 +25,7 @@
# include "win32/stdint.h"
#endif
-#ifndef _WIN32
+#if defined(__CYGWIN__) || !defined(_WIN32)
# include <pthread.h>
# include <errno.h>
# include <signal.h>