summaryrefslogtreecommitdiffstats
path: root/libc/private
Commit message (Collapse)AuthorAgeFilesLines
* Update the number of jemalloc reserved keys.Christopher Ferris2015-04-151-8/+2
| | | | | | | jemalloc now uses a single key pointing to a structure rather than multiple keys. Change-Id: Ib76185a594ab2cd4dc400d9a7a5bc0a57a7ac92d
* Provide writer preference option in rwlock.Yabin Cui2015-04-081-0/+74
| | | | | | | | | | | | | | | | | | | | | Previous implementation of rwlock contains four atomic variables, which is hard to maintain and change. So I make following changes in this CL: 1. Add pending flags in rwlock.state, so we don't need to synchronize between different atomic variables. Using compare_and_swap operations on rwlock.state is enough for all state change. 2. Add pending_lock to protect readers/writers waiting and wake up operations. As waiting/wakeup is not performance critical, using a lock is easier to maintain. 3. Add writer preference option. 4. Add unit tests for rwlock. Bug: 19109156 Change-Id: Idcaa58d695ea401d64445610b465ac5cff23ec7c
* Make ThreadLocalBuffer a class rather than a macro.Elliott Hughes2015-03-312-38/+40
| | | | | Bug: 19995392 Change-Id: I497c512648fbe66257da3fb3bcd5c9911f983705
* For libm, use a macro for aliasing symbols.Christopher Ferris2015-03-131-0/+4
| | | | Change-Id: Ibd42ebc387c2bf3eba9aa96091770915b4b34184
* Use pthread_once for g_uselocale_key creation.Yabin Cui2015-03-051-2/+2
| | | | | Bug: 19625804 Change-Id: I57ec4c965067dc0c157c795c1f7217a3ca403286
* Better control of pthread keys used in bionic.Yabin Cui2015-03-042-6/+8
| | | | Change-Id: I1e1bc77c0e7879baead6c3417282ce549a1153b5
* Merge "Refactor pthread_key.cpp to be lock-free."Yabin Cui2015-03-041-17/+18
|\
| * Refactor pthread_key.cpp to be lock-free.Yabin Cui2015-03-031-17/+18
| | | | | | | | Change-Id: I20dfb9d3cdc40eed10ea12ac34f03caaa94f7a49
* | Lose bionic_atomic stuff.Yabin Cui2015-02-266-386/+0
|/ | | | | Bug: 17177189 Change-Id: Ie1f5d7af359d31b14f58e53ec89c72111362d7ec
* valgrind can't find syscall because we didn't put it in <unistd.h>.Elliott Hughes2015-02-191-0/+1
| | | | Change-Id: I1e47291d4476bd2816138a8cf58f29d4986d39e3
* Split the shared group data from the shared passwd data.Elliott Hughes2014-12-181-2/+3
| | | | | | | | | | | | | | Found by the toybox id(1) which calls both getpwuid(3) and getgrgid(3) before looking at either result. The use of a shared buffer in this code meant that even on a single thread, the data for any of the passwd functions would be clobbered by the data for any of the group functions (or vice versa). This might seem like an insufficient fix, but POSIX explicitly says (for getpwnam) that the result "might be overwritten by a subsequent call to getpwent(), getpwnam(), or getpwuid()" and likewise for other members of that group, plus equivalent text for the group-related functions. Change-Id: I2272f47e91f72e043fdaf7c169fa9f6978ff4370
* Fix pthread key num calculation.Yabin Cui2014-12-121-5/+23
| | | | | Bug: 18723085 Change-Id: Iba2c834b350e4cdba0b2d771b221560a3e5df952
* Fix ptsname(3) and ttyname(3) to use TLS.Elliott Hughes2014-12-091-1/+1
| | | | | | Be safe by default. Change-Id: I6c4a3f1fd4eee3a651b3162ce95b7e873de57521
* Move some pthread functions to signal.h.Dan Albert2014-11-211-0/+2
| | | | | | | | | | | | | POSIX specifies that pthread_kill(3) and pthread_sigmask(3) are supposed to live in signal.h rather than pthread.h. Since signal.h now needs pthread_t and pthread_attr_t, I've moved those defintions into include/machine/pthread_types.h to keep the namespace clean. I also sorted some includes. The combination of these two things seems to have exploded into a cascade of missing includes, so this patch also cleans up all those. Change-Id: Icfa92a39432fe83f542a797e5a113289d7e4ad0c
* Remove remaining bionic support for TARGET_CPU_SMP being false.Elliott Hughes2014-11-174-19/+0
| | | | Change-Id: I02a0a1c0ae55ccb5c45d17fb99a09c374d71def4
* Bionic: Make DISALLOW_COPY_AND_ASSIGN conditionalAndreas Gampe2014-11-111-0/+5
| | | | | | | | | Make the definition of DISALLOW_COPY_AND_ASSIGN conditional. This is so that the projects that include libnativehelper and bionic macros do not have to be careful in which order those projects are included. Bug: 18334516 Change-Id: Ib12a2c2b7ad2e360edcf3b26cb1be626540fadc1
* Add semaphore tests, fix sem_destroy.Elliott Hughes2014-09-192-0/+24
| | | | | Bug: https://code.google.com/p/android/issues/detail?id=76088 Change-Id: I4a0561b23e90312384d40a1c804ca64ee98f4066
* Remove "private/bionic_pthread.h".Elliott Hughes2014-09-121-41/+0
| | | | | Bug: 17476168 Change-Id: Id642987e641de81e914a28daea4ffe9d11e090ed
* Refactoring: C++11 style DISABLE_ bionic marcosDmitriy Ivanov2014-09-082-10/+10
| | | | | | | | | Enable the -std=gnu++11 flag for libstdc++ static and dynamic libs. ScopeGuard uses DISABLE_ macros instead of '= delete'; Change-Id: I07e21b306f95fffd49345f7fa136cfdac61e0225
* Load libraries in breadth-first orderDmitriy Ivanov2014-09-081-0/+140
| | | | | | | | | | This patch fixes the problem with symbol search order for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries and ld_preloads in correct order. Bug: https://code.google.com/p/android/issues/detail?id=74255 Change-Id: If1ba5c807322409faa914e27ecb675e2c4541f0d Attempt: 2
* Revert "Load libraries in breadth-first order"Dmitriy Ivanov2014-09-051-140/+0
| | | | | | This reverts commit a3ad450a2e3fb6b3fe359683b247eba20896f646. Change-Id: Ia2b838ad2159c643b80c514849582f4b4f4f40e5
* Load libraries in breadth-first orderDmitriy Ivanov2014-09-032-0/+193
| | | | | | | | | This patch fixes the problem with symbol search order for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries and ld_preloads in correct order. Bug: https://code.google.com/p/android/issues/detail?id=74255 Change-Id: I4cf84c70dbaabe99310230dfda12385ae5401859
* Fix pthread_getattr_np for the main thread.Elliott Hughes2014-08-261-0/+31
| | | | | | | | | | | | | | | | | | | | 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
* Simplify _ALIGN_TEXT.Elliott Hughes2014-08-201-1/+1
| | | | | Bug: 16872067 Change-Id: I2b622f252c21ce1b344c040f828ab3f4bf9b6c0a
* Expose android_set_abort_message().Dan Albert2014-08-181-2/+0
| | | | | | | | Removes the leading underscores from __android_set_abort_message() and moves its declaration into a public header file. Bug: 17059126 Change-Id: I470c79db47ec783ea7a54b800f8b78ecbe7479ab
* Hide ScopedTrace.Dan Albert2014-08-131-1/+1
| | | | | Bug: 11156955 Change-Id: I6cddc868d1c6503e30f1ffcf460f45670631d64a
* Label pages mapped by linker_allocatorDmitriy Ivanov2014-08-111-0/+26
| | | | Change-Id: I7e0bf29bc1a480e9be0d1ae573ca1063d90d82ff
* Added a bionic systrace class and tracing to pthread_mutex.cpp.Brigid Smith2014-07-281-0/+35
| | | | | | | | | | bionic_systrace.h contains an implementation of tracing that can be used with systrace.py and its associated viewer. pthread_mutex now uses this tracing to track pthread_mutex contention, which can be enabled by using the "bionic" command line option to systrace. Bug: 15116468 Change-Id: I30ed5b377c91ca4c36568a0e647ddf95d4e4a61a
* Start hiding "private/bionic_time.h".Elliott Hughes2014-07-251-26/+2
| | | | | Bug: 15765976 Change-Id: Ibd9cf07067ec8dffe9fda6c3d498d4ab90708220
* Use upstream OpenBSD's arc4random.Elliott Hughes2014-07-211-2/+3
| | | | | | | The getentropy_linux.c is lightly modified to build on Android, but we're now completely in sync with upstream OpenBSD's arc4random implementation. Change-Id: If32229fc28aba908035fb38703190d41ddcabc95
* Remove non-standard prctl constants from <sys/prctl.h>.Elliott Hughes2014-07-171-41/+0
| | | | | | | Also remove __bionic_name_mem which has exactly one caller, and is only ever expected to be used in this one place. Change-Id: I833744f91e887639f5b2d1269f966ee9032af207
* Fix BIONIC_ROUND_UP_POWER_OF_2 for 64 bit.Christopher Ferris2014-07-151-1/+3
| | | | | | | | | | There were two bugs here: - For 64 bit values, this did not properly round up. - The macro rounded to the power of 2 less than value, not to the power of 2 greater than value. Change-Id: If8cb41536a9d2f5c1bc213676f1e67a7903a36b0
* Fix visibility for a bunch more symbols.Elliott Hughes2014-07-141-1/+1
| | | | | | Bug: 11156955 Bug: 15291317 Change-Id: I664f25cce7c17085a101d6593d8e01525a1f6a90
* Upstream atexitDmitriy Ivanov2014-07-141-2/+6
| | | | Change-Id: Ia454a2181b5058ed9783dc02b6b1805d0e4d2715
* Slim down static binaries by avoiding stdio.Elliott Hughes2014-07-101-1/+1
| | | | | | | | | | | | | | It's okay for a program to choose to drag in stdio, but it's unfortunate if even the minimal "int main() { return 42; }" drags in stdio... This brings the minimal static binary on ARM down from 78KiB to 46KiB. Given that we don't have a separate -lpthread it's not obvious to me that we can shave this down any further. I'm not sure whether this is a worthwhile change for that reason. (And the fact that dynamic binaries, the usual case, are unaffected either way.) Change-Id: I02f91dcff37d14354314a30b72fed2563f431c88
* Load library using file handle.Dmitriy Ivanov2014-07-021-0/+59
| | | | | | | | * This patch enables dlopen by file descriptor instead of path/name. Bug: 15984217 Change-Id: Ib39051e00567fb97070bf96d8ce63993877c0a01
* Sync to current upstream arc4random.Elliott Hughes2014-06-241-2/+12
| | | | | | | | | | This is actually revision 1.33, which is no longer the latest, but it's as close to head as we can currently reasonably get. I've also switched to the OpenBSD getentropy_linux.c implementation of getentropy, lightly modified to try to report an error on failure. Bug: 14499627 Change-Id: Ia7c561184b1f366c9bf66f248aa60f0d53535fcb
* Build tzcode with hidden visibility.Elliott Hughes2014-06-191-3/+4
| | | | | Bug: 11156955 Change-Id: Ib98d837b56cbbdfd01687cb3054fe3103eec0da9
* Move common macros into bionic_macros.h.Christopher Ferris2014-06-182-2/+7
| | | | | Bug: 15590152 Change-Id: I730636613ef3653f68c5ab1d43b53beaf8e0dc25
* Use a separate config.h for config like defines.Christopher Ferris2014-06-161-0/+26
| | | | | | | | | | This allows an easier way to share config parameters between unit tests and the bionic code. It also fixes a problem where the 32 bit bionic tests based on glibc, or the cts list executable did not have the pvalloc,valloc tests. Change-Id: Ib47942cb8a278252faa7498a6ef23e9578db544f
* Adds functionality specified by uchar.hDan Albert2014-06-041-0/+54
| | | | | | | | mbrtoc32 and c32rtomb get their implementations from mbrtowc and wcrtomb. The wc functions now simply call the c32 functions. Bug: 14646575 Change-Id: I49d4b95fed0f9d790260c996c4d0f8bfd1686324
* Return the actual success result from __futex.Elliott Hughes2014-05-291-4/+4
| | | | | | | futex(2) can return non-zero successes. Bug: 15195455 Change-Id: I7818bc922a5a2df31228ff72c169320b5e69a544
* Revert "Revert "Lose the hand-written futex assembler.""Elliott Hughes2014-05-282-21/+27
| | | | | | | | | | | | | | | | | | | | | | The problem with the original patch was that using syscall(3) means that errno can be set, but pthread_create(3) was abusing the TLS errno slot as a pthread_mutex_t for the thread startup handshake. There was also a mistake in the check for syscall failures --- it should have checked against -1 instead of 0 (not just because that's the default idiom, but also here because futex(2) can legitimately return values > 0). This patch stops abusing the TLS errno slot and adds a pthread_mutex_t to pthread_internal_t instead. (Note that for LP64 sizeof(pthread_mutex_t) > sizeof(uintptr_t), so we could potentially clobber other TLS slots too.) I've also rewritten the LP32 compatibility stubs to directly reuse the code from the .h file. This reverts commit 75c55ff84ebfa686c7ae2cc8ee431c6a33bd46b4. Bug: 15195455 Change-Id: I6ffb13e5cf6a35d8f59f692d94192aae9ab4593d
* Revert "Lose the hand-written futex assembler."Narayan Kamath2014-05-281-17/+6
| | | | | | | | | | This reverts commit ced906c849704f379d7191822f6d74993d4fa296. Causes issues on art / dalvik due to a broken return value check and other undiagnosed issues. bug: 15195455 Change-Id: I5d6bbb389ecefb0e33a5237421a9d56d32a9317c
* Lose the hand-written futex assembler.Elliott Hughes2014-05-221-6/+17
| | | | | | | Also stop exporting 'futex'. Bug: 12250341 Change-Id: Icc4fa4296cd04dfe0d1061822c69e2eb40c3433a
* Hide most of the private futex functions.Elliott Hughes2014-05-211-9/+19
| | | | | | | | | | Also hide part of the system properties compatibility code, since we needed to touch that to keep it building. I'll remove __futex_syscall4 and futex in a later patch. Bug: 11156955 Change-Id: Ibbf42414c5bb07fb9f1c4a169922844778e4eeae
* Support for jemalloc to replace dlmalloc.Christopher Ferris2014-05-201-1/+8
| | | | | | | | | | | | To use jemalloc, add MALLOC_IMPL = jemalloc in a board config file and you get the new version automatically. Update the pthread_create_key tests since jemalloc uses a few keys. Add a new test to verify memalign works as expected. Bug: 981363 Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
* Mark sockets on creation (socket()) and accept4().Sreeram Ramachandran2014-05-191-1/+2
| | | | | | Remove the separate syscall for accept() and implement it as accept4(..., 0). Change-Id: Ib0b8f5d7c5013b91eae6bbc3847852eb355c7714
* Query libnetd_client for the appropriate netId for host resolution.Paul Jensen2014-05-191-0/+1
| | | | | | | | | | If libnetd_client can't be found, operate as before and use the default netId potentially overriden by a more specific netId passed in to android_get*fornet(). (cherry picked from commit 559c7842cc6862568d9b5799fc0bcf74d58b596b) Change-Id: I42ef3293172651870fb46d2de22464c4f03e8e0b
* Cosmetic changes to netd client files.Sreeram Ramachandran2014-05-181-6/+11
| | | | | | | | | | + Name the dispatch header correctly (NetdClientDispatch.h). + Hide the global dispatch variable (__netdClientDispatch). + Explain why it's okay to read the variable without locking. + Use quotes instead of angle-brackets for non-system includes. + Add necessary declarations for C compiles (and not just C++). Change-Id: Id0932165e71d81da5fce77a684f40c2263f58e61