Commit graph

193 commits

Author SHA1 Message Date
Jean-Baptiste Queru
6b9d2d6839 am 6d4d8cb7: resolved conflicts for merge of 4f086aeb to gingerbread-plus-aosp
Merge commit '6d4d8cb79c5578d33ab17806d67b1e53a730fbc3'

* commit '6d4d8cb79c5578d33ab17806d67b1e53a730fbc3':
  Implemented pthread_atfork()
2010-07-23 15:04:24 -07:00
Jean-Baptiste Queru
6d4d8cb79c resolved conflicts for merge of 4f086aeb to gingerbread-plus-aosp
Change-Id: Ice2a6d41a7e9d04eca02e15ed189d648d61b5801
2010-07-23 13:53:19 -07:00
Matt Fischer
4f086aeb4a Implemented pthread_atfork()
Change-Id: Ie6c0bf593315d3507b3c4a6c8903a74a1fa053db
2010-07-23 13:10:16 -07:00
The Android Open Source Project
fb6907d39c am 0e78f786: merge from open-source master
Merge commit '0e78f786777a04af498b43564a8d6ed8e15e8940'

* commit '0e78f786777a04af498b43564a8d6ed8e15e8940':
  Change-Id: I68cc462aeb2460345a53bdb9941ce4bfc10456fb
2010-07-09 10:54:06 -07:00
The Android Open Source Project
0e78f78677 merge from open-source master
Change-Id: Id84ff747889d6f2c15c0510263e32fdfdd18dbed
2010-07-09 10:48:45 -07:00
Jean-Baptiste Queru
fc6d95b10e Merge "Change-Id: I68cc462aeb2460345a53bdb9941ce4bfc10456fb bionic: fix clearenv() compiler warning and related comment typos" 2010-07-08 15:38:13 -07:00
David 'Digit' Turner
cf38531741 resolved conflicts for merge of 2576abf0 to master
Change-Id: Ibd3ed11f3cc27ff12c0464b0f56d7057be6a7b85
2010-07-02 15:22:19 -07:00
David 'Digit' Turner
519763265e libc: Fix sem_post() implementation to wake up all waiting threads.
This also allows us to optimize the case where we increment an
uncontended semaphore (no need to call futex_wake() then).

Change-Id: Iad48efe8551dc66dc89d3e3f18c001e5a6c1939f
2010-07-02 15:09:57 -07:00
David 'Digit' Turner
3b43f87d29 Allow dlclose() to properly call static C++ destructors.
With this patch _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

Note that this change introduces crtbegin_so.S and crtend_so.S which
are currently ignored by the build system.

+ move definition of __dso_handle to the right place
(before that, all shared libraries used the __dso_handle
global variable from the C library).

Note that we keep a 'weak' __dso_handle in aeabi.c to avoid
breaking the build until the next patch to build/core/combo/
appears. We will be able to remove that later.

+ move bionic/aeabi.c to arch-arm/bionic/ (its proper location)

NOTE: The NDK will need to be modified to enable this feature in
         the shared libraries that are generated through it.

Change-Id: I99cd801375bbaef0581175893d1aa0943211b9bc
2010-07-01 23:09:28 -07:00
David 'Digit' Turner
4e6043a355 am 7d1d98b9: am a02b93bd: libc: add sanity checks to pthread_mutex_destroy()
Merge commit '7d1d98b97e947de22aff4c0b67eec7ae68c822ee'

* commit '7d1d98b97e947de22aff4c0b67eec7ae68c822ee':
  libc: add sanity checks to pthread_mutex_destroy()
2010-06-29 12:55:34 -07:00
David 'Digit' Turner
a02b93bd75 libc: add sanity checks to pthread_mutex_destroy()
Change-Id: Iddb2204fa792fa9aca5f19838926dddbb09b74a2
2010-06-28 14:20:22 -07:00
Wink Saville
ccc3d1eea1 Use a recursive lock for pthread_once.
bug: 2292366
Change-Id: I9fc8b790dcfcb30ca94a0beb340d43fe5cd6c22e
2010-06-28 11:41:16 -07:00
Chris Peterson
2bf607d599 Change-Id: I68cc462aeb2460345a53bdb9941ce4bfc10456fb
bionic: fix clearenv() compiler warning and related comment typos
2010-06-27 20:53:04 -07:00
David 'Digit' Turner
50ace4fec5 Remove compiler warnings when building Bionic.
Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.

Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
2010-06-22 17:51:41 -07:00
David 'Digit' Turner
6a9b888d7c Allow static C++ destructors to be properly called on dlclose().
With this patch, _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

Note that this change introduces crtbegin_so.S and crtend_so.S which
are currently ignored by the build system.

+ move definition of __dso_handle to the right place
  (before that, all shared libraries used the __dso_handle
   global variable from the C library).

  Note that we keep a 'weak' __dso_handle in aeabi.c to avoid
  breaking the build until the next patch to build/core/combo/
  appears. We will be able to remove that later.

+ move bionic/aeabi.c to arch-arm/bionic/ (its proper location)

Change-Id: Ie771aa204e3acbdf02fd30ebd4150373a1398f39
NOTE: The NDK will need to be modified to enable this feature in
      the shared libraries that are generated through it.
2010-06-18 16:07:10 -07:00
David 'Digit' Turner
6c8a2f2a5b libc: remove cutils dependencies
We simply copy the stuff we need from cutils headers.

A future patch will change cutils to include the private <bionic_atomic_inline.h>

Change-Id: Ib6fd9a03bc9e337ce867bd606dc94c2b4438480a
2010-06-11 13:49:09 -07:00
David 'Digit' Turner
6304d8b218 Use private futexes for semaphores, unless they are initialized with pshared != 0.
Change-Id: I534e36a7171cd37037ae03b910ba71ea6968286d
Note: previously, sem_init() would return an error if pshared != 0.
2010-06-08 17:04:49 -07:00
Jean-Baptiste Queru
a8a2148863 resolved conflicts for merge of 7b6e6fa5 to kraken
Change-Id: I2b9b80a7fa32c56be2b85ff8be0d6e7ac1848afe
2010-06-03 15:05:04 -07:00
The Android Open Source Project
7b6e6fa572 merge from open-source master
Change-Id: Ib7fc9c6f79f9b13e2175da137005d8968ea85eaf
2010-06-03 14:39:20 -07:00
Andy McFadden
fcd00ebbdf Atomic/SMP update, part 3.
Update ARM atomic ops to use LDREX/STREX.  Stripped out #if 0 chunk.

Insert explicit memory barriers in pthread and semaphore code.

For bug 2721865.

Change-Id: I0f153b797753a655702d8be41679273d1d5d6ae7
2010-05-28 16:12:01 -07:00
André Goddard Rosa
78c1c04ced pthread: introduce pthread_setname_np() as a mean to give names to threads
... so that each cloned process at the kernel level can be named
independently. Tools like 'top' can display the CPU/memory statistics
for each process's thread if "Show Threads" mode is on.

With this function in place, we can convert dalvik/Thread.c setThreadName()
function over this function. This feature ought to be provided by the
underlying C library and not coded directly in Dalvik.

Change-Id: Ifa997665dbaa114e0b126f8c667708be9a4137fd
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-05-19 23:17:16 -03:00
David 'Digit' Turner
8a1d2cf142 Add pthread_rwlock_t implementation to the C library (DO NOT MERGE)
Change-Id: I756d8c26afc37cd7b71117ddbaa02a2cb40fdecb
2010-05-19 14:53:18 -07:00
The Android Open Source Project
f450fa5f99 merge from open-source master
Change-Id: If02d33af51017dbd85e91c79ac2e848eda6cf253
2010-05-03 15:33:05 -07:00
David Turner
0be7eda75a Merge "Fix log channel initialization at bionic/logd_write.c." 2010-05-01 15:31:39 -07:00
André Goddard Rosa
5751c54bf1 bionic: add missing NULL check from memory allocation on record_backtrace()
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>

Change-Id: I739c63c5a7344fff1775580044dc647edf246ebf
2010-04-29 07:37:42 -07:00
The Android Open Source Project
95faecefde merge from open-source master
Change-Id: If77618a329fc7b497c44c2585e644bc50e7e1406
2010-04-08 11:11:53 -07:00
André Goddard Rosa
350bb359fa bionic: fix memory leak in get_malloc_leak_info() error path
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-03-29 21:21:26 -03:00
André Goddard Rosa
3f61212781 bionic: clear only the part of the buffer which is not overwritten afterward
Change-Id: I5ddd93f0557e5a7401460dc9fc8a55b330a79c3a
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-03-28 21:32:36 -03:00
David 'Digit' Turner
5207d78c32 Fix typo that broke recursive mutexes implementation.
Change-Id: I832901604b487c6a50304c311b5ba135e153530d
2010-03-23 05:30:55 -07:00
David 'Digit' Turner
b5e4a41606 pthread: Use private futexes by default in condition variables
Now that the system properly uses shared condvars when needed, we
can enable the use of private futexes for them too.

Change-Id: Icf8351fc0a2309f764cba45c65bc3af047720cdf
2010-03-22 17:31:50 -07:00
The Android Open Source Project
377d4c979d merge from open-source master
Change-Id: I70266ee8c520b216773f267e46c8273d2334c31d
2010-03-22 15:55:09 -07:00
David 'Digit' Turner
88f06cd84a Use private futexes for pthread_mutex_t.
This does not change the implementation of conditional variables
since we're waiting for other system components to properly use
pthread_condattr_init/setpshared before that.

Also remove an obsolete x86 source file.

Change-Id: Ia3e3fbac35b87a534fb04d4381c3c66b975bc8f7
2010-03-18 17:13:41 -07:00
David Turner
1825fb5d5f Merge "bionic: on pthread_join(), avoid extra check in case we find the thread" 2010-03-18 16:42:49 -07:00
David Turner
c0e464268d Merge "bionic: ftell() returns a long, not an int" 2010-03-18 16:35:42 -07:00
David 'Digit' Turner
ee7b077abf Add pthread_condattr_init/destroy/setpshared/getpshared
Note that this does not change the implementation of conditional variables
which still use shared futexes, independent on the flags being selected.

This will be fixed in a later patch, once our system is modified to use
pthread_condattr_setpshared(attr, PTHREAD_PROCESS_SHARED) properly.

Change-Id: I935de50964cd41f97a13dbfd6626d3407b0406c3
2010-03-18 14:07:42 -07:00
David 'Digit' Turner
40e6b82286 Fix indentation in pthread mutex implementation.
This is preliminary work to simplify later changes to support
private futexes.

Change-Id: I06750936a93747a5e3f5a10228cbdc29e39c528c
2010-03-17 11:25:46 -07:00
David Turner
a9c41a8e0a Merge "bionic: remove unneeded variable from chk_realloc()" 2010-03-16 17:26:44 -07:00
Fabrice Di Meglio
8641833b62 Revert "bionic: pthread: use private futexes by default for mutexes and condvars"
This reverts commit ba9c6f0989.
2010-03-11 14:47:47 -08:00
David 'Digit' Turner
ba9c6f0989 bionic: pthread: use private futexes by default for mutexes and condvars
Private futexes are a recent kernel addition: faster futexes that cannot be
shared between processes. This patch uses them by default, unless the PROCESS_SHARED
attribute flag is used when creating a mutex and/or conditional variable.

Also introduces pthread_condattr_init/destroy/setpshared/getpshared.

Change-Id: I3a0e2116f467072b046524cb5babc00e41057a53
2010-03-11 11:48:38 -08:00
Mike Chan
9f6915631b bonic: libc: cpuacct support for setuid functions
Any of the setuid functions now updates /acct/uid/ with its own tid
before changing users. This is so we can properly account for cpu time
per uid.

Change-Id: I34186cf4d5228cac8439e582a9e26c01ef3011e4
Signed-off-by: Mike Chan <mike@android.com>
2010-03-02 18:18:04 -08:00
David 'Digit' Turner
8f8b5310d2 Fix pthread_sigmask() to return correct error values.
Before that, it returned -1 on error and set errno (not Posix)
After the patch, it returns the error code and leaves errno untouched.
2010-03-01 11:30:40 -08:00
Vladimir Chtchetkine
b55462328f Merge "Merge memory checking functionality from sandbox" 2010-02-17 13:43:15 -08:00
Vladimir Chtchetkine
75fba6888a Merge memory checking functionality from sandbox
Change-Id: I304c789a752c9f4af4944ca14b9bf1e7644da15a
2010-02-16 11:43:18 -08:00
David 'Digit' Turner
4f920f685b Fix sem_post() behaviour to wake up multiple waiting threads. 2010-02-12 12:50:32 -08:00
David 'Digit' Turner
294dd0b86b Fix sem_trywait() implementation + update changelog. 2010-02-12 12:18:37 -08:00
David 'Digit' Turner
1dcf07a84c Fix android_id_from_name to accept "app_0" as a valid ID.
This fixes getpwnam and getpwgrp which returned NULL for "app_0".
"app_0" corresponds to uid/gid 10000 and is perfectly valid.
2010-02-12 11:35:38 -08:00
André Goddard Rosa
699237baf5 bionic: equalize the <unknown> program name between ssp.c and libc_init_common.c
... for the consistency sake.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-02-05 17:48:07 -02:00
André Goddard Rosa
291100c795 bionic: remove unneeded variable from chk_realloc()
... and simplify the generated code.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-02-05 16:32:56 -02:00
André Goddard Rosa
a28336c735 bionic: on pthread_join(), avoid extra check in case we find the thread
... by using similar logic as used in pthread_detach().

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-02-05 16:21:07 -02:00
André Goddard Rosa
3b06c128cf bionic: ftell() returns a long, not an int
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-02-05 16:05:52 -02:00
David 'Digit' Turner
97cf7f3394 Implement clone() C library function properly.
Only provide an implementation for ARM at the moment, since
it requires specific assembly fragments (the standard syscall
stubs cannot be used because the child returns in a different
stack).
2010-01-25 11:18:30 -08:00
Colin Cross
fc10b24acc Add implementation of fdprintf, clearenv, and stubs for ttyname_r, *usershell
Change-Id:	I5fe7e8b6ee5edbb49e707c3b6737a58563781fa3
2010-01-15 16:52:35 -08:00
Colin Cross
64ceac3f49 Add fts, err, and sys/queue for grep
Change-Id:	Id47514a1812d828e95efa2fab0e9c15c5b682b58
2010-01-15 15:57:02 -08:00
Alexey Tarasov
c22da7ed32 Fix log channel initialization at bionic/logd_write.c.
log_channel_t contains fd member, which is file descriptor for
exact logging channel. change cc05d12716
lacks initialization of this member in __write_to_log_init(), thus
logging code is not working, although not crashable.

Additional details may be found in comments here:
http://review.source.android.com/5617
2009-12-03 11:37:22 +10:00
Andy McFadden
5cdb2b73d2 Fix libc logging implementation.
The file descriptor wasn't getting set, so the writev() call was
silently failing.

There's a parallel implementation over in system/core/liblog, but it's
still using the old approach and didn't have this problem.
2009-11-30 17:09:45 -08:00
Vladimir Chtchetkine
fdfa16776c am 362b2aab: Merge change Ib4550a04 into eclair-mr2
Merge commit '362b2aabee2dd04e04a3ad9c09f0ad0212569be4' into eclair-mr2-plus-aosp

* commit '362b2aabee2dd04e04a3ad9c09f0ad0212569be4':
  Split libc_debug.so into two .so modules loaded on demand from libc.so
2009-11-19 11:28:22 -08:00
Vladimir Chtchetkine
b74ceb25aa Split libc_debug.so into two .so modules loaded on demand from libc.so
This change is intended to eliminate need to replace libc.so with libc_debug.so in order to enablememory allocation debugging.
This is also the first step towards implementing extended memoryallocation debugging using emulator's capabilities in monitoring memory access.
2009-11-18 10:36:25 -08:00
Jean-Baptiste Queru
95604529ec merge from eclair 2009-11-15 12:05:31 -08:00
Jean-Baptiste Queru
194d3fa048 eclair snapshot 2009-11-12 18:45:14 -08:00
David 'Digit' Turner
7e5e9f4270 am bc10cd29: Fix a typo that resulted in a crash in the boot sequence
Merge commit 'bc10cd2900cdb7fed077163b6a33e0f8572b2b19' into eclair-plus-aosp

* commit 'bc10cd2900cdb7fed077163b6a33e0f8572b2b19':
  Fix a typo that resulted in a crash in the boot sequence
2009-09-23 16:09:39 -07:00
David 'Digit' Turner
bc10cd2900 Fix a typo that resulted in a crash in the boot sequence 2009-09-23 15:56:50 -07:00
David 'Digit' Turner
9641805419 am d154954f: Merge change 26419 into eclair
Merge commit 'd154954f02691618fdf73a5a97336e64cad37af0' into eclair-plus-aosp

* commit 'd154954f02691618fdf73a5a97336e64cad37af0':
  Add pthread_mutex_lock_timeout_np
2009-09-23 12:20:52 -07:00
David 'Digit' Turner
3f56b7f65a Add pthread_mutex_lock_timeout_np
This is used to perform a mutex lock for a given amount of
milliseconds before giving up. Using the _np prefix since this
is absolutely not portable.

Also remove a compiler warning in pthread_attr_getstackaddr
2009-09-22 15:17:50 -07:00
Jean-Baptiste Queru
895244b2ab merge from open-source master 2009-09-16 16:21:35 -07:00
Matthieu CASTET
a4e67f4512 Remove code duplication for pthread_cond_timeout_np : use __pthread_cond_timedwait_relative helper 2009-09-14 09:19:42 -07:00
Jean-Baptiste Queru
00fb8b45d9 merge from open-source master 2009-09-01 08:27:42 -07:00
Alexey Tarasov
cc05d12716 Changed logging functions in bionic/logd_write.c.
Main differences from original code:
1. now log channel for LOG_ID_MAIN may exist even if LOG_ID_RADIO
   facility failed.
2. __write_to_log_null() now acts as always successful function.
3. it's more simplier to add new logging channels now

ammended commit fixes my typo on line 130
2009-08-25 10:27:26 -07:00
Jean-Baptiste Queru
44ac5d5d93 merge from open-source master 2009-08-07 17:04:35 -07:00
Android Code Review
bb08537104 Merge change 10057
* changes:
  Add mspace_merge_objects
2009-08-07 16:43:33 -07:00
Andy McFadden
e40fb3d68f am 39f3745c: Restore malloc debug.
Merge commit '39f3745cf30efe38482ffead1c32f4e62f6fe32e'

* commit '39f3745cf30efe38482ffead1c32f4e62f6fe32e':
  Restore malloc debug.
2009-07-21 16:40:00 -07:00
Andy McFadden
39f3745cf3 Restore malloc debug.
Some libc changes were preventing the initialization call from being made.
The basic problem appears to be that libc_init_common.c is only built once,
and it's only built for the non-debug libc.
2009-07-21 15:44:23 -07:00
David 'Digit' Turner
d5b3513cca am b56b5659: Fix the C library runtime initialization order.
Merge commit 'b56b5659b3996e98c2060f168d1cff1474e77d2a'

* commit 'b56b5659b3996e98c2060f168d1cff1474e77d2a':
  Fix the C library runtime initialization order.
2009-07-20 00:13:21 -07:00
David 'Digit' Turner
b56b5659b3 Fix the C library runtime initialization order.
This allows libc.so to run the C runtime initializer as soon as the
dynamic linker loads the shared library, i.e. before any other initializers
(e.g. static C++ constructors in other shared libraries the executable depends
on).

This also removes the bug where the initializers from the executable itself
were run twice: once by the dynamic linker, and another time by __libc_init
as defined by libc_init_dynamic.c
2009-07-18 01:11:10 +02:00
Mathias Agopian
b7681167cb allow pthread_mutexattr_setpshared to accept SHARED mutexes, since our current impl actually uses shared mutexes 2009-07-13 22:00:33 -07:00
Mathias Agopian
a2f5e21244 added pthread_cond_timedwait_relative_np() 2009-07-13 18:37:40 -07:00
David 'Digit' Turner
c4eee3765b Prevent a crash in the memory leak checker (which happened in chk_free())
Simplify the code a little, removing un-necessary mutex locks/unlocks.
Provide slightly better diagnostic message in case of corruption.
Use snprintf/strlcat instead of sprintf/strcat
2009-07-10 00:32:08 +02:00
David 'Digit' Turner
3a654b1e04 Revert "Fix the C library initialization to avoid calling static C++ constructors twice."
This reverts commit 03eabfe65e.
2009-06-03 19:32:37 +02:00
Barry Hayes
f30dae9cf4 Add mspace_merge_objects 2009-06-02 14:48:59 -07:00
David 'Digit' Turner
03eabfe65e Fix the C library initialization to avoid calling static C++ constructors twice.
The problem was due to the fact that, in the case of dynamic executables,
the dynamic linker calls the DT_PREINIT_ARRAY, DT_INIT and DT_INIT_ARRAY
constructors when loading shared libraries and dynamic executables,
*before* calling the executable's entry point (i.e. arch-$ARCH/bionic/crtbegin_dynamic.c)
which in turns call __libc_init() in libc.so, as defined by bionic/libc_init_dynamic.c

The latter did call these constructors array again, mistakenly.

The patch also updates the documentation of many related functions.

Also adds a new section to linker/README.TXT explaining restrictions on
C library usage.

The patch has been tested on a Dream for stability issues with
proprietary blobs:

- H264 decoding works
- Camera + Video recording works
- GPS works
- Sensors work

The tests in system/extra/tests/bionic/libc/common/test_static_cpp_mutex.cpp has been
run and shows the static C++ constructor being called only once.
2009-06-02 23:27:44 +02:00
David 'Digit' Turner
0ba91ed3ca Fix __eabi_atexit() implementation, as well as a bug in the BSD-originated __cxa_finalize() implementation
This patch uses "#if ANDROID" instead of "#if 1" in the __cxa_finalize() fix
2009-05-20 11:42:52 +02:00
David 'Digit' Turner
d386afcc41 revert to previous implementation of __aeabi_atexit() since the new one seems to crash a static ICU String destructor.
I don't have the time to investigate why right now, so a revert is preferred. Damn...
2009-05-15 02:11:12 +02:00
David 'Digit' Turner
3e16f84fca Fix __aeabi_atexit to call __cxa_atexit properly. This function is defined by the C++ ABI for ARM document. 2009-05-14 14:25:26 +02:00
The Android Open Source Project
1dc9e472e1 auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
The Android Open Source Project
1767f908af auto import from //depot/cupcake/@135843 2009-03-03 18:28:13 -08:00
The Android Open Source Project
a799b53f10 auto import from //depot/cupcake/@132589 2009-03-03 14:03:51 -08:00
The Android Open Source Project
fe5745033a auto import from //depot/cupcake/@137055 2009-03-02 22:54:14 -08:00
The Android Open Source Project
6f04a0f4c7 auto import from //branches/cupcake/...@132276 2009-02-19 10:57:29 -08:00
The Android Open Source Project
2489551343 auto import from //branches/cupcake/...@131421 2009-02-13 12:57:48 -08:00
The Android Open Source Project
9f65adf2ba auto import from //branches/cupcake/...@130745 2009-02-10 15:43:56 -08:00
The Android Open Source Project
d37527501c auto import from //branches/cupcake/...@127101 2009-01-20 14:03:55 -08:00
The Android Open Source Project
e5cc1f386b auto import from //branches/cupcake/...@126645 2009-01-15 16:12:07 -08:00
The Android Open Source Project
4e468ed2eb Code drop from //branches/cupcake/...@124589 2008-12-17 18:03:48 -08:00
The Android Open Source Project
a27d2baa0c Initial Contribution 2008-10-21 07:00:00 -07:00