From: David Lichteblau Date: Tue, 9 Aug 2011 18:51:06 +0000 (+0200) Subject: Tweak os_validate to support running SBCL on recent versions of Wine X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=ef751cf976650ff2821644f0003e90276e41506d;p=sbcl.git Tweak os_validate to support running SBCL on recent versions of Wine SBCL now builds and runs on Wine reliably. Credits: Fix developed by Anton Kovalenko. --- diff --git a/NEWS b/NEWS index ff52c7d..53f446f 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ changes relative to sbcl-1.0.50: chroot. (Use "SBCL_ARCH=x86 sh make.sh" to build.) * enhancement: added new toplevel options --quit and --non-interactive (lp#822712). + * enhancement: the Windows port of SBCL now builds and runs on Wine + (thanks to Anton Kovalenko). * optimization: unsigned integer divisions by a constant are implemented using multiplication (affects CEILING, FLOOR, TRUNCATE, MOD, and REM.) * optimization: improved type-derivation for LOAD-TIME-VALUE. diff --git a/src/runtime/win32-os.c b/src/runtime/win32-os.c index c674ca6..a767461 100644 --- a/src/runtime/win32-os.c +++ b/src/runtime/win32-os.c @@ -161,7 +161,22 @@ os_validate(os_vm_address_t addr, os_vm_size_t len) return 0; } - if ((mem_info.State == MEM_RESERVE) && (mem_info.RegionSize >=len)) return addr; + if ((mem_info.State == MEM_RESERVE) && (mem_info.RegionSize >=len)) { + /* It would be correct to return here. However, support for Wine + * is beneficial, and Wine has a strange behavior in this + * department. It reports all memory below KERNEL32.DLL as + * reserved, but disallows MEM_COMMIT. + * + * Let's work around it: reserve the region we need for a second + * time. The second reservation is documented to fail on normal NT + * family, but it will succeed on Wine if this region is + * actually free. + */ + VirtualAlloc(addr, len, MEM_RESERVE, PAGE_EXECUTE_READWRITE); + /* If it is wine, the second call has succeded, and now the region + * is really reserved. */ + return addr; + } if (mem_info.State == MEM_RESERVE) { fprintf(stderr, "validation of reserved space too short.\n");