Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2005 23:19:57 +0200
From:      "jean-marc DETREZ" <jm.detrez@cegetel.net>
To:        <wine-patches@winehq.com>, <emulation@freebsd.org>
Cc:        barner@FreeBSD.org
Subject:   patch for libs/wine/mmap.c making wine running on FreeBSD 5.x
Message-ID:  <20050727212000.161C91A4282@smtp.cegetel.net>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi, 

I'm currently testing a patch I've made for unbreaking wine (20050725) on
FreeBSD.I'ts seems that like other OS a call to mmap() return not always the
desired address range.

 

For NetBSD it appears that a special function was compiled "try_mmap_fixed"
who call mmap with MAP_FIXED after verifying that the memory address is
free.

 

I'm use this function to Create Heap System at base address 0x80000000 , I
didn't always use that function for all calls to mmap because it seems that
cause performance issues.

 

  I made a little correction of  "try_mmap_fixed" because it's seems to me
that the function didn't really test the result (vec).

 

I've some feedbacks from users who could run wine on BSD with that patch.

 

Jean-marc.

 


[-- Attachment #2 --]
--- mmap.orig	Mon Jun 20 13:43:47 2005
+++ mmap.c	Wed Jul 27 22:26:53 2005
@@ -59,7 +59,7 @@ static inline int munmap( void *ptr, siz
 #endif
 
 
-#if (defined(__svr4__) || defined(__NetBSD__)) && !defined(MAP_TRYFIXED)
+#if (defined(__svr4__) || defined(__NetBSD__) || defined (__FreeBSD__)) && !defined(MAP_TRYFIXED)
 /***********************************************************************
  *             try_mmap_fixed
  *
@@ -116,7 +116,7 @@ static int try_mmap_fixed (void *addr, s
            If any of these calls succeeds, the page is already
            mapped and we must fail. */
         for ( i = 0; i < len; i += pagesize )
-            if ( mincore( (caddr_t)addr + i, pagesize, &vec ) != -1 )
+            if ( mincore( (caddr_t)addr + i, pagesize, &vec ) != -1 && (vec&1))
                _exit(1);
 
         /* Perform the mapping with MAP_FIXED set.  This is safe
@@ -159,7 +159,7 @@ static int try_mmap_fixed (void *addr, s
     }
 }
 
-#endif  /* (__svr4__ || __NetBSD__) && !MAP_TRYFIXED */
+#endif  /* (__svr4__ || __NetBSD__ || __FreeBSD__ ) && !MAP_TRYFIXED */
 
 
 /***********************************************************************
@@ -207,6 +207,13 @@ void *wine_anon_mmap( void *start, size_
 #elif defined(__svr4__) || defined(__NetBSD__) || defined(__APPLE__)
         if ( try_mmap_fixed( start, size, prot, flags, fdzero, 0 ) )
             return start;
+#elif defined(__FreeBSD__)
+	/*for FreeBSD assure system heap adress of 0x80000000*/
+	if (start == (void *)0x80000000)
+		{
+		if (try_mmap_fixed( start, size, prot, flags, fdzero, 0 ) )
+		return start;
+		}
 #endif
     }
     return mmap( start, size, prot, flags, fdzero, 0 );

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050727212000.161C91A4282>