On 31-07-2012 19:23, Maxime Chevalier wrote:
New to the D language here. I'm working on a tracing JIT compiler and
will need to allocate chunks of memory that are marked as executable.

Is there a standard way of doing this in D, or do I need to directly
call into mprotect? If I'm going to be calling mprotect, what's the
cleanest way to do that, do I need to declare my own prototype for the
function and its flags, or should I write some C code that does the call?

Thanks for your help.

There's no standard way to do it. You'll have to either use mprotect or just pass the relevant flags when you call mmap.

The functions and constants related to this are all in core.sys.posix.mman.

See also:

* https://github.com/lycus/mci/blob/master/src/mci/core/memory.d#L71 (and further down)
* https://github.com/lycus/mci/blob/master/src/mci/vm/code.d

--
Alex Rønne Petersen
a...@lycus.org
http://lycus.org

Reply via email to