Commit graph

3646 commits

Author SHA1 Message Date
Dmitriy Ivanov
adab51aefd Added script generating additions to libgcc_compat.c from linker errors
bug: 12234455
Change-Id: Icac35237f06e75745da5a91d9c4c941d7df4f84d
2014-02-20 11:34:08 -08:00
Elliott Hughes
1fbe6213cd Don't explicitly list the tzcode files.
Change-Id: I3ac19899523ac1f5fd2fdd6c942aefce75a964a4
2014-02-20 11:28:20 -08:00
Elliott Hughes
d465eb4e76 Remove the useless _C_LABEL from generated system calls.
Change-Id: Id1d2fd39972652831ea825f6f9cf940b08f42b5c
2014-02-19 18:59:19 -08:00
Elliott Hughes
9abbbdc534 Make mips/mips64 syscall stubs more like the other architectures.
Change-Id: I55f8c1a95f643a6e484f12fbcc25e2c77e55b6b8
2014-02-19 14:54:31 -08:00
Elliott Hughes
eae27dc55a Make mips generated assembler more like the mips64 stuff.
I broke the mips build yesterday because it doesn't use
<private/bionic_asm.h> like the other architectures, including mips64.
I want to move mips closer to mips64 to try to avoid this kind of thing
in future.

Change-Id: Idb985587ff355b9e5e765c1f5671dc0144cd2488
2014-02-19 12:20:00 -08:00
Elliott Hughes
44ef37c1b4 Merge "Use uid_t and gid_t for st_uid and st_gid in struct stat." 2014-02-19 00:51:31 +00:00
Elliott Hughes
6b5559315d Use uid_t and gid_t for st_uid and st_gid in struct stat.
Change-Id: Ide62dc714d76d881e3aa79e7a59ee6533a23dd00
2014-02-18 16:43:31 -08:00
Elliott Hughes
986f906710 Fix build by avoiding the _C_LABEL macro.
Change-Id: Ide367c2b65071388bd95fbc81a4ed6ae94aec4e4
2014-02-18 16:42:36 -08:00
Elliott Hughes
db1ea34748 Implement some of the missing LFS64 support.
This gives us:

* <dirent.h>
  struct dirent64
  readdir64, readdir64_r, alphasort64, scandir64

* <fcntl.h>
  creat64, openat64, open64.

* <sys/stat.h>
  struct stat64
  fstat64, fstatat64, lstat64, stat64.

* <sys/statvfs.h>
  struct statvfs64
  statvfs64, fstatvfs64.

* <sys/vfs.h>
  struct statfs64
  statfs64, fstatfs64.

This also removes some of the incorrect #define hacks we've had in the
past (for stat64, for example, which we promised to clean up way back
in bug 8472078).

Bug: 11865851
Bug: 8472078
Change-Id: Ia46443521918519f2dfa64d4621027dfd13ac566
2014-02-18 15:39:24 -08:00
Elliott Hughes
ffe026680e Merge "bionic: fix __set_errno for arm64 syscalls that return a 64-bit value" 2014-02-18 20:31:01 +00:00
Colin Cross
3d19a8319b bionic: fix __set_errno for arm64 syscalls that return a 64-bit value
bionic/libc/arch-arm64/syscalls/read.S ends with:
    b.hi __set_errno
    ret
END(read)

If __set_errno returns int, it will set w0 to 0xFFFFFFFF, which means
x0 is 0x00000000FFFFFFFF.  When interpreted as a ssize_t that is
INT_MAX, not -1.

Change __set_errno to return long, which will cause x0 to be set instead
of w0.

Change-Id: I9f9ea0f2995928d2ea240eb2ff7758ecdf0ff412
2014-02-18 12:11:38 -08:00
Elliott Hughes
a38cb08861 Clean up various warnings in bionic.
Change-Id: Ic57541d0a567fd4ae79f0ad59b2ffde1130eb7d2
2014-02-18 12:04:54 -08:00
Elliott Hughes
cfbfe7059c Remove duplicate definitions of MIN and MAX.
These were needed when bionic's header files were missing these macros (though
it would have made a lot more sense to just fix the header files!) but cause
warnings now.

Change-Id: I65a677122f4f6bd07dffc3f37a0c4c0e823d1bb0
2014-02-17 10:57:56 -08:00
Elliott Hughes
671e236d5f Restore sys_signame for LP64.
mksh is using this, and we probably build as much BSD source as glibc source.

Change-Id: I400d255a67f9614ca9e57090e3a2e49d2b10cba4
2014-02-12 19:04:27 -08:00
Elliott Hughes
aa0ebdafc7 Clean up sys_signame and sys_siglist a little.
We don't need quite so much duplication because we already have a way
to get the signal number from its name, and that already copes with the
fact that the mips/mips64 numbers are different from everyone else's.

Also remove sys_signame from LP64. glibc doesn't have this BSD-ism.

Change-Id: I6dc411a3d73589383c85d3b07d9d648311492a10
2014-02-12 17:09:25 -08:00
Ying Wang
76c8b88269 Fix missing args.
Change-Id: I89a366db984ea6b2553896a4351e59bb91f93040
2014-02-12 16:40:55 -08:00
Ying Wang
c4c50b25f8 Merge "Reconfig libc's Android.mk to build for multilib" 2014-02-12 23:53:08 +00:00
Ying Wang
f25d677147 Reconfig libc's Android.mk to build for multilib
1. Moved arch-specific setup to their own files:
    - <arch>/<arch>.mk, arch-specific configs. Variables in those config
      end with the arch name.
    - removed the extra complexity introduced by function libc-add-cpu-variant-src,
      which seems to be not very useful these days.
2. Separated out the crt object files generation rules and set up the
   rules for both TARGET_ARCH and TARGET_2ND_ARCH.
3. Build all the libraries for both TARGET_ARCH and TARGET_2ND_ARCH,
  with the arch-specific LOCAL_ variables.

Bug: 11654773
Change-Id: I9c2d85db0affa49199d182236d2210060a321421
2014-02-12 13:58:34 -08:00
Elliott Hughes
199346a2ab Fix NSIG.
Our sigset_t definition hasn't been tied to our NSIG definition since we
switched to uapi headers, so we can now fix it without breaking the LP32 ABI.
The kernel uapi headers define and use _NSIG, so we need to have our scripts
rename the kernel's definitions out of the way, then we can define _NSIG
and NSIG in terms of the kernel's off-by-one value.

Bug: 12938442
Change-Id: Ic7c86fd5be5ad1d822f7b2b1d88c8a0d70a1ac0f
2014-02-11 22:16:04 -08:00
Chris Dearman
9918665a45 [MIPS64] Dynamic linker
Change-Id: I937c7c776cae3d66e214798d5217a922cd106bfc
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Duane Sand <duane.sand@imgtec.com>
2014-02-11 15:33:14 -08:00
Elliott Hughes
b3a23bd017 Build syscall stubs in their own library.
This lets us lose the auto-generated makefiles.

Change-Id: I2de0c71b3b9c08f9cce8f4ff7fd7254dda008c86
2014-02-11 13:52:02 -08:00
Elliott Hughes
a6ecba4d23 Clean up cacheflush.
No cacheflush for LP64; use the GCC builtin instead. Clean up the
32-bit MIPS implementation now we no longer need to worry about
old versions of GCC.

Bug: 12924756
Change-Id: Ie23955b3ec194e226c4b2bce35b11d5e061f4753
2014-02-11 10:24:40 -08:00
Elliott Hughes
0266ae5f88 Switch <elf.h> over to linux uapi under the covers.
Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

All platforms need dl_iterate_phdr_static, so it doesn't make sense
to have that part of the per-architecture configuration.

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
2014-02-10 18:22:24 -08:00
Elliott Hughes
3a9c5d66dc Fix <link.h>.
Also move some of the stuff that should be in <link.h> out of the
private "linker.h", to make it clearer that these are public API
known to gdb that we can't change.

Bug: 12554197
Change-Id: I830e1260d3d8b833ed99bc1518f1c6b6102be8af
2014-02-10 13:31:13 -08:00
Elliott Hughes
ebd90b9ba9 Fix socklen_t (on LP64 only).
Too late to fix LP32 :-(

Bug: 12935461
Change-Id: Ib056ca1eaf9ae8712f88ae21ff94e91b08cf588b
2014-02-07 16:50:55 -08:00
Elliott Hughes
c16a453291 Merge "Remove <sys/_types.h>." 2014-02-08 00:23:50 +00:00
Elliott Hughes
9f87a0b285 Remove <sys/_types.h>.
Bug: 12213562
Change-Id: I0d10664f9da60739bdbad0408be0dd61eea3c1fe
2014-02-07 14:55:58 -08:00
Chris Dearman
645d0312c2 [MIPS64] libc/libm support
libc/libm support for MIPS64 targets

Change-Id: I8271941d418612a286be55495f0e95822f90004f
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Raghu Gandham <raghu.gandham@imgtec.com>
2014-02-06 16:22:20 -08:00
Chris Dearman
5043212b76 [MIPS64] Add syscall related files
Change-Id: I2f5d05df0e767538a6fe467ca0a2386325f8b71f
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Raghu Gandham <raghu.gandham@imgtec.com>
Signed-off-by: Duane Sand <duane.sand@imgtec.com>
2014-02-06 15:39:38 -08:00
Elliott Hughes
ea0fab18ba Remove unused cruft from MIPS <machine/signal.h>.
An extra (unused) struct sigcontext doesn't help anybody.

Change-Id: I73899fe7e1ccccf50a507c737945cf014d430396
2014-02-05 14:11:38 -08:00
Elliott Hughes
9afe2884c7 Kill <machine/_types.h>.
Most of <machine/_types.h> was either unused, wrong, or identical across
all 32-/64-bit architectures.

I'm not a huge fan of <sys/_types.h> either, but moving the bits we need
up into there is a step forward.

Bug: 12213562
Change-Id: Id13551c78966e324beee2dd90c5575e37d2a71e6
2014-02-04 19:26:31 -08:00
Elliott Hughes
f64b8ea09d Add fallocate/fallocate64/posix_fallocate/posix_fallocate64.
Bug: 5287571
Bug: 12612860
Change-Id: I4501b9c6cdf9a830336ce0b3afc4ea716b6a0f6f
2014-02-03 16:20:46 -08:00
Elliott Hughes
8d60cc6316 Use __inline__ for fortify.
libunwind has #define inline /* empty */ which breaks our fortified headers.
glibc uses __inline but our BSD-derived headers often override that. __inline__
is the third alternative understood by GCC that -- as far as I know -- neither
the C library itself nor third-party code tries to mess with.

Bug: 12871594
Change-Id: I6677e70ea531bb7d4c46021b43af760d4ad8ecf7
2014-02-03 15:41:57 -08:00
Arve Hjønnevåg
fb4da1e7b7 Merge "Regenerate binder header" 2014-02-03 21:13:23 +00:00
Elliott Hughes
47ff6b9faa Merge "Add missing ucontext_t definition to bionic for arch-arm64." 2014-01-31 18:51:36 +00:00
Ross McIlroy
7b95807fa0 Add missing ucontext_t definition to bionic for arch-arm64.
Change-Id: I1ee15230c63e00f01d2063cfffcffe7f1a1eeb6a
2014-01-31 04:45:53 +00:00
Chris Dearman
46f3db6bb8 [MIPS] SA_RESTORER support is not needed for MIPS
Change-Id: I1c000c94973e811193c80c9770da4f3157594f90
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Duane Sand <duane.sand@imgtec.com>
2014-01-30 20:39:53 -08:00
Elliott Hughes
3614424e10 Make ARM <user.h> more glibc-compatible.
Change-Id: I681930ad7f80a5e7bc40eb0f36872e415445f0f9
2014-01-30 10:39:02 -08:00
Elliott Hughes
02c661b883 Add mips <sys/ucontext.h>.
Change-Id: I2821f523f0c3bb4400b2ad5d36e21e5a3d6d777c
2014-01-29 18:37:15 -08:00
Elliott Hughes
4e72fcc3c2 Add arm <sys/ucontext.h>.
Change-Id: I14d435f9e3e82f77d8a7e886ff88c18f5d09d14a
2014-01-29 17:53:59 -08:00
Elliott Hughes
677a07cb9a Add x86 <sys/ucontext.h>.
Change-Id: I43e72604f7a932f134733b78094b577415a5edb7
2014-01-29 16:46:00 -08:00
Pavel Chupin
e61d106008 Add x86_64 ucontext.h for better compatibility
As suggested here: https://android-review.googlesource.com/#/c/71267/
it may be used for x86_64 libunwind enabling.

Change-Id: I21623261a48ea7099e030d33932556e294d226ff
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2014-01-29 15:35:33 -08:00
Arve Hjønnevåg
fbaa254016 Regenerate binder header
Adds 64 bit support

Change-Id: I6db3c4f68bf2c337bff753599af193e2b062ec05
2014-01-28 19:29:46 -08:00
Elliott Hughes
908e8c24ab Remove a __system_property_get call from the DNS code.
Change-Id: I48082ad9eb1b56349c6746ab2c371728c8571a81
2014-01-28 14:54:11 -08:00
Elliott Hughes
431166d995 Fix 32-bit mmap/mmap64 handling of negative offsets.
We don't actually need to worry about sign extension if we reject
negative values ourselves. Previously it was possible to come up
with negative but aligned values that we would pass to the kernel;
in the case of mmap (as opposed to mmap64) we'd incorrectly turn
those into large positive offsets.

Change-Id: I2aa583e0f892d59bb77429aea8730b72db32dcb0
2014-01-27 16:36:56 -08:00
Elliott Hughes
6f23ce36ce Merge "Remove __STDC_FORMAT_MACROS and __STDC_LIMIT_MACROS guards (and fix SIZE_MAX for LP64)." 2014-01-25 01:25:16 +00:00
Elliott Hughes
e2a292d278 Remove __STDC_FORMAT_MACROS and __STDC_LIMIT_MACROS guards (and fix SIZE_MAX for LP64).
The various committees decided that everyone should get all these macros,
all the time.

Bug: 12708004
Change-Id: Ib56010dcba9b0656e5701546fefb7f78dc0bf916
2014-01-24 16:38:07 -08:00
Ben Cheng
62ffe14a7e Add all implicitly loaded symbols from libgcc.a into libgcc_compat.c.
Change-Id: I0e66a73e849a01817d016a688d7291c2fb604e48
2014-01-24 15:20:11 -08:00
Colin Cross
513f83bb7f Merge "bionic: rename aarch64 target to arm64" 2014-01-24 20:33:23 +00:00
Bernhard Rosenkränzer
f38fb19d9d Re-export libgcc's __aeabi_uidivmod and __popcount_tab
This is required to make the Nexus 10 graphics driver work on a system
compiled with gcc 4.9.

Change-Id: If3f3d488652a736d9ea3e583548d74fae3ffa902
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
2014-01-24 12:57:13 +01:00
Colin Cross
d1973ca513 bionic: rename aarch64 target to arm64
Rename aarch64 build targets to arm64.  The gcc toolchain is still
aarch64.

Change-Id: Ia92d8a50824e5329cf00fd6f4f92eae112b7f3a3
2014-01-23 18:35:39 -08:00
Elliott Hughes
5b4884fac9 Merge "Add "__noreturn" to assert and assert2" 2014-01-15 21:26:47 +00:00
Vadim Markovtsev
323d4b6f68 Add "__noreturn" to assert and assert2
These functions should print assertion violation messages and then
call abort(). They do really not return control flow afterwards.
Consider the declaration of the similar __assert_fail from glibc:

extern void __assert_fail (const char *__assertion,
                           const char *__file,
			   unsigned int __line,
                           const char *__function)
     __THROW __attribute__ ((__noreturn__));

Bionic has __noreturn defined in sys/cdefs.h to be that GNU
noreturn attribute.

This patch has a practical value. Consider the following function:

void check(void* ptr) {
  assert(ptr != NULL);
}

Without this patch applied, gcc (and presumably clang) shows even in
debug mode:

warning: unused parameter 'ptr' [-Wunused-parameter]

In release mode, NDEBUG is defined and assert() becomes a no-op, as
one should expect. Thus, the warning is shown correctly then.

Another code sample:

float array[2];
int i = 3;
...
assert(i < 2);
array[i] = 0;

gcc says,

warning: array subscript is below array bounds [-Warray-bounds]

In other words, without noreturn attribute, assertions do not
allow a compiler's static analyzer to properly understand
the preconditions.

Change-Id: I3be92e99787c528899cf243ed448c4730c00c45b
Signed-off-by: Vadim Markovtsev <gmarkhor@gmail.com>
2014-01-15 07:32:52 +00:00
Elliott Hughes
af8aebebb5 Move _thread_created_hook to where it belongs.
Change-Id: I643d761c78ccaae25270aeffa2afb811c4e2fcd7
2014-01-14 17:16:18 -08:00
Elliott Hughes
b5e211031b Merge "AArch64: Use LDXR/STXR instead of LDAXR/STLXR for bionic_atomic_cmpxchg()" 2014-01-14 01:01:41 +00:00
Elliott Hughes
ae189740de Merge "Add some more headers." 2014-01-10 23:35:47 +00:00
Elliott Hughes
c835c35727 Add some more headers.
This patch adds trivial implementations of the missing sys headers
needed by strace. All strace needs are the constants and structures,
so this is enough for now. We can come back and add the functions
if/when we ever need them.

Change-Id: Idb87c1a8b6b1c62f6e16ae94f147e1169722b48e
2014-01-10 15:32:31 -08:00
JP Abgrall
4e9cb032d1 Add extra libc stubs for mntent related functions.
This adds stubs for setmntent() and endmntent().

Change-Id: I6ccaa044145405cd7226c1c54a25d435c96a2308
2014-01-10 01:24:34 +00:00
Elliott Hughes
33c3e8d3b2 Merge "Add NT_PRSTATUS to <elf.h>." 2014-01-09 23:53:58 +00:00
Elliott Hughes
1272dbd1d7 Add NT_PRSTATUS to <elf.h>.
Needed by aarch64.

Bug: 12476126
Change-Id: I7764664459a06cf4f2a60e707bd968d321a78430
2014-01-09 15:45:07 -08:00
Elliott Hughes
8e6bf35a16 Merge "Add <sgidefs.h>." 2014-01-09 22:24:34 +00:00
Elliott Hughes
f8b2b3c81e Fix x86 user_regs_struct.
I fixed x86-64 yesterday, but didn't fix x86 at the same time.

Change-Id: I5c081f5956dfedb9389af303369b841dd0fc1953
2014-01-09 14:01:18 -08:00
Elliott Hughes
1c2cf23a0c Add <sgidefs.h>.
Change-Id: I543d502a81dcb8d5969f814b8a9a9c819bc4fa2c
2014-01-09 13:54:49 -08:00
Elliott Hughes
a8a3178445 Add the glibc-compatible d_fileno.
d_ino is the POSIX name, but glibc also offers d_fileno, and
that's what strace is using.

Change-Id: I3fadbe7a64700b42e78c7f4631620e864d43147b
2014-01-09 12:37:12 -08:00
Elliott Hughes
0f461e35f6 Fix <sys/resource.h>.
The situation here is a bit confusing. On 64-bit, rlimit and rlimit64 are
the same, and so getrlimit/getrlimit64, setrlimit/setrlimit64,
and prlimit/prlimit64 are all the same. On 32-bit, rlimit and rlimit64 are
different. 32-bit architectures other than MIPS go one step further by having
an even more limited getrlimit system call, so arm and x86 need to use
ugetrlimit instead of getrlimit. Worse, the 32-bit architectures don't have
64-bit getrlimit- and setrlimit-equivalent system calls, and you have to use
prlimit64 instead. There's no 32-bit prlimit system call, so there's no
easy implementation of that --- what should we do if the result of prlimit64
won't fit in a struct rlimit? Since 32-bit survived without prlimit/prlimit64
for this long, I'm not going to bother implementing prlimit for 32-bit.

We need the rlimit64 functions to be able to build strace 4.8 out of the box.

Change-Id: I1903d913b23016a2fc3b9f452885ac730d71e001
2014-01-09 11:00:04 -08:00
Elliott Hughes
8276d2875f Merge "Our dirent is a dirent64." 2014-01-09 01:15:27 +00:00
Elliott Hughes
38f0ef3ff7 Our dirent is a dirent64.
Change-Id: Idc9ebfd900fddd4f7c7ac95bc9b74401ebc801a3
2014-01-08 16:31:36 -08:00
Elliott Hughes
5b17e4da39 Add <sys/reg.h>.
This describes the offsets into ptrace's returned arrays of registers
for x86 and x86-64.

Change-Id: I044f03e286673999a298b73a813d4ad366625845
2014-01-08 16:29:22 -08:00
Elliott Hughes
8a6eec38eb Merge "Fix x86_64 register names in <sys/user.h>." 2014-01-09 00:24:55 +00:00
Elliott Hughes
eddc8ece3d Fix x86_64 register names in <sys/user.h>.
Change-Id: Ieb327247a41f6195589716170e324d1cd1251b96
2014-01-08 15:54:19 -08:00
Elliott Hughes
155b076420 We shouldn't have a <sys/dirent.h> that's a subset of <dirent.h>.
glibc has no <sys/dirent.h>. If we do have to bring this back, we
should probably just have one file #include the other.

Change-Id: I5c0bf9c03769daf3b23f69778e9f01f81c3de9ec
2014-01-08 15:51:13 -08:00
Elliott Hughes
4c8caf0ad3 Merge "<sched.h> should offer both __sched_priority and sched_priority." 2014-01-08 02:41:04 +00:00
Elliott Hughes
4faf76ca11 Merge "<fcntl.h> should get you the POSIX_FADV_* constants." 2014-01-08 02:40:44 +00:00
Elliott Hughes
bc4e135a8e Merge "Add SWAP_FLAG_* constants to <sys/swap.h>." 2014-01-08 02:31:55 +00:00
Elliott Hughes
65c6f3099e Add SWAP_FLAG_* constants to <sys/swap.h>.
Bug: 9336527
Change-Id: I679be4d8425ba177dd782e714f465caf9daa976c
2014-01-08 02:23:06 +00:00
Elliott Hughes
bbb34f9536 <sched.h> should offer both __sched_priority and sched_priority.
If glibc hadn't already done things this way round, I'd have
called the field sched_priority and the macro __sched_priority
since that would seem less likely to cause trouble, but glibc
source compatibility is probably more important.

Change-Id: I8a8a477f2aa87cae641069c5c84b4fcab3152a82
2014-01-07 17:48:30 -08:00
Elliott Hughes
01e505ac9c <fcntl.h> should get you the POSIX_FADV_* constants.
Change-Id: I9de8b840570b228308c12d72b7617b8758237fb8
2014-01-07 17:47:20 -08:00
Elliott Hughes
abfc88fed7 Define fsid_t as well as __fsid_t.
Change-Id: Ib8efbd913a0e6bfe27b88c1342bd5cec926dd74e
2014-01-07 17:44:51 -08:00
Elliott Hughes
54a7494f17 Regenerate the NOTICE files.
Also standardize the orthography in a few places to reduce near-duplicates
in the NOTICE files.

Change-Id: I347c75e817be61ec1b9c5b4b96226feedc8d09ab
2014-01-07 13:46:11 -08:00
Christopher Ferris
10cd709ff9 Merge "Add cfi directives to x86 syscalls." 2014-01-07 01:36:44 +00:00
Christopher Ferris
e4bc756121 Add cfi directives to x86 syscalls.
Modify the syscalls script to generate the cfi directives for x86
syscalls.

Update the x86 syscalls.

Change-Id: Ia1993dc714a7e79f917087fff8200e9a02c52603
2014-01-06 16:39:10 -08:00
Elliott Hughes
b235f8c877 Merge "Fix dev_t (for LP64)." 2014-01-06 20:37:03 +00:00
Elliott Hughes
338e6102a6 Add TCPOPT_* constants.
Adds the TCPOPT_* constants from NetBSD. Note that the BSDs also have
TCPOPT_SIGNATURE, but Linux calls that TCPOPT_MD5SIG and glibc doesn't
have any corresponding constant yet, so let's wait until we see which name
wins out.

Change-Id: If53cdada5595285d9a7e7248ef74cd7502d804c0
2014-01-03 15:58:40 -08:00
Elliott Hughes
894f8cb139 Fix dev_t (for LP64).
32-bit Android's dev_t was wrong too. We can't fix that without ABI breakage,
but we can at least fix 64-bit Android. And add tests.

Bug: https://code.google.com/p/android/issues/detail?id=54966
Change-Id: Ie2e42cc042b78b669a1a44e55f959dbd9c52c5c9
2014-01-03 14:49:37 -08:00
Elliott Hughes
c1c3f7d446 Merge "Remove as many hard-coded constants from the MIPS vfork.S as possible." 2014-01-03 22:36:53 +00:00
Elliott Hughes
c5bf703c4c Remove as many hard-coded constants from the MIPS vfork.S as possible.
We could do better, but not without MIPS cleaning up their kernel headers.

Change-Id: Ib4d4ce5d720ce8ca27a3f9a1ae07a9a277675af9
2014-01-03 14:27:17 -08:00
Elliott Hughes
a85aaf11fa Use the MAX_ERRNO constant.
If you're going to hardcode a constant, you could at least try to
get the constant right...

Change-Id: I886a2593357d1c4dfd6c42649c63e8a35c15a441
2014-01-02 16:23:24 -08:00
Elliott Hughes
b0a2efc6f2 Remove a hardcoded constant from aarch64's vfork.
Change-Id: Ifc09ca066c32988b8cc9db9e808b9ef4c4d2bfcb
2014-01-02 14:17:30 -08:00
Elliott Hughes
887e1140fe Clean up <sched.h>.
This patch switches to using the uapi constants. It also adds the missing
setns system call, fixes sched_getcpu's error behavior, and fixes the
gensyscalls script now ARM is uapi-only too.

Change-Id: I8e16b1693d6d32cd9b8499e46b5d8b0a50bc4f1d
2014-01-02 12:05:50 -08:00
Elliott Hughes
5063791535 Fix MIPS build.
Change-Id: I175f427e355fca9a5a3f4e4379d7fcd1f7f6a22d
2013-12-22 12:02:32 -08:00
Elliott Hughes
2aace21a19 Remove the bogus exit status from _exit_with_stack_teardown.
It should always be 0, and there's no reason to pass a constant in as
an argument.

Change-Id: I92ac59b718a18e298bd7c52821af447f9181ca2a
2013-12-21 15:30:49 -08:00
Elliott Hughes
6d929061c3 Merge "Fix MIPS build." 2013-12-21 02:47:01 +00:00
Elliott Hughes
5b395ce071 Fix MIPS build.
Change-Id: Idd3bcda1803fd16b728a352d325bb070aed8fd94
2013-12-20 18:46:14 -08:00
Elliott Hughes
3fdb735590 Merge "Avoid sign extension in 32-bit mmap." 2013-12-21 02:23:35 +00:00
Elliott Hughes
99868904fe Avoid sign extension in 32-bit mmap.
Change-Id: I2a77925f62f381a0b34648c3db8154a55dd80c46
2013-12-20 18:17:34 -08:00
Elliott Hughes
68d89c7d65 Remove some old kernel header cruft not needed with uapi.
Change-Id: If543b056ae40f0eb660be4a0629ad22f4c4cb92f
2013-12-20 17:26:30 -08:00
Elliott Hughes
5eccb9646d Fix aarch64 futex assembly routines.
Also make the other architectures more similar to one another,
use NULL instead of 0 in calling code, and remove an unused #define.

Change-Id: I52b874afb6a351c802f201a0625e484df6d093bb
2013-12-20 16:58:06 -08:00
Chris Dearman
766c7efe28 Allocate additional space on stack for indirect syscall
The caller is only required to allocate 16 bytes on the
stack for a0-a3. syscall is handling up to 6 arguments so
additional space is needed on the stack to avoid corrupting the
callers frame.

Change-Id: I054b31696decc3e17d9c70af18cd278b852235d1
2013-12-20 15:36:00 -08:00
Greg Hackmann
5e26221a1d Merge "Fix backwards compatible system property structure" 2013-12-20 21:54:38 +00:00
Elliott Hughes
498295ca2b Upgrade to tzdata2013i.
From the release notes:

  Changes affecting near-future time stamps:

    Jordan switches back to standard time at 00:00 on December 20, 2013.
    The 2006-2011 transition schedule is planned to resume in 2014.
    (Thanks to Steffen Thorsen.)

  Changes affecting past time stamps:

    In 2004, Cuba began DST on March 28, not April 4.
    (Thanks to Steffen Thorsen.)

Change-Id: I8f26cc50f6b571804a18ff2113b4a47a22bc56dd
2013-12-20 11:26:19 -08:00
Elliott Hughes
aa267685c9 Merge "Allow GCC-built fortified code to run on a clang-built bionic." 2013-12-20 02:54:56 +00:00
Elliott Hughes
a19a41b6b5 Merge "Fix struct stat for aarch64." 2013-12-20 01:45:33 +00:00
Elliott Hughes
f85b9ac3ec Merge "Don't force O_LARGEFILE on LP64." 2013-12-20 01:44:24 +00:00
Elliott Hughes
b8fa5b1ca9 Fix struct stat for aarch64.
Another kernel, another struct stat.

Change-Id: Ia5ee553d4a2ffc878d2fed82a763ff64c02b12e8
2013-12-19 16:50:22 -08:00
Elliott Hughes
17cabe15d5 Don't force O_LARGEFILE on LP64.
aarch64's strace is confused by this, and it isn't necessary anyway.

Change-Id: Ib07b649eb1c38ff0296003874f73af78c47bc276
2013-12-19 16:48:56 -08:00
Ben Cheng
e3fb66dd01 Add __popcountsi2 to the function compat list.
This is needed if we use Clang to compile Bionic, which won't include
__popcountsi2 anymore as Clang generates inline instructions. However
prebuilt binary blobs still depend on libc.so to resolve __popcountsi2.

Change-Id: I9001a3884c4be250c0ceebcd79922783fae1a0b7
2013-12-19 16:26:40 -08:00
Elliott Hughes
cd0609f4fc Allow GCC-built fortified code to run on a clang-built bionic.
Even though code built with clang won't be fully fortified
and won't contain calls to our various helpers, binaries built
with GCC will.

Change-Id: I389b2f1e22a3e89b22aadedc46397bf704f9ca79
2013-12-19 14:20:22 -08:00
Elliott Hughes
cf7a4a4fda Merge "Revert "Add C linkage for __open_2 and __openat_2."" 2013-12-19 20:02:28 +00:00
Elliott Hughes
9a42eef8b1 Revert "Add C linkage for __open_2 and __openat_2."
This reverts commit c13d89b829.

Change-Id: I40a3c6b926e920b65dd054353a2db8d314d5b300
2013-12-19 20:02:16 +00:00
Serban Constantinescu
845c778fa6 ARM: Change dmb domain for bionic_atomic_barrier()
This patch changes the domain that the memory barrier operates on. Assumes
that the scope of bionic_atomic_barrier() does not include device memory,
memory shared with the GPU or any other memory external to the processor
cluster.

Change-Id: I291e741c98a64c86f3a3cf99811bbf1e714ac9aa
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-12-19 11:39:01 -08:00
Elliott Hughes
da9775509b Fix aarch64 custom assembler now non-uapi is gone.
Change-Id: I9c8ad17d9bae2de9d793444d87d4ee133728e900
2013-12-19 11:32:42 -08:00
Ben Cheng
c13d89b829 Add C linkage for __open_2 and __openat_2.
Otherwise Clang mangle them with C++ names.

Change-Id: I844e28d834df8b0752b32d2aadd2013fc8804a43
2013-12-19 10:49:20 -08:00
Serban Constantinescu
bf3ec9ad52 AArch64: Use LDXR/STXR instead of LDAXR/STLXR for bionic_atomic_cmpxchg()
The bionic_atomic_cmpxchg() API states that the cmpxchg() will be done without
explicit memory barriers. LDAXR/STLXR semantics involve half barriers for
load/store.

This patch optimises cmpxchg() by using LDXR/STXR and avoiding unnecessary half
bariers. It also fixes the clobber list for all the bionic_atomic_*() functions.

Change-Id: Iae9468965785cfeeec791d52f1e8cbc524adb682
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-12-19 18:32:53 +00:00
Christopher Ferris
81ddd14381 Merge "Remove the non-uapi kernel headers." 2013-12-19 06:58:53 +00:00
Nick Kralevich
e4c6b08c4e Clean up more recursive FORTIFY_SOURCE calls
Don't use FORTIFY_SOURCE on functions which implement
FORTIFY_SOURCE, to avoid infinite recursion problems.

The previous patch only addressed one of the problems.

Bug: 12216860
Change-Id: I6f30ae7cb5b481be9942add18182ea4839d348a6
2013-12-18 19:17:14 -08:00
Nick Kralevich
ddea383433 __strnlen_chk: avoid recursive strlen calls
Don't use FORTIFY_SOURCE on functions which implement
FORTIFY_SOURCE.

Bug: 12216860
Change-Id: I61db1b47ccdd6bdcf41eab3303f4806494016199
2013-12-18 18:17:52 -08:00
Elliott Hughes
28d4b9bbcb Fix linking of aarch64 static binaries.
Change-Id: If1fa8b560074058b8f7ef32db21a7ca3c53d1fd7
2013-12-18 15:22:08 -08:00
Elliott Hughes
ba9fee97cf Fix the x86-64 int64_t/uint64_t.
This now matches aarch64, which was already correct.

Bug: 12213562
Change-Id: I5da19f0af98347992fea2a62938472f86427740f
2013-12-18 14:00:14 -08:00
Elliott Hughes
ad8842f5c6 Don't use __kernel_ulong_t.
Change-Id: Ifdfbac0ac6da647276a84bd64bb342bb5a07ad61
2013-12-18 12:22:33 -08:00
Elliott Hughes
2b333ea31e Remove <machine/kernel.h>.
Bug: 12175484
Change-Id: I127f7f91f36bd879109d653e0c56ec56e2529d4d
2013-12-18 11:21:55 -08:00
Christopher Ferris
be5231442b Remove the non-uapi kernel headers.
Bug: 11559337
Change-Id: Id1ee4dadbd673cf35b9c79bc87f9a6fb7b2253c6
2013-12-18 10:34:18 -08:00
Elliott Hughes
9e79af3b61 Small style cleanup.
Change-Id: Ib45a4a2296232968296f9bd7cc3592ba46fd412d
2013-12-18 10:05:42 -08:00
Elliott Hughes
611b903ca7 Merge "Properly detect timeout in pthread_mutex_lock_timeout_np_impl" 2013-12-18 17:56:22 +00:00
Elliott Hughes
e00f4890c7 Merge "Move bionic over to GCC's 'warning' attribute." 2013-12-18 17:52:18 +00:00
Elliott Hughes
e7c59f9e20 Fix compilation of crtbegin.c and pthread_debug.cpp.
Because there was no default := for the aarch64 libc_crt_target_cflags,
the += was causing libc_crt_target_cflags to be recursively-defined
variable, which meant that when we were compiling crtbegin.c LOCAL_PATH
would be bionic/tests/ and we'd have -Ibionic/tests/include/ and find
none of our include files.

Also fix linking of pthread_debug.cpp, at least in the disabled mode.
The enabled mode was already broken for all architectures, and continues
to be broken after this change. It's been broken for long enough that
we might want to just remove it...

(aarch64 is using the FSF linker where arm uses the gold linker.)

Change-Id: I7db2e386694f6933db043138e6e97e5ae54d4174
2013-12-18 09:47:44 -08:00
Elliott Hughes
c13fb75cea Move bionic over to GCC's 'warning' attribute.
This is a better solution than the old __warn_references because it's
a compile-time rather than link-time warning, it doesn't rely on something
that doesn't appear to be supported by gold (which is why you only used
to see these warnings on mips builds), and the errors refer to the exact
call site(s) rather than just telling you which object file contains a
reference to the bad function.

This is primarily so we can build bionic for aarch64; building libc.so
caused these warnings to fire (because link time is the wrong time) and
warnings are errors.

Change-Id: I5df9281b2a9d98b164a9b11807ea9472c6faa9e3
2013-12-17 20:43:30 -08:00
Marcus Oakland
e365f9d654 AArch64: Linker64 support for AArch64
Addition of support for AArch64 in the linker64 target.

Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2013-12-17 15:02:43 -08:00
Ken Mixter
4fae14f333 Properly detect timeout in pthread_mutex_lock_timeout_np_impl
Previously we were checking against a positive errno which
would not be returned from a system call.

Change-Id: I8e3a36f6fbf5ccc2191a152a1def37e2d6f93124
2013-12-17 14:26:01 -08:00
Serban Constantinescu
e210488e0d AArch64: Add initial support for AArch64
This is the first patch out of a series of patches that add support for
AArch64, the new 64bit execution state of the ARMv8 Architecture. The
patches add support for LP64 programming model.

The patch adds:
* "arch-aarch64" to the architecture directories.
* "arch-aarch64/include" - headers used by libc
* "arch-aarch64/bionic":
    - crtbegin, crtend support;
    - aarch64 specific syscall stubs;
    - setjmp, clone, vfork assembly files.

Change-Id: If72b859f81928d03ad05d4ccfcb54c2f5dbf99a5
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-12-16 17:00:22 -08:00
Serban Constantinescu
1924a5c92e AArch64: Add support for AArch64 atomic operations
This patch adds support for AArch64 atomic operations. Some
of the stubs use the lightweight store/load exclusive.

Change-Id: Iaf704d048b2dc15bf08cf8e4f0c3ea9f2052fe13
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-12-16 13:09:33 -08:00
Elliott Hughes
4c186ffb83 Fix typo.
Change-Id: I85157a6b2056b6c17cae193200960b8cae3cb3b3
2013-12-16 13:02:49 -08:00
Elliott Hughes
2b333b97a2 Clean up the pthread-only atomic stuff a little.
It looks like we can probably just use the generic GCC stuff instead;
the generated code looks pretty similar. We should come back to that.

These routines are only used by the pthread implementation, and
__bionic_atomic_inc isn't used, so we can remove it.

Change-Id: I8b5b8cb30a1b159f0e85c3675aee06ddef39b429
2013-12-16 10:18:11 -08:00
Elliott Hughes
c54ca40aef Clean up some ARMv4/ARMv5 cruft.
Change-Id: I29e836fea4b53901e29f96c6888869c35f6726be
2013-12-13 14:02:30 -08:00
Joshua J. Drake
063a572e6b Fix backwards compatible system property structure
The original structure included four reserved 32-bit values. This
change adds these back into the structure so that the
__system_property_find_compat function will (again) process the system
properties correctly.
2013-12-13 13:56:39 -06:00
Elliott Hughes
8623bf7b4d Merge "Make <sys/param.h> more glibc-like." 2013-12-12 23:38:25 +00:00
Elliott Hughes
c2f082f655 Make <sys/param.h> more glibc-like.
In particular, add MAX and MIN, needed by elfutils.

Bug: 11864683
Change-Id: I1b876732cdf68cdf5b930319e5ef5b5647586718
2013-12-12 15:31:35 -08:00
Christopher Ferris
802a0a7285 Add ioprio.h.
Change-Id: I153d05c5b6e9d640e319d65acb48b9cb12b6dafb
2013-12-12 15:23:22 -08:00
Elliott Hughes
1887621de8 PTHREAD_KEYS_MAX cleanup.
I fixed this bug a while back, but didn't remove it from the list,
could have added a better test, and could have written clearer code
that didn't require a comment.

Change-Id: Iebdf0f9a54537a7d5cbca254a5967b1543061f3d
2013-12-12 12:51:08 -08:00
Serban Constantinescu
ed76a9361c AArch64: Fix mmap64() definition for AArch64, X86_64
For 64bit Architectures mmap() is equivalent to mmap64(). This patch
maps mmap64() to mmap() in a similar way to other syscalls that differ
based on the size of off_t and off64_t

Change-Id: If21b21ef71120bad23d9a608d02d4a7de5220a87
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-12-12 10:41:52 -08:00
Elliott Hughes
dff7203ee9 Remove harmful attempts to be helpful in pthread_mutex functions.
Most callers won't check for EINVAL, so it's best to fail early.
GCC takes the nonnull attribute as a guarantee that an argument
won't be NULL, so these hacks were already ineffective, which is
how we found that at least one commercial game was using NULL
as if it's a mutex, but actually getting no-op behavior.

Bug: 11971278
Change-Id: I89646e043d931778805a8b692e07a34d076ee6bf
2013-12-11 14:54:00 -08:00
Elliott Hughes
960ee37f2a Clarify a comment.
Change-Id: Iad2e33fb059170f808023ce3d17e9b8c13191f42
2013-12-11 12:41:54 -08:00
Robert Greenwalt
2e3591557f Merge "Fix dns search domain use in gethostbyname." 2013-12-11 19:32:37 +00:00
Robert Greenwalt
c11f6f0f39 Fix dns search domain use in gethostbyname.
Need to load search domain data before we attempt to use it.
bug:6799630

Change-Id: Ib228f4ca260339f71a2e28d5930c0a722bd43c92
2013-12-11 11:30:09 -08:00
Christopher Ferris
101fb7d963 Do not clear tids on detached threads.
Make sure that the kernel isn't going to try and clear the tid of
freed memory.

Bug: 11963327
Change-Id: I95d02340bfbe92f56036d2cc58dbf0e3079eb7c3
2013-12-06 23:00:44 -08:00
Christopher Ferris
ed45970ac5 Add cfi directives to all arm assembly.
Since the ENTRY/END macros now have .cfi_startproc/.cfi_endproc, most of the
custom arm assembly has no unwind information. Adding the proper cfi directives
for these and removing the arm directives.

Update the gensyscalls.py script to add these cfi directives for the generated
assembly. Also fix the references to non-uapi headers to the proper uapi
header.

In addition, remove the kill.S, tkill.S, tgkill.S for arm since they are not
needed at all. The unwinder (libunwind) is able to properly unwind using the
normal abort.

After this change, I can unwind through the system calls again.

Bug: 11559337
Bug: 11825869
Bug: 11321283

Change-Id: I18b48089ef2d000a67913ce6febc6544bbe934a3
2013-12-02 19:13:12 -08:00
Elliott Hughes
ab797cb4fd Finish <sys/user.h>.
Change-Id: I1d97d7fa3d5be2ff4728571ed5376705a27091ec
2013-11-26 17:57:31 -08:00
Elliott Hughes
99c393dff3 Fix the order of arguments to sys_clone for x86.
Unlike x86-64, x86's arguments are just like every other
architecture's.

Change-Id: Ic6da23f2a70599683b68e7e12ab9ba061e0b349c
2013-11-26 16:20:50 -08:00
Elliott Hughes
80906141f7 Work around CLONE_SETTLS being weird on x86.
Unlike other architectures, on x86 (but not x86-64), CLONE_SETTLS
takes a pointer to a struct user_desc instead of a pointer to the
TLS itself. Rather than have to deal with this here, let's just use
the old __set_tls mechanism we used to use (and still use for the
main thread on all architectures, so it's not going away any time
soon).

Bug: 11826724
Change-Id: I02a27939a73ae6cea1134a3f4c1dd7eafea479da
2013-11-26 13:57:21 -08:00
Elliott Hughes
9dec707bd6 Fix _exit_with_stack_teardown for x86.
Change-Id: Ife8f9c538c86f7c0017143015d5ee849a99b625b
2013-11-26 13:48:24 -08:00
Elliott Hughes
e96d4bffe5 Make <sys/timerfd.h> standalone.
There's no uapi timerfd.h.

Bug: 11559337
Change-Id: I77a4b1365fdcf2c9f18673b11341a165e54b4bbd
2013-11-25 13:58:38 -08:00
Elliott Hughes
c43d16a458 Regenerate the bionic kernel headers to match external/kernel-headers.
Bug: 11859767
Change-Id: I3d746188a1c4bdf8db1358521438435d3e63dbac
2013-11-25 13:50:55 -08:00
Christopher Ferris
cda0c61dc7 am 14d6be45: Merge "Delete non-uapi headers."
* commit '14d6be45b960f8fbb039bd946e22ce406e8b65c3':
  Delete non-uapi headers.
2013-11-24 00:20:23 -08:00
Christopher Ferris
dd1d4f1cfd am 985c3fbb: Merge "Move arm user.h definitions to sys/user.h."
* commit '985c3fbb3b1dabfa799e2a8c102867349bcb5a76':
  Move arm user.h definitions to sys/user.h.
2013-11-23 08:02:04 -08:00
Christopher Ferris
e5a9200534 Delete non-uapi headers.
Update headers and delete non-uapi headers that have been removed from
external/kernel-headers project.

Change-Id: I9ed9632a941095fe1bf3b207bafe1151f00de033
2013-11-23 08:01:25 -08:00
Christopher Ferris
985c3fbb3b Merge "Move arm user.h definitions to sys/user.h." 2013-11-23 15:59:57 +00:00
Christopher Ferris
363390eaff Move arm user.h definitions to sys/user.h.
There is no uapi user.h file for arm, it was included by accident.
Move the user struct definition into the file to follow the pattern
used by the other architectures.

Change-Id: Ib9cea0deca551c9268382ddd6de9202fd32ef941
2013-11-22 18:00:09 -08:00
Christopher Ferris
038919d37c am 507f95e2: Merge "Update script to copy in extra generated files."
* commit '507f95e22b39fb58b9ffbba38ab593475b926af5':
  Update script to copy in extra generated files.
2013-11-22 17:22:10 -08:00
Christopher Ferris
b4091e69f1 Update script to copy in extra generated files.
There are files in generated/asm that simply include asm-generic files. The
script now copies any file in generated/asm that also exists in asm-generic.

Change-Id: I075161c68624e9e9e81797224831988ce02220eb
2013-11-22 17:04:34 -08:00
The Android Open Source Project
f00c938c7f Merge commit '811b0cdb2d6e4a697dbc63a678712759dd0db242' into HEAD
Change-Id: I786944f80fb1a2d502fed51dc2c391ed5db66761
2013-11-22 13:38:33 -08:00
Christopher Ferris
26f0e54ae0 Merge "Script to grab uapi headers from android kernel." 2013-11-21 22:20:14 +00:00
Christopher Ferris
e994d41578 Script to grab uapi headers from android kernel.
Change-Id: Ia140e3ab27fbfee6b02f04c085f3e0e351bbe68d
2013-11-21 14:09:54 -08:00
Elliott Hughes
8cb52b056c Regenerate uapi header files.
Change-Id: Idc934ed8ae17aba3300e4022e9b42177b0907e9d
2013-11-21 13:43:23 -08:00
Elliott Hughes
880d0e6c64 Merge "Remove hidden __reboot from header" 2013-11-21 20:37:26 +00:00
Pavel Chupin
811cba00af Remove hidden __reboot from header
This change is required:
https://android-review.googlesource.com/#/c/70570

Change-Id: Idb991f96a424aa5b0f9e06d9fb787fe8c8530750
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-11-22 00:19:34 +04:00
Elliott Hughes
1198fd3864 Add support for the ternary operator to the header scrubber.
Used in various uapi headers.

Change-Id: Id0f862d2adc7ddc9727e8a29160d5435f8d547c3
2013-11-21 11:12:34 -08:00
Elliott Hughes
d4143c8e4c Merge "Fix useconds_t for LP64." 2013-11-21 17:05:04 +00:00
Elliott Hughes
15a6494856 Merge "Remove obsolete kernel/arch-mips headers." 2013-11-21 17:04:44 +00:00
Elliott Hughes
b135f6e58c Merge "Remove the unused arch-x86 and arch-x86-64 kernel headers." 2013-11-21 17:04:24 +00:00
Elliott Hughes
9c67d4307c Fix useconds_t for LP64.
Change-Id: I869e60484999c1feda3dcdb86bee5b5373e6b3df
2013-11-21 08:55:46 -08:00
Elliott Hughes
b867fd6825 Remove obsolete kernel/arch-mips headers.
Bug: 11559337
Change-Id: I70e205ff1f5acd07fddd7d82367e818b13847acd
2013-11-20 18:09:34 -08:00
Elliott Hughes
ab61eb366a Switch to upstream sleep(3) and usleep(3).
Also fix the signature of usleep, and the definition of useconds_t which
should be unsigned, as the 'u' in its name implies.

This patch also cleans up the existing FreeBSD hacks by moving the libm
stuff from <sys/cdefs.h> to a libm-private header, and adding comments
about the hacks we use to build FreeBSD source.

Change-Id: Ibe5067a380502df94a0a3a7901969b35411085b6
2013-11-20 16:24:16 -08:00
Elliott Hughes
d8482b6c7e Fix <signal.h> for mips uapi.
Bug: 11559337
Change-Id: I4c6080f162d74ee78c81d698c7b50470b0e09586
2013-11-20 12:51:52 -08:00
Elliott Hughes
db1dec1ed4 Merge "Clean up pthread_internal_t." 2013-11-20 01:23:33 +00:00
Elliott Hughes
cef3faec0e Clean up pthread_internal_t.
Bug: 11755300
Change-Id: Ib509e8c5ec6b23513aa78b5ac5141d7c34ce2dc8
2013-11-19 17:22:22 -08:00
Elliott Hughes
5cb66cfdc2 Remove the unused arch-x86 and arch-x86-64 kernel headers.
x86-64 already used uapi headers, and x86 can too now.

Bug: 11559337
Change-Id: I1196d2500f06ad40f2488b96fc8ccc7e02c7d5c0
2013-11-19 16:57:42 -08:00
Christopher Ferris
507cfe2e10 Add .cfi_startproc/.cfi_endproc to ENTRY/END.
Bug: 10414953
Change-Id: I711718098b9f3cc0ba8277778df64557e9c7b2a0
2013-11-19 16:31:24 -08:00
Elliott Hughes
e888de81df Provide <sys/user.h>.
strace wants this, for example.

Change-Id: Icb4d64bde392abbc091fa3375a4fa19b2707b12c
2013-11-19 15:32:31 -08:00
Elliott Hughes
36d6188f8c Clean up forking and cloning.
The kernel now maintains the pthread_internal_t::tid field for us,
and __clone was only used in one place so let's inline it so we don't
have to leave such a dangerous function lying around. Also rename
files to match their content and remove some useless #includes.

Change-Id: I24299fb4a940e394de75f864ee36fdabbd9438f9
2013-11-19 14:08:54 -08:00
Elliott Hughes
318e86ed88 Merge "bionic: call stdio cleanup on exit" 2013-11-19 04:01:55 +00:00
Elliott Hughes
303fe0cb38 Merge "Fix pthread_join." 2013-11-19 03:49:00 +00:00
Elliott Hughes
877ec6d904 Fix pthread_join.
Let the kernel keep pthread_internal_t::tid updated, including
across forks and for the main thread. This then lets us fix
pthread_join to only return after the thread has really exited.

Also fix the thread attributes of the main thread so we don't
unmap the main thread's stack (which is really owned by the
dynamic linker and contains things like environment variables),
which fixes crashes when joining with an exited main thread
and also fixes problems reported publicly with accessing environment
variables after the main thread exits (for which I've added a new
unit test).

In passing I also fixed a bug where if the clone(2) inside
pthread_create(3) fails, we'd unmap the child's stack and TLS (which
contains the mutex) and then try to unlock the mutex. Boom! It wasn't
until after I'd uploaded the fix for this that I came across a new
public bug reporting this exact failure.

Bug: 8206355
Bug: 11693195
Bug: https://code.google.com/p/android/issues/detail?id=57421
Bug: https://code.google.com/p/android/issues/detail?id=62392
Change-Id: I2af9cf6e8ae510a67256ad93cad891794ed0580b
2013-11-18 19:48:11 -08:00
Pawit Pornkitprasan
652289942d bionic: call stdio cleanup on exit
As of 61e699a133, stdio clean up
functions are no longer registered in atexit and must be called
manually via __cleanup.

The issue this fixes is some static binaries linked against bionic
cannot output properly when piped or redirected because the buffer
is not flushed before closing.

This is done by pulling in exit.c (and other dependencies) from
netbsd.

Change-Id: I193e54a6d08900f291550029fe75ce76394d9e22
2013-11-19 09:49:17 +07:00
Christopher Ferris
e372ec8cf9 Pull in cleaned version.h header.
Change-Id: Ia917af9336b63ed5a10147770a8110134cb274cb
2013-11-15 16:29:28 -08:00
Elliott Hughes
e48b68570d Clean up the pthread_create trampoline.
Bug: 8206355
Bug: 11693195
Change-Id: I35cc024d5b6ebd19d1d2e45610db185addaf45df
2013-11-15 14:57:45 -08:00
Elliott Hughes
70b24b1cc2 Switch pthread_create over to __bionic_clone.
Bug: 8206355
Bug: 11693195
Change-Id: I04aadbc36c87e1b7e33324b9a930a1e441fbfed6
2013-11-15 14:41:19 -08:00
Chris Dearman
effaa7824d [MIPS] Reimplement syscall to invoke the system call directly
Some MIPS kernels do not correctly restart interrupted system calls that
have been invoked using the indirect syscall (NR_syscall).

The simplest workaround is to handle the indirection in userland and then
call the required system call directly.

Change-Id: I8385399621529db9a52b463c96925f6decaaca30
2013-11-14 16:53:15 -08:00
Elliott Hughes
007eced93b Remove the mips regdef.h and fpregdef.h old kernel headers.
Bug: 11559337
Change-Id: I6352cac9c4ef425cb21e34d0299223711ec079af
2013-11-13 16:13:01 -08:00
Elliott Hughes
740531354e Add a temporary uapi/linux/compiler.h until upstream has one.
Bug: 11559337
Change-Id: I205974b1a26e4f85d0e11503afa80669195d211c
2013-11-08 15:13:54 -08:00
Elliott Hughes
2ecc164ae9 Remove the dependency on the non-uapi __kernel_nlink_t.
The kernel doesn't have an nlink_t; it just uses the equivalent of
uint32_t. We already had a usable __nlink_t in the C library, so
let's just define our nlink_t in terms of __nlink_t, which is what
__nlink_t was meant for anyway.

Note that our struct stat just follows the kernel, and doesn't refer
to nlink_t anyway.

Change-Id: I2a56e418e42404b1741b08c50554b03c11caebae
2013-11-08 14:38:12 -08:00
Elliott Hughes
abd626117c Generate the uapi headers for mips and x86/x86_64.
Bug: 11559337
Change-Id: I23b1a43e7bfa8fa6f9df7e59d2e731a0ec52dafc
2013-11-08 11:46:03 -08:00
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
ed74484dcb Stop using the non-uapi <linux/err.h> header file.
We only need it for MAX_ERRNO, and it's time we had somewhere to put
the little assembler utility macros we've been putting off writing.

Change-Id: I9354d2e0dc47c689296a34b5b229fc9ba75f1a83
2013-11-07 10:31:05 -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
9be07fa527 Fix a TODO; we've had SOCK_CLOEXEC for a while now.
Change-Id: I4bc39b57f3c33441ead74127f576bf5a4e311566
2013-11-06 17:04:56 -08:00
Elliott Hughes
9e63e03d34 Merge "Clean up the 32-bit kernel support, fix LP64 fcntl declaration." 2013-11-07 01:02:55 +00: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
Ben Cheng
af10f9e927 Merge "Add processed uapi kernel headers for ARM." 2013-11-06 23:55:25 +00:00
Ben Cheng
a6b53f03c7 Add processed uapi kernel headers for ARM.
Change-Id: Id34de841b7b4b5a1bf7d22eb793860f92f24a6e5
2013-11-06 15:51:05 -08:00
Elliott Hughes
8fbf8deb34 Fix pread/pwrite for LP64.
Unlike on 32-bit systems where off_t is 32-bit, we don't want to
throw away the top 32 bits of an LP64 system's 64-bit off_t.

Change-Id: Ib2e0daeb4fc0b8ab3d1b983d0b371d8f81033b50
2013-11-06 13:10:37 -08:00
Elliott Hughes
40596aa005 Make cpp.py less braindead.
The old code ignored operator precedence (!), despite having two tables
of operator precedence. The code's still pretty awful, but I've cleaned
it up enough to fix this, the most important bug.

This patch lets us correctly clean the uapi unistd.h, stat.h, and swab.h files,
and also fixes the mess we were already making of various old kernel
header files. I've added a bunch more tests, fixed the existing tests that
the existing script was already failing (!), and changed the script so that
the tests are run every time the script is run.

We can probably remove some of the old kernel header files that we were
parsing incorrectly, but we can worry about that later.

Bug: 11253477
Change-Id: Ie66c65b3a7ae13b4e98ed8038a6a534f06eae0e5
2013-11-06 12:04:48 -08:00