[pypy-commit] pypy default: Cygwin patch by Uwe F. Mayer, slightly edited to minimize the length of

arigo noreply at buildbot.pypy.org
Wed Jun 13 13:19:20 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r55644:c7dff5469611
Date: 2012-06-13 13:19 +0200
http://bitbucket.org/pypy/pypy/changeset/c7dff5469611/

Log:	Cygwin patch by Uwe F. Mayer, slightly edited to minimize the length
	of the diff.

diff --git a/ctypes_configure/cbuild.py b/ctypes_configure/cbuild.py
--- a/ctypes_configure/cbuild.py
+++ b/ctypes_configure/cbuild.py
@@ -372,7 +372,7 @@
         self.library_dirs = list(eci.library_dirs)
         self.compiler_exe = compiler_exe
         self.profbased = profbased
-        if not sys.platform in ('win32', 'darwin'): # xxx
+        if not sys.platform in ('win32', 'darwin', 'cygwin'): # xxx
             if 'm' not in self.libraries:
                 self.libraries.append('m')
             if 'pthread' not in self.libraries:
diff --git a/pypy/rlib/rmmap.py b/pypy/rlib/rmmap.py
--- a/pypy/rlib/rmmap.py
+++ b/pypy/rlib/rmmap.py
@@ -14,6 +14,7 @@
 _MS_WINDOWS = os.name == "nt"
 _LINUX = "linux" in sys.platform
 _64BIT = "64bit" in platform.architecture()[0]
+_CYGWIN = "cygwin" == sys.platform
 
 class RValueError(Exception):
     def __init__(self, message):
@@ -115,6 +116,10 @@
 
 PTR = rffi.CCHARP
 
+if _CYGWIN:
+    c_malloc, _ = external('malloc', [size_t], PTR)
+    c_free, _ = external('free', [PTR], lltype.Void)
+
 c_memmove, _ = external('memmove', [PTR, PTR, size_t], lltype.Void)
 
 if _POSIX:
@@ -692,6 +697,14 @@
         so the memory has the executable bit set and gets allocated
         internally in case of a sandboxed process.
         """
+        if _CYGWIN:
+            # XXX: JIT memory should be using mmap MAP_PRIVATE with
+            #      PROT_EXEC but Cygwin's fork() fails.  mprotect()
+            #      cannot be used, but seems to be unnecessary there.
+            res = c_malloc(map_size)
+            if res == rffi.cast(PTR, 0):
+                raise MemoryError
+            return res
         flags = MAP_PRIVATE | MAP_ANONYMOUS
         prot = PROT_EXEC | PROT_READ | PROT_WRITE
         hintp = rffi.cast(PTR, hint.pos)
@@ -708,7 +721,10 @@
         return res
     alloc._annenforceargs_ = (int,)
 
-    free = c_munmap_safe
+    if _CYGWIN:
+        free = c_free
+    else:
+        free = c_munmap_safe
 
 elif _MS_WINDOWS:
     def mmap(fileno, length, tagname="", access=_ACCESS_DEFAULT, offset=0):
diff --git a/pypy/translator/c/src/thread_pthread.h b/pypy/translator/c/src/thread_pthread.h
--- a/pypy/translator/c/src/thread_pthread.h
+++ b/pypy/translator/c/src/thread_pthread.h
@@ -134,10 +134,15 @@
 	/* Jump through some hoops for Alpha OSF/1 */
 	threadid = pthread_self();
 
+#ifdef __CYGWIN__
+	/* typedef __uint32_t pthread_t; */
+	return (long) threadid;
+#else
 	if (sizeof(pthread_t) <= sizeof(long))
 		return (long) threadid;
 	else
 		return (long) *(long *) &threadid;
+#endif
 }
 
 static long _pypythread_stacksize = 0;
@@ -190,10 +195,15 @@
 
         pthread_detach(th);
 
+#ifdef __CYGWIN__
+	/* typedef __uint32_t pthread_t; */
+	return (long) th;
+#else
 	if (sizeof(pthread_t) <= sizeof(long))
 		return (long) th;
 	else
 		return (long) *(long *) &th;
+#endif
 }
 
 long RPyThreadGetStackSize(void)
diff --git a/pypy/translator/platform/distutils_platform.py b/pypy/translator/platform/distutils_platform.py
--- a/pypy/translator/platform/distutils_platform.py
+++ b/pypy/translator/platform/distutils_platform.py
@@ -52,7 +52,7 @@
         self.compile_extra = list(eci.compile_extra)
         self.link_extra = list(eci.link_extra)
         self.frameworks = list(eci.frameworks)
-        if not self.name in ('win32', 'darwin'): # xxx
+        if not self.name in ('win32', 'darwin', 'cygwin'): # xxx
             if 'm' not in self.libraries:
                 self.libraries.append('m')
             self.compile_extra += CFLAGS + ['-fomit-frame-pointer']


More information about the pypy-commit mailing list