summaryrefslogtreecommitdiffstats
path: root/libc
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Add the posix_memalign(3) function to bionic"Ken Sumrall2011-12-202-0/+30
|\
| * Add the posix_memalign(3) function to bionicKen Sumrall2011-12-142-0/+30
| | | | | | | | | | | | | | | | | | | | The posix_memalign(3) function is very similar to the traditional memalign(3) function, but with better error reporting and a guarantee that the memory it allocates can be freed. In bionic, memalign(3) allocated memory can be freed, so posix_memalign(3) is just a wrapper around memalign(3). Change-Id: I62ee908aa5ba6b887d8446a00d8298d080a6a299
* | am a37f3729: readdir: fix interface to kernel getdents64 functionBruce Beare2011-12-191-4/+10
|\ \ | |/ |/| | | | | * commit 'a37f3729730e4e7345977915d67adc3eea93dfe4': readdir: fix interface to kernel getdents64 function
| * readdir: fix interface to kernel getdents64 functionBruce Beare2011-12-191-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: The kernel will pad the entry->d_reclen in a getdents64 call to a long-word boundary. For very long records, this could exceed the size of a struct dirent. The mismatch in the size was causing error paranoid checking code in bionic to fail... thus causing an early "end" when reading the dirent structures from the kernel buffer. Test: ls mkdir abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu ls Change-Id: I75d1f8e45e1655fdd7bac4a08a481d086f28073a Author: Bruce Beare <bruce.j.beare@intel.com>
* | libc: x86: Use SSE2 or SSSE3 optimized routines when possible.David 'Digit' Turner2011-12-141-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch uses the new hardware feature macros for x86 to define various compile-time macros used to make the C library use SSE2 and/or SSSE3 optimized memory functions for target CPUs that support these features. Note that previously, we relied on the macros being defined by build/core/combo/TARGET_linux-x86.mk, but this is no longer the case. Change-Id: Ieae5ff5284c0c839bc920953fb6b91d2f2633afc
* | am 8d28b043: am 94963af2: update video/dsscomp.hErik Gilling2011-12-131-27/+30
|\ \ | |/ | | | | | | * commit '8d28b043e93d323684add3406ebae6b8fe6475d5': update video/dsscomp.h
| * am 94963af2: update video/dsscomp.hErik Gilling2011-12-131-27/+30
| |\ | | | | | | | | | | | | * commit '94963af28e445384e19775a838a29e6a71708179': update video/dsscomp.h
| | * update video/dsscomp.hErik Gilling2011-12-131-27/+30
| | | | | | | | | | | | | | | Change-Id: I9da47f7fb7f34f9c4baa860bb767cb8fd4f8020c Signed-off-by: Erik Gilling <konkers@android.com>
* | | am f3087c6e: am af96d4da: x86: libc may use the gcc flags from ↵Bruce Beare2011-12-121-5/+2
|\ \ \ | |/ / | | | | | | | | | | | | | | | TARGET_linux-x86.mk * commit 'f3087c6e86f54874538669d899d8a2ede59f7433': x86: libc may use the gcc flags from TARGET_linux-x86.mk
| * | am af96d4da: x86: libc may use the gcc flags from TARGET_linux-x86.mkBruce Beare2011-12-091-5/+2
| |\ \ | | | | | | | | | | | | | | | | * commit 'af96d4dadc3f3d8466dbbeaf3a816e6871715fbc': x86: libc may use the gcc flags from TARGET_linux-x86.mk
| | * | x86: libc may use the gcc flags from TARGET_linux-x86.mkBruce Beare2011-12-091-5/+2
| | | | | | | | | | | | | | | | | | | | Change-Id: Iaf4d864d4b6fe388bd3c2d7c4d7d6e42aebb0d35 Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
* | | | am 68ec71eb: am 7d03c9cb: pathconf: dead loop in bionic function __2_symlinksBruce Beare2011-12-121-14/+11
|\ \ \ \ | |/ / / | | | | | | | | | | | | * commit '68ec71ebd6df12596dc5688c907c76ea4b32c9b4': pathconf: dead loop in bionic function __2_symlinks
| * | | am 7d03c9cb: pathconf: dead loop in bionic function __2_symlinksBruce Beare2011-12-091-14/+11
| |\ \ \ | | |/ / | | | | | | | | | | | | * commit '7d03c9cbcedb1dc7e3a8210ac0001120558ec6df': pathconf: dead loop in bionic function __2_symlinks
| | * | pathconf: dead loop in bionic function __2_symlinksBruce Beare2011-12-071-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix dead loops in file ./bionic/libc/unistd/pathconf.c Change-Id: I7a1e6bcd9879c96bacfd376b88a1f899793295c8 Author: Jin Wei <wei.a.jin@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
* | | | am ffe65783: am bba5c314: update video/dsscomp.hErik Gilling2011-12-121-31/+44
|\ \ \ \ | |/ / / | | | | | | | | | | | | * commit 'ffe65783b4afc3f687a54b582a4e236caa22ed30': update video/dsscomp.h
| * | | am bba5c314: update video/dsscomp.hErik Gilling2011-12-081-31/+44
| |\ \ \ | | | |/ | | |/| | | | | | | | | * commit 'bba5c314b2420483e2c0e3e441bf54bda6935bc1': update video/dsscomp.h
| | * | update video/dsscomp.hErik Gilling2011-12-081-31/+44
| | | | | | | | | | | | | | | | | | | | Change-Id: Ic5f1c01add1f2adb5a09d05c94129f3dc9cc3f1f Signed-off-by: Erik Gilling <konkers@android.com>
* | | | libc: optimize pthread mutex lock/unlock operations (1/2)David 'Digit' Turner2011-12-071-80/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides several small optimizations to the implementation of mutex locking and unlocking. Note that a following patch will get rid of the global recursion lock, and provide a few more aggressive changes, I though it'd be simpler to split this change in two parts. + New behaviour: pthread_mutex_lock et al now detect recursive mutex overflows and will return EAGAIN in this case, as suggested by POSIX. Before, the counter would just wrap to 0. - Remove un-necessary reloads of the mutex value from memory by storing it in a local variable (mvalue) - Remove un-necessary reload of the mutex value by passing the 'shared' local variable to _normal_lock / _normal_unlock - Remove un-necessary reload of the mutex value by using a new macro (MUTEX_VALUE_OWNER()) to compare the thread id for recursive/errorcheck mutexes - Use a common inlined function to increment the counter of a recursive mutex. Also do not use the global recursion lock in this case to speed it up. Change-Id: I106934ec3a8718f8f852ef547f3f0e9d9435c816
* | | | libc: optimize pthread_once() implementation.David 'Digit' Turner2011-12-071-8/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the implementation of pthread_once() to avoid the use of a single global recursive mutex. This should also slightly speed up the non-common case where we have to call the init function, or wait for another thread to finish the call. Change-Id: I8a93f4386c56fb89b5d0eb716689c2ce43bdcad9
* | | | am a73de44b: am 177ba8cb: Prevent deadlock when using forkRabin Vincent2011-12-061-8/+16
|\ \ \ \ | |/ / / | | | | | | | | | | | | * commit 'a73de44b7c0a50908ea8afe16134316cfc6cfbbe': Prevent deadlock when using fork
| * | | am 177ba8cb: Prevent deadlock when using forkRabin Vincent2011-12-061-8/+16
| |\ \ \ | | | |/ | | |/| | | | | | | | | * commit '177ba8cb42ed6d232e7c8bcad5e6ee21fc51a0e8': Prevent deadlock when using fork
| | * | Prevent deadlock when using forkRabin Vincent2011-12-061-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When forking of a new process in bionic, it is critical that it does not allocate any memory according to the comment in java_lang_ProcessManager.c: "Note: We cannot malloc() or free() after this point! A no-longer-running thread may be holding on to the heap lock, and an attempt to malloc() or free() would result in deadlock." However, as fork is using standard lib calls when tracing it a bit, they might allocate memory, and thus causing the deadlock. This is a rewrite so that the function cpuacct_add, that fork calls, will use system calls instead of standard lib calls. Signed-off-by: christian bejram <christian.bejram@stericsson.com> Change-Id: Iff22ea6b424ce9f9bf0ac8e9c76593f689e0cc86
* | | | Merge 35765066 from ics-mr1-plus-aospJean-Baptiste Queru2011-12-061-1/+1
|\ \ \ \ | |/ / / | | | | | | | | Change-Id: Ibaeb49dc20f3c736417d5cb68769e7b501a61632
| * | | am e4a21c89: signal: Align the sigset_t size passed to from user space to ↵Bruce Beare2011-12-051-8/+37
| |\ \ \ | | |/ / | | | | | | | | | | | | | | | | | | | | kernel. * commit 'e4a21c89a8b24b32f7a2637b45522dfa59f2aaa4': signal: Align the sigset_t size passed to from user space to kernel.
| | * | signal: Align the sigset_t size passed to from user space to kernel.Bruce Beare2011-12-051-8/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pass kernel space sigset_t size to __rt_sigprocmask to workaround the miss-match of NSIG/sigset_t definition between kernel and bionic. Note: Patch originally from Google... Change-Id: I4840fdc56d0b90d7ce2334250f04a84caffcba2a Signed-off-by: Chenyang Du <chenyang.du@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
* | | | am cb835cd7: am cb1df916: string: Fix wrong comparison semanticsBruce Beare2011-12-054-7/+7
|\ \ \ \ | |/ / / | | | | | | | | | | | | * commit 'cb835cd77c8e60b4a9fb8a54a06d4fd4039ae1b0': string: Fix wrong comparison semantics
| * | | am cb1df916: string: Fix wrong comparison semanticsBruce Beare2011-12-054-7/+7
| |\ \ \ | | |/ / | | | | | | | | | | | | * commit 'cb1df9161666db2a312814752de67fc623149a9b': string: Fix wrong comparison semantics
| | * | string: Fix wrong comparison semanticsBruce Beare2011-12-054-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Chars are signed for x86 -- correct the comparison semantics. Change-Id: I2049e98eb063c0b4e83ea973d3fcae49c6817dde Author: Liubov Dmitrieva <liubov.dmitrieva@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
* | | | am 75039baf: am 89d3fdca: MALLOC_DEBUG: enable the option libc.debug.malloc = 10Bruce Beare2011-12-051-1/+1
|\ \ \ \ | |/ / / | | | | | | | | | | | | * commit '75039bafde8e6f03caffa9d6aa7142a09ba50952': MALLOC_DEBUG: enable the option libc.debug.malloc = 10
| * | | am 89d3fdca: MALLOC_DEBUG: enable the option libc.debug.malloc = 10Bruce Beare2011-12-051-1/+1
| |\ \ \ | | |/ / | | | | | | | | | | | | * commit '89d3fdcae26980bf81a4622c3c83e48ead4c1c3a': MALLOC_DEBUG: enable the option libc.debug.malloc = 10
| | * | MALLOC_DEBUG: enable the option libc.debug.malloc = 10Bruce Beare2011-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the compile warning to let the libc.debug.malloc=10 works well Due to unsuitable value comparison, which cause compiler optimize the code of comparing two digits. Change-Id: I0bedd596c9ca2ba308fb008da20ecb328d8548f5 Signed-off-by: Bruce Beare <bruce.j.beare@intel.com> Author: liu chuansheng <chuansheng.liu@intel.com>
* | | | am 0c3d21e6: am e480fc83: bionic: fix pthread_{create, exit}/signal race ↵Jack Ren2011-11-302-1/+6
|\ \ \ \ | |/ / / | | | | | | | | | | | | | | | | | | | | condition * commit '0c3d21e63c6e75ae73aaf2b8d64af0bd8caa6beb': bionic: fix pthread_{create, exit}/signal race condition
| * | | am e480fc83: bionic: fix pthread_{create, exit}/signal race conditionJack Ren2011-11-292-1/+6
| |\ \ \ | | |/ / | | | | | | | | | | | | * commit 'e480fc83b2887388d469eb3bf58c86c610f5b082': bionic: fix pthread_{create, exit}/signal race condition
| | * | bionic: fix pthread_{create, exit}/signal race conditionJack Ren2011-11-292-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (1) in pthread_create: If the one signal is received before esp is subtracted by 16 and __thread_entry( ) is called, the stack will be cleared by kernel when it tries to contruct the signal stack frame. That will cause that __thread_entry will get a wrong tls pointer from the stack which leads to the segment fault when trying to access tls content. (2) in pthread_exit After pthread_exit called system call unmap(), its stack will be freed. If one signal is received at that time, there is no stack available for it. Fixed by subtracting the child's esp by 16 before the clone system call and by blocking signal handling before pthread_exit is started. Author: Jack Ren <jack.ren@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
* | | | am 621df526: am 31e72bc3: bionic: fix __get_tls( ) crash issueJack Ren2011-11-301-0/+5
|\ \ \ \ | |/ / / | | | | | | | | | | | | * commit '621df52644cc19001688c0964ad425c5ed6c8990': bionic: fix __get_tls( ) crash issue
| * | | am 31e72bc3: bionic: fix __get_tls( ) crash issueJack Ren2011-11-291-0/+5
| |\ \ \ | | |/ / | | | / | | |/ | |/| * commit '31e72bc3289acdd85b0b745fbf64c5949ca33432': bionic: fix __get_tls( ) crash issue
| | * bionic: fix __get_tls( ) crash issueJack Ren2011-11-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | When running the stress test of pthread create/destroy, a crash may oocur in __get_tls(). That is caused by the race condition with __set_tls( ): Author: Jack Ren <jack.ren@intel.com> Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
* | | Merge "Request both v4 and v6 dns when on secondary net"Robert Greenwalt2011-11-291-8/+19
|\ \ \
| * | | Request both v4 and v6 dns when on secondary netRobert Greenwalt2011-11-221-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't easily tell the protocol family of the secondary network, so try both and trust that the carrier has configured dns servers according to the protocols supported on its network. bug:5468224 Change-Id: If4f017573d313a6ad8354574076de6d63d43b444
* | | | update capabilities.hNick Kralevich2011-11-281-40/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull in an updated version of capabilities.h from the linux kernel. This file was generated using the following command: cd bionic/libc/kernel/ ./tools/clean_header.py -u ../../../external/kernel-headers/original/linux/capability.h Change-Id: I43c8f014954f543858006f24e60a2e69955349da
* | | | libc: Fix typo that broke NDK compatibility.David 'Digit' Turner2011-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function must be named __atomic_cmpxchg, not __android_cmpxchg. This typo broke existing prebuilt binaries (they couldn't be loaded at runtime anymore). Change-Id: I25ca7d18329817f0056e616a0409113269ad7b1f
* | | | Merge "libc: provide atomic operations will full barriers for NDK apps."David 'Digit' Turner2011-11-227-307/+244
|\ \ \ \
| * | | | libc: provide atomic operations will full barriers for NDK apps.David 'Digit' Turner2011-11-167-307/+244
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __atomic_cmpxchg and other related atomic operations did not provide memory barriers, which can be a problem for non-platform code that links against them when it runs on multi-core devices. This patch does two things to fix this: - It modifies the existing implementation of the functions that are exported by the C library to always provide full memory barriers. We need to keep them exported by the C library to prevent breaking existing application machine code. - It also modifies <sys/atomics.h> to only export always-inlined versions of the functions, to ensure that any application code compiled against the new header will not rely on the platform version of the functions. This ensure that said machine code will run properly on all multi-core devices. This is based on the GCC built-in sync primitives. The end result should be only slightly slower than the previous implementation. Note that the platform code does not use these functions at all. A previous patch completely removed their usage in the pthread and libstdc++ code. + rename arch-arm/bionic/atomics_arm.S to futex_arm.S + rename arch-x86/bionic/atomics_x86.S to futex_x86.S + remove arch-x86/include/sys/atomics.h which already provided inlined functions to the x86 platform. Change-Id: I752a594475090cf37fa926bb38209c2175dda539
* | | | Merge "Add tgkill syscall."Jeff Brown2011-11-2110-2/+121
|\ \ \ \
| * | | | Add tgkill syscall.Jeff Brown2011-11-1810-2/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use tgkill instead of tkill to implement pthread_kill. This is safer in the event that the thread has already terminated and its id has been reused by a different process. Change-Id: Ied715e11d7eadeceead79f33db5e2b5722954ac9
* | | | | ASLR: enable pthread stack location randomizationNick Kralevich2011-11-181-4/+1
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | Allow the kernel to choose a memory location to put the thread stack, rather than hard coding 0x10000000 Change-Id: Ib1f37cf0273d4977e8d274fbdab9431ec1b7cb4f
* | | | Merge "libc: speed-up flockfile()/funlockfile()"David 'Digit' Turner2011-11-164-153/+44
|\ \ \ \
| * | | | libc: speed-up flockfile()/funlockfile()David 'Digit' Turner2011-11-154-153/+44
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For Honeycomb, we added proper file thread-safety for all FILE* operations. However, we did implement that by using an out-of-band hash table to map FILE* pointers to phtread_mutex_t mutexes, because we couldn't change the size of 'struct _sFILE' without breaking the ABI. It turns out that our BSD-derived code already has some support code to extend FILE* objects, so use it instead. See libc/stdio/fileext.h This patch gets rid of the hash table, and put the mutex directly into the sFILE extension. Change-Id: If1c3fe0a0a89da49c568e9a7560b7827737ff4d0
* | | | Merge "bionic: Do not use <sys/atomics.h> for platform code."David Turner2011-11-167-159/+457
|\ \ \ \
| * | | | bionic: Do not use <sys/atomics.h> for platform code.David 'Digit' Turner2011-11-167-159/+457
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're going to modify the __atomic_xxx implementation to provide full memory barriers, to avoid problems for NDK machine code that link to these functions. First step is to remove their usage from our platform code. We now use inlined versions of the same functions for a slight performance boost. + remove obsolete atomics_x86.c (was never compiled) NOTE: This improvement was benchmarked on various devices. Comparing a pthread mutex lock + atomic increment + unlock we get: - ARMv7 emulator, running on a 2.4 GHz Xeon: before: 396 ns after: 288 ns - x86 emulator in KVM mode on same machine: before: 27 ns after: 27 ns - Google Nexus S, in ARMv7 mode (single-core): before: 82 ns after: 76 ns - Motorola Xoom, in ARMv7 mode (multi-core): before: 121 ns after: 120 ns The code has also been rebuilt in ARMv5TE mode for correctness. Change-Id: Ic1dc72b173d59b2e7af901dd70d6a72fb2f64b17