summaryrefslogtreecommitdiffstats
path: root/libc/bionic/pthread_attr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix pthread_attr_getstack under valgrind.Elliott Hughes2014-10-091-3/+8
| | | | | | | | | | | valgrind seems to mess with the stack enough that the kernel will report "[stack:pid]" rather than "[stack]" in /proc/self/maps, so switch to the task-specific file instead to force "[stack]". (There are two conditions in the kernel code that decides which form to output.) Bug: 17897476 Change-Id: Iff85ceb6d52e8716251fab4e45d95a27184c5529
* Have pthread_attr_getstack for the main thread report RLIMIT_STACK...Elliott Hughes2014-08-271-11/+12
| | | | | | | | | | ...rather than just what's already mapped in. This seems somewhat contrary to POSIX's "All pages within the stack described by stackaddr and stacksize shall be both readable and writable by the thread", but it's what glibc does. Bug: 17111575 Change-Id: If9e2dfad9a603c0d0615a8123aacda4946e95b2c
* Fix pthread_getattr_np for the main thread.Elliott Hughes2014-08-261-5/+46
| | | | | | | | | | | | | | | | | | | | On most architectures the kernel subtracts a random offset to the stack pointer in create_elf_tables by calling arch_align_stack before writing the auxval table and so on. On all but x86 this doesn't cause a problem because the random offset is less than a page, but on x86 it's up to two pages. This means that our old technique of rounding the stack pointer doesn't work. (Our old implementation of that technique was wrong too.) It's also incorrect to assume that the main thread's stack base and size are constant. Likewise to assume that the main thread has a guard page. The main thread is not like other threads. This patch switches to reading /proc/self/maps (and checking RLIMIT_STACK) whenever we're asked. Bug: 17111575 Signed-off-by: Fengwei Yin <fengwei.yin@intel.com> Change-Id: I1d4dbffe7bc7bda1d353c3a295dbf68d29f63158
* Removed pthread_attr_getstackaddr/pthread_attr_setstackaddrCalin Juravle2014-03-111-16/+0
| | | | | | | Moved existing definitions to ndk_cruft to preserve NDK compatibility. Bug: 13281069 Change-Id: I6f260de69afa55a6274f0d13145c19ac6517b9d5
* Fix some pthread symbols build as C++ symbol under x64 lunch.Halton Huo2014-03-051-2/+5
| | | | | | | | Functions protected with !defined(__LP64__) will be get build as C++ symbols for X64 build. This is not the desired work. So protect the implementation with !defined(__LP64__) as well. Change-Id: I4ef50ec36e46289ab308063e24f6c5ac61a6ca8d
* <pthread.h> fixes and pthread cleanup.Elliott Hughes2013-10-311-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | <pthread.h> was missing nonnull attributes, noreturn on pthread_exit, and had incorrect cv qualifiers for several standard functions. I've also marked the non-standard stuff (where I count glibc rather than POSIX as "standard") so we can revisit this cruft for LP64 and try to ensure we're compatible with glibc. I've also broken out the pthread_cond* functions into a new file. I've made the remaining pthread files (plus ptrace) part of the bionic code and fixed all the warnings. I've added a few more smoke tests for chunks of untested pthread functionality. We no longer need the libc_static_common_src_files hack for any of the pthread implementation because we long since stripped out the rest of the armv5 support, and this hack was just to ensure that __get_tls in libc.a went via the kernel if necessary. This patch also finishes the job of breaking up the pthread.c monolith, and adds a handful of new tests. Change-Id: Idc0ae7f5d8aa65989598acd4c01a874fe21582c7
* Remove more assumptions that pointers are 32-bit.Elliott Hughes2013-10-011-1/+1
| | | | Change-Id: I2157e2fc4db7692b746c697982c3d028a056462a
* Simplify main thread stack size initializationBrian Carlstrom2013-09-131-7/+1
| | | | Change-Id: Iec09433d9de501031cce09dc75848a5e8f3d96bf
* Improve stack overflow diagnostics (take 2).Elliott Hughes2013-07-171-2/+6
| | | | | | | | | | This reverts commits eb1b07469f2b5a392dc1bfd8adc211aea8c72bc5 and d14dc3b87fbf80553f1cafa453816b7f11366627, and fixes the bug where we were calling mmap (which might cause errno to be set) before __set_tls (which is required to implement errno). Bug: 8557703 Change-Id: I2c36d00240c56e156e1bb430d8c22a73a068b70c
* Revert "Improve stack overflow diagnostics."Guang Zhu2013-07-171-6/+2
| | | | | | This reverts commit aa754dca90487356cabf07ade0e8d88c2630b784. Change-Id: Ifa76eee31f7f44075eb3a48554315b2693062f44
* Improve stack overflow diagnostics.Elliott Hughes2013-07-161-2/+6
| | | | | | | | | We notify debuggerd of problems by installing signal handlers. That's fine except for when the signal is caused by us running off the end of a thread's stack and into the guard page. Bug: 8557703 Change-Id: I1ef65b4bb3bbca7e9a9743056177094921e60ed3
* Fix pthread_getattr_np, pthread_attr_setguardsize, and ↵Elliott Hughes2013-07-151-4/+1
| | | | | | | | | | | | | | | pthread_attr_setstacksize. pthread_getattr_np was reporting the values supplied to us, not the values we actually used, which is kinda the whole point of pthread_getattr_np. pthread_attr_setguardsize and pthread_attr_setstacksize were reporting EINVAL for any size that wasn't a multiple of the system page size. This is unnecessary. We can just round like POSIX suggests and glibc already does. Also improve the error reporting for pthread_create failures. Change-Id: I7ebc518628a8a1161ec72e111def911d500bba71
* Simplify pthread_create, using more public API.Elliott Hughes2013-02-121-11/+7
| | | | Change-Id: I08e65ba88ed01436223e4e528631c9e41ec0e7f4
* Revert "Revert "More pthreads cleanup.""Elliott Hughes2013-02-121-0/+165
| | | | | | | | | This reverts commit 6f94de3ca49e4ea147b1c59e5818fa175846518f (Doesn't try to increase the number of TLS slots; that leads to an inability to boot. Adds more tests.) Change-Id: Ia7d25ba3995219ed6e686463dbba80c95cc831ca
* Revert "More pthreads cleanup."Elliott Hughes2013-02-121-165/+0
| | | | | | This reverts commit 2a1bb4e64677b9abbc17173c79768ed494565047 Change-Id: Ia443d0748015c8e9fc3121e40e68258616767b51
* More pthreads cleanup.Elliott Hughes2013-02-111-0/+165
POSIX says pthread_create returns EAGAIN, not ENOMEM. Also pull pthread_attr_t functions into their own file. Also pull pthread_setname_np into its own file. Also remove unnecessary #includes from pthread_key.cpp. Also account for those pthread keys used internally by bionic, so they don't count against the number of keys available to user code. (They do with glibc, but glibc's limit is the much more generous 1024.) Also factor out the common errno-restoring idiom to reduce gotos. Bug: 6702535 Change-Id: I555e66efffcf2c1b5a2873569e91489156efca42