Skip to content
Snippets Groups Projects
Commit 8b7dc908 authored by sof's avatar sof
Browse files

[project @ 1999-01-14 18:31:17 by sof]

Forgot to commit this before Christmas...on Win32 platforms use
VirtualAlloc() instead CreateFileMapping()&friends to ask for
mega-blocks from the OS. Windows 95-friendlier.
parent abcfc36e
No related branches found
No related tags found
No related merge requests found
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: MBlock.c,v 1.3 1999/01/13 17:25:40 simonm Exp $ * $Id: MBlock.c,v 1.4 1999/01/14 18:31:17 sof Exp $
* *
* MegaBlock Allocator Interface. This file contains all the dirty * MegaBlock Allocator Interface. This file contains all the dirty
* architecture-dependent hackery required to get a chunk of aligned * architecture-dependent hackery required to get a chunk of aligned
...@@ -87,32 +87,22 @@ getMBlocks(nat n) ...@@ -87,32 +87,22 @@ getMBlocks(nat n)
#else #else
# ifdef _WIN32 # ifdef _WIN32
{ {
/* avoid using cygwin32's mmap implementation, it's buggy and /* Note: on 95, the legal range for next_request is: [0x00400000, 0x7fffffff]
it's just as easy to do what we want to do directly. under NT it is: [0x00010000, 0x7fffffff]
*/
HANDLE hFile = (HANDLE)0xFFFFFFFF;
SECURITY_ATTRIBUTES sa;
HANDLE h;
sa.nLength = sizeof (SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = 0;
h = CreateFileMapping(hFile, &sa, PAGE_READWRITE, 0, size, NULL); We start allocating at 0x50000000, hopefully that's not conflicting with
if ( h == 0 ) { others.. (ToDo: have the allocator try to gracefully rebase itself in
# ifdef DEBUG case our initial guess is conflicting with others.)
fprintf(stderr, "getMBlocks: CreateFileMapping failed with: %d\n", GetLastError()); */
# endif ret = VirtualAlloc(next_request, size, MEM_RESERVE | MEM_COMMIT , PAGE_READWRITE);
ret=(void*)-1; if (!ret) {
} else {
ret = MapViewOfFileEx (h, FILE_MAP_WRITE, 0, 0, size, next_request);
if ( ret != next_request ) {
# ifdef DEBUG # ifdef DEBUG
fprintf(stderr, "getMBlocks: MapViewOfFileEx failed with: %d\n", GetLastError()); fprintf(stderr, "getMBlocks: VirtualAlloc failed with: %d\n", GetLastError());
# endif # endif
ret =(void*)-1; ret =(void*)-1;
}
} }
return ret;
} }
# else # else
ret = mmap(next_request, size, PROT_READ | PROT_WRITE, ret = mmap(next_request, size, PROT_READ | PROT_WRITE,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment