diff options
author | DJ Delorie <dj@redhat.com> | 2005-04-03 04:41:10 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2005-04-03 04:41:10 +0000 |
commit | 14a88c496bef288d66f245d1d07c7bfa7f6062fb (patch) | |
tree | ad4d2c6176db68eb7d06ff8fb67d55395c581e49 /libiberty | |
parent | 26dae57f146e8b7d546a90c4317389281eb879e7 (diff) | |
download | fsf-binutils-gdb-14a88c496bef288d66f245d1d07c7bfa7f6062fb.zip fsf-binutils-gdb-14a88c496bef288d66f245d1d07c7bfa7f6062fb.tar.gz fsf-binutils-gdb-14a88c496bef288d66f245d1d07c7bfa7f6062fb.tar.bz2 |
merge from gcc
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 4 | ||||
-rw-r--r-- | libiberty/bcmp.c | 17 | ||||
-rw-r--r-- | libiberty/bcopy.c | 18 | ||||
-rw-r--r-- | libiberty/bzero.c | 10 |
4 files changed, 26 insertions, 23 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 3099668..6e9bf11 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,5 +1,9 @@ 2005-04-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + * bcmp.c: Fix warnings and implement using memcmp. + * bcopy.c: Fix warnings. + * bzero.c: Fix warnings and implement using memset. + * configure.ac (ac_libiberty_warn_cflags): Add -Wwrite-strings -Wstrict-prototypes. * configure, config.in: Regenerate. diff --git a/libiberty/bcmp.c b/libiberty/bcmp.c index 1bd2816..c639f98 100644 --- a/libiberty/bcmp.c +++ b/libiberty/bcmp.c @@ -15,20 +15,13 @@ result mean @var{x} sorts before @var{y}). */ +#include <stddef.h> + +extern int memcmp(const void *, const void *, size_t); int -bcmp (char *from, char *to, int count) +bcmp (const void *s1, const void *s2, size_t count) { - int rtnval = 0; - - while (count-- > 0) - { - if (*from++ != *to++) - { - rtnval = 1; - break; - } - } - return (rtnval); + return memcmp (s1, s2, count); } diff --git a/libiberty/bcopy.c b/libiberty/bcopy.c index 0944247..1e2eca9 100644 --- a/libiberty/bcopy.c +++ b/libiberty/bcopy.c @@ -9,17 +9,23 @@ Copies @var{length} bytes from memory region @var{in} to region */ +#include <stddef.h> + void -bcopy (register char *src, register char *dest, int len) +bcopy (const void *src, void *dest, size_t len) { if (dest < src) - while (len--) - *dest++ = *src++; + { + const char *firsts = src; + char *firstd = dest; + while (len--) + *firstd++ = *firsts++; + } else { - char *lasts = src + (len-1); - char *lastd = dest + (len-1); + const char *lasts = (const char *)src + (len-1); + char *lastd = (char *)dest + (len-1); while (len--) - *(char *)lastd-- = *(char *)lasts--; + *lastd-- = *lasts--; } } diff --git a/libiberty/bzero.c b/libiberty/bzero.c index 1f52d2d..44ad73d 100644 --- a/libiberty/bzero.c +++ b/libiberty/bzero.c @@ -12,12 +12,12 @@ is deprecated in favor of @code{memset}. */ +#include <stddef.h> + +extern void *memset(void *, int, size_t); void -bzero (char *to, int count) +bzero (void *to, size_t count) { - while (count-- > 0) - { - *to++ = 0; - } + memset (to, 0, count); } |