1 #include <u.h>
2 #include <sys/mman.h>
3 #include "threadimpl.h"
4 
5 #ifndef MAP_STACK
6 #define MAP_STACK 0
7 #endif
8 
9 void*
_threadstkalloc(int n)10 _threadstkalloc(int n)
11 {
12 	void *p;
13 
14 	p = mmap(nil, n, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_STACK, -1, 0);
15 	if(p == (void*)-1)
16 		return nil;
17 	return p;
18 }
19 
20 void
_threadstkfree(void * v,int n)21 _threadstkfree(void *v, int n)
22 {
23 	if(n > 0)
24 		munmap(v, n);
25 }
26