[PATCH] ntdll: Use the old mmap() wrapper on 32-bit Mac OS. (try 3)

Charles Davis cdavis at mymail.mines.edu
Fri May 14 13:46:51 CDT 2010


From: Charles Davis <cdavis at mines.edu>

This version doesn't have the 64-bit wrapper.
---
 dlls/ntdll/virtual.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 6fedbf3..9cfffaf 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -61,6 +61,22 @@
 WINE_DEFAULT_DEBUG_CHANNEL(virtual);
 WINE_DECLARE_DEBUG_CHANNEL(module);
 
+/*
+ * In Mac OS 10.5, the mmap() function was changed to match UNIX '03 (as
+ * Linux does). In particular, this means that unaligned file offsets fail
+ * with EINVAL. However, that check is done at the library level, not the
+ * kernel level. This is done to maintain backwards compatibility with old
+ * programs that expect unaligned offsets to succeed.
+ * The old wrapper is still exported from the 32-bit libc, so we use that
+ * on Mac OS. Everywhere else, we use the default mmap().
+ */
+#if defined(__APPLE__) && !defined(__x86_64__)
+extern void *wine_mmap( void *start, size_t size, int port, int flags, int fd,
+                        off_t off ) __asm("_mmap");
+#else
+#define wine_mmap mmap
+#endif
+
 #ifndef MS_SYNC
 #define MS_SYNC 0
 #endif
@@ -867,7 +883,7 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start
     {
         int flags = MAP_FIXED | (shared_write ? MAP_SHARED : MAP_PRIVATE);
 
-        if (mmap( (char *)view->base + start, size, prot, flags, fd, offset ) != (void *)-1)
+        if (wine_mmap( (char *)view->base + start, size, prot, flags, fd, offset ) != (void *)-1)
             goto done;
 
         /* mmap() failed; if this is because the file offset is not    */
-- 
1.7.1




More information about the wine-patches mailing list