summaryrefslogtreecommitdiff
path: root/src/thread/pthread_getattr_np.c
AgeCommit message (Collapse)AuthorLines
2018-05-05improve joinable/detached thread state handlingRich Felker-1/+1
previously, some accesses to the detached state (from pthread_join and pthread_getattr_np) were unsynchronized; they were harmless in programs with well-defined behavior, but ugly. other accesses (in pthread_exit and pthread_detach) were synchronized by a poorly named "exitlock", with an ad-hoc trylock operation on it open-coded in pthread_detach, whose only purpose was establishing protocol for which thread is responsible for deallocation of detached-thread resources. instead, use an atomic detach_state and unify it with the futex used to wait for thread exit. this eliminates 2 members from the pthread structure, gets rid of the hackish lock usage, and makes rigorous the trap added in commit 80bf5952551c002cf12d96deb145629765272db0 for catching attempts to join detached threads. it should also make attempt to detach an already-detached thread reliably trap.
2018-02-03store pthread stack guard sizes for pthread_getattr_npWilliam Pitcock-0/+1
2016-11-07simplify pthread_attr_t stack/guard size representationRich Felker-2/+2
previously, the pthread_attr_t object was always initialized all-zero, and stack/guard size were represented as differences versus their defaults. this required lots of confusing offset arithmetic everywhere they were used. instead, have pthread_attr_init fill in the default values, and work with absolute sizes everywhere.
2013-09-15support configurable page size on mips, powerpc and microblazeSzabolcs Nagy-0/+1
PAGE_SIZE was hardcoded to 4096, which is historically what most systems use, but on several archs it is a kernel config parameter, user space can only know it at execution time from the aux vector. PAGE_SIZE and PAGESIZE are not defined on archs where page size is a runtime parameter, applications should use sysconf(_SC_PAGE_SIZE) to query it. Internally libc code defines PAGE_SIZE to libc.page_size, which is set to aux[AT_PAGESZ] in __init_libc and early in __dynlink as well. (Note that libc.page_size can be accessed without GOT, ie. before relocations are done) Some fpathconf settings are hardcoded to 4096, these should be actually queried from the filesystem using statfs.
2013-07-31in pthread_getattr_np, use mremap rather than madvise to measure stackRich Felker-1/+2
the original motivation for this patch was that qemu (and possibly other syscall emulators) nop out madvise, resulting in an infinite loop. however, there is another benefit to this change: madvise may actually undo an explicit madvise the application intended for its stack, whereas the mremap operation is a true nop. the logic here is that mremap must fail if it cannot resize the mapping in-place, and the caller knows that it cannot resize in-place because it knows the next page of virtual memory is already occupied.
2013-03-31implement pthread_getattr_npRich Felker-0/+21
this function is mainly (purely?) for obtaining stack address information, but we also provide the detach state since it's easy to do anyway.