configure: Check for madvise and posix_madvise

André Hentschel nerv at dawncrow.de
Sat Nov 10 11:31:14 CST 2012


---
 configure.ac         | 2 ++
 dlls/ntdll/virtual.c | 9 ++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index cc32c24..a907758 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1996,6 +1996,7 @@ AC_CHECK_FUNCS(\
 	getuid \
 	kqueue \
 	lstat \
+	madvise \
 	memmove \
 	mmap \
 	pclose \
@@ -2003,6 +2004,7 @@ AC_CHECK_FUNCS(\
 	poll \
 	popen \
 	port_create \
+	posix_madvise \
 	prctl \
 	pread \
 	pwrite \
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 88bcdbb..30df655 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1940,7 +1940,14 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
     else if (type & MEM_RESET)
     {
         if (!(view = VIRTUAL_FindView( base, size ))) status = STATUS_NOT_MAPPED_VIEW;
-        else madvise( base, size, MADV_DONTNEED );
+        else
+        {
+#if defined(HAVE_MADVISE)
+            madvise( base, size, MADV_DONTNEED );
+#elif defined(HAVE_POSIX_MADVISE)
+            posix_madvise( base, size, MADV_DONTNEED );
+#endif
+        }
     }
     else  /* commit the pages */
     {
-- 
1.8.0


-- 

Best Regards, André Hentschel


More information about the wine-patches mailing list