platform_bionic/libc/include/sys
George Burgess IV bd3d2088d9 libc: add const-correct string.h overloads
libcxx provides const-correct overloads for a few string.h functions.
These overloads use clang's enable_if attribute, so they're preferred
over our FORTIFY'ed equivalents.

This weakens _FORTIFY_SOURCE=2 when used with some of these functions,
since clang needs to see __pass_object_size in order to pass an accurate
result for __builtin_object_size(s, 1) at a callsite. Since those
functions don't have __pass_object_size on their params, clang can't do
that. This makes LLVM lower the __builtin_object_size calls, which means
we get the same result as __builtin_object_size(s, 0).

We have to provide all of the overloads in Bionic, since enable_if is
only used to disambiguate overloads with (otherwise) the same type. In
other words:

// overload 1
char *strchr(const char *, int s) __attribute__((enable_if(1, "")));
// overload 2
char *strchr(char *, int s);

void foo() {
  char cs[1] = {};
  strchr(static_cast<const char *>(cs), '\0'); // calls overload #1.
  strchr(cs, '\0'); // calls overload #2.
}

Bug: 34747525
Test: m checkbuild on bullhead internal master + AOSP. vts -m
BionicUnitTests passes on both. Surprisingly, the only code that this
seems to break is contained in Bionic.

Change-Id: Ie406f42fb3d1c5bf940dc857889876fc39b57c90
2017-04-05 13:17:07 -07:00
..
_system_properties.h Hide internal __system_property_* functions 2017-02-23 14:20:13 -08:00
auxv.h Update header versions for NDK platform fixes. 2016-06-02 13:40:35 -07:00
cachectl.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
capability.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
cdefs.h libc: add const-correct string.h overloads 2017-04-05 13:17:07 -07:00
endian.h Rename __pure, __pure2, and __purefunc. 2016-09-28 12:36:38 -07:00
epoll.h Use <linux/eventpoll.h> to implement <sys/epoll.h>. 2017-02-23 17:26:24 -08:00
errno.h auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
eventfd.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
fcntl.h libc: Add sys/fcntl.h for compatibility. 2015-07-08 15:07:17 -06:00
file.h POSIX says flock is in <sys/file.h>, not <unistd.h>. 2015-02-17 09:08:24 -08:00
fsuid.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
inotify.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
ioctl.h Remove <sys/ioctl_compat.h>. 2016-05-02 12:53:00 -07:00
ipc.h glibc ipc64_perm __key compatibility. 2017-01-27 19:12:32 -08:00
klog.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
limits.h Clean up <sys/limits.h> a bit. 2016-11-30 09:06:53 -08:00
mman.h Only rename mmap to mmap64 if we're L or newer. 2017-03-20 12:57:13 -07:00
mount.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
msg.h Flesh out <sys/msg.h>, <sys/sem.h>, <sys/shm.h>. 2016-08-18 15:23:38 -07:00
param.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
personality.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
poll.h auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
prctl.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
procfs.h Fix x86 gdbserver build. 2015-06-24 17:31:24 -07:00
ptrace.h Fixes for building gdbserver (and gdb) out of the box. 2015-06-16 16:04:35 -07:00
queue.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
quota.h Add __INTRODUCED_IN_FUTURE for unreleased APIs. 2016-04-29 16:39:50 -07:00
reboot.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
reg.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
resource.h Fix getpriority/setpriority types. 2016-11-29 15:14:11 -08:00
select.h Add and use constants for the Android API levels. 2016-11-16 16:55:42 -08:00
sem.h Flesh out <sys/msg.h>, <sys/sem.h>, <sys/shm.h>. 2016-08-18 15:23:38 -07:00
sendfile.h Only rename sendfile to sendfile64 if we're L or newer. 2017-03-17 18:50:12 -07:00
shm.h Flesh out <sys/msg.h>, <sys/sem.h>, <sys/shm.h>. 2016-08-18 15:23:38 -07:00
signal.h libc: add sys/signal.h for compatibility 2013-02-22 10:38:28 -08:00
signalfd.h versioner: refactor to use CompilerInstance directly. 2016-11-09 13:50:07 -08:00
socket.h add fortified implementations of send/sendto 2017-02-14 15:50:28 -08:00
stat.h libc: add clang FORTIFY support 2017-02-09 15:49:32 -08:00
statfs.h auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
statvfs.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
swap.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
syscall.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
sysconf.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
sysinfo.h Add versioning information to symbols. 2016-04-29 16:39:50 -07:00
syslog.h Add all the glibc one-line "synonym" header files. 2015-07-17 13:59:36 -07:00
sysmacros.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
system_properties.h Hide internal __system_property_* functions 2017-02-23 14:20:13 -08:00
time.h Update symbol versions. 2016-06-10 17:50:14 -07:00
timerfd.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
times.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
timex.h Add versioning information to symbols. 2016-04-29 16:39:50 -07:00
ttydefaults.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
types.h Fix an obsolete comment. 2016-12-14 12:43:30 -08:00
ucontext.h versioner: refactor to use CompilerInstance directly. 2016-11-09 13:50:07 -08:00
uio.h Correct the return types of readv and writev. 2016-11-29 14:26:15 -08:00
un.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00
unistd.h Add all the glibc one-line "synonym" header files. 2015-07-17 13:59:36 -07:00
user.h Fix instances of '#if __i386__'. 2016-09-15 14:21:28 -07:00
utsname.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
vfs.h Remove unnecessary 'extern's. 2016-07-22 18:57:12 -07:00
vt.h Add all the glibc one-line "synonym" header files. 2015-07-17 13:59:36 -07:00
wait.h Add and use constants for the Android API levels. 2016-11-16 16:55:42 -08:00
xattr.h Always include <sys/cdefs.h>. 2016-07-22 17:01:54 -07:00