add FreeBSD + DragonFlyBSD MAP_STACK workaround

http://lists.freebsd.org/pipermail/freebsd-bugs/2011-July/044840.html
according to libgreen, DragonFlyBSD suffers from this too
This commit is contained in:
edef 2015-04-16 07:56:26 -04:00
parent 68f70fb1c9
commit af7e9ea67c

View File

@ -20,9 +20,15 @@ pub fn sys_page_size() -> usize {
const GUARD_PROT: c_int = libc::PROT_NONE;
const STACK_PROT: c_int = libc::PROT_READ
| libc::PROT_WRITE;
#[cfg(not(any(target_os = "freebsd", target_os = "dragonfly")))]
const STACK_FLAGS: c_int = libc::MAP_STACK
| libc::MAP_PRIVATE
| libc::MAP_ANON;
// workaround for http://lists.freebsd.org/pipermail/freebsd-bugs/2011-July/044840.html
// according to libgreen, DragonFlyBSD suffers from this too
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
const STACK_FLAGS: c_int = libc::MAP_PRIVATE
| libc::MAP_ANON;
pub unsafe fn map_stack(len: usize) -> Option<*mut u8> {
let ptr = mmap(ptr::null_mut(), len as size_t,