summaryrefslogtreecommitdiffstats
path: root/libc/include
Commit message (Collapse)AuthorAgeFilesLines
* bionic: revert to a single (larger) property areaGreg Hackmann2013-06-241-5/+1
| | | | | | | | | | | | | | | | d329697 is too complicated. Change the multiple property pages back to a single 128K property area that's mapped in entirely at initialization (the memory will not get allocated until the pages are touched). d329697 has other changes useful for testing (moving property area initialization inside bionic and adding __system_property_set_filename) so undo the change manually rather than with git revert. Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit 5f05348c18286a2cea46eae8acf94ed5b7932fac) Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f
* bionic: reimplement property area as hybrid trie/binary treeGreg Hackmann2013-06-241-11/+1
| | | | | | | | | | | | | | | | See the comments for an explanation of how properties are stored. The trie structure is designed to scale better than the previous array-based implementation. Searching an array with n properties required average O(n) string compares of the entire key; searching the trie requires average O(log n) string compares of each token (substrings between '.' characters). Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit 6ac8e6a46d71a51bec16938efa89f275fa89cf7d) Change-Id: Icbe31908572f33b4d9b85d5b62ac837cbd0f85e0
* bionic: make property area expandableGreg Hackmann2013-06-241-6/+13
| | | | | | | | | | | | | | | | | The property area is initially one 4K region, automatically expanding as needed up to 64 regions. To avoid duplicating code, __system_property_area_init() now allocates and initializes the first region (previously it was allocated in init's init_property_area() and initialized in bionic). For testing purposes, __system_property_set_filename() may be used to override the file used to map in regions. Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit d32969701be070c0161c2643ee3c3df16066bbb8) Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
* libc: enable sprintf FORTIFY_SOURCE under clangNick Kralevich2013-06-241-2/+11
| | | | | | | clang doesn't support __builtin_va_arg_pack(), so we have to use #define instead. Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
* libc: enable FORTIFY_SOURCE clang strlcpyNick Kralevich2013-06-201-2/+2
| | | | Change-Id: Idcfe08f5afc3dde592416df9eba83f64e130c7c2
* Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)"Elliott Hughes2013-06-191-4/+4
|\
| * stdint.h header is not fully compatible with C99(ISO9899:1999)Sergey Melnikov2013-06-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | 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
* | bionic: add __system_property_foreachGreg Hackmann2013-06-181-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | find_nth() will be inefficient on a trie. Since find_nth() is only used internally and only for enumerating properties, we can add a foreach() function to do this directly. Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit 577418403d68e663fb33c7b0c8a90d862d9c00cf) Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f
* | libc: Rename fortify error functions.Nick Kralevich2013-06-182-8/+8
| | | | | | | | | | | | | | | | __umask_error -> __umask_invalid_mode __creat_error -> __creat_missing_mode __too_many_args_error -> __creat_too_many_args Change-Id: I4036f344a3a93628e70f2e948ad73cfed3a967ea
* | libc: add limited FORTIFY_SOURCE support for clangNick Kralevich2013-06-186-17/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 829c089f83ddee37203b52bcb294867a9ae7bdbc, we disabled all FORTIFY_SOURCE support when compiling under clang. At the time, we didn't have proper test cases, and couldn't easily create targeted clang tests. This change re-enables FORTIFY_SOURCE support under clang for a limited set of functions, where we have explicit unittests available. The functions are: * memcpy * memmove * strcpy * strncpy * strcat * strncat * memset * strlen (with modifications) * strchr (with modifications) * strrchr (with modifications) It may be possible, in the future, to enable other functions. However, I need to write unittests first. For strlen, strchr, and strrchr, clang unconditionally calls the fortified version of the relevant function. If it doesn't know the size of the buffer it's dealing with, it passes in ((size_t) -1), which is the largest possible size_t. I added two new clang specific unittest files, primarily copied from fortify?_test.cpp. I've also rebuild the entire system with these changes, and didn't observe any obvious problems. Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa
* | libc: Introduce __errordecl()Nick Kralevich2013-06-185-21/+16
| | | | | | | | | | | | | | | | 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
* | bionic: move system property writing from init to bionicColin Cross2013-06-171-17/+49
|/ | | | | | | | | | | | | | | | | Move the implementation of writing to the system property area from init to bionic, next to the reader implementation. This will allow full property testing to be added to bionic tests. Add new accessor and waiting functions to hide the implementation from watchprops and various bionic users. Also hide some of the implementation details of the property area from init by moving them into _system_properties.h, and other details from everybody by moving them into system_properties.h. (cherry picked from commit dc1038b7900acb664e99643d2974e1a0f4703781) Change-Id: I192d3825ee276c5047bc751039fe6cfe226a7cca
* Ensure that <stdint.h> defines SIZE_MAX and friends.Elliott Hughes2013-06-132-1/+22
| | | | | | | We were missing SIG_ATOMIC_MAX, SIG_ATOMIC_MIN, SIZE_MAX, WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN. Change-Id: I2535f36bc220fbaea009b483599b7af811c4cb5c
* Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."Elliott Hughes2013-06-121-1/+1
| | | | | | | | | | | | | This reverts commit d8627af159c6b1bc40296fb29297c61b30a5a8e2 which caused build breakage: In file included from bionic/libc/include/limits.h:86:0, from bionic/libc/include/stdint.h:33, from bionic/libc/arch-arm/bionic/crtbegin.c:31: bionic/libc/include/sys/limits.h:30:26: fatal error: linux/limits.h: No such file or directory compilation terminated. make: *** [out/target/product/generic/obj/lib/crtbegin_dynamic1.o] Error 1 Change-Id: I128095ecb99df92626e1f57e34c61e08c98a4078
* Add SIZE_MAX to <stdint.h> in a way that might actually work.Elliott Hughes2013-06-121-1/+1
| | | | | | Take two. Change-Id: I7d08b6d14c82a171312a7f5898270b4441d5cfa2
* <stdint.h> should expose SIZE_MAX.Elliott Hughes2013-06-121-0/+1
| | | | Change-Id: Id27222c24955c83f29ad953933cbdc48b6f1e900
* update signal.h to be C90 compatableErik Gilling2013-06-051-3/+3
| | | | | | | | 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>
* Ensure header files using __BEGIN_DECLS include sys/cdefs.h.Elliott Hughes2013-06-055-2/+8
| | | | | | | | | | 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
* sys/personality.h: include <sys/cdefs.h>Kito Cheng2013-06-051-0/+1
| | | | Change-Id: Ia3fa558a38e0cffe5287bc454e85d5d3bdaa6ba1
* Merge "Fix declaration of malloc_usable_size()"Elliott Hughes2013-06-051-1/+1
|\
| * Fix declaration of malloc_usable_size()David 'Digit' Turner2013-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | 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
* | FORTIFY_SOURCE: strcat / strncat optimizeNick Kralevich2013-05-311-2/+1
|/ | | | | | | | | | | | | | | | __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
* Add more __restricts, clean up __format__ attributes.Elliott Hughes2013-05-143-96/+88
| | | | Change-Id: I7e2d270cc722d339d221eaea92747eaff3b51403
* epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT eventsTodd Poynor2013-05-141-0/+3
| | | | | | (cherry-pick of d1ad4f6dab06189d4d3dcfa19ae4bc301481eb3f.) Change-Id: I4a8476bff068951533d4188de94097c8b84bc489
* libc: add timerfd callsTodd Poynor2013-05-141-0/+45
| | | | | | (cherry-pick of 04c0ac14a49e0969333008a9522b64046d58fbdc.) Change-Id: I06d0b6c2a8781602362b81f48faf1cca76b9ec05
* libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HRTodd Poynor2013-05-141-2/+3
| | | | | | | | | | 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
* libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARMTodd Poynor2013-05-141-0/+2
| | | | | | (cherry-pick of b928bda83d4413b703329f607e2706602f15293f.) Change-Id: Ica6aad84299819ffc5e57ae4891e057d2e401fa1
* Use restrict pointers for various libc functions.Nick Kralevich2013-05-071-22/+22
| | | | | | | | | 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
* libc: upgrade strrchr to FORTIFY_SOURCE=2Nick Kralevich2013-04-301-1/+1
| | | | Change-Id: I4c34c2ce22c5092c4446dc1ab55f37604c1c223f
* libc: upgrade some libc functions to _FORTIFY_SOURCE=2Nick Kralevich2013-04-302-13/+11
| | | | | | | | | | | | | | | | | | Upgrade the following functions: * vsnprintf * vsprintf * snprintf * fgets * strcpy * strcat * strncat * strlcpy * strlcat * strlen * strchr Change-Id: Icc036fc7f0bb317e05f7c051617887a1601271aa
* libc: upgrade sprintf to _FORTIFY_SOURCE=2Nick Kralevich2013-04-292-3/+3
| | | | | | | Upgrade sprintf to fortify_source level 2, to catch additional security bugs. Change-Id: Ibc957d65e4cb96152de84b3745a04e00fa22659e
* strncpy: implement _FORTIFY_SOURCE=2Nick Kralevich2013-04-292-1/+14
| | | | | | | | | | | | | | | | 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
* Prevent name conflict for eventfd.cpp and eventfd.s when building libc.aKito Cheng2013-04-031-7/+6
| | | | | | | | | | - eventfd.cpp and eventfd.s will output to the same file when building libc.a out/target/product/*/obj/STATIC_LIBRARIES/libc_intermediates/WHOLE/libc_common_objs/eventfd.o - And then `eventfd` will undefined when statically linked to libc. Also add a unit test. Change-Id: Ib310ade3256712ca617a90539e8eb07459c98505
* Stop generating <sys/linux-syscalls.h>.Elliott Hughes2013-03-221-474/+0
| | | | | | | | | The <asm/unistd.h> files contain the canonical data, and <sys/glibc-syscalls.h> contain new glibc-compatible names, and if you #include the standard <sys/syscall.h> you get both sets of names. Change-Id: I9919c080931c0ba1660f5e37c6a6265ea716d603
* Use the correct names for the __ARM_NR_* syscalls.Elliott Hughes2013-03-221-5/+3
| | | | | | | | This lets us move all the ARM syscall stubs over to the kernel <asm/unistd.h>. Our generated <sys/linux-syscalls.h> is now unused, but I'll remove that in a later change. Change-Id: Ie5ff2cc4abce1938576af7cbaef615a79c7f310d
* Fix builds where _FORTIFY_SOURCE is off.Elliott Hughes2013-03-226-11/+12
| | | | | | | Also add a more intention-revealing guard so we don't have loads of places checking whether our inlining macro is defined. Change-Id: I168860cedcfc798b07a5145bc48a125700265e47
* The SYS_ constants should cover all __NR_ values.Elliott Hughes2013-03-211-459/+1046
| | | | | | | | | | | <sys/linux-syscalls.h> only contains constants for the syscalls we're generating stubs for. We want all the syscalls available on the architecture in question. Keep using <sys/linux-syscalls.h> on ARM for now because the __NR_ARM_set_tls and __NR_ARM_cacheflush values aren't in <asm/unistd.h>. Change-Id: I66683950d87d9b18d6107d0acc0ed238a4496f44
* Don't #define SYS_ constants unless they make sense for the current ↵Elliott Hughes2013-03-211-186/+414
| | | | | | | | | architecture. Fixes the MIPS and x86 builds. strace tests whether syscalls are supported using #ifdef of the appropriate SYS_ constant. Change-Id: I90be118dc42abfdaf5b0f9b1e676e8601f55106e
* Provide glibc-compatible SYS_* aliases for the __NR_* constants.Elliott Hughes2013-03-213-1/+238
| | | | | | This helps us remove another external/strace bionic hack. Change-Id: I3e82c0d2fd27e479be98f096e05b666fd16f8eb3
* Let bionic use the correct definition of ssize_t.Elliott Hughes2013-03-081-6/+2
| | | | | Bug: 8253769 Change-Id: I50c7cc20828fc089b83580e039ce9153a6c5a8cc
* Switch to upstream-freebsd for the unmolested wchar code.Elliott Hughes2013-03-011-0/+5
| | | | Change-Id: I87b4d76ff8da04109ae53638eec4f11629798960
* unistd.h: don't include sys/capability.hNick Kralevich2013-03-011-1/+0
| | | | | | | Don't pull in unnecessary header files. AFAIK, I've fixed all the code which didn't include the correct header files. Change-Id: If0b7bba74e77cb24a0cf9ce8968aa07400855e58
* Avoid changing the C++ ABI with ssize_t.Elliott Hughes2013-02-281-0/+9
| | | | | Bug: 8253769 Change-Id: Ia325003ed6e59da553e2bdde7c43515bc191b8ba
* libc: create sys/capability.hNick Kralevich2013-02-262-3/+43
| | | | | | | | | | Per "man capset", sys/capability.h is the appropriate header file for the capget / capset definition, not unistd.h. Fixed. As a short term hack, continue to include sys/capability.h in unistd.h, until we can fix all the code which uses capget / capset. Change-Id: I6e7cf55955d761ca785a14c5e4b7a44125d8fc15
* Merge "Add the glibc-compatible names to <sys/endian.h>."Elliott Hughes2013-02-221-16/+16
|\
| * Add the glibc-compatible names to <sys/endian.h>.Elliott Hughes2013-02-221-16/+16
| | | | | | | | | | | | | | | | Also remove declarations for functions that don't exist; these are all macros. Bug: http://code.google.com/p/android/issues/detail?id=41769 Change-Id: Ia3774ab2ff7d3c535f83774eac61068f9b11e194
* | Merge "Fix <memory.h> to be a synonym for <string.h> like in glibc."Elliott Hughes2013-02-221-0/+1
|\ \
| * | Fix <memory.h> to be a synonym for <string.h> like in glibc.Elliott Hughes2013-02-221-0/+1
| |/ | | | | | | Change-Id: If23589c5d85dffd28788e04b010303620fa178ca
* | libc: add sys/signal.h for compatibilityNick Kralevich2013-02-221-0/+1
| | | | | | | | | | | | | | Some applications look for sys/signal.h instead of signal.h. Work around those apps. Change-Id: I76ac7744ebc56d196b5f0cb9ed381d32817436b9
* | Stop advertising rindex(3), which is both deprecated and unimplemented.Elliott Hughes2013-02-212-2/+0
| | | | | | | | Change-Id: I3c775d9974e49c3f76a53e46e022659657b89034