joto / osmium

C++/Javascript framework for working with OSM files.
http://wiki.openstreetmap.org/wiki/Osmium
GNU General Public License v3.0
123 stars 31 forks source link

Mac OS X/Darwin doesn't support mremap #38

Closed kkaefer closed 12 years ago

kkaefer commented 12 years ago

Compiling fails at https://github.com/joto/osmium/blob/master/include/osmium/storage/byid.hpp#L323 on Mac OS X (10.7) because Darwin doesn't have mremap.

joto commented 12 years ago

This patch breaks the anonymous mapping. If you use munmap/mmap on an mmaped file, thats fine. But this class also supports anonymous mapping and there you would loose the contents of the mmaped area on munmap. Mremap is actually needed here. We could break up the class into two classes so that we could at least support mmaped files on Darwin. But maybe there is a different way of doing the mremap() on Darwin that would be better? Splitting up Osmium::Storage::Mmap() into two classes would break lots of code using the Mmap class, so I don't want to do this if it is not necessary.

springmeyer commented 12 years ago

perhaps useful: http://dank.qemfd.net/bugzilla/show_bug.cgi?id=119

MaZderMind commented 12 years ago

Wouldn't it hep to fallback to munmap/mmap for files and malloc/realloc fpr anonymous storage? Even under Unix I'm not sure what the benefit of using anonymous mmap vs. malloc is.

MaZderMind commented 12 years ago

take a look at #44

joto commented 12 years ago

Mac OS X doesn't support mremap() and I see no way around that without potentially using twice as much memory when copying data around. So I have re-factored the code into those bits thats work on Mac OSX and those that don't. Mac users just have to use those parts that work.