Windows and mmap

1,733 views
Skip to first unread message

Stan

unread,
Nov 23, 2009, 1:57:40 PM11/23/09
to Avian
Windows, at least mingw, doesn't have sys/mmap.h. Instead I changed
main.cpp to use the MS equivalents for memory mapping:

17,19d16
< #ifdef WIN32
< #include <windows.h>
< #else
21d17
< #endif
159,176d154
< #ifdef WIN32
< HANDLE fm;
< HANDLE h = (HANDLE) _get_osfhandle (fd);
<
< fm = CreateFileMapping(
< h,
< NULL,
< PAGE_READONLY,
< 0,
< 0,
< NULL);
< data = static_cast<uint8_t*>(MapViewOfFile(
< fm,
< FILE_MAP_READ,
< 0,
< 0,
< s.st_size));
< #else
179d156
< #endif
181d157
<
200,202d175
< #ifdef WIN32
< UnmapViewOfFile(data);
< #else
204d176
< #endif

Stan

unread,
Nov 23, 2009, 2:07:26 PM11/23/09
to Avian
Oh, probably want to close that file mapping handle:

CloseHandle(fm);
Message has been deleted

Joel Dice

unread,
Nov 24, 2009, 10:34:36 AM11/24/09
to Avian
On Nov 23, 12:07 pm, Stan <goo.in.my.sh...@gmail.com> wrote:
> Oh, probably want to close that file mapping handle:
>
> CloseHandle(fm);
>
> On Nov 23, 1:57 pm, Stan <goo.in.my.sh...@gmail.com> wrote:
>
> > Windows, at least mingw, doesn't have sys/mmap.h.  Instead I changed
> > main.cpp to use the MS equivalents for memory mapping:
...

I've applied your patch. Thanks!
Reply all
Reply to author
Forward
0 new messages