From 890c8ed6ef773160cd6840a92e0d469fe530871f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 22 Mar 2013 10:58:55 -0700 Subject: [PATCH] Fix builds where _FORTIFY_SOURCE is off. 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 --- libc/include/fcntl.h | 4 ++-- libc/include/stdio.h | 4 ++-- libc/include/string.h | 4 ++-- libc/include/strings.h | 4 ++-- libc/include/sys/cdefs.h | 3 ++- libc/include/sys/stat.h | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index 7ab720542..de2e3e354 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -49,7 +49,7 @@ extern int unlinkat(int dirfd, const char *pathname, int flags); extern int fcntl(int fd, int command, ...); extern int creat(const char* path, mode_t mode); -#if defined(__BIONIC_FORTIFY_INLINE) +#if defined(__BIONIC_FORTIFY) extern void __creat_error() __attribute__((__error__ ("called with O_CREAT, but missing mode"))); @@ -101,7 +101,7 @@ int openat(int dirfd, const char *pathname, int flags, ...) { return __openat_real(dirfd, pathname, flags, __builtin_va_arg_pack()); } -#endif /* defined(__BIONIC_FORTIFY_INLINE) */ +#endif /* defined(__BIONIC_FORTIFY) */ __END_DECLS diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 62882dba7..fdf747d1f 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -457,7 +457,7 @@ int vfdprintf(int, const char*, __va_list) __END_DECLS #endif /* _GNU_SOURCE */ -#if defined(__BIONIC_FORTIFY_INLINE) +#if defined(__BIONIC_FORTIFY) __BEGIN_DECLS @@ -538,6 +538,6 @@ char *fgets(char *dest, int size, FILE *stream) __END_DECLS -#endif /* defined(__BIONIC_FORTIFY_INLINE) */ +#endif /* defined(__BIONIC_FORTIFY) */ #endif /* _STDIO_H_ */ diff --git a/libc/include/string.h b/libc/include/string.h index 63e768eb7..56d89a4b8 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -84,7 +84,7 @@ extern char* strsignal(int sig); extern int strcoll(const char *, const char *) __purefunc; extern size_t strxfrm(char *, const char *, size_t); -#if defined(__BIONIC_FORTIFY_INLINE) +#if defined(__BIONIC_FORTIFY) extern void __memcpy_dest_size_error() __attribute__((__error__("memcpy called with size bigger than destination"))); @@ -258,7 +258,7 @@ char* strrchr(const char *s, int c) { } -#endif /* defined(__BIONIC_FORTIFY_INLINE) */ +#endif /* defined(__BIONIC_FORTIFY) */ __END_DECLS diff --git a/libc/include/strings.h b/libc/include/strings.h index 0ee691dec..e72798b66 100644 --- a/libc/include/strings.h +++ b/libc/include/strings.h @@ -50,12 +50,12 @@ char *index(const char *, int); int strcasecmp(const char *, const char *); int strncasecmp(const char *, const char *, size_t); -#if defined(__BIONIC_FORTIFY_INLINE) +#if defined(__BIONIC_FORTIFY) __BIONIC_FORTIFY_INLINE void bzero (void *s, size_t n) { __builtin___memset_chk(s, '\0', n, __builtin_object_size (s, 0)); } -#endif /* defined(__BIONIC_FORTIFY_INLINE) */ +#endif /* defined(__BIONIC_FORTIFY) */ __END_DECLS diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index 3617aba53..1976d6ac2 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -516,13 +516,14 @@ #include #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && !defined(__clang__) +#define __BIONIC_FORTIFY 1 #define __BIONIC_FORTIFY_INLINE \ extern inline \ __attribute__ ((always_inline)) \ __attribute__ ((gnu_inline)) \ __attribute__ ((artificial)) -#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1) #endif +#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1) /* Android-added: for FreeBSD's libm. */ #define __weak_reference(sym,alias) \ diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 05b221fb7..4e8beb6a5 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -129,7 +129,7 @@ extern int lstat(const char *, struct stat *); extern int mknod(const char *, mode_t, dev_t); extern mode_t umask(mode_t); -#if defined(__BIONIC_FORTIFY_INLINE) +#if defined(__BIONIC_FORTIFY) extern mode_t __umask_chk(mode_t); extern mode_t __umask_real(mode_t) @@ -147,7 +147,7 @@ mode_t umask(mode_t mode) { } return __umask_chk(mode); } -#endif /* defined(__BIONIC_FORTIFY_INLINE) */ +#endif /* defined(__BIONIC_FORTIFY) */ #define stat64 stat