Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
72b97eeb
Commit
72b97eeb
authored
Sep 03, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add a helper function for memory allocations through mmap().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
74deee7d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
server.c
dlls/ntdll/unix/server.c
+2
-3
unix_private.h
dlls/ntdll/unix/unix_private.h
+1
-0
virtual.c
dlls/ntdll/unix/virtual.c
+13
-6
No files found.
dlls/ntdll/unix/server.c
View file @
72b97eeb
...
...
@@ -85,7 +85,6 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winnt.h"
#include "wine/library.h"
#include "wine/server.h"
#include "wine/debug.h"
#include "unix_private.h"
...
...
@@ -914,8 +913,8 @@ static BOOL add_fd_to_cache( HANDLE handle, int fd, enum server_fd_type type,
if
(
!
entry
)
fd_cache
[
0
]
=
fd_cache_initial_block
;
else
{
void
*
ptr
=
wine_anon_mmap
(
NULL
,
FD_CACHE_BLOCK_SIZE
*
sizeof
(
union
fd_cache_entry
),
PROT_READ
|
PROT_WRITE
,
0
);
void
*
ptr
=
anon_mmap_alloc
(
FD_CACHE_BLOCK_SIZE
*
sizeof
(
union
fd_cache_entry
),
PROT_READ
|
PROT_WRITE
);
if
(
ptr
==
MAP_FAILED
)
return
FALSE
;
fd_cache
[
entry
]
=
ptr
;
}
...
...
dlls/ntdll/unix/unix_private.h
View file @
72b97eeb
...
...
@@ -177,6 +177,7 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o
data_size_t
*
ret_len
)
DECLSPEC_HIDDEN
;
extern
void
*
anon_mmap_fixed
(
void
*
start
,
size_t
size
,
int
prot
,
int
flags
)
DECLSPEC_HIDDEN
;
extern
void
*
anon_mmap_alloc
(
size_t
size
,
int
prot
)
DECLSPEC_HIDDEN
;
extern
void
virtual_init
(
void
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
virtual_map_ntdll
(
int
fd
,
void
**
module
)
DECLSPEC_HIDDEN
;
extern
ULONG_PTR
get_system_affinity_mask
(
void
)
DECLSPEC_HIDDEN
;
...
...
dlls/ntdll/unix/virtual.c
View file @
72b97eeb
...
...
@@ -217,6 +217,13 @@ void *anon_mmap_fixed( void *start, size_t size, int prot, int flags )
return
mmap
(
start
,
size
,
prot
,
MAP_PRIVATE
|
MAP_ANON
|
MAP_FIXED
|
flags
,
-
1
,
0
);
}
/* allocate anonymous mmap() memory at any address */
void
*
anon_mmap_alloc
(
size_t
size
,
int
prot
)
{
return
mmap
(
NULL
,
size
,
prot
,
MAP_PRIVATE
|
MAP_ANON
,
-
1
,
0
);
}
static
void
mmap_add_reserved_area
(
void
*
addr
,
SIZE_T
size
)
{
struct
reserved_area
*
area
;
...
...
@@ -756,7 +763,7 @@ static BOOL alloc_pages_vprot( const void *addr, size_t size )
for
(
i
=
idx
>>
pages_vprot_shift
;
i
<
(
end
+
pages_vprot_mask
)
>>
pages_vprot_shift
;
i
++
)
{
if
(
pages_vprot
[
i
])
continue
;
if
((
ptr
=
wine_anon_mmap
(
NULL
,
pages_vprot_mask
+
1
,
PROT_READ
|
PROT_WRITE
,
0
))
==
(
void
*
)
-
1
)
if
((
ptr
=
anon_mmap_alloc
(
pages_vprot_mask
+
1
,
PROT_READ
|
PROT_WRITE
))
==
MAP_FAILED
)
return
FALSE
;
pages_vprot
[
i
]
=
ptr
;
}
...
...
@@ -1299,8 +1306,8 @@ static struct file_view *alloc_view(void)
}
if
(
view_block_start
==
view_block_end
)
{
void
*
ptr
=
wine_anon_mmap
(
NULL
,
view_block_size
,
PROT_READ
|
PROT_WRITE
,
0
);
if
(
ptr
==
(
void
*
)
-
1
)
return
NULL
;
void
*
ptr
=
anon_mmap_alloc
(
view_block_size
,
PROT_READ
|
PROT_WRITE
);
if
(
ptr
==
MAP_FAILED
)
return
NULL
;
view_block_start
=
ptr
;
view_block_end
=
view_block_start
+
view_block_size
/
sizeof
(
*
view_block_start
);
}
...
...
@@ -1746,7 +1753,7 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
for
(;;)
{
if
((
ptr
=
wine_anon_mmap
(
NULL
,
view_size
,
get_unix_prot
(
vprot
),
0
))
==
(
void
*
)
-
1
)
if
((
ptr
=
anon_mmap_alloc
(
view_size
,
get_unix_prot
(
vprot
)
))
==
MAP_FAILED
)
{
if
(
errno
==
ENOMEM
)
return
STATUS_NO_MEMORY
;
return
STATUS_INVALID_PARAMETER
;
...
...
@@ -2405,9 +2412,9 @@ void virtual_init(void)
if
(
mmap_enum_reserved_areas
(
alloc_virtual_heap
,
&
alloc_views
,
1
))
mmap_remove_reserved_area
(
alloc_views
.
base
,
alloc_views
.
size
);
else
alloc_views
.
base
=
wine_anon_mmap
(
NULL
,
alloc_views
.
size
,
PROT_READ
|
PROT_WRITE
,
0
);
alloc_views
.
base
=
anon_mmap_alloc
(
alloc_views
.
size
,
PROT_READ
|
PROT_WRITE
);
assert
(
alloc_views
.
base
!=
(
void
*
)
-
1
);
assert
(
alloc_views
.
base
!=
MAP_FAILED
);
view_block_start
=
alloc_views
.
base
;
view_block_end
=
view_block_start
+
view_block_size
/
sizeof
(
*
view_block_start
);
free_ranges
=
(
void
*
)((
char
*
)
alloc_views
.
base
+
view_block_size
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment