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

@@ -94,8 +94,8 @@ __BIONIC_FORTIFY_INLINE
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 @@ void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amou
__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 @@ char *strncat(char* __restrict dest, const char* __restrict src, size_t n) {
__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)