Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 May 2005 20:04:28 +0200
From:      "jean-marc DETREZ" <jm.detrez@cegetel.net>
To:        <wine-patches@winehq.com>, <emulation@freebsd.org>
Subject:   patch for unbreaking wine on freebsd (with the patch!!!!)
Message-ID:  <20050530180342.A6C7B1A453F@smtp.cegetel.net>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Hi, 

I'm currently testing a patch I've made for unbreaking wine 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).

 

What do you think of that, if it work for all (emulation@freebsd.com: could
you test) could you insert it in the future wine release?

 

 

Don't miss to give me feedback, I've a few more patch to send.

 

Jean-marc.

 

 

The patch is for libs/wine/mmap.c


[-- Attachment #2 --]
--- mmap.orig	Wed Dec 15 11:51:51 2004
+++ mmap.c	Sat May 28 21:58:35 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
  *
@@ -115,8 +115,9 @@ static int try_mmap_fixed (void *addr, s
         /* We call mincore() for every page in the desired range.
            If any of these calls succeeds, the page is already
            mapped and we must fail. */
+	/*patch for BSD testing the result of mincore not only if failed */
         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
@@ -137,7 +138,7 @@ static int try_mmap_fixed (void *addr, s
 
     return result == addr;
 }
-#endif  /* (__svr4__ || __NetBSD__) && !MAP_TRYFIXED */
+#endif  /* (__svr4__ || __NetBSD__ || __FreeBSD__) && !MAP_TRYFIXED */
 
 
 /***********************************************************************
@@ -182,10 +183,21 @@ void *wine_anon_mmap( void *start, size_
 #ifdef MAP_TRYFIXED
         /* If available, this will attempt a fixed mapping in-kernel */
         flags |= MAP_TRYFIXED;
-#elif defined(__svr4__) || defined(__NetBSD__)
+
+#elif defined(__svr4__) || defined(__NetBSD__) 
         if ( try_mmap_fixed( start, size, prot, flags, fdzero, 0 ) )
             return start;
+
+#elif defined(__FreeBSD__) 
+	/* for creating system heap use this to assure the adress of start is good*/
+	if (start== (void *)0x80000000)
+		{
+		if (try_mmap_fixed( start, size, prot, flags, fdzero, 0 ) )
+		  return start;
+		TRACE("Creating System Heap in FreeBSD using try_mmap_fixed");
+		}
 #endif
+
     }
     return mmap( start, size, prot, flags, fdzero, 0 );
 #else
@@ -249,6 +261,7 @@ static void reserve_dos_area(void)
     wine_anon_mmap( NULL, page_size, PROT_NONE, MAP_NORESERVE|MAP_FIXED );
     wine_mmap_add_reserved_area( NULL, dos_area_size );
 }
+
 
 
 /***********************************************************************
help

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