diff options
author | Russ Cox <rsc@swtch.com> | 2020-01-14 12:40:09 -0500 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2020-01-14 13:58:47 -0500 |
commit | 8c573cab6819c69142389d36b978b3c683771afe (patch) | |
tree | 8c97a0523b4b9dbddc2ad5afc49e89d9815ecbda /src/libthread/stkmmap.c | |
parent | 4ae529dbfe8573ae105d0d66f7f453c4f850fa1f (diff) | |
download | plan9port-8c573cab6819c69142389d36b978b3c683771afe.tar.gz plan9port-8c573cab6819c69142389d36b978b3c683771afe.tar.bz2 plan9port-8c573cab6819c69142389d36b978b3c683771afe.zip |
libthread: use mmap to allocate OpenBSD stacks
Should fix faults on OpenBSD.
Fixes #218.
Fixes #226.
Diffstat (limited to 'src/libthread/stkmmap.c')
-rw-r--r-- | src/libthread/stkmmap.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libthread/stkmmap.c b/src/libthread/stkmmap.c new file mode 100644 index 00000000..f4a24630 --- /dev/null +++ b/src/libthread/stkmmap.c @@ -0,0 +1,25 @@ +#include <u.h> +#include <sys/mman.h> +#include "threadimpl.h" + +#ifndef MAP_STACK +#define MAP_STACK 0 +#endif + +void* +_threadstkalloc(int n) +{ + void *p; + + p = mmap(nil, n, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_STACK, -1, 0); + if(p == (void*)-1) + return nil; + return p; +} + +void +_threadstkfree(void *v, int n) +{ + if(n > 0) + munmap(v, n); +} |