Changeset View
Changeset View
Standalone View
Standalone View
lib/libthr/thread/thr_init.c
Show All 31 Lines | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "namespace.h" | #include "namespace.h" | ||||
#include <sys/types.h> | #include <sys/param.h> | ||||
#include <sys/auxv.h> | |||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <sys/link_elf.h> | #include <sys/link_elf.h> | ||||
#include <sys/resource.h> | #include <sys/resource.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/ttycom.h> | #include <sys/ttycom.h> | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
#include <sys/rtprio.h> | #include <sys/rtprio.h> | ||||
▲ Show 20 Lines • Show All 408 Lines • ▼ Show 20 Lines | init_private(void) | ||||
/* | /* | ||||
* Avoid reinitializing some things if they don't need to be, | * Avoid reinitializing some things if they don't need to be, | ||||
* e.g. after a fork(). | * e.g. after a fork(). | ||||
*/ | */ | ||||
if (init_once == 0) { | if (init_once == 0) { | ||||
__thr_pshared_init(); | __thr_pshared_init(); | ||||
__thr_malloc_init(); | __thr_malloc_init(); | ||||
/* Find the stack top */ | /* Find the stack top */ | ||||
mib[0] = CTL_KERN; | mib[0] = CTL_KERN; | ||||
if (elf_aux_info(AT_USRSTACKBASE, &_usrstack, | |||||
sizeof(_usrstack)) != 0) { | |||||
mib[0] = CTL_KERN; | |||||
mib[1] = KERN_USRSTACK; | mib[1] = KERN_USRSTACK; | ||||
len = sizeof (_usrstack); | len = sizeof (_usrstack); | ||||
if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1) | if (sysctl(mib, nitems(mib), &_usrstack, &len, | ||||
NULL, 0) == -1) | |||||
PANIC("Cannot get kern.usrstack from sysctl"); | PANIC("Cannot get kern.usrstack from sysctl"); | ||||
} | |||||
env_bigstack = getenv("LIBPTHREAD_BIGSTACK_MAIN"); | env_bigstack = getenv("LIBPTHREAD_BIGSTACK_MAIN"); | ||||
env_splitstack = getenv("LIBPTHREAD_SPLITSTACK_MAIN"); | env_splitstack = getenv("LIBPTHREAD_SPLITSTACK_MAIN"); | ||||
if (env_bigstack != NULL || env_splitstack == NULL) { | if (env_bigstack != NULL || env_splitstack == NULL) { | ||||
if (elf_aux_info(AT_USRSTACKLIM, &_thr_stack_initial, | |||||
sizeof(_thr_stack_initial)) != 0) { | |||||
if (getrlimit(RLIMIT_STACK, &rlim) == -1) | if (getrlimit(RLIMIT_STACK, &rlim) == -1) | ||||
PANIC("Cannot get stack rlimit"); | PANIC("Cannot get stack rlimit"); | ||||
_thr_stack_initial = rlim.rlim_cur; | _thr_stack_initial = rlim.rlim_cur; | ||||
} | |||||
} | } | ||||
_thr_is_smp = sysconf(_SC_NPROCESSORS_CONF); | _thr_is_smp = sysconf(_SC_NPROCESSORS_CONF); | ||||
if (_thr_is_smp == -1) | if (_thr_is_smp == -1) | ||||
PANIC("Cannot get _SC_NPROCESSORS_CONF"); | PANIC("Cannot get _SC_NPROCESSORS_CONF"); | ||||
_thr_is_smp = (_thr_is_smp > 1); | _thr_is_smp = (_thr_is_smp > 1); | ||||
_thr_page_size = getpagesize(); | _thr_page_size = getpagesize(); | ||||
_thr_guard_default = _thr_page_size; | _thr_guard_default = _thr_page_size; | ||||
_pthread_attr_default.guardsize_attr = _thr_guard_default; | _pthread_attr_default.guardsize_attr = _thr_guard_default; | ||||
Show All 14 Lines |