Alexandre Julliard : libwine:
Only try to mmap the exact address when reserving memory.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Apr 14 04:13:17 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: e814b24e6d2eb0252a9da9ce074de5d78f1745af
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=e814b24e6d2eb0252a9da9ce074de5d78f1745af
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Apr 13 21:55:33 2006 +0200
libwine: Only try to mmap the exact address when reserving memory.
This should avoid some extra work on platforms that need the
try_mmap_fixed function.
---
libs/wine/mmap.c | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/libs/wine/mmap.c b/libs/wine/mmap.c
index dbfa8a2..76fb7ff 100644
--- a/libs/wine/mmap.c
+++ b/libs/wine/mmap.c
@@ -218,6 +218,27 @@ void *wine_anon_mmap( void *start, size_
/***********************************************************************
+ * mmap_reserve
+ *
+ * mmap wrapper used for reservations, only maps the specified address
+ */
+static inline int mmap_reserve( void *addr, size_t size )
+{
+ void *ptr;
+ int flags = MAP_PRIVATE | MAP_ANON | MAP_NORESERVE;
+
+#ifdef MAP_TRYFIXED
+ flags |= MAP_TRYFIXED;
+#elif defined(__svr4__) || defined(__NetBSD__) || defined(__APPLE__)
+ return try_mmap_fixed( addr, size, PROT_NONE, flags, get_fdzero(), 0 );
+#endif
+ ptr = mmap( addr, size, PROT_NONE, flags, get_fdzero(), 0 );
+ if (ptr != addr && ptr != (void *)-1) munmap( ptr, size );
+ return (ptr == addr);
+}
+
+
+/***********************************************************************
* reserve_area
*
* Reserve as much memory as possible in the given area.
@@ -225,19 +246,14 @@ void *wine_anon_mmap( void *start, size_
*/
static void reserve_area( void *addr, void *end )
{
- void *ptr;
size_t size = (char *)end - (char *)addr;
if (!size) return;
- if ((ptr = wine_anon_mmap( addr, size, PROT_NONE, MAP_NORESERVE )) != (void *)-1)
+ if (mmap_reserve( addr, size ))
{
- if (ptr == addr)
- {
- wine_mmap_add_reserved_area( addr, size );
- return;
- }
- else munmap( ptr, size );
+ wine_mmap_add_reserved_area( addr, size );
+ return;
}
if (size > granularity_mask + 1)
{
More information about the wine-cvs
mailing list