[erlang-patches] win32 memory allocation fix / mmap emulation
Rickard Green
rickard@REDACTED
Fri Dec 11 23:21:20 CET 2009
Nice!
Blaine Whittle wrote:
> Björn Gustavsson wrote:
>> My gut feeling, though, is that lying about Windows having MMAP might
>> not be the best way to
>> got, as MMAP could possibly be used in other places in a future
>> version of OTP. So it may be
>> better to change the memory management code to test some other define
>> that covers both the
>> mmap() case and the virtual allocation functions on Windows. (For ease
>> of reviewing, it would
>> be a good idea to put such re-factoring into a separate commit.)
>
> Ya, I was unsure the best way to handle the defines for that very reason.
> The only files that involved the MMAP change are erl_mseg.h and
> erl_mseg.c. However any win32 specific should go in win32\erl_win_sys.h
> and win32\sys.c
>
However, apart from the above, the mmap()/munmap() emulation
implementation is copyright GeNeSys mbH and without any specific license
which makes it hard to include into Erlang/OTP.
The best solution would be to drop the mmap()/munmap() emulation and
just implement mseg_create()/mseg_destroy() (in erl_mseg.c) using
VirtualAlloc()/VirtualFree() (which should be straightforward since they
map onto each other very well). When this have been done, change the
following in erl_mseg.h:
#if HAVE_MMAP
# define HAVE_ERTS_MSEG 1
#else
# define HAVE_ERTS_MSEG 0
#endif
to:
#if HAVE_MMAP || defined(__WIN32__)
# define HAVE_ERTS_MSEG 1
#else
# define HAVE_ERTS_MSEG 0
#endif
which will make other allocators use mseg_alloc for retrieving raw memory.
Regards,
Rickard
--
Rickard Green, Erlang/OTP, Ericsson AB.
More information about the erlang-patches
mailing list