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
diff --git a/libc/include/string.h b/libc/include/string.h
index 5409391..f6b4acf 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -94,8 +94,8 @@
 void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amount) {
     char *d = (char *) dest;
     const char *s = (const char *) src;
-    size_t s_len = __builtin_object_size(s, 0);
-    size_t d_len = __builtin_object_size(d, 0);
+    size_t s_len = __bos0(s);
+    size_t d_len = __bos0(d);
 
     if (__builtin_constant_p(copy_amount) && (copy_amount > d_len)) {
         __memcpy_dest_size_error();
@@ -110,7 +110,7 @@
 
 __BIONIC_FORTIFY_INLINE
 void* memmove(void *dest, const void *src, size_t len) {
-    return __builtin___memmove_chk(dest, src, len, __builtin_object_size (dest, 0));
+    return __builtin___memmove_chk(dest, src, len, __bos0(dest));
 }
 
 __BIONIC_FORTIFY_INLINE
@@ -153,7 +153,7 @@
 
 __BIONIC_FORTIFY_INLINE
 void* memset(void *s, int c, size_t n) {
-    return __builtin___memset_chk(s, c, n, __builtin_object_size (s, 0));
+    return __builtin___memset_chk(s, c, n, __bos0(s));
 }
 
 extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t)
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index a4c1aff..175c28b 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -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 \