Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115267403
D31898.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D31898.diff
View Options
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -61,7 +61,7 @@
#include "libc_private.h"
#include "thr_private.h"
-char *_usrstack;
+char *_stacktop;
struct pthread *_thr_initial;
int _libthr_debug;
int _thread_event_mask;
@@ -388,7 +388,7 @@
* resource limits, so this stack needs an explicitly mapped
* red zone to protect the thread stack that is just beyond.
*/
- if (mmap(_usrstack - _thr_stack_initial -
+ if (mmap(_stacktop - _thr_stack_initial -
_thr_guard_default, _thr_guard_default, 0, MAP_ANON,
-1, 0) == MAP_FAILED)
PANIC("Cannot allocate red zone for initial thread");
@@ -402,7 +402,7 @@
* actually free() it; it just puts it in the free
* stack queue for later reuse.
*/
- thread->attr.stackaddr_attr = _usrstack - _thr_stack_initial;
+ thread->attr.stackaddr_attr = _stacktop - _thr_stack_initial;
thread->attr.stacksize_attr = _thr_stack_initial;
thread->attr.guardsize_attr = _thr_guard_default;
thread->attr.flags |= THR_STACK_USER;
@@ -427,7 +427,7 @@
thread->attr.prio = sched_param.sched_priority;
#ifdef _PTHREAD_FORCED_UNWIND
- thread->unwind_stackend = _usrstack;
+ thread->unwind_stackend = _stacktop;
#endif
/* Others cleared to zero by thr_alloc() */
@@ -464,10 +464,13 @@
__thr_malloc_init();
/* Find the stack top */
mib[0] = CTL_KERN;
- mib[1] = KERN_USRSTACK;
- len = sizeof (_usrstack);
- if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1)
- PANIC("Cannot get kern.usrstack from sysctl");
+ mib[1] = KERN_STACKTOP;
+ len = sizeof (_stacktop);
+ if (sysctl(mib, 2, &_stacktop, &len, NULL, 0) == -1) {
+ mib[1] = KERN_USRSTACK;
+ if (sysctl(mib, 2, &_stacktop, &len, NULL, 0) == -1)
+ PANIC("Cannot get kern.usrstack from sysctl");
+ }
env_bigstack = getenv("LIBPTHREAD_BIGSTACK_MAIN");
env_splitstack = getenv("LIBPTHREAD_SPLITSTACK_MAIN");
if (env_bigstack != NULL || env_splitstack == NULL) {
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -724,7 +724,7 @@
* Global variables for the pthread kernel.
*/
-extern char *_usrstack __hidden;
+extern char *_stacktop __hidden;
/* For debugger */
extern int _libthr_debug;
diff --git a/lib/libthr/thread/thr_stack.c b/lib/libthr/thread/thr_stack.c
--- a/lib/libthr/thread/thr_stack.c
+++ b/lib/libthr/thread/thr_stack.c
@@ -149,18 +149,20 @@
{
int mib[2];
struct rlimit rlim;
- u_long usrstack;
+ u_long stacktop;
size_t len;
mib[0] = CTL_KERN;
- mib[1] = KERN_USRSTACK;
- len = sizeof(usrstack);
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &usrstack, &len, NULL, 0)
- == -1)
- return;
+ mib[1] = KERN_STACKTOP;
+ len = sizeof(stacktop);
+ if (sysctl(mib, nitems(mib), &stacktop, &len, NULL, 0) == -1) {
+ mib[1] = KERN_USRSTACK;
+ if (sysctl(mib, nitems(mib), &stacktop, &len, NULL, 0) == -1)
+ return;
+ }
if (getrlimit(RLIMIT_STACK, &rlim) == -1)
return;
- mprotect((void *)(uintptr_t)(usrstack - rlim.rlim_cur),
+ mprotect((void *)(uintptr_t)(stacktop - rlim.rlim_cur),
rlim.rlim_cur, _rtld_get_stack_prot());
}
@@ -213,7 +215,7 @@
/*
* Use the garbage collector lock for synchronization of the
- * spare stack lists and allocations from usrstack.
+ * spare stack lists and allocations from stacktop.
*/
THREAD_LIST_WRLOCK(curthread);
/*
@@ -249,11 +251,11 @@
}
else {
/*
- * Allocate a stack from or below usrstack, depending
+ * Allocate a stack from or below stacktop, depending
* on the LIBPTHREAD_BIGSTACK_MAIN env variable.
*/
if (last_stack == NULL)
- last_stack = _usrstack - _thr_stack_initial -
+ last_stack = _stacktop - _thr_stack_initial -
_thr_guard_default;
/* Allocate a new stack. */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 23, 1:21 AM (10 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17705962
Default Alt Text
D31898.diff (3 KB)
Attached To
Mode
D31898: libthr: Use kern.stacktop for thread stack calculation.
Attached
Detach File
Event Timeline
Log In to Comment