Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 May 2005 20:11:02 +0200
From:      "jean-marc DETREZ" <jm.detrez@cegetel.net>
To:        <emulation@freebsd.org>
Subject:   patch for unbreaking wine on freebsd 
Message-ID:  <20050530181015.98A2C1A4438@smtp.cegetel.net>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

------=_NextPart_000_000C_01C56553.B506F470
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

=20

=20

  _____ =20

De : jean-marc DETREZ [mailto:jm.detrez@cegetel.net]=20
Envoy=E9 : lundi 30 mai 2005 20:04
=C0 : 'wine-patches@winehq.com'; 'emulation@freebsd.org'
Cc : 'Gerald Pfeifer'
Objet : patch for unbreaking wine on freebsd (with the patch!!!!)

=20

Hi,=20

I=92m currently testing a patch I=92ve made for unbreaking wine on =
FreeBSD.

=20

It=92s seems that like other OS a call to mmap() return not always the =
desired
address range.

=20

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

=20

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

=20

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

=20

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?

=20

=20

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

=20

Jean-marc.

=20

=20

The patch is for libs/wine/mmap.c


------=_NextPart_000_000C_01C56553.B506F470
Content-Type: application/octet-stream;
	name="mmap.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="mmap.patch"

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

------=_NextPart_000_000C_01C56553.B506F470--





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