[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    patch for unbreaking wine on freebsd (with the patch!!!!)
From:       "jean-marc DETREZ" <jm.detrez () cegetel ! net>
Date:       2005-05-30 18:04:28
Message-ID: 20050530180342.A6C7B1A453F () smtp ! cegetel ! net
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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 #5 (text/html)]

<html xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:Arial;
	color:windowtext;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=FR link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Hi, <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>I&#8217;m currently testing a patch I&#8217;ve made
for unbreaking wine on FreeBSD.I&#8217;ts seems that like other OS a call to
mmap() return not always the desired address range.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>For NetBSD it appears that a special function was
compiled &#8220;try_mmap_fixed&#8221; who call mmap with MAP_FIXED after
verifying that the memory address is free.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>I&#8217;m use this function to Create Heap System at
base address 0x80000000 , I didn&#8217;t always use that function for all calls
to mmap because it seems that cause performance issues.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>&nbsp;&nbsp;I made a little correction of
&nbsp;&#8220;try_mmap_fixed&#8221; because it&#8217;s seems to me that the
function didn&#8217;t really test the result (vec).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>What do you think of that, if it work for all (<a
href="mailto:emulation@freebsd.com" \
title="mailto:emulation@freebsd.com">emulation@freebsd.com</a>: could you test) could \
you insert it in the future wine release?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Don&#8217;t miss to give me feedback, I&#8217;ve a
few more patch to send.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Jean-marc.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>The patch is for \
libs/wine/mmap.c<o:p></o:p></span></font></p>

</div>

</body>

</html>


["mmap.patch" (application/octet-stream)]

--- 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 );
 }
+
 
 
 /***********************************************************************

["Screen01.JPG" (image/jpeg)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic