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
This commit is contained in:
Nick Kralevich
2013-08-28 13:22:52 -07:00
parent eb8f36223e
commit bd8e6749b7
2 changed files with 13 additions and 4 deletions

View File

@@ -526,6 +526,14 @@
#define __BIONIC__ 1
#include <android/api-level.h>
/*
* When _FORTIFY_SOURCE is defined, automatic bounds checking is
* added to commonly used libc functions. If a buffer overrun is
* detected, the program is safely aborted.
*
* See
* http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html for details.
*/
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
#define __BIONIC_FORTIFY 1
#if _FORTIFY_SOURCE == 2
@@ -533,6 +541,7 @@
#else
#define __bos(s) __builtin_object_size((s), 0)
#endif
#define __bos0(s) __builtin_object_size((s), 0)
#define __BIONIC_FORTIFY_INLINE \
extern inline \