summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2003-04-15 03:53:53 +0000
committerDJ Delorie <dj@delorie.com>2003-04-15 03:53:53 +0000
commit72d5763de01fb4f565dc6f4cfc416e1179f9b70b (patch)
tree408d58d2bfb88a074489e7f4d2a1f69c56af4769
parent13da8485b6140ef98cc75cda0f1cce0b0281cea2 (diff)
downloadbinutils-redhat-72d5763de01fb4f565dc6f4cfc416e1179f9b70b.tar.gz
merge from gcc
-rw-r--r--libiberty/ChangeLog4
-rw-r--r--libiberty/argv.c2
-rw-r--r--libiberty/copysign.c8
-rw-r--r--libiberty/memchr.c2
-rw-r--r--libiberty/memcmp.c8
-rw-r--r--libiberty/memcpy.c9
-rw-r--r--libiberty/memmove.c4
-rw-r--r--libiberty/memset.c8
-rw-r--r--libiberty/sigsetmask.c4
-rw-r--r--libiberty/strcasecmp.c2
-rw-r--r--libiberty/strdup.c21
-rw-r--r--libiberty/strncasecmp.c2
-rw-r--r--libiberty/strncmp.c2
-rw-r--r--libiberty/xatexit.c2
-rw-r--r--libiberty/xmalloc.c2
15 files changed, 55 insertions, 25 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 28cb255551..6e9f6937dd 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2003-04-14 Roger Sayle <roger@eyesopen.com>
+
+ * strdup.c (strdup): Tweak implementation to use memcpy.
+
2003-04-14 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* configure.in (HAVE_UINTPTR_T): Always define.
diff --git a/libiberty/argv.c b/libiberty/argv.c
index 4205579a57..e4a03793b6 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA. */
/* Routines imported from standard C runtime libraries. */
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#include <string.h>
diff --git a/libiberty/copysign.c b/libiberty/copysign.c
index 5c48a5422e..d288be239e 100644
--- a/libiberty/copysign.c
+++ b/libiberty/copysign.c
@@ -131,7 +131,9 @@ typedef union
#if defined(__IEEE_BIG_ENDIAN) || defined(__IEEE_LITTLE_ENDIAN)
-double DEFUN(copysign, (x, y), double x AND double y)
+double
+copysign (x, y)
+ double x, y;
{
__ieee_double_shape_type a,b;
b.value = y;
@@ -142,7 +144,9 @@ double DEFUN(copysign, (x, y), double x AND double y)
#else
-double DEFUN(copysign, (x, y), double x AND double y)
+double
+copysign (x, y)
+ double x, y;
{
if ((x < 0 && y > 0) || (x > 0 && y < 0))
return -x;
diff --git a/libiberty/memchr.c b/libiberty/memchr.c
index f94bea018f..3948125963 100644
--- a/libiberty/memchr.c
+++ b/libiberty/memchr.c
@@ -15,7 +15,7 @@ returned.
*/
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
diff --git a/libiberty/memcmp.c b/libiberty/memcmp.c
index d8d3997d06..92f2b6e642 100644
--- a/libiberty/memcmp.c
+++ b/libiberty/memcmp.c
@@ -16,15 +16,17 @@ as if comparing unsigned char arrays.
*/
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
int
-DEFUN(memcmp, (str1, str2, count),
- const PTR str1 AND const PTR str2 AND size_t count)
+memcmp (str1, str2, count)
+ const PTR str1;
+ const PTR str2;
+ size_t count;
{
register const unsigned char *s1 = (const unsigned char*)str1;
register const unsigned char *s2 = (const unsigned char*)str2;
diff --git a/libiberty/memcpy.c b/libiberty/memcpy.c
index 0f2bac7ac2..5eece7a0a0 100644
--- a/libiberty/memcpy.c
+++ b/libiberty/memcpy.c
@@ -13,14 +13,19 @@ Copies @var{length} bytes from memory region @var{in} to region
*/
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
+void bcopy PARAMS((const void*, void*, size_t));
+
PTR
-DEFUN(memcpy, (out, in, length), PTR out AND const PTR in AND size_t length)
+memcpy (out, in, length)
+ PTR out;
+ const PTR in;
+ size_t length;
{
bcopy(in, out, length);
return out;
diff --git a/libiberty/memmove.c b/libiberty/memmove.c
index 3ec73208ca..00ac053401 100644
--- a/libiberty/memmove.c
+++ b/libiberty/memmove.c
@@ -13,12 +13,14 @@ Copies @var{count} bytes from memory area @var{from} to memory area
*/
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
+void bcopy PARAMS ((const void*, void*, size_t));
+
PTR
memmove (s1, s2, n)
PTR s1;
diff --git a/libiberty/memset.c b/libiberty/memset.c
index 489ca17481..5119f858ad 100644
--- a/libiberty/memset.c
+++ b/libiberty/memset.c
@@ -13,15 +13,17 @@ Sets the first @var{count} bytes of @var{s} to the constant byte
*/
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
#endif
PTR
-DEFUN(memset, (dest, val, len),
- PTR dest AND register int val AND register size_t len)
+memset (dest, val, len)
+ PTR dest;
+ register int val;
+ register size_t len;
{
register unsigned char *ptr = (unsigned char*)dest;
while (len-- > 0)
diff --git a/libiberty/sigsetmask.c b/libiberty/sigsetmask.c
index f705fbb2df..4de3e4b1eb 100644
--- a/libiberty/sigsetmask.c
+++ b/libiberty/sigsetmask.c
@@ -25,8 +25,8 @@ extern void abort PARAMS ((void)) ATTRIBUTE_NORETURN;
#ifdef SIG_SETMASK
int
-DEFUN(sigsetmask,(set),
- int set)
+sigsetmask (set)
+ int set;
{
sigset_t new;
sigset_t old;
diff --git a/libiberty/strcasecmp.c b/libiberty/strcasecmp.c
index 4bfe650771..d2608dc0b8 100644
--- a/libiberty/strcasecmp.c
+++ b/libiberty/strcasecmp.c
@@ -25,7 +25,7 @@ static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
diff --git a/libiberty/strdup.c b/libiberty/strdup.c
index 49233ba7aa..071a4a401a 100644
--- a/libiberty/strdup.c
+++ b/libiberty/strdup.c
@@ -9,13 +9,24 @@ Returns a pointer to a copy of @var{s} in memory obtained from
*/
+#include <ansidecl.h>
+#ifdef ANSI_PROTOTYPES
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+extern size_t strlen PARAMS ((const char*));
+extern PTR malloc PARAMS ((size_t));
+extern PTR memcpy PARAMS ((PTR, const PTR, size_t));
+
char *
strdup(s)
char *s;
{
- char *result = (char*)malloc(strlen(s) + 1);
- if (result == (char*)0)
- return (char*)0;
- strcpy(result, s);
- return result;
+ size_t len = strlen (s) + 1;
+ char *result = (char*) malloc (len);
+ if (result == (char*) 0)
+ return (char*) 0;
+ return (char*) memcpy (result, s, len);
}
diff --git a/libiberty/strncasecmp.c b/libiberty/strncasecmp.c
index 77cb421770..10feee8219 100644
--- a/libiberty/strncasecmp.c
+++ b/libiberty/strncasecmp.c
@@ -25,7 +25,7 @@ static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
diff --git a/libiberty/strncmp.c b/libiberty/strncmp.c
index 819cea6cb5..ad87e1fde8 100644
--- a/libiberty/strncmp.c
+++ b/libiberty/strncmp.c
@@ -13,7 +13,7 @@ Compares the first @var{n} bytes of two strings, returning a value as
*/
#include <ansidecl.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
diff --git a/libiberty/xatexit.c b/libiberty/xatexit.c
index abf340737e..075599c61f 100644
--- a/libiberty/xatexit.c
+++ b/libiberty/xatexit.c
@@ -27,7 +27,7 @@ failure. If you use @code{xatexit} to register functions, you must use
#include <stdio.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index 4c8249ae70..c3fe1a84f4 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -68,7 +68,7 @@ function will be called to print an error message and terminate execution.
#include <stdio.h>
-#ifdef __STDC__
+#ifdef ANSI_PROTOTYPES
#include <stddef.h>
#else
#define size_t unsigned long