Commit graph

604 commits

Author SHA1 Message Date
Elliott Hughes
61fb3fc770 Prepare to switch to the uapi <linux/signal.h>.
<time.h> didn't need to copy the cruft from <signal.h>, and
<signal.h> only needs the uid_t hack when it's not using
uapi headers.

pthread_exit.cpp should include what it uses.

Change-Id: I836c36abe0f0a781d41fc425b249d1c7686bb124
2013-11-07 12:29:07 -08:00
Elliott Hughes
7250d2e5b4 Remove pathconf's dependencies on non-uapi header files.
Change-Id: I597996e4b141b009916f7ad2866dd100e08aa4d3
2013-11-06 17:21:09 -08:00
Elliott Hughes
062092543f Clean up the 32-bit kernel support, fix LP64 fcntl declaration.
In practice, thanks to all the registers the stubs don't actually change,
but it's confusing to have an incorrect declaration.

I suspect that fcntl remains broken for aarch64; it happens to work for
x86_64 because the first vararg argument gets placed in the right register
anyway, but I have no reason to believe that's true for aarch64.

This patch adds a unit test, though, so we'll be able to tell when we get
as far as running the unit tests.

Change-Id: I58dd0054fe99d7d51d04c22781d8965dff1afbf3
2013-11-06 16:33:39 -08:00
Elliott Hughes
6fa79c5cf5 Remove unnecessary #include.
Change-Id: I99dade0b3803272ee29eba2ad36b0311f8a24c31
2013-11-05 11:59:06 -08:00
Elliott Hughes
66759d6041 Move the pthread debugging flags to the right place.
Change-Id: Ie805bd837d1f72cdf1818e056c0baeb0857e4e84
2013-10-31 14:09:39 -07:00
Elliott Hughes
c3f114037d <pthread.h> fixes and pthread cleanup.
<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
2013-10-31 12:31:16 -07:00
Elliott Hughes
2b6e43e00e Explain the sigprocmask in pthread_exit.
Also remove the SIGSEGV special case, which was probably because
hand-written __exit_with_stack_teardown stubs used to try to cause
SIGSEGV if the exit system call returned (which it never does, so
that dead code disappeared).

Also move the sigprocmask into the only case where it's necessary ---
the one where we unmap the stack that would be used by a signal
handler.

Change-Id: Ie40d20c1ae2f5e7125131b6b492cba7a2c6d08e9
2013-10-29 16:11:06 -07:00
Elliott Hughes
27586ebe1a Fix utime/utimes when passed a NULL pointer.
Bug: 11383777
Change-Id: If944a42f3adfa8a6ce91c167c249e009ed63300a
2013-10-28 13:21:06 -07:00
Elliott Hughes
6b53c2349a Fix the exit syscall stub's name.
I've left the exit_group syscall as _exit because otherwise we'd have to
convince the compiler that our _exit (which just calls __exit_group) is
actually "noreturn", and it seems like that would be less clean than just
cutting out the middleman.

We'll just have to trust ourselves not to add anything to SYSCALLS.TXT
that ought to be private but that only has a single leading underscore.
Hopefully we can manage that.

Change-Id: Iac47faea9f516186e1774381846c54cafabc4354
2013-10-24 22:41:50 -07:00
Elliott Hughes
567a8de3ca Start moving 32-bit cruft somewhere it won't pollute 64-bit.
Change-Id: I03a6a50a5243f29e50fb58a3cf8b5e7198640baa
2013-10-24 17:14:55 -07:00
Elliott Hughes
bf425680e4 Let the compiler worry about implementing ffs(3).
It does at least as good a job as our old hand-written assembly anyway.

Change-Id: If7c4a1ac508bace0b71ee7b67808caa6eabf11d2
2013-10-24 16:29:40 -07:00
Elliott Hughes
11952073af Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.
(aarch64 kernels don't have these system calls.)

Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
2013-10-24 15:48:32 -07:00
Elliott Hughes
cac7b9d6ec Remove dependencies on obsolete __ARCH_WANT_SYSCALL_NO_FLAGS syscalls.
(aarch64 kernels only have the newer system calls.)

Also expose the new functionality that's exposed by glibc in our header files.

Change-Id: I45d2d168a03f88723d1f7fbf634701006a4843c5
2013-10-23 09:48:29 -07:00
Elliott Hughes
f8fcfbc85a Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.
Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.

Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
2013-10-22 16:31:01 -07:00
Elliott Hughes
8c39e58b6a Merge "Make sure we have a mkfifo symbol." 2013-10-22 19:03:57 +00:00
Elliott Hughes
594b1a4af2 Make sure we have a mkfifo symbol.
Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: Ic0a883a5f30beb82cb7be3c4e81b6d693d5fbb4d
2013-10-22 12:03:19 -07:00
Serban Constantinescu
7f70c9b64e AArch64: Fix uses of stack size for 32/64bit libc builds
This patch fixes stack size uses to size_t.

Change-Id: I0671c85ddb1c1aceaf9440a7c73c21fe528653fa
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-10-22 12:01:29 -07:00
Elliott Hughes
c7e9b23317 Fix sigaction(3) for 64-bit.
Also clean up <signal.h> and revert the hacks that were necessary
for 64-bit in linker/debugger.cpp until now.

Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
2013-10-17 11:36:55 -07:00
Elliott Hughes
6b9321b858 am d6e117b6: am 1f29c2f5: Merge "Switch sigpending over to rt_sigpending."
* commit 'd6e117b64bdfbf8d793eb59ea9604b806608ec75':
  Switch sigpending over to rt_sigpending.
2013-10-16 16:09:42 -07:00
Elliott Hughes
40d105ccb3 Switch sigpending over to rt_sigpending.
Change-Id: I7b28984796b5fb343cfbcc47e0afc3a84293d417
2013-10-16 14:07:01 -07:00
Elliott Hughes
afaebc3fef am 87fc78de: am 608c65f6: Merge "Fix sigsuspend to use rt_sigsuspend on all platforms."
* commit '87fc78de6c869d0403ccdd2e756ec1f5d456f3d3':
  Fix sigsuspend to use rt_sigsuspend on all platforms.
2013-10-15 18:20:32 -07:00
Elliott Hughes
1f5af926fa Fix sigsuspend to use rt_sigsuspend on all platforms.
Change-Id: I981c1a66d35480d4457a0a08a1b042dac94daa5b
2013-10-15 18:15:19 -07:00
Elliott Hughes
f2a760dca7 am a85606e1: am c100a100: Merge "\'Avoid confusing "read prevented write" log messages\' 2."
* commit 'a85606e1563c2153bea3c73dfe4ca1588e778f22':
  'Avoid confusing "read prevented write" log messages' 2.
2013-10-15 17:38:17 -07:00
Elliott Hughes
68b67113a4 'Avoid confusing "read prevented write" log messages' 2.
This time it's assembler.

Change-Id: Iae6369833b8046b8eda70238bb4ed0cae64269ea
2013-10-15 17:17:05 -07:00
Elliott Hughes
cbfa1afda3 am 0287db52: am d9913b0b: Merge "Make pthread_create report sched_setscheduler failures on LP64."
* commit '0287db52ed93df39ab45c7f60a241ae621866b90':
  Make pthread_create report sched_setscheduler failures on LP64.
2013-10-15 17:14:59 -07:00
Elliott Hughes
d9913b0b0d Merge "Make pthread_create report sched_setscheduler failures on LP64." 2013-10-16 00:09:54 +00:00
Elliott Hughes
df17ce7858 am 26491483: am 76725214: Merge "Avoid confusing "read prevented write" log messages."
* commit '264914838d1c22c15ed0069d1217a780835c6d1c':
  Avoid confusing "read prevented write" log messages.
2013-10-15 16:58:19 -07:00
Elliott Hughes
b01ebe6d4e am 14e7482c: am d16391bb: Merge "Fix indentation in sched_getaffinity."
* commit '14e7482c556820d8ad3b77f025dfc465d55c7262':
  Fix indentation in sched_getaffinity.
2013-10-15 16:58:19 -07:00
Elliott Hughes
7672521440 Merge "Avoid confusing "read prevented write" log messages." 2013-10-15 23:53:45 +00:00
Elliott Hughes
98624c3746 Make pthread_create report sched_setscheduler failures on LP64.
We couldn't fix this for 32-bit because there's too much broken
code out there. (Pretty much everyone asks for real-time
scheduling for all their threads, and the kernel says "don't be
stupid".)

Change-Id: I43c5271e6b6bb91278b9a19eec08cbf05391e3c4
2013-10-15 16:51:17 -07:00
Elliott Hughes
0cfc95e010 Fix indentation in sched_getaffinity.
Change-Id: I966852149a0255ca132cd7a15f135a875ce400d0
2013-10-15 16:49:49 -07:00
Elliott Hughes
d1eda33f01 Avoid confusing "read prevented write" log messages.
Moving to a "function: message" style avoids ambiguity.

Change-Id: If9d590e50265c61725d3673bd03796e65edd2d5e
2013-10-15 16:49:28 -07:00
Elliott Hughes
4681f8244e am 5b3f1d8b: am 22b83da4: Merge "Clean up the sigprocmask/pthread_sigmask implementation."
* commit '5b3f1d8b3a6a1caf059dc376e4967a27ddd57dac':
  Clean up the sigprocmask/pthread_sigmask implementation.
2013-10-15 14:16:02 -07:00
Elliott Hughes
19e62325c2 Clean up the sigprocmask/pthread_sigmask implementation.
Let's have both use rt_sigprocmask, like in glibc. The 64-bit ABIs
can share the same code as the 32-bit ABIs.

Also, let's test the return side of these calls, not just the
setting.

Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
2013-10-15 11:23:57 -07:00
Nick Kralevich
49bb53c8e2 am 95de0df8: am eda2679e: Merge "FORTIFY_SOURCE: fortify read()"
* commit '95de0df8c2daeefca358010f2d15c3346a5284f1':
  FORTIFY_SOURCE: fortify read()
2013-10-09 21:28:52 -07:00
Elliott Hughes
2d38f0c1c7 am 21d70d5f: am 39385aa7: Merge "Clean up the cpuacct cruft."
* commit '21d70d5fd8ff2823a6879d59c7d5a8d6c3e0ce8b':
  Clean up the cpuacct cruft.
2013-10-09 21:28:51 -07:00
Nick Kralevich
eda2679e30 Merge "FORTIFY_SOURCE: fortify read()" 2013-10-10 04:11:48 +00:00
Nick Kralevich
b036b5ca36 FORTIFY_SOURCE: fortify read()
Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
2013-10-09 20:17:03 -07:00
Elliott Hughes
232163cf70 Clean up the cpuacct cruft.
Change-Id: I6ed63af8dfc2368e211420389fa8af4d5dc0908f
2013-10-09 17:35:36 -07:00
Nick Kralevich
b8771d9fd8 am b35ebe3d: am 848efa9d: Merge "Revert "FORTIFY_SOURCE: fortify read()""
* commit 'b35ebe3d7097899fd4498ebb2b93e48fd836ebcf':
  Revert "FORTIFY_SOURCE: fortify read()"
2013-10-09 16:53:05 -07:00
Nick Kralevich
8d25327639 Revert "FORTIFY_SOURCE: fortify read()"
This change reverts
* fb3f956d07.
* 65c99de2cb

Change-Id: Id5774eeede41130579115cf67a72ee914f2b47d5
2013-10-09 16:46:25 -07:00
Elliott Hughes
6b6c5791a0 am aa3c17e8: am 37953ee3: Merge "Fix build."
* commit 'aa3c17e8f8b9b3b5b8dc3c7c0fbe85b774f83722':
  Fix build.
2013-10-09 16:39:06 -07:00
Elliott Hughes
1cdc9fe6d5 am 8826ba8a: am bc545e8a: Merge "Fix x86_64 build, clean up intermediate libraries."
* commit '8826ba8ab6922927bdac2466d2903916d5806a06':
  Fix x86_64 build, clean up intermediate libraries.
2013-10-09 16:35:46 -07:00
Nick Kralevich
45e3076cdc am 731ced6b: am c147478c: Merge "FORTIFY_SOURCE: fortify read()"
* commit '731ced6b289629a552b5841561fdcccf08d8c43a':
  FORTIFY_SOURCE: fortify read()
2013-10-09 16:32:25 -07:00
Elliott Hughes
fb3f956d07 Fix build.
'private' is no longer on the default include path inside bionic.

Change-Id: I9bfab213a496fac585787118603af3aa2a1f9951
2013-10-09 16:29:42 -07:00
Elliott Hughes
bc545e8a98 Merge "Fix x86_64 build, clean up intermediate libraries." 2013-10-09 23:29:00 +00:00
Nick Kralevich
c147478cb7 Merge "FORTIFY_SOURCE: fortify read()" 2013-10-09 23:23:27 +00:00
Elliott Hughes
eb847bc866 Fix x86_64 build, clean up intermediate libraries.
The x86_64 build was failing because clone.S had a call to __thread_entry which
was being added to a different intermediate .a on the way to making libc.so,
and the linker couldn't guarantee statically that such a relocation would be
possible.

  ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC

This patch addresses that by ensuring that the caller and callee end up in the
same intermediate .a. While I'm here, I've tried to clean up some of the mess
that led to this situation too. In particular, this removes libc/private/ from
the default include path (except for the DNS code), and splits out the DNS
code into its own library (since it's a weird special case of upstream NetBSD
code that's diverged so heavily it's unlikely ever to get back in sync).

There's more cleanup of the DNS situation possible, but this is definitely a
step in the right direction, and it's more than enough to get x86_64 building
cleanly.

Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
2013-10-09 16:00:17 -07:00
Elliott Hughes
ac045c32d0 am f83148af: am 0c17099a: Merge "Fix __errno for LP64 and clean up __get_tls."
* commit 'f83148af74704c574ad1bf60082f2f56bcb29706':
  Fix __errno for LP64 and clean up __get_tls.
2013-10-09 13:52:56 -07:00
Nick Kralevich
65c99de2cb FORTIFY_SOURCE: fortify read()
Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
2013-10-09 13:44:38 -07:00
Elliott Hughes
2a0b873065 Fix __errno for LP64 and clean up __get_tls.
If __get_tls has the right type, a lot of confusing casting can disappear.

It was probably a mistake that __get_tls was exposed as a function for mips
and x86 (but not arm), so let's (a) ensure that the __get_tls function
always matches the macro, (b) that we have the function for arm too, and
(c) that we don't have the function for any 64-bit architecture.

Change-Id: Ie9cb989b66e2006524ad7733eb6e1a65055463be
2013-10-09 13:39:13 -07:00
Elliott Hughes
e17457fbf5 am 3c13dade: am 14b66bff: Merge "Fix malloc debugging for LP64."
* commit '3c13daded375cad5fc77613872a85639cd09f54f':
  Fix malloc debugging for LP64.
2013-10-08 17:28:25 -07:00
Elliott Hughes
8cc98f0b1e am 54c7ef7f: am 7027841d: Merge "Fix bionic\'s built-in stack trace dumping for LP64."
* commit '54c7ef7fbd1f79ae490eb737f558fccf3c1dbd55':
  Fix bionic's built-in stack trace dumping for LP64.
2013-10-08 17:28:24 -07:00
Elliott Hughes
14b66bffb0 Merge "Fix malloc debugging for LP64." 2013-10-09 00:20:08 +00:00
Elliott Hughes
c7c5f85ead Fix bionic's built-in stack trace dumping for LP64.
Change-Id: I967c5789d7bb2d3d248d94d81a40d5ec4e1bf26d
2013-10-08 17:02:26 -07:00
Elliott Hughes
ef0696d46a Fix malloc debugging for LP64.
Change-Id: Idd0b239f5c66d45de315d556271a5d13b8eb907c
2013-10-08 16:18:55 -07:00
Elliott Hughes
42b618cffe am 58b8f225: am 5cf1f229: Merge "pthread_exit should call __NR_exit with status 0."
* commit '58b8f2256637c5b1e24b568b699fb3aa6cf0ca96':
  pthread_exit should call __NR_exit with status 0.
2013-10-08 15:06:49 -07:00
Elliott Hughes
5cf1f22962 Merge "pthread_exit should call __NR_exit with status 0." 2013-10-08 22:02:20 +00:00
Elliott Hughes
c4c6e192ac pthread_exit should call __NR_exit with status 0.
We shouldn't have been passing the bottom 32 bits of the address used
for pthread_join to the kernel.

Change-Id: I487e5002d60c27adba51173719213abbee0f183f
2013-10-08 14:48:05 -07:00
Elliott Hughes
6260fa5025 am ee9da565: am 58522099: Merge "Make logging fall back to /dev/stderr if we\'re on the host."
* commit 'ee9da5653361f0171e417a4bcb1958a2b91f886d':
  Make logging fall back to /dev/stderr if we're on the host.
2013-10-08 13:47:48 -07:00
Elliott Hughes
0f395b7ba0 Make logging fall back to /dev/stderr if we're on the host.
Otherwise you get no logging, which sucks.

Change-Id: Iea1e8f996461afbb217a55711b7967005c39cfcb
2013-10-08 13:19:00 -07:00
Elliott Hughes
3fc57ce6fd am d8d60a92: am 04cdfa67: Merge "Clean up the x86 and x86_64 _exit_with_stack_teardown implementations."
* commit 'd8d60a92e7029ff8eeae5cbe62db94972e6cc06d':
  Clean up the x86 and x86_64 _exit_with_stack_teardown implementations.
2013-10-07 10:53:08 -07:00
Elliott Hughes
a97cc5b458 Clean up the x86 and x86_64 _exit_with_stack_teardown implementations.
Change-Id: I4bcbbc53893612bd94643ef07722becb00f91792
2013-10-07 10:25:11 -07:00
Nick Kralevich
7909bd19ab am 9da8b682: am c417d0a5: Merge "Make error messages even better!"
* commit '9da8b6829cb8febb70af46761b7f2ca19e6498ce':
  Make error messages even better!
2013-10-04 12:02:57 -07:00
Nick Kralevich
6861c6f85e Make error messages even better!
Change-Id: I72bd1eb1d526dc59833e5bc3c636171f7f9545af
2013-10-04 11:43:30 -07:00
Nick Kralevich
e0a14e7573 am ed1f8ea0: am bf452313: Merge "FORTIFY_SOURCE: emphasize prevention in error messages."
* commit 'ed1f8ea0369195aa0c3aa9926a94efa26fd14639':
  FORTIFY_SOURCE: emphasize prevention in error messages.
2013-10-04 09:58:25 -07:00
Elliott Hughes
9d3b4b48d8 am 71e0b240: am 41ba05e2: Merge "x86_64: Fix get_tls and statvfs"
* commit '71e0b240ed980e77f736be2a27d255d64747b388':
  x86_64: Fix get_tls and statvfs
2013-10-04 09:58:23 -07:00
Nick Kralevich
e2617290fc FORTIFY_SOURCE: emphasize prevention in error messages.
FORTIFY_SOURCE prevents buffer overflows from occurring.
However, the error message often implies that we only
detect it, not prevent it.

Bring more clarity to the error messages by emphasizing
prevention over detection.

Change-Id: I5f3e1478673bdfc589e6cc4199fce8e52e197a24
2013-10-04 08:57:17 -07:00
Pavel Chupin
1e52a54a47 x86_64: Fix get_tls and statvfs
* bionic_tls.h - Add x86_64 version of get_tls macro;
* statvfs.h - 64-bit kernels don't have __statfs64/__fstatfs64, applying
workaround;

Change-Id: I20d7ddad74c7b7243866373d0142da6627c08280
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-03 17:31:50 -07:00
Nick Kralevich
2837f83068 am 687c7e3e: am e8dc673c: Merge "Don\'t export unnecessary symbol."
* commit '687c7e3ece0f485c79654ca0c4da15b86b1f8a7f':
  Don't export unnecessary symbol.
2013-10-03 15:57:09 -07:00
Nick Kralevich
6f10368926 am 2e819c58: am 2ff3c746: Merge "Check memory size on FD_* functions"
* commit '2e819c58c9396eec3e4311ef2c9bdcadd107f001':
  Check memory size on FD_* functions
2013-10-03 15:57:09 -07:00
Nick Kralevich
e8dc673ca5 Merge "Don't export unnecessary symbol." 2013-10-03 22:52:02 +00:00
Nick Kralevich
7943df62f7 Check memory size on FD_* functions
Make sure the buffer we're dealing with has enough room.
Might as well check for memory issues while we're here,
even though I don't imagine they'll happen in practice.

Change-Id: I0ae1f0f06aca9ceb91e58c70183bb14e275b92b5
2013-10-03 15:45:10 -07:00
Nick Kralevich
35c1862cdf Don't export unnecessary symbol.
Change-Id: I8b1d75a08476c41dd8e3f09fc93a3df617928f88
2013-10-03 14:59:05 -07:00
Nick Kralevich
5634373320 am 8598cd68: am f741e1c2: Merge "FORTIFY_SOURCE: Add __FD_* checks"
* commit '8598cd6888366008033286113bd633b44c70b7dd':
  FORTIFY_SOURCE: Add __FD_* checks
2013-10-02 16:30:51 -07:00
Nick Kralevich
90201d5eca FORTIFY_SOURCE: Add __FD_* checks
Add FORTIFY_SOURCE checks for the following macros:

* FD_CLR
* FD_ISSET
* FD_SET

Bug: 11047121
Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
2013-10-02 16:11:30 -07:00
Stephen Hines
9218adc390 am 62f95981: am 70e1730c: Merge "Remove _FORTIFY_SOURCE in implementation files."
* commit '62f95981df783575efd44cb4206be7b2cbdfcf1c':
  Remove _FORTIFY_SOURCE in implementation files.
2013-10-02 09:33:27 -07:00
Stephen Hines
95fa896206 am dcffa999: am e0e6409c: Merge "Add simple implementation _Unwind_GetIP() for clang compiles."
* commit 'dcffa9998e95dc0fb89d0c9e0ae51a0557d5b2b4':
  Add simple implementation _Unwind_GetIP() for clang compiles.
2013-10-02 09:33:27 -07:00
Stephen Hines
70e1730c38 Merge "Remove _FORTIFY_SOURCE in implementation files." 2013-10-02 16:30:15 +00:00
Stephen Hines
e0e6409c12 Merge "Add simple implementation _Unwind_GetIP() for clang compiles." 2013-10-02 16:29:22 +00:00
Stephen Hines
5f6cfce4f6 Add simple implementation _Unwind_GetIP() for clang compiles.
Clang (prior to 3.4) does not actually provide a declaration (or definition)
of _Unwind_GetIP() for ARM. We can work around this by writing our own
basic implementation using the available primitive operations.

Change-Id: If6c66846952d8545849ad32d2b55daa4599cfe2c
2013-10-01 18:20:51 -07:00
Elliott Hughes
a1de7e5033 am f1c534ce: am 6892a29b: Merge "Remove more assumptions that pointers are 32-bit."
* commit 'f1c534ce222de66bdeac06f2dca62fbd84f629f9':
  Remove more assumptions that pointers are 32-bit.
2013-10-01 17:34:34 -07:00
Elliott Hughes
405f8553cf Remove more assumptions that pointers are 32-bit.
Change-Id: I2157e2fc4db7692b746c697982c3d028a056462a
2013-10-01 17:25:28 -07:00
Stephen Hines
35d937e4eb Remove _FORTIFY_SOURCE in implementation files.
This was causing conflicting declarations for the library definitions of
common functions like sprintf(), snprintf(), and strchr().

Change-Id: I5daaa8a58183aa0d4d0fae8a7cb799671810f576
2013-10-01 15:02:07 -07:00
Elliott Hughes
a08be021cc am 57e55fe3: am fd152c31: Merge "Clean up some comments."
* commit '57e55fe3b32465023071a19e368d91f4804ade3b':
  Clean up some comments.
2013-10-01 11:14:27 -07:00
Elliott Hughes
c0af695426 Clean up some comments.
Copyright headers shouldn't contain the filename (and especially
shouldn't contain a different file's filename).

Change-Id: I82690a3bf371265402bc16f5d2fbb9299c3a1926
2013-10-01 11:10:21 -07:00
Elliott Hughes
d4e6961041 am 1a46de67: am f281fd02: Merge "Better statfs/fstatfs glibc compatibility."
* commit '1a46de67b3f78ce44ddf622bcf5918fe758dd4d4':
  Better statfs/fstatfs glibc compatibility.
2013-10-01 10:04:30 -07:00
Elliott Hughes
58413fe735 am 4b5a0e1a: am 693bd73f: Merge "Remove 32-bit assumptions from the ELF code."
* commit '4b5a0e1ad76d76d6a8793f61e3c0902ea4628ce7':
  Remove 32-bit assumptions from the ELF code.
2013-10-01 10:04:29 -07:00
Elliott Hughes
f281fd02e9 Merge "Better statfs/fstatfs glibc compatibility." 2013-10-01 15:30:40 +00:00
Elliott Hughes
693bd73fcd Merge "Remove 32-bit assumptions from the ELF code." 2013-10-01 15:23:44 +00:00
Elliott Hughes
01a700e5d2 Better statfs/fstatfs glibc compatibility.
Change-Id: I069d169c96cd71b75a045ec911fb4bd484c6b2c9
2013-09-30 21:57:07 -07:00
Elliott Hughes
6c8dc46406 am 28317d3a: am f5ea738b: Merge "Fix x86 build."
* commit '28317d3a161c88f88e85d97d584d656ffbe63a19':
  Fix x86 build.
2013-09-30 20:53:55 -07:00
Elliott Hughes
3456a1f5f4 Fix x86 build.
Change-Id: I1f2d8189bec3d0e25d21ca7d7bd73fd02f8678e2
2013-09-30 19:20:02 -07:00
Elliott Hughes
c620059479 Remove 32-bit assumptions from the ELF code.
Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
2013-09-30 18:43:46 -07:00
Nick Kralevich
9a622f874c am cc362291: am 8427b745: Merge "libc: fortify recvfrom()"
* commit 'cc362291362f8183431eccb19267c8a625f36006':
  libc: fortify recvfrom()
2013-09-27 09:11:00 -07:00
Nick Kralevich
60f4f9a5b9 libc: fortify recvfrom()
Fortify calls to recv() and recvfrom().

We use __bos0 to match glibc's behavior, and because I haven't
tested using __bos.

Change-Id: Iad6ae96551a89af17a9c347b80cdefcf2020c505
2013-09-24 16:45:01 -07:00
Elliott Hughes
e74f77f92d am 48a909c9: am aad3c52e: Merge "Ensure we have the off64_t variant of every function that takes an off_t."
* commit '48a909c9fd6dbe9be5655ad172d1083fa69c4107':
  Ensure we have the off64_t variant of every function that takes an off_t.
2013-09-19 17:43:01 -07:00
Elliott Hughes
b4f7616fd6 Ensure we have the off64_t variant of every function that takes an off_t.
Change-Id: Ib2eee0cf13162be3b62559b84e90c6dcf5aab1c3
2013-09-19 16:27:24 -07:00
Elliott Hughes
a5a508a9b6 am 35cfcc11: am f8e71bac: Merge "Add mmap64()"
* commit '35cfcc11fa923c75ead9356c71466ecabfafcc42':
  Add mmap64()
2013-09-19 14:27:34 -07:00
Daniel Leung
afcc0cccda Add mmap64()
This adds mmap64() to bionic so that it is possible to have
large offset passed to kernel. However, the syscall mechanism
only passes 32-bit number to kernel. So effectively, the
largest offset that can be passed is about 43 bits (since
offset is signed, and the number passed to kernel is number
of pages (page size == 4K => 12 bits)).

Change-Id: Ib54f4e9b54acb6ef8b0324f3b89c9bc810b07281
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2013-09-19 14:11:26 -07:00
Elliott Hughes
44fd0d92d6 am 94c325fb: am 269851bf: Merge "Declare __page_shift and __page_size with C linkage."
* commit '94c325fb3bd8844dcc58640afb8f33668b684bc1':
  Declare __page_shift and __page_size with C linkage.
2013-09-19 12:06:43 -07:00
Bernhard Rosenkraenzer
9ae59c02ca Declare __page_shift and __page_size with C linkage.
__page_shift and __page_size were accidentally declared in unistd.h with
C linkage - their implementation needs to use the same linkage.

Going forward, though, let's stop the inlining madness and let's kill
the non-standard __getpageshift(). This patch takes getpagesize(3) out
of line and removes __getpageshift but fixes __page_shift and __page_size
for backwards binary compatibility.

Change-Id: I35ed66a08989ced1db422eb03e4d154a5d6b5bda
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2013-09-19 11:55:36 -07:00
Elliott Hughes
a3285dc914 am 8ff879a5: am a259472c: Merge "Fix mismatch between declaration and forward declaration"
* commit '8ff879a528b8876db811f5abd4dbf0640e3a0408':
  Fix mismatch between declaration and forward declaration
2013-09-19 11:46:46 -07:00
Bernhard Rosenkraenzer
edad1e1558 Fix mismatch between declaration and forward declaration
KernelArgumentBlock is defined as a class in KernelArgumentBlock.h, but
forward declarations refer to it as a struct.

While this is essentially the same, the mismatch causes a compiler
warning in clang (and may cause warnings in future versions of gcc) in
code that is supposed to be compiled with -Werror.

Change-Id: I4ba49d364c44d0a42c276aff3a8098300dbdcdf0
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2013-09-18 23:40:19 +02:00
Brian Carlstrom
4105fcdb3c am 059f5c3f: am 8512992f: Merge "Simplify main thread stack size initialization"
* commit '059f5c3f6ce2a1783b5d96b4059df1b9104101d5':
  Simplify main thread stack size initialization
2013-09-13 17:05:20 -07:00
Brian Carlstrom
50af69e8f3 Simplify main thread stack size initialization
Change-Id: Iec09433d9de501031cce09dc75848a5e8f3d96bf
2013-09-13 16:44:47 -07:00
Brian Carlstrom
322e7bce23 Use kernel default for initial thread size
Bug: 10697851

Change-Id: I8d980f5e0b584799536f6e6b891056c968d26cdf
2013-09-13 16:25:25 -07:00
Brian Carlstrom
0890436da9 am 9a74e36f: Use kernel default for initial thread size
* commit '9a74e36f4810ca22cb12f8eafe4f929edfa57e58':
  Use kernel default for initial thread size
2013-09-13 13:20:19 -07:00
Brian Carlstrom
9a74e36f48 Use kernel default for initial thread size
Bug: 10697851

Change-Id: I8d980f5e0b584799536f6e6b891056c968d26cdf
2013-09-12 22:19:44 -07:00
Elliott Hughes
a015800e73 am 5d094c40: am df7436e7: Merge "Avoid segfaults if properties are not initialized"
* commit '5d094c408841370e4a6f2846ae3408d2e6d12f94':
  Avoid segfaults if properties are not initialized
2013-09-03 14:12:31 -07:00
Pavel Chupin
a21e696d90 Avoid segfaults if properties are not initialized
Null or constant dereferencing occurs if properties are not initialized.
On Android devices it shouldn't happen but can be faced if testing bionic
libc.so on Linux host.

Change-Id: I8f047cbe17d0e7bcde40ace000a8aa53789c16cb
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-09-03 13:27:09 +04:00
Nick Kralevich
2c87c3ff02 am cfd0d72d: am eb8f3622: Merge "FORTIFY_SOURCE: introduce __strncpy_chk2"
* commit 'cfd0d72da8641087f9c4015ee586614da9f7320a':
  FORTIFY_SOURCE: introduce __strncpy_chk2
2013-08-28 13:07:57 -07:00
Nick Kralevich
93501d3ab8 FORTIFY_SOURCE: introduce __strncpy_chk2
This change detects programs reading beyond the end of "src" when
calling strncpy.

Change-Id: Ie1b42de923385d62552b22c27b2d4713ab77ee03
2013-08-28 12:39:06 -07:00
Jeff Hao
e9e10c13ff Fix pthread_getcpuclockid.
clock_gettime was returning EINVAL for the values
produced by pthread_getcpuclockid.

Bug: 10346183

(cherry picked from commit 9b06cc3c1b)

Change-Id: Ib81a7024c218a4502f256c3002b9030e2aaa278d
2013-08-26 14:04:16 -07:00
Elliott Hughes
e714eb157e am 6b6aaec8: am 4eacb341: Merge "Fix pthread_getcpuclockid."
* commit '6b6aaec892b1f256787fbbf106449f7d7e5888a2':
  Fix pthread_getcpuclockid.
2013-08-16 12:25:58 -07:00
Jeff Hao
9b06cc3c1b Fix pthread_getcpuclockid.
clock_gettime was returning EINVAL for the values
produced by pthread_getcpuclockid.

Bug: 10346183
Change-Id: Iabe643d7d46110bb311a0367aa0fc737f653208e
2013-08-15 15:34:22 -07:00
Christopher Ferris
59a13c122e Optimize __memset_chk, __memcpy_chk. DO NOT MERGE.
This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
  three calls to __memset_chk. First call dest_len is length + 1. Second
  call dest_len is length. Third call dest_len is length - 1.
  Verified that the first two calls pass, and the third fails. Examined
  the logcat output on all nexus devices to verify that the fortify
  error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
  __memcpy_chk and large copies, the savings is relatively small (about 1%).
  For small copies, the savings is large on cortex-a15/krait devices
  (between 5% to 30%).
  For cortex-a9 and small copies, the speed up is present, but relatively
  small (about 3% to 5%).
  For __memset_chk and large copies, the savings is also small (about 1%).
  However, all processors show larger speed-ups on small copies (about 30% to
  100%).

Bug: 9293744

Merge from internal master.

(cherry-picked from 7c860db074)

Change-Id: I916ad305e4001269460ca6ebd38aaa0be8ac7f52
2013-08-14 18:14:43 -07:00
Elliott Hughes
840a114eb1 Add futimens.
(cherry picked from commit d0be7c8f9a)

Bug: 10239370
Change-Id: I0087e85a94d83b6ce68ec6a0768c44cbe4bd0132
2013-08-08 17:52:06 -07:00
Elliott Hughes
d0be7c8f9a Add futimens.
Bug: 10239370
Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
2013-08-08 17:13:33 -07:00
Colin Cross
7f4074d17d bionic: name malloc'd regions
Use the new __bionic_name_mem function to name malloc'd memory as
"libc_malloc" on kernels that support it.

Change-Id: I7235eae6918fa107010039b9ab8b7cb362212272
2013-08-08 00:42:39 +00:00
Colin Cross
6771b9cef6 bionic: add function to name memory
Only works on some kernels, and only on page-aligned regions of
anonymous memory.  It will show up in /proc/pid/maps as
[anon:<name>] and in /proc/pid/smaps as Name: <name>

Change-Id: If31667cf45ff41cc2a79a140ff68707526def80e
2013-08-07 15:41:30 -07:00
Christopher Ferris
7c860db074 Optimize __memset_chk, __memcpy_chk.
This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
  three calls to __memset_chk. First call dest_len is length + 1. Second
  call dest_len is length. Third call dest_len is length - 1.
  Verified that the first two calls pass, and the third fails. Examined
  the logcat output on all nexus devices to verify that the fortify
  error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
  __memcpy_chk and large copies, the savings is relatively small (about 1%).
  For small copies, the savings is large on cortex-a15/krait devices
  (between 5% to 30%).
  For cortex-a9 and small copies, the speed up is present, but relatively
  small (about 3% to 5%).
  For __memset_chk and large copies, the savings is also small (about 1%).
  However, all processors show larger speed-ups on small copies (about 30% to
  100%).

Bug: 9293744

Change-Id: I8926d59fe2673e36e8a27629e02a7b7059ebbc98
2013-08-06 15:38:29 -07:00
Elliott Hughes
c03e1e7439 Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way.
Also make sysconf use PTHREAD_STACK_MIN rather than redefining its
own, different, constant.

Bug: 9997352
Change-Id: I9a8e7d2b18e691439abfb45533e82c36eee9e81d
2013-07-29 17:09:36 -07:00
Elliott Hughes
e320a8c780 Avoid sign extension of the mmap offset.
off_t is signed to support seeking backwards, but that's a liability
when using off_t to represent a subset of a file.

Change-Id: I2a3615166eb16212347eb47f1242e3bfb93c2022
2013-07-25 10:15:07 -07:00
Rom Lemarchand
d0f2a6014c Restore dlmalloc mmap threshold to 64k
Restoring DEFAULT_MMAP_THRESHOLD to 64k, the way it was before
999089181e.

This forces allocations in the 64k-256k range to be mmaped.

Change-Id: Iace55ed638edd272b3e94fa6cd2ddd349042be84
Signed-off-by: Rom Lemarchand <romlem@google.com>
2013-07-23 13:48:39 -07:00
Elliott Hughes
4cf1395217 Move stuff only needed by pthread-timers.c into pthread-timers.c.
Change-Id: I4915b3fff9c4f5a36b4f51027fb22019c11607b0
2013-07-19 16:42:27 -07:00
Elliott Hughes
84114c8dd5 Improve stack overflow diagnostics (take 2).
This reverts commits eb1b07469f and
d14dc3b87f, 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
2013-07-17 13:33:19 -07:00
Elliott Hughes
107cdd406b Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno.
Bug: 9889616
Change-Id: I4a7323e0ae5aeb5cbe0da1b2bc7501d83b3a2aa4
2013-07-17 13:12:26 -07:00
Rom Lemarchand
e459bba398 mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps
Reinstate mmap calling madvise(MADV_MERGEABLE) removed in
635df850e5

(cherry-pick of c702a904679a36511bead29c51eeac15d81f4fd2.)

Change-Id: I18803fb54701b2b3d8186dff5c678211ee3efa1f
2013-07-17 13:00:45 -07:00
Guang Zhu
d14dc3b87f Revert "Improve stack overflow diagnostics."
This reverts commit aa754dca90.

Change-Id: Ifa76eee31f7f44075eb3a48554315b2693062f44
2013-07-17 03:17:05 +00:00
Elliott Hughes
aa754dca90 Improve stack overflow diagnostics.
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
2013-07-16 13:14:24 -07:00
Elliott Hughes
d4e753fea9 Clean up __builtin_expect usage.
Also remove some dead code; our malloc debugging doesn't use this
any more.

Change-Id: Id69cf182371f5f37d40b5bbd08f2744ade286e66
2013-07-16 12:45:46 -07:00
Elliott Hughes
b95cf0d23a Fix pthread_getattr_np, pthread_attr_setguardsize, and 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
2013-07-15 14:51:07 -07:00
Elliott Hughes
6184c1feaa Fix MIPS build.
Change-Id: I583b1794dbc12fcded8c4f57f367593a742ab33f
2013-07-09 14:18:36 -07:00
Elliott Hughes
06040fd75c Add <sys/statvfs.h>.
Bug: 2512019
Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
2013-07-09 13:25:03 -07:00
Colin Cross
5e9a086145 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 ad76c85b9c)

Change-Id: Ib496e818a62a5834d40c71eb4745783d998be893
2013-06-25 16:52:40 -07:00
Colin Cross
1ec20a086c 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 285b42a04c)

Change-Id: I074204e9e6591b35faf7c1c58fb11ec162aff7bf
2013-06-25 16:52:34 -07:00
Sergey Melnikov
c45087bffa 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
2013-06-25 13:12:39 -07:00
Greg Hackmann
836dbf65e4 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 492ce95d9f)

Change-Id: Ib074192d1b71150233d78c58e9ffcf7ecf688b6b
2013-06-24 16:35:46 -07:00
Colin Cross
1d36ee1a6e 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 fb9b7b436f)

Change-Id: I6df3afedbfb5d07891b095aa24b78278381a5aaf
2013-06-24 16:35:41 -07:00
Greg Hackmann
1540f601be 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 5f05348c18)

Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f
2013-06-24 16:35:37 -07:00
Greg Hackmann
996cdc4b1a 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 6ac8e6a46d)

Change-Id: Icbe31908572f33b4d9b85d5b62ac837cbd0f85e0
2013-06-24 16:35:32 -07:00
Greg Hackmann
f7511e3bc9 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 5bfa3ee8b3)

Change-Id: Id3fa45261fc2df2ae493ab5194bc2b6bff04e966
2013-06-24 16:35:27 -07:00
Greg Hackmann
cb215a7e9e 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 d32969701b)

Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
2013-06-24 16:35:15 -07:00
Nick Kralevich
17fc25d20f 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
2013-06-21 13:28:42 -07:00
Greg Hackmann
c6ff844d75 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 577418403d)

Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f
2013-06-18 19:24:29 -07:00
Colin Cross
5cf32de7a0 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 dc1038b790)

Change-Id: I192d3825ee276c5047bc751039fe6cfe226a7cca
2013-06-17 16:58:43 -07:00
msg555
0f020d18b1 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
2013-06-12 17:30:58 -07:00
Elliott Hughes
61e699a133 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
2013-06-12 14:14:53 -07:00
Elliott Hughes
2fbc9dda34 Merge "bionic/x86: Optimization for string routines" 2013-06-08 00:45:07 +00:00