Commit graph

743 commits

Author SHA1 Message Date
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
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
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
The Android Open Source Project
f00c938c7f Merge commit '811b0cdb2d6e4a697dbc63a678712759dd0db242' into HEAD
Change-Id: I786944f80fb1a2d502fed51dc2c391ed5db66761
2013-11-22 13:38:33 -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
9c67d4307c Fix useconds_t for LP64.
Change-Id: I869e60484999c1feda3dcdb86bee5b5373e6b3df
2013-11-21 08:55:46 -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
e888de81df Provide <sys/user.h>.
strace wants this, for example.

Change-Id: Icb4d64bde392abbc091fa3375a4fa19b2707b12c
2013-11-19 15:32:31 -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
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
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
Elliott Hughes
3503ce2177 Fix <sys/select.h> for LP64, clean up <time.h>.
The 64-bit uapi headers don't define FD_CLR and friends, so this
patch updates libc/kernel/common/linux/time.h after the change
b934bbec145e9e084bf48149a3a94ae3dd132157 in external/kernel-headers,
then fixes <sys/select.h> to work in this new world, and removes
some now-unnecessary duplication from <time.h> (with other cruft
cleaned up while I'm here).

Change-Id: Ifd26f901b4d200c65065b3e6ef1b74055127e052
2013-11-05 13:28:36 -08: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
126405039e Update <sys/exec_elf.h> to include EM_AARCH64.
Upstream added the constant for us.

Change-Id: I197e32d2e5b3fd499d069546ccfcc1d35d65e0a0
2013-10-28 21:28:40 -07:00
Serban Constantinescu
7f8863dc07 AArch64: Autogenerated syscalls for AArch64
This patch adds AArch64 syscalls, autogenerated using:
        ./libc/tools/gensyscalls.py

Change-Id: I1cc60430423ecb52a35448bf2c358b82136b2f16
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-10-28 16:18:42 -07:00
Elliott Hughes
74ce45972d Update <sys/exec_elf.h> to get the DF_* flags.
Change-Id: Ia9e785f6b95122f94ee3b01a312db1d5bb91a72e
2013-10-28 14:59:41 -07:00
Elliott Hughes
e4d792adb8 Don't allow text relocations on 64-bit.
I've also updated our <sys/exec_elf.h> to match upstream.

Change-Id: I52f9fce3167541811208d273ff23ceaa112f7135
2013-10-28 14:34:56 -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
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
93de3d881d Fix header file dependencies.
MIPS' asm/fcntl.h assumes a bunch of __kernel_* types are already declared.

Change-Id: Iff701bbb5ede9667a78230c2de3a8f4fe41371c5
2013-10-23 11:25:54 -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
Serban Constantinescu
debc021491 AArch64: Fix definitions for STDINT_LIMITS
This patches fixes the definitions for STDINT_LIMITS on __LP64__
systems.

Change-Id: I5eb1664e9ef7c303432a2b041c99cec663816b75
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-10-22 12:40:16 -07: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
Elliott Hughes
c7fdee72dd Fix struct statfs for LP64.
Change-Id: I9649d881588931a1d672b65ddcf94009daadb0ef
2013-10-18 17:00:11 -07:00
Pavel Chupin
f68fac8c00 x86_64: Fix sys/stat.h
Add 64-bit stat structure mapping 64-bit stat syscall.

Change-Id: Ice517616391bee1d556b6c03e7f5ee610050e6c6
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-18 13:24:25 -07:00
Andrei Emeltchenko
43d2137af0 Add SOCK_CLOEXEC and SOCK_NONBLOCK socket flags.
SOCK_CLOEXEC is used to atomically set close-on-exec flag for the new
descriptor(s), and SOCK_NONBLOCK is used to mark descriptor(s) as
non-blocking.

Change-Id: I8ba6a70543d23759e3ddcc7ff9c21b567184d681
2013-10-17 13:32:32 -07:00
Elliott Hughes
e989399dc2 O_CLOEXEC is always defined for arm, mips, x86, and x86_64.
I built all four, just to be sure.

Change-Id: I5c818575c8142fccfc8fb163468832807a535e90
2013-10-17 11:45:22 -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
b2386fed55 am 4346bd9f: am bffe261a: Merge "Sort the syscalls.mk files, give all generated files the same header."
* commit '4346bd9fbcfe4144df7ac0e920bdda274d523fc4':
  Sort the syscalls.mk files, give all generated files the same header.
2013-10-16 16:33:50 -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
103ccde8fe Sort the syscalls.mk files, give all generated files the same header.
No non-comment changes to the .S files.

Change-Id: Iafcfd004c3ea92b64268f80ab16df615b97cefac
2013-10-16 14:27:59 -07:00
Elliott Hughes
40d105ccb3 Switch sigpending over to rt_sigpending.
Change-Id: I7b28984796b5fb343cfbcc47e0afc3a84293d417
2013-10-16 14:07:01 -07:00
Stephen Hines
8161b23689 am 4691325d: am abeafbd6: Merge "Wrap sprintf()/snprintf() macros to prevent expansion errors."
* commit '4691325d48406033632fe84a944ac9c3bd2e5097':
  Wrap sprintf()/snprintf() macros to prevent expansion errors.
2013-10-11 16:33:07 -07:00
Stephen Hines
6e38072add Wrap sprintf()/snprintf() macros to prevent expansion errors.
Previously, FORTIFY_SOURCE used single macros to define these standard
functions for use with clang. This can cause conflicts with other macros used
to call these functions, particularly when those macros expand the number of
arguments to the function. This change wraps our macro definitions, so that
expansion properly takes place for programmer arguments first.

Change-Id: I55929b1fd2a643b9d14a17631c4bcab3b0b712cf
2013-10-11 12:14:49 -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
Nick Kralevich
b036b5ca36 FORTIFY_SOURCE: fortify read()
Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
2013-10-09 20:17:03 -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
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
Nick Kralevich
65c99de2cb FORTIFY_SOURCE: fortify read()
Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
2013-10-09 13:44:38 -07:00
Elliott Hughes
e769368d76 am c8bd2c2e: am 458076c3: Merge "Fix the ALIGN and ALIGNBYTES macros for LP64."
* commit 'c8bd2c2e45c93b999a40449e4c6f44470f010367':
  Fix the ALIGN and ALIGNBYTES macros for LP64.
2013-10-08 16:15:33 -07:00
Elliott Hughes
78df45e1d1 Fix the ALIGN and ALIGNBYTES macros for LP64.
Change-Id: I3a361255afce375ab1cefa449721f0aea4d47919
2013-10-08 15:31:44 -07:00
Elliott Hughes
9258c7b23e am b7d77a9e: am 56777421: Merge "Add arch-x86_64/include/machine."
* commit 'b7d77a9eb1effd5f0472dff14a8fe77d9da2c7a2':
  Add arch-x86_64/include/machine.
2013-10-04 16:21:25 -07:00
Elliott Hughes
72645164b6 Add arch-x86_64/include/machine.
This is basically the other half of I5de76f6c46ac87779f207d568a86bb453e2414de
from Pavel Chupin <pavel.v.chupin@intel.com>, but taking the exact upstream
_types.h instead of the modified version. (I was confused when I suggested
otherwise.)

I've also cleaned up the internal_types.h situation; we weren't gaining
anything from these empty files, and there is no upstream internal_types.h
for x86_64.

Change-Id: I802a9a6a8df1c979e820659212c75a47c2ef392e
2013-10-04 16:10:13 -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
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
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
Nick Kralevich
944ce989f8 am f7da611b: am 00d51c9f: Merge "Use alloc_size attribute on *alloc functions"
* commit 'f7da611b3dedaf9951e08b0296daf67eda8228c0':
  Use alloc_size attribute on *alloc functions
2013-10-02 14:38:12 -07:00
Nick Kralevich
b91791d71c Use alloc_size attribute on *alloc functions
malloc and family were not declared with __attribute__((alloc_size)).
This was (sometimes) preventing FORTIFY_SOURCE related functions
from knowing the size of the buffer it's dealing with, inhibiting
FORTIFY_SOURCE protections.

Add __attribute__((alloc_size))

Information about the alloc_size attribute can be found
at http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Change-Id: Ia2f0a445f0170a7325f69259b5e7fb35a9f14921
2013-10-02 14:14:40 -07:00
Elliott Hughes
a0a5a50152 am 2e2a4f97: am 4bbf3a8b: Merge "Remove #define _BITSIZE 32."
* commit '2e2a4f97bfbb7b94d12690395c5cbcf7d7d1edc7':
  Remove #define _BITSIZE 32.
2013-10-02 10:10:27 -07:00
Elliott Hughes
5e72c513bf Remove #define _BITSIZE 32.
I've no idea what _BITSIZE was supposed to be, glibc doesn't have it,
the BSDs don't have it, and no code is currently using it. But having
it set unconditionally to 32 sounds like a bad idea.

Change-Id: I900235c1489afba891fff0bc3b43e9d593249a4f
2013-10-02 09:23:46 -07:00
Elliott Hughes
35336777f1 am 67e0214d: am 232dff3a: Merge "Regenerate the system call stubs (to get x86_64)."
* commit '67e0214d0f620df7a7928ef0fa1a9c0aac326a20':
  Regenerate the system call stubs (to get x86_64).
2013-10-01 13:59:59 -07:00
Elliott Hughes
e4ffd9f234 Regenerate the system call stubs (to get x86_64).
This touches the x86 stubs too because arm, x86, and x86_64 now
all share the same header (at a source level), which causes a
reordering of the #include lines.

Change-Id: If9a1e2b2718bd41d8399fea748bce672c513ef84
2013-10-01 13:29:43 -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
01a700e5d2 Better statfs/fstatfs glibc compatibility.
Change-Id: I069d169c96cd71b75a045ec911fb4bd484c6b2c9
2013-09-30 21:57:07 -07:00
Elliott Hughes
5d641bcf70 am f5dcdfc4: am 6dee3b9a: Merge "Add x86_64 to the bionic headers."
* commit 'f5dcdfc438684bbe93e398b6551f915fe3fe10bf':
  Add x86_64 to the bionic headers.
2013-09-30 18:45:57 -07:00
Elliott Hughes
c620059479 Remove 32-bit assumptions from the ELF code.
Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
2013-09-30 18:43:46 -07:00
Elliott Hughes
d3e64a3f40 Add x86_64 to the bionic headers.
Manual changes:

  cpp.py: cope with macros that refer to other macros.

  defaults.py: x86 no longer always implies __i386__; use __i386__ to replace
  the kernel CONFIG_X86_32 flag.

  asm/page.h: the upstream page.h isn't a uapi header and no longer includes
  the stuff we were using it for. Let's just have our own static file, since
  it's the same for all our architectures (both 32- and 64-bit).

  sys/select.h: we used to use the various FD_SET-related macros from the
  kernel header files, but they've gone. Adjust by adding trivial equivalent
  definitions.

Automated changes:

  libc/kernel/arch-x86, libc/kernel/common: regenerated from
  external/kernel-headers.

Change-Id: I84fc0ed52dc742e043b4ae300fd3b58ee99b7fcd
2013-09-30 18:42:13 -07:00
Elliott Hughes
b277509095 am 34284954: am 76218efb: Merge "Fix inttypes.h and stdint.h for 64-bit (and C++11)."
* commit '34284954b3b43010d87c6f99a50dc673a55fbb04':
  Fix inttypes.h and stdint.h for 64-bit (and C++11).
2013-09-30 16:23:03 -07:00
Elliott Hughes
a9a02acc9f Fix inttypes.h and stdint.h for 64-bit (and C++11).
Change-Id: I394630348413c9aafcac137ce1ca5f0a93d9ab6f
2013-09-30 14:46:47 -07:00
Nick Kralevich
cadc6aaf41 am f56e0e4b: am 6aed6077: Merge "Fix unnecessary call to __strncpy_chk2"
* commit 'f56e0e4b5e97f4e7fed6e06dde30053ea687716e':
  Fix unnecessary call to __strncpy_chk2
2013-09-27 15:18:21 -07:00
Nick Kralevich
d13c2b1ba6 Fix unnecessary call to __strncpy_chk2
If "n" is smaller than the size of "src", then we'll
never read off the end of src. It makes no sense to call
__strncpy_chk2 in those circumstances.

For example, consider the following code:

int main() {
  char src[10];
  char dst[5];
  memcpy(src, "0123456789", sizeof(src));
  strncpy(dst, src, sizeof(dst));
  dst[4] = '\0';
  printf("%s\n", dst);
  return 0;
}

In this code, it's clear that the strncpy will never read off
the end of src.

Change-Id: I9cf58857a0c5216b4576d21d3c1625e2913ccc03
2013-09-27 13:21:24 -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
Christopher Ferris
5cb0436930 am 1a88ca08: am 98c726ec: Merge "Add the dl_iterate_phdr function to libdl for arm."
* commit '1a88ca08046ea510bfc8d3de6875537f124b3ce3':
  Add the dl_iterate_phdr function to libdl for arm.
2013-09-06 10:57:40 -07:00
Christopher Ferris
24053a461e Add the dl_iterate_phdr function to libdl for arm.
Bug: 8410085

Merge from internal master.

(cherry-picked from cb491bc66d)

Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f
2013-09-06 09:53:54 -07:00
Elliott Hughes
eb31e1c558 am 1e96d49a: am afa31042: Merge "Fix strchr for basic non-sse case on x86"
* commit '1e96d49a7d4d1af8f3bd6630e4ec9369813f18e7':
  Fix strchr for basic non-sse case on x86
2013-09-03 14:07:11 -07:00
Pavel Chupin
3c4b50fd8c Fix strchr for basic non-sse case on x86
Fix source location. Move declaration of __strchr_chk out of
ifdef __BIONIC_FORTIFY which should be available for strchr.cpp
compilation when __BIONIC_FORTIFY is not defined.

Change-Id: I552a6e16656e59b276b322886cfbf57bbfb2e6a7
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-09-03 16:20:52 +04:00
Nick Kralevich
4d0fbf9b07 am 89dcc10c: am 4e3ed44d: Merge "cdefs.h: introduce __bos0"
* commit '89dcc10c320c032faef83c4940a57949ade01dba':
  cdefs.h: introduce __bos0
2013-08-28 14:36:50 -07:00
Nick Kralevich
bd8e6749b7 cdefs.h: introduce __bos0
Introduce __bos0 as a #define for __builtin_object_size((s), 0).
This macro is intended to be used for places where the standard
__bos macro isn't appropriate.

memcpy, memmove, and memset deliberately use __bos0. This is done
for two reasons:

1) I haven't yet tested to see if __bos is safe to use.
2) glibc uses __bos0 for these methods.

Change-Id: Ifbe02efdb10a72fe3529dbcc47ff647bde6feeca
2013-08-28 14:27:14 -07: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
Elliott Hughes
34cd499875 am fd61eccf: am ff9b7aa6: Merge "Make ctype.h a little less unhygienic."
* commit 'fd61eccf6b909ee6374ad43164f0e9bcd4b3547c':
  Make ctype.h a little less unhygienic.
2013-08-13 14:45:44 -07:00
Elliott Hughes
5e9b20f721 Make ctype.h a little less unhygienic.
This caused trouble for stlport.

Change-Id: Id40787c5a2b7a3a4e12fb557efe549778a01cbbd
2013-08-13 14:30:59 -07:00
Elliott Hughes
c1772397f9 am ff8dcd4a: am c933493a: Merge "Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols."
* commit 'ff8dcd4a1056257b454da71e1ea1371bb73d3a79':
  Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
2013-08-12 14:28:52 -07:00
Elliott Hughes
aec2ffbc5a Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
Change-Id: I94c411c22634e43184445c82e7388e51fc46a8cc
2013-08-12 12:07:05 -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
Elliott Hughes
e66ffef900 am cd927519: Merge "Fix stdint.h intptr_t/uintptr_t for x86_64/x32"
* commit 'cd927519a94939f2ebc307544f827baade529bc9':
  Fix stdint.h intptr_t/uintptr_t for x86_64/x32
2013-08-05 15:51:54 -07:00
Elliott Hughes
28e0ec8d61 am a0473d77: Merge "syslog needs a valid socket path for _PATH_LOG"
* commit 'a0473d77b2d3a6f26e29cc8c2fdaeb2a4b3ab8f8':
  syslog needs a valid socket path for _PATH_LOG
2013-08-05 15:51:53 -07:00
Elliott Hughes
cd927519a9 Merge "Fix stdint.h intptr_t/uintptr_t for x86_64/x32" 2013-08-05 20:55:24 +00:00
Elliott Hughes
a0473d77b2 Merge "syslog needs a valid socket path for _PATH_LOG" 2013-08-05 20:41:50 +00:00
Pavel Chupin
0a9c615a89 Fix stdint.h intptr_t/uintptr_t for x86_64/x32
Patch is required in NDK headers as well to be able to build multilib
GCC with libgomp support.
It's here: https://android-review.googlesource.com/#/c/62982

Change-Id: I2bec25d8cbca0e5ef1a0857008ececd92f4911be
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-08-02 19:23:37 +04:00
Elliott Hughes
abf3638317 am 101b5e1f: Merge "Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way."
* commit '101b5e1f6cc4e24635760928b3d2c1e51c1e5774':
  Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way.
2013-07-29 17:35:49 -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
47c7e33ccb am ff20b911: am 8a363692: Merge "Add TCP_INFO state enum values."
* commit 'ff20b9110659e67433ce641a6224cdc9ccc01301':
  Add TCP_INFO state enum values.
2013-07-11 18:57:42 -07:00
Nick Kralevich
4fa5d6a5db am ef49e99d: am d30877ae: Merge "syslog.h: add __printflike to syslog functions"
* commit 'ef49e99d92597a4e9fddbba0e1e3feddc06fee53':
  syslog.h: add __printflike to syslog functions
2013-07-11 18:57:41 -07:00
Elliott Hughes
ff20b91106 am 8a363692: Merge "Add TCP_INFO state enum values."
* commit '8a363692be45ed1b36e1f1f21707b6f35f5519c8':
  Add TCP_INFO state enum values.
2013-07-11 18:52:22 -07:00
Nick Kralevich
ef49e99d92 am d30877ae: Merge "syslog.h: add __printflike to syslog functions"
* commit 'd30877ae28f3c308edf142c091b3a8acc4467c6d':
  syslog.h: add __printflike to syslog functions
2013-07-11 18:52:01 -07:00
Elliott Hughes
0dff43cab4 Add TCP_INFO state enum values.
Bug: https://code.google.com/p/android/issues/detail?id=38881
Change-Id: Ie22816c666474e6441e0ec3afd2a6eb04d64a673
2013-07-11 16:21:32 -07:00
Geremy Condra
bb17967761 Merge "Add marking of DNS sockets for mark based routing" 2013-07-11 22:10:31 +00:00
Nick Kralevich
6b1dd1797e syslog.h: add __printflike to syslog functions
Allow the compiler to detect formating bugs.

Change-Id: I6a4af6cae59dc3adf14b075431a41885213a649a
2013-07-10 07:37:11 -07:00
Elliott Hughes
731f7c2d0e am 9d476716: Merge "Add <sys/statvfs.h>."
* commit '9d476716c2bd7bc5a018a71e121257c35e965058':
  Add <sys/statvfs.h>.
2013-07-09 13:44:57 -07:00
Elliott Hughes
06040fd75c Add <sys/statvfs.h>.
Bug: 2512019
Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
2013-07-09 13:25:03 -07:00
Chad Brubaker
c39214e0ac Add marking of DNS sockets for mark based routing
Adds an extra mark parameter to android_getaddrinfoforiface,
android_gethostbyaddrforiface and android_gethostbynameforiface that if set
will cause all packets sent by DNS requests to have that mark

Change-Id: I6f72390e4ce5bfc3cc73183f9b2fb3705a11685f
2013-07-09 13:16:22 -07:00
Elliott Hughes
f3f72e7f27 am 4fc8a0c1: Merge "Remove <netinet/icmp6.h> ni_* macros."
* commit '4fc8a0c1165537b693c900ac3e2c61470bd7e484':
  Remove <netinet/icmp6.h> ni_* macros.
2013-07-08 15:09:07 -07:00
Elliott Hughes
c2cd33efc4 Remove <netinet/icmp6.h> ni_* macros.
glibc doesn't have these, and they prevent ping from building out of
the box because it assumes it can define them.

Bug: 9671560
Change-Id: I815f2a9c4fd96a0ea2952eb5a71ddf51e0763660
2013-07-08 15:07:41 -07:00
Elliott Hughes
233050b15e am e31c45c9: Merge "Make bionic\'s <netinet/icmp6.h> standalone, like glibc\'s."
* commit 'e31c45c9fa5e0d2853941282e619b753550b82ae':
  Make bionic's <netinet/icmp6.h> standalone, like glibc's.
2013-07-08 11:21:53 -07:00
Elliott Hughes
3a040d8379 Make bionic's <netinet/icmp6.h> standalone, like glibc's.
This removes the need for a bionic-specific hack in external/iproute2.

Bug: 9671560
Change-Id: I9f15be0711d26bca863bd66be9a39606500fb948
2013-07-08 11:16:24 -07:00
Elliott Hughes
62bdd03120 am 6b33f31b: Merge "Fix IPv6 filtering definitions in netinet/icmp6.h."
* commit '6b33f31b0994b8132bed8936685522e2e01754d8':
  Fix IPv6 filtering definitions in netinet/icmp6.h.
2013-07-08 10:34:41 -07:00
Lorenzo Colitti
bfc6a59556 Fix IPv6 filtering definitions in netinet/icmp6.h.
Linux and *BSD kernels use opposite values to indicate pass/block
in ICMPv6 filters, and assign a different value to the
ICMP6_FILTER sockopt.

Bug: 9671560
Bug: 9469682
Change-Id: Ic0f1fcd48891add992acf97632f60aebd172c1d7
2013-07-08 10:31:29 -07:00
Elliott Hughes
24400ac1e3 am e63ea6ac: Merge "Clean up <sys/mount.h>/<linux/fs.h> duplication."
* commit 'e63ea6aca7d01ba9219b877ed5fab6de5c6037fb':
  Clean up <sys/mount.h>/<linux/fs.h> duplication.
2013-07-08 10:12:32 -07:00
Elliott Hughes
e42e51d563 Clean up <sys/mount.h>/<linux/fs.h> duplication.
Roll on uapi...

Bug: 6340120
Change-Id: Ic9521905683946e836574e4d768e34853ea777fa
2013-07-03 14:58:04 -07:00
Elliott Hughes
a8b954c51e am de2781d9: Merge changes I01345c23,I3b57517c
* commit 'de2781d906f27be4df3e03a8e5041dcc1aeb281d':
  Include linux/termios.h from sys/ioctl.h.
  Update linux/types.h to linux 2.6.20.
2013-07-03 13:39:16 -07:00
Lorenzo Colitti
f936ef1a9f Include linux/termios.h from sys/ioctl.h.
On NetBSD and glibc, including sys/ioctl.h provides some
terminal ioctl data structures such as struct winsize. For
compatibility, provide these via sys/ioctl.h in bionic as well.
bionic does not have its own definitions for these structures, so
get them from the Linux kernel definitions.

Change-Id: I01345c23c0bebd60b0a80fc33668e7c0ad7356c3
2013-07-03 13:35:18 -07:00
Elliott Hughes
833dc584d4 am 87b4286f: Merge "Expose dn_comp and dn_expand to system C code."
* commit '87b4286f092094a2e8069a06e20ef5036a258172':
  Expose dn_comp and dn_expand to system C code.
2013-07-02 16:02:30 -07:00
Lorenzo Colitti
b8e435c1d5 Expose dn_comp and dn_expand to system C code.
This is needed to compile open-source code that wants to
expand/compress domain names itself, such as ping6.

Bug: 9469682
Change-Id: I339c6538936d05c031bc6fb0a8793aaf1429dea4
2013-07-02 15:57:57 -07:00
Elliott Hughes
7c808b29d5 am feec97a7: Merge "Fix inttypes.h PRI?PTR and SCN?PTR macros."
* commit 'feec97a7c7fbd032174fb4870a02422c2acd891a':
  Fix inttypes.h PRI?PTR and SCN?PTR macros.
2013-07-02 15:44:48 -07:00
Elliott Hughes
74f0833df6 Fix inttypes.h PRI?PTR and SCN?PTR macros.
Our intptr_t and uintptr_t aren't "long". Add a compilation test so we remember
to fix this to cope with 32- and 64-bit later.

Bug: http://code.google.com/p/android/issues/detail?id=57218
Change-Id: I2f816d339edb4f7d57e4418b818fb4c602093f38
2013-07-02 15:35:27 -07:00
Elliott Hughes
dcd237a897 am 1ba3a2c2: Merge "Update icmp6.h to current NetBSD."
* commit '1ba3a2c26937c68a4a0bd4fdffe95f5162077997':
  Update icmp6.h to current NetBSD.
2013-07-02 12:34:36 -07:00
Lorenzo Colitti
ce7c404dc7 Update icmp6.h to current NetBSD.
This adds a few bits we need such as RFC 6106 support and the
definition of MLD_LISTENER_REDUCTION.

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/netinet/icmp6.h?rev=1.47

Bug: 9469682
Change-Id: I97a4c2f0893012ce315334367c055097d0f8bb10
2013-07-02 09:38:59 -07:00
Nick Kralevich
28d298a673 am 413eef71: Merge "More FORTIFY_SOURCE functions under clang"
* commit '413eef716f822d5eb4f57618f6780c6af5036460':
  More FORTIFY_SOURCE functions under clang
2013-07-01 10:00:09 -07:00
Nick Kralevich
a6cde39276 More FORTIFY_SOURCE functions under clang
* bzero
* umask
* strlcat

Change-Id: I65065208e0b8b37e10f6a266d5305de8fa9e59fc
2013-06-29 08:16:22 -07:00
Nick Kralevich
f9ef0106da am 78a7bf99: Merge "stdio.h: enable vs?printf clang FORTIFY_SOURCE"
* commit '78a7bf998d2d29592504984fcf419cd2701c6c54':
  stdio.h: enable vs?printf clang FORTIFY_SOURCE
2013-06-27 10:15:31 -07:00
Nick Kralevich
c8ae8bd941 stdio.h: enable vs?printf clang FORTIFY_SOURCE
Enable FORTIFY_SOURCE protections under clang for the following
functions:

  * vsprintf
  * vsnprintf

and add unittests.

Change-Id: I90f8a27f7b202c78b5dd8ebf53050bf9e33496f7
2013-06-27 09:17:48 -07:00
Colin Cross
146d79c22a am fbec57d4: Merge changes Ib496e818,I074204e9
* commit 'fbec57d46c42460b2381484d1610ff21922d162e':
  bionic: add compatibility mode for properties
  bionic: use the size of the file to determine property area size
2013-06-25 17:08:48 -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
Elliott Hughes
db6dd600d2 am b116bf76: Merge "Switch to current upstream getopt_long."
* commit 'b116bf76286178a7d552c4d0a72b79212c8c93d1':
  Switch to current upstream getopt_long.
2013-06-25 15:58:53 -07:00
Elliott Hughes
b116bf7628 Merge "Switch to current upstream getopt_long." 2013-06-25 22:56:59 +00:00
Rom Lemarchand
baa61864c5 am 995f17e6: Merge "libc: add swapon and swapoff syscalls"
* commit '995f17e6a9a9903f03f542192da9a83b1cabc684':
  libc: add swapon and swapoff syscalls
2013-06-25 15:28:21 -07:00
Elliott Hughes
d278b828fe Switch to current upstream getopt_long.
Change-Id: I4c646dcb8be9e88dd54d069a03bbc5fbfd92de03
2013-06-25 14:56:17 -07:00
Rom Lemarchand
d206b560e7 libc: add swapon and swapoff syscalls
Change-Id: Ie79dc8e3f2ff1cd427dd6d95e3850920c4b407b0
Signed-off-by: Rom Lemarchand <romlem@google.com>
2013-06-25 13:18:03 -07:00
Nick Kralevich
7180213557 am bfacb603: Merge "libc: enable FORTIFY_SOURCE snprintf under clang"
* commit 'bfacb603e417c1e2c25ce8482b5c6e31b4db8c9b':
  libc: enable FORTIFY_SOURCE snprintf under clang
2013-06-25 10:34:20 -07:00
Nick Kralevich
621b19dddb libc: enable FORTIFY_SOURCE snprintf under clang
Change-Id: I8b8059782a720104722b0841994b38f873ed02aa
2013-06-25 10:02:35 -07:00
Colin Cross
a99e29e610 am 1642edb5: Merge changes Ib074192d,I6df3afed,I69070455,Icbe31908,Id3fa4526,I038d451f
* commit '1642edb5208fe02ef64d5734fffaf7c4a724fd2f':
  bionic: store property names as variable-length strings
  bionic: prevent root processes from calling __system_property_add
  bionic: revert to a single (larger) property area
  bionic: reimplement property area as hybrid trie/binary tree
  bionic: add missing memory barriers to system properties
  bionic: make property area expandable
2013-06-24 17:10:16 -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
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
954480393f am 0ea1d5c0: Merge "libc: enable sprintf FORTIFY_SOURCE under clang"
* commit '0ea1d5c0ae94ee581c72451b20813c028f51090c':
  libc: enable sprintf FORTIFY_SOURCE under clang
2013-06-24 15:20:39 -07:00
Nick Kralevich
c6eb985454 libc: enable sprintf FORTIFY_SOURCE under clang
clang doesn't support __builtin_va_arg_pack(), so we have
to use #define instead.

Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
2013-06-24 14:10:29 -07:00
Nick Kralevich
33ae76abf3 am 5fed0eea: am 0ce28d20: Merge "libc: enable FORTIFY_SOURCE clang strlcpy"
* commit '5fed0eeabd88bfe241c416f2c2f44a14b6e447fa':
  libc: enable FORTIFY_SOURCE clang strlcpy
2013-06-20 12:34:11 -07:00
Nick Kralevich
5fed0eeabd am 0ce28d20: Merge "libc: enable FORTIFY_SOURCE clang strlcpy"
* commit '0ce28d20ea5fde250576f355004dbcd741b0b884':
  libc: enable FORTIFY_SOURCE clang strlcpy
2013-06-20 12:29:38 -07:00
Nick Kralevich
8bafa7452e libc: enable FORTIFY_SOURCE clang strlcpy
Change-Id: Idcfe08f5afc3dde592416df9eba83f64e130c7c2
2013-06-20 12:17:44 -07:00
Elliott Hughes
cb4fd62762 am 33df38a0: am 4eed6509: Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)"
* commit '33df38a04c31de0fca431c549469edb6d2de75e2':
  stdint.h header is not fully compatible with C99(ISO9899:1999)
2013-06-19 12:57:39 -07:00
Elliott Hughes
33df38a04c am 4eed6509: Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)"
* commit '4eed65090b1f0d0d087f26bd7367da90a0cca92d':
  stdint.h header is not fully compatible with C99(ISO9899:1999)
2013-06-19 12:46:40 -07:00
Elliott Hughes
4eed65090b Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)" 2013-06-19 19:45:09 +00:00
Greg Hackmann
d32969701b 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.

Change-Id: Ibe00ef52464bfa590953c4699a6d98383b0142b1
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-19 11:02:15 -07:00
Colin Cross
f4250508d5 am 3225f498: Merge "bionic: add __system_property_foreach"
* commit '3225f4984837c4d9e6e9495d2154f2d9987cf457':
  bionic: add __system_property_foreach
2013-06-19 10:27:23 -07:00
Sergey Melnikov
dc5d3426d8 stdint.h header is not fully compatible with C99(ISO9899:1999)
stdint.h provides macros with incorrect type:
  * UINT8_C
  * UINT16_C
  * UINT8_MAX
  * UINT16_MAX

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: I2d130c782d4485bf6c9e9f068de0bdaa4ba7303f
2013-06-19 12:33:31 +04: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
Greg Hackmann
577418403d 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.

Change-Id: I66bde9926c193073d74b244cce9fffd52108fff8
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-18 15:38:31 -07:00
Nick Kralevich
d98d35c538 am 0846109c: Merge "libc: Rename fortify error functions."
* commit '0846109c96d54a28e413893b0cd4b4acb3aa87fc':
  libc: Rename fortify error functions.
2013-06-18 13:27:18 -07:00
Nick Kralevich
3bf6279034 am dd0880fe: Merge "libc: add limited FORTIFY_SOURCE support for clang"
* commit 'dd0880fec3bb8c998680e78aff9e2ddc2bcf6d7a':
  libc: add limited FORTIFY_SOURCE support for clang
2013-06-18 13:27:17 -07:00
Nick Kralevich
ba6c021a53 am e2fb05b4: Merge "libc: Introduce __errordecl()"
* commit 'e2fb05b45b9af7b9af8df0ea15bfec63d331d882':
  libc: Introduce __errordecl()
2013-06-18 13:17:35 -07:00
Nick Kralevich
a641c18f0c libc: Rename fortify error functions.
__umask_error -> __umask_invalid_mode
__creat_error -> __creat_missing_mode
__too_many_args_error -> __creat_too_many_args

Change-Id: I4036f344a3a93628e70f2e948ad73cfed3a967ea
2013-06-18 13:07:18 -07:00
Nick Kralevich
16d1af167f libc: add limited FORTIFY_SOURCE support for clang
In 829c089f83, we disabled all
FORTIFY_SOURCE support when compiling under clang. At the time,
we didn't have proper test cases, and couldn't easily create targeted
clang tests.

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

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

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

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

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

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

Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa
2013-06-18 12:14:20 -07:00
Nick Kralevich
b24c0637d0 libc: Introduce __errordecl()
Define __errordecl and replace __attribute__((__error__("foo")))
with __errordecl. Make sure __errordecl is a no-op on clang, as it
generates a compile time warning.

Change-Id: Ifa1a2d3afd6881de9d479fc2adac6737871a2949
2013-06-18 12:13:52 -07:00
Colin Cross
f6e6e5e727 am 977a3313: Merge changes Iac00ce10,I192d3825
* commit '977a33137d2be0093f474055f839cf665b82b588':
  bionic: add tests for properties
  bionic: move system property writing from init to bionic
2013-06-17 18:21:37 -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
Elliott Hughes
c1e4183c7a am 560e9f7e: Merge "Ensure that <stdint.h> defines SIZE_MAX and friends."
* commit '560e9f7e7a39e02aca96709043ca06f562f75d58':
  Ensure that <stdint.h> defines SIZE_MAX and friends.
2013-06-13 16:21:55 -07:00
Elliott Hughes
7c89506e3a Ensure that <stdint.h> defines SIZE_MAX and friends.
We were missing SIG_ATOMIC_MAX, SIG_ATOMIC_MIN, SIZE_MAX,
WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN.

Change-Id: I2535f36bc220fbaea009b483599b7af811c4cb5c
2013-06-13 16:02:53 -07:00
Elliott Hughes
dc5f5f857c am f1867d47: Merge "Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work.""
* commit 'f1867d47cbce4225d712a2684da67031f7350909':
  Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."
2013-06-12 15:22:04 -07:00
Elliott Hughes
9248d3a58c Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."
This reverts commit d8627af159 which caused build breakage:

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

Change-Id: I128095ecb99df92626e1f57e34c61e08c98a4078
2013-06-12 22:18:47 +00:00
Elliott Hughes
b0a2262c3f am 55c5ec64: Merge "Add SIZE_MAX to <stdint.h> in a way that might actually work."
* commit '55c5ec64bd26d92bd1882a9a4c91445de73ebfa2':
  Add SIZE_MAX to <stdint.h> in a way that might actually work.
2013-06-12 15:06:51 -07:00
Elliott Hughes
d8627af159 Add SIZE_MAX to <stdint.h> in a way that might actually work.
Take two.

Change-Id: I7d08b6d14c82a171312a7f5898270b4441d5cfa2
2013-06-12 14:54:16 -07:00
Elliott Hughes
834f83de3f am 5cde15eb: Merge "<stdint.h> should expose SIZE_MAX."
* commit '5cde15eb17f4ddc0949c0cbd38a46e6c0bad7019':
  <stdint.h> should expose SIZE_MAX.
2013-06-12 10:58:23 -07:00
Elliott Hughes
2c157aec9b <stdint.h> should expose SIZE_MAX.
Change-Id: Id27222c24955c83f29ad953933cbdc48b6f1e900
2013-06-12 10:28:26 -07:00
Elliott Hughes
e84cfbefd8 am b7b4f5b8: Merge "update signal.h to be C90 compatable"
* commit 'b7b4f5b838cd41407c734af74e8211f5c7da0036':
  update signal.h to be C90 compatable
2013-06-05 18:09:17 -07:00
Elliott Hughes
5a6a0a9445 am 18af4503: Merge "Ensure header files using __BEGIN_DECLS include sys/cdefs.h."
* commit '18af450393b005b4ead896d82cda750e6876fd33':
  Ensure header files using __BEGIN_DECLS include sys/cdefs.h.
2013-06-05 18:06:04 -07:00
Erik Gilling
156ccf42ff update signal.h to be C90 compatable
sigismember, sigaddset, and sigdelset had mixed code and declarations
which are not allowed in C90 and before.

Change-Id: I662af944fc1489e34bed228ce592e41f50d00e17
Signed-off-by: Erik Gilling <konkers@android.com>
2013-06-05 18:05:36 -07:00
Elliott Hughes
36fa67bcdd Ensure header files using __BEGIN_DECLS include sys/cdefs.h.
We keep fixing these one-by-one; let's fix them all at once.

Found thus:

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

Change-Id: I188842aa2484dc6176e96556d57c38a0f785b59b
2013-06-05 17:58:08 -07:00
Elliott Hughes
b9e2dae427 am c5bfb624: Merge "sys/personality.h: include <sys/cdefs.h>"
* commit 'c5bfb62433751579e86d5fd24cddf3ae28a49b43':
  sys/personality.h: include <sys/cdefs.h>
2013-06-05 17:29:01 -07:00
Kito Cheng
328223230b sys/personality.h: include <sys/cdefs.h>
Change-Id: Ia3fa558a38e0cffe5287bc454e85d5d3bdaa6ba1
2013-06-05 11:30:17 +08:00
Elliott Hughes
4b47d9f978 am 4c001859: Merge "Fix declaration of malloc_usable_size()"
* commit '4c001859feeda27727917c5bd00338e90b801742':
  Fix declaration of malloc_usable_size()
2013-06-04 19:00:03 -07:00
Elliott Hughes
4c001859fe Merge "Fix declaration of malloc_usable_size()" 2013-06-05 01:58:26 +00:00
Nick Kralevich
027a8fae77 am 8539961f: Merge "FORTIFY_SOURCE: strcat / strncat optimize"
* commit '8539961ff299b05d8feac9be8b119698be22da03':
  FORTIFY_SOURCE: strcat / strncat optimize
2013-05-31 11:14:56 -07:00
Nick Kralevich
cf870199d5 FORTIFY_SOURCE: strcat / strncat optimize
__strcat_chk and __strncat_chk are slightly inefficient,
because they end up traversing over the same memory region
two times.

This change optimizes __strcat_chk / __strncat_chk so they
only access the memory once. Although I haven't benchmarked these
changes, it should improve the performance of these functions.

__strlen_chk - expose this function, even if -D_FORTIFY_SOURCE
isn't defined. This is needed to compile libc itself without
-D_FORTIFY_SOURCE.

Change-Id: Id2c70dff55a276b47c59db27a03734d659f84b74
2013-05-31 09:07:46 -07:00
David 'Digit' Turner
25a87f7641 Fix declaration of malloc_usable_size()
The function should take a 'const void*' parameter, instead of 'void*'.
Note that the implementation in upstream-dlmalloc/malloc.c already does
this.

For context, see http://b.android.com/55725

Change-Id: Iefd55cdb8996699189e0545f9195972490306227
2013-05-23 10:02:02 +02:00
Elliott Hughes
975d4464ce am 6f502bc7: Merge "Add more __restricts, clean up __format__ attributes."
* commit '6f502bc74374804766639e6b1515644875810bda':
  Add more __restricts, clean up __format__ attributes.
2013-05-14 16:56:49 -07:00
Elliott Hughes
d04c183979 Add more __restricts, clean up __format__ attributes.
Change-Id: I7e2d270cc722d339d221eaea92747eaff3b51403
2013-05-14 16:08:43 -07:00
Elliott Hughes
01678789bc am 5b7b2809: Merge "epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events"
* commit '5b7b2809a2110dad1b2434f1070e13a08085d94b':
  epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events
2013-05-14 14:59:16 -07:00
Elliott Hughes
562804ff87 am f0f4fa3f: Merge "libc: add timerfd calls"
* commit 'f0f4fa3fb1ea8623b1e1bc59f7967e0470c8e532':
  libc: add timerfd calls
2013-05-14 14:59:16 -07:00
Elliott Hughes
3136623600 am e1c58ab5: Merge "libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR"
* commit 'e1c58ab5bb6284b3e3a2d0e54c295a93780b3f70':
  libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR
2013-05-14 14:59:15 -07:00
Elliott Hughes
91cc8014e8 am 7cb82791: Merge "libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM"
* commit '7cb82791cada0283648fedc316171cbffda79af7':
  libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM
2013-05-14 14:59:15 -07:00
Todd Poynor
b0a2fc35d6 epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events
(cherry-pick of d1ad4f6dab06189d4d3dcfa19ae4bc301481eb3f.)

Change-Id: I4a8476bff068951533d4188de94097c8b84bc489
2013-05-14 14:48:43 -07:00
Todd Poynor
4200e6203a libc: add timerfd calls
(cherry-pick of 04c0ac14a49e0969333008a9522b64046d58fbdc.)

Change-Id: I06d0b6c2a8781602362b81f48faf1cca76b9ec05
2013-05-14 14:45:02 -07:00
Todd Poynor
5c4340b2ab libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR
Add CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE, and CLOCK_MONOTONIC_COARSE
as supported by recent linux kernels.

(cherry-pick of 60e5144ca312b210b54ac8e6966108da0c97ff80.)

Bug: 8895727
Change-Id: If79a4d05d1301108f49a37588f9416c4be19277a
2013-05-14 14:43:59 -07:00
Todd Poynor
23b9fd2c1d libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM
(cherry-pick of b928bda83d4413b703329f607e2706602f15293f.)

Change-Id: Ica6aad84299819ffc5e57ae4891e057d2e401fa1
2013-05-14 14:43:09 -07:00
Nick Kralevich
37cd8800d5 am d541ba17: Merge "Use restrict pointers for various libc functions."
* commit 'd541ba17197fd3ef1f60462e51261c4340369218':
  Use restrict pointers for various libc functions.
2013-05-08 13:26:11 -07:00
Nick Kralevich
1c462b7a04 Use restrict pointers for various libc functions.
All the cool kids say this is the best thing since sliced bread.
http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html

For the most part, these changes match what glibc does.

Change-Id: I176268f27f82800162fe5f2515b08d5469ea2dfe
2013-05-07 10:00:21 -07:00
Nick Kralevich
8355ab5524 am bee0ab16: Merge "libc: upgrade strrchr to FORTIFY_SOURCE=2"
* commit 'bee0ab16e47086d2f31f6f9ff41328066d5a7128':
  libc: upgrade strrchr to FORTIFY_SOURCE=2
2013-04-30 16:25:23 -07:00
Nick Kralevich
3b2e6bc9ac libc: upgrade strrchr to FORTIFY_SOURCE=2
Change-Id: I4c34c2ce22c5092c4446dc1ab55f37604c1c223f
2013-04-30 14:19:23 -07:00
Nick Kralevich
2ff94a0964 am c4687130: Merge "libc: upgrade some libc functions to _FORTIFY_SOURCE=2"
* commit 'c46871302e7bd099aaf54d91da93a2248acbf733':
  libc: upgrade some libc functions to _FORTIFY_SOURCE=2
2013-04-30 11:56:08 -07:00
Nick Kralevich
9020fd503c libc: upgrade some libc functions to _FORTIFY_SOURCE=2
Upgrade the following functions:

* vsnprintf
* vsprintf
* snprintf
* fgets
* strcpy
* strcat
* strncat
* strlcpy
* strlcat
* strlen
* strchr

Change-Id: Icc036fc7f0bb317e05f7c051617887a1601271aa
2013-04-30 11:31:35 -07:00
Nick Kralevich
aed0c3ac54 am b94b2851: Merge "libc: upgrade sprintf to _FORTIFY_SOURCE=2"
* commit 'b94b2851d72187cc9095864a9c99429ee62d7786':
  libc: upgrade sprintf to _FORTIFY_SOURCE=2
2013-04-29 16:56:29 -07:00
Nick Kralevich
78d6d9888c libc: upgrade sprintf to _FORTIFY_SOURCE=2
Upgrade sprintf to fortify_source level 2, to catch
additional security bugs.

Change-Id: Ibc957d65e4cb96152de84b3745a04e00fa22659e
2013-04-29 16:41:54 -07:00
Nick Kralevich
56a1b492c4 am 382a7753: Merge "strncpy: implement _FORTIFY_SOURCE=2"
* commit '382a7753786646483a8101f4e337f9e3a82ec852':
  strncpy: implement _FORTIFY_SOURCE=2
2013-04-29 16:25:41 -07:00
Nick Kralevich
1aae9bd170 strncpy: implement _FORTIFY_SOURCE=2
Add support for fortify source level 2 to strncpy.
This will enable detection of more areas where strncpy
is used inappropriately. For example, this would have detected
bug 8727221.

Move the fortify_source tests out of string_test.cpp, and
put it into fortify1_test.cpp.

Create a new fortify2_test.cpp file, which copies all
the tests in fortify1_test.cpp, and adds fortify_source level
2 specific tests.

Change-Id: Ica0fba531cc7d0609e4f23b8176739b13f7f7a83
2013-04-29 15:22:10 -07:00