Skip to content

Commit

Permalink
Use MAP_STACK on FreeBSD
Browse files Browse the repository at this point in the history
Also removes PROT_EXEC
  • Loading branch information
devnexen authored and laverdet committed Aug 27, 2019
1 parent 5c24f96 commit e60463c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
"version": "4.0.1",
"description": "Cooperative multi-tasking for Javascript",
"keywords": [
"fiber", "fibers", "coroutine", "thread", "async", "parallel", "worker", "future", "promise"],
"fiber",
"fibers",
"coroutine",
"thread",
"async",
"parallel",
"worker",
"future",
"promise"
],
"homepage": "https://github.com/laverdet/node-fibers",
"author": "Marcel Laverdet <[email protected]> (https://github.com/laverdet/)",
"main": "fibers",
Expand Down
15 changes: 5 additions & 10 deletions src/libcoro/coro.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,20 +649,15 @@ coro_stack_alloc (struct coro_stack *stack, unsigned int size)
void *base;

#if CORO_MMAP
int mflags = MAP_PRIVATE | MAP_ANONYMOUS;
#if defined(__OpenBSD__) || defined(__FreeBSD__)
mflags |= MAP_STACK;
#endif
/* mmap supposedly does allocate-on-write for us */
#ifdef __OpenBSD__
base = mmap (0, ssze, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
#else
base = mmap (0, ssze, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#endif
base = mmap (0, ssze, PROT_READ | PROT_WRITE, mflags, -1, 0);

if (base == (void *)-1)
{
/* some systems don't let us have executable heap */
/* we assume they won't need executable stack in that case */
base = mmap (0, ssze, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

if (base == (void *)-1)
return 0;
}

Expand Down

0 comments on commit e60463c

Please sign in to comment.