This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH GOLD] [7/N mingw host] Instead of using ::mmap use CreateFileMapping/MapViewOfFile
- From: Andrew Pinski <Andrew_Pinski at playstation dot sony dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Wed, 7 Oct 2009 12:31:09 -0700
- Subject: [PATCH GOLD] [7/N mingw host] Instead of using ::mmap use CreateFileMapping/MapViewOfFile
Hi,
Mingw does not have the mmap function but it does have the ability
to map files into memory. Using the CreateFileMapping/MapViewOfFile
Win32 APIs we can map the files into memory. Or even do an anonymous
mapping.
This patch has some #ifdef _WIN32 in it, I did not have time to figure
out the best way to extract that from it but it should not be hard
with classes and such.
This is my last patch using mingw as the host OS when building gold.
Built and tested on i686-linux-gnu.
I also built and tested with 5 patches together on i686-mingw
targeting i686-linux-gnu.
Thanks,
Andrew Pinski
ChangeLog:
* fileread.cc: Don't include sys/mman.h and sys/uio.h on Win32 but do
include windows.h.
(File_read::View::~View): Use UnmapViewOfFile instead of munmap on win32.
(File_read::make_view): Use CreateFileMapping/MapViewOfFile instead of
mmap on win32.
* fileread.h (File_read::page_size): Set to 64k.
* mremap.c: Don't include sys/mman.h on Win32 but do include windows.h.
(mremap): Use CreateFileMapping/MapViewOfFile instead of mmap and
UnmapViewOfFile instead of munmap on win32.
* output.cc: Don't include sys/mman.h on Win32 but do include windows.h.
(Output_file::map_anonymous): Use CreateFileMapping/MapViewOfFile
instead of mmap on win32..
(Output_file::map_no_anonymous): Likewise.
(Output_file::unmap): Use UnmapViewOfFile instead of munmap on win32.