Skip to content
Snippets Groups Projects
Commit f1488bae authored by Fred Wright's avatar Fred Wright Committed by Christopher Nielsen
Browse files

pthread_get_stacksize_np: Cache dlsym() result.

This avoids repeatedly looking up the symbol for the OS call.

Also cleans up indentation.

TESTED:
Passes tests on all platforms.
parent 8292b6c1
No related branches found
No related tags found
No related merge requests found
...@@ -59,12 +59,16 @@ size_t pthread_get_stacksize_np(pthread_t t) { ...@@ -59,12 +59,16 @@ size_t pthread_get_stacksize_np(pthread_t t) {
} }
} else { } else {
/* bug only affects main thread */ /* bug only affects main thread */
size_t (*real_pthread_get_stacksize_np)(pthread_t); static size_t (*os_pthread_get_stacksize_np)(pthread_t);
real_pthread_get_stacksize_np = dlsym(RTLD_NEXT, "pthread_get_stacksize_np"); if (!os_pthread_get_stacksize_np) {
if (real_pthread_get_stacksize_np == NULL) { os_pthread_get_stacksize_np =
exit(EXIT_FAILURE); dlsym(RTLD_NEXT, "pthread_get_stacksize_np");
/* Something's badly broken if this fails */
if (!os_pthread_get_stacksize_np) {
abort();
}
} }
return real_pthread_get_stacksize_np(t); return (*os_pthread_get_stacksize_np)(t);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment