OSDN Git Service

android-x86/bionic.git
11 years agoMerge "Reorganize FORTIFY_SOURCE tests."
Nick Kralevich [Fri, 28 Jun 2013 20:05:57 +0000 (20:05 +0000)]
Merge "Reorganize FORTIFY_SOURCE tests."

11 years agoReorganize FORTIFY_SOURCE tests.
Nick Kralevich [Fri, 28 Jun 2013 17:34:09 +0000 (10:34 -0700)]
Reorganize FORTIFY_SOURCE tests.

Get rid of a lot of the duplication in the various FORTIFY_SOURCE
tests. Instead, we build 4 separate static libraries, with
4 different compile time options, and link them into the final test
binary.

Change-Id: Idb0b7cccc8dd837adb037bf4ddfe8942ae138230

11 years agoMerge "stdio.h: enable vs?printf clang FORTIFY_SOURCE"
Nick Kralevich [Thu, 27 Jun 2013 17:13:25 +0000 (17:13 +0000)]
Merge "stdio.h: enable vs?printf clang FORTIFY_SOURCE"

11 years agostdio.h: enable vs?printf clang FORTIFY_SOURCE
Nick Kralevich [Thu, 27 Jun 2013 15:58:14 +0000 (08:58 -0700)]
stdio.h: enable vs?printf clang FORTIFY_SOURCE

Enable FORTIFY_SOURCE protections under clang for the following
functions:

  * vsprintf
  * vsnprintf

and add unittests.

Change-Id: I90f8a27f7b202c78b5dd8ebf53050bf9e33496f7

11 years agoMerge changes Ib496e818,I074204e9
Colin Cross [Wed, 26 Jun 2013 00:03:24 +0000 (00:03 +0000)]
Merge changes Ib496e818,I074204e9

* changes:
  bionic: add compatibility mode for properties
  bionic: use the size of the file to determine property area size

11 years agobionic: add compatibility mode for properties
Colin Cross [Tue, 25 Jun 2013 01:36:39 +0000 (18:36 -0700)]
bionic: add compatibility mode for properties

Allow a new bionic to work with an old init property area by supporting
the old format.

(cherry picked from commit ad76c85b9ca587084089d086f954158bc0eae905)

Change-Id: Ib496e818a62a5834d40c71eb4745783d998be893

11 years agobionic: use the size of the file to determine property area size
Colin Cross [Tue, 25 Jun 2013 01:42:21 +0000 (18:42 -0700)]
bionic: use the size of the file to determine property area size

On the reader size, don't assume that the property size is PA_SIZE,
read it from the size of the file.  Allows init to use a different
property size without recompiling statically linked executables.

(cherry picked from commit 285b42a04cbe8e627a75c9bfb3c7cb3f7b539267)

Change-Id: I074204e9e6591b35faf7c1c58fb11ec162aff7bf

11 years agoMerge "Switch to current upstream getopt_long."
Elliott Hughes [Tue, 25 Jun 2013 22:56:59 +0000 (22:56 +0000)]
Merge "Switch to current upstream getopt_long."

11 years agoMerge "libc: add swapon and swapoff syscalls"
Rom Lemarchand [Tue, 25 Jun 2013 22:25:30 +0000 (22:25 +0000)]
Merge "libc: add swapon and swapoff syscalls"

11 years agoSwitch to current upstream getopt_long.
Elliott Hughes [Tue, 25 Jun 2013 21:48:10 +0000 (14:48 -0700)]
Switch to current upstream getopt_long.

Change-Id: I4c646dcb8be9e88dd54d069a03bbc5fbfd92de03

11 years agoMerge "Update x86 machine/endian.h from upstream"
Elliott Hughes [Tue, 25 Jun 2013 21:20:18 +0000 (21:20 +0000)]
Merge "Update x86 machine/endian.h from upstream"

11 years agoUpdate x86 machine/endian.h from upstream
Pavel Chupin [Fri, 19 Apr 2013 09:09:25 +0000 (13:09 +0400)]
Update x86 machine/endian.h from upstream

After download new version from upstream (OpenBSD 1.17) did the
following:
 * changed all u_int* types to uint*
 * add #include <sys/types.h>

All these changes are Android-specific and had been done before for
previous version (1.14).

Bug: http://code.google.com/p/android/issues/detail?id=54465
Change-Id: Ieb44e7fce4e794d997bb00ee0dd417fb61521720
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
11 years agolibc: add swapon and swapoff syscalls
Rom Lemarchand [Thu, 6 Jun 2013 21:29:40 +0000 (14:29 -0700)]
libc: add swapon and swapoff syscalls

Change-Id: Ie79dc8e3f2ff1cd427dd6d95e3850920c4b407b0
Signed-off-by: Rom Lemarchand <romlem@google.com>
11 years agoMerge "Kernel dso support for 'dl_iterate_phdr' function"
Elliott Hughes [Tue, 25 Jun 2013 20:15:29 +0000 (20:15 +0000)]
Merge "Kernel dso support for 'dl_iterate_phdr' function"

11 years agoKernel dso support for 'dl_iterate_phdr' function
Sergey Melnikov [Fri, 25 Jan 2013 12:40:13 +0000 (16:40 +0400)]
Kernel dso support for 'dl_iterate_phdr' function

Kernel provides virtual DSO for stack unwinding/exception handlind info for
signal usage case. Stack unwinding routines use 'dl_iterate_phdr' function
for additional DWARF info gathering from DSOs. Patch enables virtual DSO
enumeration via dl_iterate_phdr function.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ic2882b28f40b456a088bc1e63c50cbfda7e4a102

11 years agoMerge "libc: enable FORTIFY_SOURCE snprintf under clang"
Nick Kralevich [Tue, 25 Jun 2013 17:26:20 +0000 (17:26 +0000)]
Merge "libc: enable FORTIFY_SOURCE snprintf under clang"

11 years agolibc: enable FORTIFY_SOURCE snprintf under clang
Nick Kralevich [Tue, 25 Jun 2013 17:02:35 +0000 (10:02 -0700)]
libc: enable FORTIFY_SOURCE snprintf under clang

Change-Id: I8b8059782a720104722b0841994b38f873ed02aa

11 years agoMerge changes Ib074192d,I6df3afed,I69070455,Icbe31908,Id3fa4526,I038d451f
Colin Cross [Tue, 25 Jun 2013 00:07:53 +0000 (00:07 +0000)]
Merge changes Ib074192d,I6df3afed,I69070455,Icbe31908,Id3fa4526,I038d451f

* changes:
  bionic: store property names as variable-length strings
  bionic: prevent root processes from calling __system_property_add
  bionic: revert to a single (larger) property area
  bionic: reimplement property area as hybrid trie/binary tree
  bionic: add missing memory barriers to system properties
  bionic: make property area expandable

11 years agobionic: store property names as variable-length strings
Greg Hackmann [Fri, 21 Jun 2013 20:02:38 +0000 (13:02 -0700)]
bionic: store property names as variable-length strings

Names are immutable, so the fixed-sized arrays can be replaced with
variable-length ones to save memory (especially on internal tree nodes).

Signed-off-by: Greg Hackmann <ghackmann@google.com>
(cherry picked from commit 492ce95d9f6149137cb5b63c55cf2b3cdbe51e5e)

Change-Id: Ib074192d1b71150233d78c58e9ffcf7ecf688b6b

11 years agobionic: prevent root processes from calling __system_property_add
Colin Cross [Sun, 16 Jun 2013 17:19:16 +0000 (10:19 -0700)]
bionic: prevent root processes from calling __system_property_add

If a root process other than init calls __system_property_add, which
it should never do, it will break the design assumption that there is
only one mutator.

Pass O_EXCL to open() in map_prop_region_rw to ensure that only one
process ever has the property pages open for write.

(cherry picked from commit fb9b7b436f3ef94385f1b0c55ab81f246f0d96b8)

Change-Id: I6df3afedbfb5d07891b095aa24b78278381a5aaf

11 years agobionic: revert to a single (larger) property area
Greg Hackmann [Wed, 19 Jun 2013 20:31:21 +0000 (13:31 -0700)]
bionic: revert to a single (larger) property area

d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Signed-off-by: Greg Hackmann <ghackmann@google.com>
(cherry picked from commit 5f05348c18286a2cea46eae8acf94ed5b7932fac)

Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f

11 years agobionic: reimplement property area as hybrid trie/binary tree
Greg Hackmann [Thu, 20 Jun 2013 18:27:56 +0000 (11:27 -0700)]
bionic: reimplement property area as hybrid trie/binary tree

See the comments for an explanation of how properties are stored.

The trie structure is designed to scale better than the previous
array-based implementation.  Searching an array with n properties
required average O(n) string compares of the entire key; searching the
trie requires average O(log n) string compares of each token (substrings
between '.' characters).

Signed-off-by: Greg Hackmann <ghackmann@google.com>
(cherry picked from commit 6ac8e6a46d71a51bec16938efa89f275fa89cf7d)

Change-Id: Icbe31908572f33b4d9b85d5b62ac837cbd0f85e0

11 years agobionic: add missing memory barriers to system properties
Greg Hackmann [Thu, 20 Jun 2013 17:33:28 +0000 (10:33 -0700)]
bionic: add missing memory barriers to system properties

1) Reading the value must finish before checking whether it's intact

2) Setting the serial's dirty bit must visible before modifying the
value

3) The modified value must be visible before clearing the serial's dirty
bit

4) New properties and their TOC entries must be visible before updating
the property count

Signed-off-by: Greg Hackmann <ghackmann@google.com>
(cherry picked from commit 5bfa3ee8b37ef162154559575193018a6235acba)

Change-Id: Id3fa45261fc2df2ae493ab5194bc2b6bff04e966

11 years agobionic: make property area expandable
Greg Hackmann [Wed, 13 Feb 2013 22:41:48 +0000 (14:41 -0800)]
bionic: make property area expandable

The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

To avoid duplicating code, __system_property_area_init() now allocates
and initializes the first region (previously it was allocated in init's
init_property_area() and initialized in bionic).  For testing purposes,
__system_property_set_filename() may be used to override the file used
to map in regions.

Signed-off-by: Greg Hackmann <ghackmann@google.com>
(cherry picked from commit d32969701be070c0161c2643ee3c3df16066bbb8)

Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7

11 years agoMerge "libc: enable sprintf FORTIFY_SOURCE under clang"
Nick Kralevich [Mon, 24 Jun 2013 22:15:12 +0000 (22:15 +0000)]
Merge "libc: enable sprintf FORTIFY_SOURCE under clang"

11 years agolibc: enable sprintf FORTIFY_SOURCE under clang
Nick Kralevich [Mon, 24 Jun 2013 18:44:00 +0000 (11:44 -0700)]
libc: enable sprintf FORTIFY_SOURCE under clang

clang doesn't support __builtin_va_arg_pack(), so we have
to use #define instead.

Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1

11 years agoMerge "linker: Emit a warning on text relocations"
Nick Kralevich [Fri, 21 Jun 2013 22:36:50 +0000 (22:36 +0000)]
Merge "linker: Emit a warning on text relocations"

11 years agolinker: Emit a warning on text relocations
Nick Kralevich [Fri, 21 Jun 2013 19:31:33 +0000 (12:31 -0700)]
linker: Emit a warning on text relocations

Text relocations unnecessarily mark pages as dirty, preventing them
from being swapped out, wasting memory. Also, text relocations
prevent the code from running on certain hardened systems.

Print a message in logcat and stderr when we see a text relocation,
to encourage developers to fix their code.

Change-Id: I6051a7463911e090ae5727a355397d539669d5b9

11 years agoMerge "libc_logging: don't keep file descriptors open forever"
Nick Kralevich [Fri, 21 Jun 2013 21:26:09 +0000 (21:26 +0000)]
Merge "libc_logging: don't keep file descriptors open forever"

11 years agolibc_logging: don't keep file descriptors open forever
Nick Kralevich [Fri, 21 Jun 2013 20:28:42 +0000 (13:28 -0700)]
libc_logging: don't keep file descriptors open forever

Avoid keeping unnecessary file descriptors around when they're not
needed. Libc doesn't log so much that opening / closing overhead
matters.

Change-Id: I590ec5c27562db9bac025f781c48ec9a7724ce77

11 years agoMerge "libc: enable FORTIFY_SOURCE clang strlcpy"
Nick Kralevich [Thu, 20 Jun 2013 19:27:47 +0000 (19:27 +0000)]
Merge "libc: enable FORTIFY_SOURCE clang strlcpy"

11 years agolibc: enable FORTIFY_SOURCE clang strlcpy
Nick Kralevich [Thu, 20 Jun 2013 19:17:44 +0000 (12:17 -0700)]
libc: enable FORTIFY_SOURCE clang strlcpy

Change-Id: Idcfe08f5afc3dde592416df9eba83f64e130c7c2

11 years agoMerge "stdint.h header is not fully compatible with C99(ISO9899:1999)"
Elliott Hughes [Wed, 19 Jun 2013 19:45:09 +0000 (19:45 +0000)]
Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)"

11 years agoMerge "Fix FORTIFY_SOURCE unittests."
Nick Kralevich [Wed, 19 Jun 2013 17:33:57 +0000 (17:33 +0000)]
Merge "Fix FORTIFY_SOURCE unittests."

11 years agoMerge "bionic: add __system_property_foreach"
Colin Cross [Wed, 19 Jun 2013 17:26:17 +0000 (17:26 +0000)]
Merge "bionic: add __system_property_foreach"

11 years agoFix FORTIFY_SOURCE unittests.
Nick Kralevich [Wed, 19 Jun 2013 17:25:44 +0000 (10:25 -0700)]
Fix FORTIFY_SOURCE unittests.

The compiler is too damn smart.

Change-Id: Ibef3ef41ec99f8cd9c06f1dbca535819f9a08197

11 years agostdint.h header is not fully compatible with C99(ISO9899:1999)
Sergey Melnikov [Thu, 22 Nov 2012 11:23:48 +0000 (15:23 +0400)]
stdint.h header is not fully compatible with C99(ISO9899:1999)

stdint.h provides macros with incorrect type:
  * UINT8_C
  * UINT16_C
  * UINT8_MAX
  * UINT16_MAX

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: I2d130c782d4485bf6c9e9f068de0bdaa4ba7303f

11 years agobionic: add __system_property_foreach
Greg Hackmann [Wed, 13 Feb 2013 00:39:31 +0000 (16:39 -0800)]
bionic: add __system_property_foreach

find_nth() will be inefficient on a trie.  Since find_nth() is only used
internally and only for enumerating properties, we can add a foreach()
function to do this directly.

Signed-off-by: Greg Hackmann <ghackmann@google.com>
(cherry picked from commit 577418403d68e663fb33c7b0c8a90d862d9c00cf)

Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f

11 years agoMerge "Always use v1 for MIPS TLS access."
Elliott Hughes [Tue, 18 Jun 2013 20:56:25 +0000 (20:56 +0000)]
Merge "Always use v1 for MIPS TLS access."

11 years agoAlways use v1 for MIPS TLS access.
Elliott Hughes [Tue, 18 Jun 2013 20:26:22 +0000 (13:26 -0700)]
Always use v1 for MIPS TLS access.

Change-Id: Ic2850b90185cfbc5b0eff804c8b74a1c553c0852

11 years agoMerge "libc: Rename fortify error functions."
Nick Kralevich [Tue, 18 Jun 2013 20:24:03 +0000 (20:24 +0000)]
Merge "libc: Rename fortify error functions."

11 years agoMerge "libc: add limited FORTIFY_SOURCE support for clang"
Nick Kralevich [Tue, 18 Jun 2013 20:23:49 +0000 (20:23 +0000)]
Merge "libc: add limited FORTIFY_SOURCE support for clang"

11 years agoMerge "Make LD_PRELOAD failures just warnings."
Elliott Hughes [Tue, 18 Jun 2013 20:23:07 +0000 (20:23 +0000)]
Merge "Make LD_PRELOAD failures just warnings."

11 years agoMerge "bionic: fix deleting property arrays in property benchmark"
Colin Cross [Tue, 18 Jun 2013 20:22:25 +0000 (20:22 +0000)]
Merge "bionic: fix deleting property arrays in property benchmark"

11 years agoMerge "libc: Introduce __errordecl()"
Nick Kralevich [Tue, 18 Jun 2013 20:15:33 +0000 (20:15 +0000)]
Merge "libc: Introduce __errordecl()"

11 years agoMake LD_PRELOAD failures just warnings.
Elliott Hughes [Tue, 18 Jun 2013 20:15:00 +0000 (13:15 -0700)]
Make LD_PRELOAD failures just warnings.

This matches glibc and makes life easier for developers who want to
sometimes preload a library from init (which has no conditionals); they
can simply move/remove the library to disable.

Change-Id: I579b8633f958235af6e46bb53b378b9e363afb1f

11 years agobionic: fix deleting property arrays in property benchmark
Colin Cross [Tue, 18 Jun 2013 20:08:28 +0000 (13:08 -0700)]
bionic: fix deleting property arrays in property benchmark

Use delete[] to delete arrays allocated with new []

Change-Id: Icc2a6b23df09049c008f7f1f50ed93a277174308

11 years agolibc: Rename fortify error functions.
Nick Kralevich [Tue, 18 Jun 2013 20:07:18 +0000 (13:07 -0700)]
libc: Rename fortify error functions.

__umask_error -> __umask_invalid_mode
__creat_error -> __creat_missing_mode
__too_many_args_error -> __creat_too_many_args

Change-Id: I4036f344a3a93628e70f2e948ad73cfed3a967ea

11 years agoMerge "bionic: change properties benchmarks to read a single property"
Colin Cross [Tue, 18 Jun 2013 20:01:04 +0000 (20:01 +0000)]
Merge "bionic: change properties benchmarks to read a single property"

11 years agobionic: change properties benchmarks to read a single property
Colin Cross [Tue, 18 Jun 2013 19:47:38 +0000 (12:47 -0700)]
bionic: change properties benchmarks to read a single property

The properties benchmarks were reading n properties from a property
area with n properties in it, which was making it hard to compare
the time between runs of different sizes.  Change the benchmark
to read a random property per iteration so the numbers between
runs are comparable.

Change-Id: Ib1648ce0948d9038fce76d209608427376cfb8da

11 years agolibc: add limited FORTIFY_SOURCE support for clang
Nick Kralevich [Mon, 17 Jun 2013 21:49:19 +0000 (14:49 -0700)]
libc: add limited FORTIFY_SOURCE support for clang

In 829c089f83ddee37203b52bcb294867a9ae7bdbc, we disabled all
FORTIFY_SOURCE support when compiling under clang. At the time,
we didn't have proper test cases, and couldn't easily create targeted
clang tests.

This change re-enables FORTIFY_SOURCE support under clang for a
limited set of functions, where we have explicit unittests available.
The functions are:

* memcpy
* memmove
* strcpy
* strncpy
* strcat
* strncat
* memset
* strlen (with modifications)
* strchr (with modifications)
* strrchr (with modifications)

It may be possible, in the future, to enable other functions. However,
I need to write unittests first.

For strlen, strchr, and strrchr, clang unconditionally calls the
fortified version of the relevant function. If it doesn't know the
size of the buffer it's dealing with, it passes in ((size_t) -1),
which is the largest possible size_t.

I added two new clang specific unittest files, primarily copied
from fortify?_test.cpp.

I've also rebuild the entire system with these changes, and didn't
observe any obvious problems.

Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa

11 years agolibc: Introduce __errordecl()
Nick Kralevich [Tue, 18 Jun 2013 17:46:02 +0000 (10:46 -0700)]
libc: Introduce __errordecl()

Define __errordecl and replace __attribute__((__error__("foo")))
with __errordecl. Make sure __errordecl is a no-op on clang, as it
generates a compile time warning.

Change-Id: Ifa1a2d3afd6881de9d479fc2adac6737871a2949

11 years agoMerge changes Iac00ce10,I192d3825
Colin Cross [Tue, 18 Jun 2013 01:11:58 +0000 (01:11 +0000)]
Merge changes Iac00ce10,I192d3825

* changes:
  bionic: add tests for properties
  bionic: move system property writing from init to bionic

11 years agobionic: add tests for properties
Colin Cross [Tue, 29 Jan 2013 01:19:43 +0000 (17:19 -0800)]
bionic: add tests for properties

(cherry picked from commit 37d9f75dde881a0ba1c1b3253b1be19d4096963d)

Change-Id: Iac00ce10a4272032a1cbdbc4204277d6876e3365

11 years agobionic: move system property writing from init to bionic
Colin Cross [Thu, 24 Jan 2013 07:07:06 +0000 (23:07 -0800)]
bionic: move system property writing from init to bionic

Move the implementation of writing to the system property area
from init to bionic, next to the reader implementation.  This
will allow full property testing to be added to bionic tests.

Add new accessor and waiting functions to hide the implementation
from watchprops and various bionic users.

Also hide some of the implementation details of the property area
from init by moving them into _system_properties.h, and other details
from everybody by moving them into system_properties.h.

(cherry picked from commit dc1038b7900acb664e99643d2974e1a0f4703781)

Change-Id: I192d3825ee276c5047bc751039fe6cfe226a7cca

11 years agoMerge "don't hardcode register r0/v1 when reading the TLS"
Elliott Hughes [Mon, 17 Jun 2013 21:51:49 +0000 (21:51 +0000)]
Merge "don't hardcode register r0/v1 when reading the TLS"

11 years agodon't hardcode register r0/v1 when reading the TLS
Mathias Agopian [Sat, 15 Jun 2013 02:00:03 +0000 (19:00 -0700)]
don't hardcode register r0/v1 when reading the TLS

this leads to much improved code when calling __get_tls()

Change-Id: I21d870fb33c33a921ca55c4e100772e0f7a8d1e4

11 years agoMerge "Slight script cleanup; make gensyscalls work from any directory."
Elliott Hughes [Mon, 17 Jun 2013 18:16:36 +0000 (18:16 +0000)]
Merge "Slight script cleanup; make gensyscalls work from any directory."

11 years agoSlight script cleanup; make gensyscalls work from any directory.
Elliott Hughes [Mon, 17 Jun 2013 17:26:10 +0000 (10:26 -0700)]
Slight script cleanup; make gensyscalls work from any directory.

Also remove a ton of dead code.

Change-Id: I1315623695a004f643b155f121cbafe24b715b8a

11 years agoMerge "Ensure that <stdint.h> defines SIZE_MAX and friends."
Elliott Hughes [Thu, 13 Jun 2013 23:19:09 +0000 (23:19 +0000)]
Merge "Ensure that <stdint.h> defines SIZE_MAX and friends."

11 years agoEnsure that <stdint.h> defines SIZE_MAX and friends.
Elliott Hughes [Thu, 13 Jun 2013 23:02:53 +0000 (16:02 -0700)]
Ensure that <stdint.h> defines SIZE_MAX and friends.

We were missing SIG_ATOMIC_MAX, SIG_ATOMIC_MIN, SIZE_MAX,
WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN.

Change-Id: I2535f36bc220fbaea009b483599b7af811c4cb5c

11 years agoMerge "Fix the qsort copyright notice (fixed upstream this afternoon)."
Elliott Hughes [Thu, 13 Jun 2013 00:44:05 +0000 (00:44 +0000)]
Merge "Fix the qsort copyright notice (fixed upstream this afternoon)."

11 years agoFix the qsort copyright notice (fixed upstream this afternoon).
Elliott Hughes [Thu, 13 Jun 2013 00:42:43 +0000 (17:42 -0700)]
Fix the qsort copyright notice (fixed upstream this afternoon).

Change-Id: I786feb42719bceaa7da91565e350c1333b0d301f

11 years agoMerge "Handles spurious wake-ups in pthread_join()"
Elliott Hughes [Thu, 13 Jun 2013 00:31:49 +0000 (00:31 +0000)]
Merge "Handles spurious wake-ups in pthread_join()"

11 years agoHandles spurious wake-ups in pthread_join()
msg555 [Thu, 6 Jun 2013 18:59:28 +0000 (14:59 -0400)]
Handles spurious wake-ups in pthread_join()

Removed 'join_count' from pthread_internal_t and switched to using the flag
PTHREAD_ATTR_FLAG_JOINED to indicate if a thread is being joined. Combined with
a switch to a while loop in pthread_join, this fixes spurious wake-ups but
prevents a thread from being joined multiple times. This is fine for
two reasons:

1) The pthread_join specification allows for undefined behavior when multiple
   threads try to join a single thread.

2) There is no thread safe way to allow multiple threads to join a single
   thread with the pthread interface.  The second thread calling pthread_join
   could be pre-empted until the thread is destroyed and its handle reused for
   a different thread.  Therefore multi-join is always an error.

Bug: https://code.google.com/p/android/issues/detail?id=52255
Change-Id: I8b6784d47620ffdcdbfb14524e7402e21d46c5f7

11 years agoMerge "Take upstream libm changes."
Elliott Hughes [Thu, 13 Jun 2013 00:29:21 +0000 (00:29 +0000)]
Merge "Take upstream libm changes."

11 years agoTake upstream libm changes.
Elliott Hughes [Wed, 12 Jun 2013 23:37:58 +0000 (16:37 -0700)]
Take upstream libm changes.

Mostly workarounds for GCC and Clang bugs.

Change-Id: I4ef428a42d4ac6d622659053711a8cc416925727

11 years agoMerge "Take some fixed upstream copyright headers and regenerate NOTICE."
Elliott Hughes [Wed, 12 Jun 2013 23:13:34 +0000 (23:13 +0000)]
Merge "Take some fixed upstream copyright headers and regenerate NOTICE."

11 years agoTake some fixed upstream copyright headers and regenerate NOTICE.
Elliott Hughes [Wed, 12 Jun 2013 23:00:41 +0000 (16:00 -0700)]
Take some fixed upstream copyright headers and regenerate NOTICE.

Change-Id: Ifff41d69c13322dbc6f928ce7d4c65f76fe36772

11 years agoMerge "Switch to current upstream stdio makebuf.c and setvbuf.c."
Elliott Hughes [Wed, 12 Jun 2013 22:56:20 +0000 (22:56 +0000)]
Merge "Switch to current upstream stdio makebuf.c and setvbuf.c."

11 years agoSwitch to current upstream stdio makebuf.c and setvbuf.c.
Elliott Hughes [Wed, 12 Jun 2013 22:24:15 +0000 (15:24 -0700)]
Switch to current upstream stdio makebuf.c and setvbuf.c.

Change-Id: I4761b5e94459815520f01062eef39abf62af621f

11 years agoMerge "Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work.""
Elliott Hughes [Wed, 12 Jun 2013 22:19:03 +0000 (22:19 +0000)]
Merge "Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work.""

11 years agoRevert "Add SIZE_MAX to <stdint.h> in a way that might actually work."
Elliott Hughes [Wed, 12 Jun 2013 22:18:47 +0000 (22:18 +0000)]
Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."

This reverts commit d8627af159c6b1bc40296fb29297c61b30a5a8e2 which caused build breakage:

In file included from bionic/libc/include/limits.h:86:0,
                 from bionic/libc/include/stdint.h:33,
                 from bionic/libc/arch-arm/bionic/crtbegin.c:31:
bionic/libc/include/sys/limits.h:30:26: fatal error: linux/limits.h: No such file or directory
compilation terminated.
make: *** [out/target/product/generic/obj/lib/crtbegin_dynamic1.o] Error 1

Change-Id: I128095ecb99df92626e1f57e34c61e08c98a4078

11 years agoMerge "Add SIZE_MAX to <stdint.h> in a way that might actually work."
Elliott Hughes [Wed, 12 Jun 2013 22:05:09 +0000 (22:05 +0000)]
Merge "Add SIZE_MAX to <stdint.h> in a way that might actually work."

11 years agoAdd SIZE_MAX to <stdint.h> in a way that might actually work.
Elliott Hughes [Wed, 12 Jun 2013 21:54:16 +0000 (14:54 -0700)]
Add SIZE_MAX to <stdint.h> in a way that might actually work.

Take two.

Change-Id: I7d08b6d14c82a171312a7f5898270b4441d5cfa2

11 years agoMerge "Clean up abort."
Elliott Hughes [Wed, 12 Jun 2013 21:53:57 +0000 (21:53 +0000)]
Merge "Clean up abort."

11 years agoClean up abort.
Elliott Hughes [Wed, 12 Jun 2013 21:05:46 +0000 (14:05 -0700)]
Clean up abort.

* A dlmalloc usage error shouldn't call abort(3) because we want to
  cause a SIGSEGV by writing the address dlmalloc didn't like to an
  address the kernel won't like, so that debuggerd will dump the
  memory around the address that upset dlmalloc.

* Switch to the simpler FreeBSD/NetBSD style of registering stdio
  cleanup. Hopefully this will let us simplify more of the stdio
  implementation.

* Clear the stdio cleanup handler before we abort because of a dlmalloc
  corruption error. This fixes the reported bug, where we'd hang inside
  dlmalloc because the stdio cleanup reentered dlmalloc.

Bug: 9301265
Change-Id: Ief31b389455d6876e5a68f0f5429567d37277dbc

11 years agoMerge "<stdint.h> should expose SIZE_MAX."
Elliott Hughes [Wed, 12 Jun 2013 17:56:23 +0000 (17:56 +0000)]
Merge "<stdint.h> should expose SIZE_MAX."

11 years ago<stdint.h> should expose SIZE_MAX.
Elliott Hughes [Wed, 12 Jun 2013 17:28:26 +0000 (10:28 -0700)]
<stdint.h> should expose SIZE_MAX.

Change-Id: Id27222c24955c83f29ad953933cbdc48b6f1e900

11 years agoMerge "fix unittests."
Nick Kralevich [Tue, 11 Jun 2013 22:52:54 +0000 (22:52 +0000)]
Merge "fix unittests."

11 years agofix unittests.
Nick Kralevich [Tue, 11 Jun 2013 22:45:23 +0000 (15:45 -0700)]
fix unittests.

7e6ce1a3c52d8533fed92c143419fedb0c93988a fixed abort() to raise
SIGABRT rather than causing SIGSEGV. However, the unittests were
not updated.

Fix unittests.

Change-Id: I73db194127b9b9e9440358aa94273863765a736b

11 years agoMerge "Fix abort(3) to raise SIGABRT rather than causing SIGSEGV."
Ben Cheng [Tue, 11 Jun 2013 00:22:14 +0000 (00:22 +0000)]
Merge "Fix abort(3) to raise SIGABRT rather than causing SIGSEGV."

11 years agoFix abort(3) to raise SIGABRT rather than causing SIGSEGV.
Ben Cheng [Tue, 11 Jun 2013 00:01:41 +0000 (17:01 -0700)]
Fix abort(3) to raise SIGABRT rather than causing SIGSEGV.

tgkill() needs the .save stack unwinding directive to get the complete
stack trace.

BUG: https://code.google.com/p/android/issues/detail?id=16672

Change-Id: Ifb447dca2147a592c48baf32769dfc175d8aea72

11 years agoMerge "Honor p_vaddr if set"
Brian Carlstrom [Mon, 10 Jun 2013 22:39:06 +0000 (22:39 +0000)]
Merge "Honor p_vaddr if set"

11 years agoMerge "bionic/x86: Optimization for string routines"
Elliott Hughes [Sat, 8 Jun 2013 00:45:07 +0000 (00:45 +0000)]
Merge "bionic/x86: Optimization for string routines"

11 years agoMerge "Revert "libc x86: Remove strcat.S""
Elliott Hughes [Sat, 8 Jun 2013 00:42:44 +0000 (00:42 +0000)]
Merge "Revert "libc x86: Remove strcat.S""

11 years agoRevert "libc x86: Remove strcat.S"
Elliott Hughes [Sat, 8 Jun 2013 00:42:35 +0000 (00:42 +0000)]
Revert "libc x86: Remove strcat.S"

This reverts commit 4fe461b3a67148a2f557605e10a34deff9c8773a

Change-Id: Ibeb76e24f054abd7c96ad6899366c2f9bfc2a5ad

11 years agoMerge "Implement malloc_usable_size for debug impls."
Christopher Ferris [Fri, 7 Jun 2013 22:15:33 +0000 (22:15 +0000)]
Merge "Implement malloc_usable_size for debug impls."

11 years agoImplement malloc_usable_size for debug impls.
Christopher Ferris [Wed, 22 May 2013 00:48:01 +0000 (17:48 -0700)]
Implement malloc_usable_size for debug impls.

- Implemented chk_memalign.
- Fixed a few bugs in leak_memalign.
- Implemented {leak,fill,check,qemu}_malloc_usable_size.
- Make malloc_usable_size update at run time.
- Add malloc_test.cpp as a small set of tests for the
  malloc debug routines.
- Fix the qemu routines since it's been broken since it moved to C++.
- Add support for the %u format to the out_vformat in libc_logging.cpp.
  This is used by the emulator code.

Tested using the bionic-unit-tests with setprop libc.debug.malloc
set to 1, 5, and 10.

I tested as much as possible on the emulator, but tracing doesn't appear
to be working properly.

Bug: 6143477

Merge change from internal master.

(cherry-picked from commit 3d594c258045783fc9e1956ce7a4d91e302f011e)

Change-Id: I4ae00fffba82315a8c283f35893fd554460722fb

11 years agoHonor p_vaddr if set
Brian Carlstrom [Fri, 11 Jan 2013 00:39:58 +0000 (16:39 -0800)]
Honor p_vaddr if set

(cherry picked from commit 88ff15c2c279d2bbe3569101b36cd2aa0931a0a9)

Change-Id: I4aabbe911d30aea8ace69e29bb6e980a4e89de90

11 years agoMerge "update signal.h to be C90 compatable"
Elliott Hughes [Thu, 6 Jun 2013 01:06:40 +0000 (01:06 +0000)]
Merge "update signal.h to be C90 compatable"

11 years agoupdate signal.h to be C90 compatable
Erik Gilling [Wed, 29 May 2013 23:26:23 +0000 (16:26 -0700)]
update signal.h to be C90 compatable

sigismember, sigaddset, and sigdelset had mixed code and declarations
which are not allowed in C90 and before.

Change-Id: I662af944fc1489e34bed228ce592e41f50d00e17
Signed-off-by: Erik Gilling <konkers@android.com>
11 years agoMerge "Ensure header files using __BEGIN_DECLS include sys/cdefs.h."
Elliott Hughes [Thu, 6 Jun 2013 01:04:13 +0000 (01:04 +0000)]
Merge "Ensure header files using __BEGIN_DECLS include sys/cdefs.h."

11 years agoEnsure header files using __BEGIN_DECLS include sys/cdefs.h.
Elliott Hughes [Thu, 6 Jun 2013 00:51:20 +0000 (17:51 -0700)]
Ensure header files using __BEGIN_DECLS include sys/cdefs.h.

We keep fixing these one-by-one; let's fix them all at once.

Found thus:

  find . -name *.h | xargs grep -L sys/cdefs.h | xargs grep -l BEGIN_DECL | xargs grep -L sys/types

Change-Id: I188842aa2484dc6176e96556d57c38a0f785b59b

11 years agoMerge "sys/personality.h: include <sys/cdefs.h>"
Elliott Hughes [Thu, 6 Jun 2013 00:28:07 +0000 (00:28 +0000)]
Merge "sys/personality.h: include <sys/cdefs.h>"

11 years agoMerge "Clean up useless declaration in thread_private.h"
Elliott Hughes [Thu, 6 Jun 2013 00:00:40 +0000 (00:00 +0000)]
Merge "Clean up useless declaration in thread_private.h"

11 years agosys/personality.h: include <sys/cdefs.h>
Kito Cheng [Wed, 5 Jun 2013 03:30:17 +0000 (11:30 +0800)]
sys/personality.h: include <sys/cdefs.h>

Change-Id: Ia3fa558a38e0cffe5287bc454e85d5d3bdaa6ba1

11 years agoClean up useless declaration in thread_private.h
Kito Cheng [Fri, 3 May 2013 02:31:17 +0000 (10:31 +0800)]
Clean up useless declaration in thread_private.h

Change-Id: Ie7bcdc7195a3fcbcd09a95f73b0c49e8897ad50b

11 years agoMerge "Fix declaration of malloc_usable_size()"
Elliott Hughes [Wed, 5 Jun 2013 01:58:26 +0000 (01:58 +0000)]
Merge "Fix declaration of malloc_usable_size()"

11 years agoMerge "Add tests for __strcpy_chk()"
Nick Kralevich [Tue, 4 Jun 2013 19:05:33 +0000 (19:05 +0000)]
Merge "Add tests for __strcpy_chk()"