map_file fails to map to empty bigarray #5463
Original bug ID: 5463
Bigarray.Array1.map_file fails if the array to be created is empty. This is a slight annoyance because it is not documented in the manual. I don't know where the various implementations of mmap stand, but a warning note would be welcome if a fix is not possible.
On Linux, "man mmap" says in the ERRORS section:
Steps to reproduce
$ cat > mapfile.ml
$ ocamlopt -o mapfile unix.cmxa bigarray.cmxa mapfile.ml
Comment author: @dbuenzli
the man says :
Comment author: gerd
@dbuenzli: map_file allows it to map files at offsets that are not a multiple of the pagesize. This is done by rounding down to the next multiple, and hiding the intitial part of the mapping from the user. What I want to say is that it does not necessarily matter what mmap allows when there is a way to emulate more general behavior.
I think an emulation for size=0 is very easy - just return the empty array instead (don't call mmap at all).