winlin

research st, always alloc on stack.

@@ -557,7 +557,7 @@ _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinabl @@ -557,7 +557,7 @@ _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinabl
557 } 557 }
558 stack->sp = sp - _ST_STACK_PAD_SIZE; 558 stack->sp = sp - _ST_STACK_PAD_SIZE;
559 #else 559 #else
560 - #error Unknown OS 560 + #error Unknown Stack Grown
561 #endif 561 #endif
562 562
563 memset(thread, 0, sizeof(_st_thread_t)); 563 memset(thread, 0, sizeof(_st_thread_t));
@@ -122,28 +122,7 @@ static char *_st_new_stk_segment(int size) @@ -122,28 +122,7 @@ static char *_st_new_stk_segment(int size)
122 #ifdef MALLOC_STACK 122 #ifdef MALLOC_STACK
123 void *vaddr = malloc(size); 123 void *vaddr = malloc(size);
124 #else 124 #else
125 - static int zero_fd = -1;  
126 - int mmap_flags = MAP_PRIVATE;  
127 - void *vaddr;  
128 -  
129 - #if defined (MD_USE_SYSV_ANON_MMAP)  
130 - if (zero_fd < 0) {  
131 - if ((zero_fd = open("/dev/zero", O_RDWR, 0)) < 0) {  
132 - return NULL;  
133 - }  
134 - fcntl(zero_fd, F_SETFD, FD_CLOEXEC);  
135 - }  
136 - #elif defined (MD_USE_BSD_ANON_MMAP)  
137 - mmap_flags |= MAP_ANON;  
138 - #else  
139 - #error Unknown OS  
140 - #endif  
141 -  
142 - vaddr = mmap(NULL, size, PROT_READ | PROT_WRITE, mmap_flags, zero_fd, 0);  
143 - if (vaddr == (void *)MAP_FAILED) {  
144 - return NULL;  
145 - }  
146 - 125 + #error Unknown Stack Malloc
147 #endif 126 #endif
148 127
149 return (char *)vaddr; 128 return (char *)vaddr;
@@ -156,7 +135,7 @@ void _st_delete_stk_segment(char *vaddr, int size) @@ -156,7 +135,7 @@ void _st_delete_stk_segment(char *vaddr, int size)
156 #ifdef MALLOC_STACK 135 #ifdef MALLOC_STACK
157 free(vaddr); 136 free(vaddr);
158 #else 137 #else
159 - (void) munmap(vaddr, size); 138 + #error Unknown Stack Malloc
160 #endif 139 #endif
161 } 140 }
162 #endif 141 #endif