loader [2/2]: change FreeBSD startup

Tijl Coosemans tijl at ulyssis.org
Tue Aug 8 10:16:57 CDT 2006


* reduce RLIMIT_DATA on FreeBSD


Index: loader/glibc.c
===================================================================
RCS file: /home/wine/wine/loader/glibc.c,v
retrieving revision 1.7
diff -u -r1.7 glibc.c
--- loader/glibc.c	23 May 2006 12:49:14 -0000	1.7
+++ loader/glibc.c	8 Aug 2006 15:04:55 -0000
@@ -27,6 +27,9 @@
 #ifdef HAVE_SYS_MMAN_H
 # include <sys/mman.h>
 #endif
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
@@ -102,6 +105,26 @@
  */
 int main( int argc, char *argv[] )
 {
+#if defined(__i386__) || defined(__x86_64__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+/* FreeBSD mmap preserves space for the maximum possible data segment.
+   With the Wine loader located at the end of the first 2Gb of address
+   space, this means that all libs are loaded in the second 2Gb, which
+   some (older) windows programs may not like.
+   Additionally, some users increase their default data segment size
+   to 1Gb and more, causing mmap to simply run out of user address
+   space.
+   So we lower the limit to a sensible value before doing anything
+   else and locate the Wine loader somewhat lower in mem than in Linux.
+   This limit is inherited by all processes created by this process,
+   including wineserver.  */
+    struct rlimit rl;
+    rl.rlim_cur = 0x18000000;
+    rl.rlim_max = 0x18000000;
+    setrlimit( RLIMIT_DATA, &rl );
+#endif
+#endif
+
     const char *loader = getenv( "WINELOADER" );
     const char *threads = get_threading();
     const char *new_argv0 = build_new_path( argv[0], threads );



More information about the wine-patches mailing list