Jeroen Demeyer on Mon, 03 Apr 2017 13:58:32 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

emscripten and mmap()

Moving discussion from bug #1912 to pari-dev

This patch causes the mmap code to be more fragile and to break in a
non-obvious way on systems where it used to work.

With "this patch" I assume that you mean my collection of commits involving mmap() with PROT_NONE and that "systems where it used to work" refers to emscripten?

As I tried to say several times already, emscripten needs to *emulate* mmap(). It has no access to the operating system, so it cannot do an actual mmap() system call. Apparently, the emulation of mmap() in emscripten lacks features: for example, MAP_FIXED and the PROT_... flags are simply not supported. For that reason, I think it's a bad idea to use mmap() with emscripten.

On systems which properly implement mmap (as described by POSIX), my patch should work.

It would be easy to add a configure check to check whether mmap(MAP_FIXED, ...) actually works. It seems that config/has_mmap.c is only *compiled* though, not *run*. Testing for MAP_FIXED support can only be done by *running* code.