[LLVMdev] Re: Autoconf

Brian R. Gaeke gaeke at uiuc.edu
Tue Jun 17 17:03:01 PDT 2003

> 	However, mmap() does provide some other small potential issues:
> 	1) The mmap() function may not exist on all Unices, or it may work 
> differently on various versions of them.

Definitely. We use mmap for a couple of different things. 

1a) In lib/Bytecode/Reader we use mmap to read in bytecode files and archives.
Certainly it would be trivial to rework this to fall back on mmap if
read/write is not possible (in one case it already does this, if we are
reading from stdin, which you can't mmap anyway.)

1b) In tools/lli/JIT we use mmap as a source of memory which has the PROT_EXEC
bit set. That is, the JIT needs to put instructions in memory, and then execute
them; if you use malloc() you are liable to get back non-executable heap
space, but with mmap() you can explicitly ask for executable heap space.
The only systems I know of that don't play nice with mmap are nasty old ones
like DYNIX and SCO, and (grimace) Windows... I don't think we have to worry
about the former. The latter may work under Cygwin...I'm not sure yet.
We need MAP_ANON(YMOUS) and PROT_EXEC for this.


gaeke at uiuc.edu

More information about the llvm-dev mailing list