summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/canonicalize.c6
-rw-r--r--stdlib/msort.c31
-rw-r--r--stdlib/random_r.c4
-rw-r--r--stdlib/strfmon.c14
-rw-r--r--stdlib/strtod.c10
-rw-r--r--stdlib/strtol.c5
-rw-r--r--stdlib/test-canon.c2
7 files changed, 42 insertions, 30 deletions
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index 356c619b5d..554e1b2cba 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -93,7 +93,7 @@ canonicalize (const char *name, char *resolved)
{
if (resolved)
{
- errno = ENAMETOOLONG;
+ __set_errno (ENAMETOOLONG);
goto error;
}
new_size = rpath_limit - rpath;
@@ -120,7 +120,7 @@ canonicalize (const char *name, char *resolved)
if (++num_links > MAXSYMLINKS)
{
- errno = ELOOP;
+ __set_errno (ELOOP);
goto error;
}
@@ -134,7 +134,7 @@ canonicalize (const char *name, char *resolved)
if ((long int) (n + strlen (end)) >= path_max)
{
- errno = ENAMETOOLONG;
+ __set_errno (ENAMETOOLONG);
goto error;
}
diff --git a/stdlib/msort.c b/stdlib/msort.c
index e2834ce6ca..7b36df41f3 100644
--- a/stdlib/msort.c
+++ b/stdlib/msort.c
@@ -1,5 +1,5 @@
/* msort -- an alternative to qsort, with an identical interface.
- Copyright (C) 1992, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
Written by Mike Haertel, September 1988.
This file is part of the GNU C Library.
@@ -19,15 +19,21 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stdlib.h>
#include <string.h>
#include <memcopy.h>
#include <errno.h>
+static void msort_with_tmp __P ((void *b, size_t n, size_t s,
+ __compar_fn_t cmp, char *t));
+
static void
-DEFUN(msort_with_tmp, (b, n, s, cmp, t),
- PTR b AND size_t n AND size_t s AND __compar_fn_t cmp AND char *t)
+msort_with_tmp (b, n, s, cmp, t)
+ void *b;
+ size_t n;
+ size_t s;
+ __compar_fn_t cmp;
+ char *t;
{
char *tmp;
char *b1, *b2;
@@ -84,10 +90,13 @@ DEFUN(msort_with_tmp, (b, n, s, cmp, t),
}
void
-DEFUN(qsort, (b, n, s, cmp),
- PTR b AND size_t n AND size_t s AND __compar_fn_t cmp)
+qsort (b, n, s, cmp)
+ void *b;
+ size_t n;
+ size_t s;
+ __compar_fn_t cmp;
{
- CONST size_t size = n * s;
+ const size_t size = n * s;
if (size < 1024)
/* The temporary array is small, so put it on the stack. */
@@ -101,9 +110,9 @@ DEFUN(qsort, (b, n, s, cmp),
{
/* Couldn't get space, so use the slower algorithm
that doesn't need a temporary array. */
- extern void EXFUN(_quicksort, (PTR __base,
- size_t __nmemb, size_t __size,
- __compar_fn_t __compar));
+ extern void _quicksort __P ((void *__base,
+ size_t __nmemb, size_t __size,
+ __compar_fn_t __compar));
_quicksort (b, n, s, cmp);
}
else
@@ -111,6 +120,6 @@ DEFUN(qsort, (b, n, s, cmp),
msort_with_tmp (b, n, s, cmp, tmp);
free (tmp);
}
- errno = save;
+ __set_errno (save);
}
}
diff --git a/stdlib/random_r.c b/stdlib/random_r.c
index f2fe923143..8c516780cd 100644
--- a/stdlib/random_r.c
+++ b/stdlib/random_r.c
@@ -185,7 +185,7 @@ __initstate_r (seed, arg_state, n, buf)
{
if (n < BREAK_0)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
buf->rand_type = TYPE_0;
@@ -271,7 +271,7 @@ __setstate_r (arg_state, buf)
break;
default:
/* State info munged. */
- errno = EINVAL;
+ __set_errno (EINVAL);
return -1;
}
diff --git a/stdlib/strfmon.c b/stdlib/strfmon.c
index 3b8c7d602a..99408c7484 100644
--- a/stdlib/strfmon.c
+++ b/stdlib/strfmon.c
@@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA. */
do { \
if (dest >= s + maxsize - 1) \
{ \
- errno = E2BIG; \
+ __set_errno (E2BIG); \
va_end (ap); \
return -1; \
} \
@@ -158,7 +158,7 @@ strfmon (char *s, size_t maxsize, const char *format, ...)
case '+': /* Use +/- for sign of number. */
if (n_sign_posn != -1)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
va_end (ap);
return -1;
}
@@ -174,7 +174,7 @@ strfmon (char *s, size_t maxsize, const char *format, ...)
case '(': /* Use ( ) for negative sign. */
if (n_sign_posn != -1)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
va_end (ap);
return -1;
}
@@ -207,7 +207,7 @@ strfmon (char *s, size_t maxsize, const char *format, ...)
can stop now and return an error. */
if (dest + width >= s + maxsize)
{
- errno = E2BIG;
+ __set_errno (E2BIG);
va_end (ap);
return -1;
}
@@ -218,7 +218,7 @@ strfmon (char *s, size_t maxsize, const char *format, ...)
{
if (!isdigit (*++fmt))
{
- errno = EINVAL;
+ __set_errno (EINVAL);
va_end (ap);
return -1;
}
@@ -236,7 +236,7 @@ strfmon (char *s, size_t maxsize, const char *format, ...)
{
if (!isdigit (*++fmt))
{
- errno = EINVAL;
+ __set_errno (EINVAL);
va_end (ap);
return -1;
}
@@ -276,7 +276,7 @@ strfmon (char *s, size_t maxsize, const char *format, ...)
right_prec = *_NL_CURRENT (LC_MONETARY, FRAC_DIGITS);
break;
default: /* Any unrecognized format is an error. */
- errno = EINVAL;
+ __set_errno (EINVAL);
va_end (ap);
return -1;
}
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 66d6726a30..b47d5edb8f 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -151,7 +151,7 @@ round_and_return (mp_limb_t *retval, int exponent, int negative,
if (shift > MANT_DIG)
{
- errno = EDOM;
+ __set_errno (EDOM);
return 0.0;
}
@@ -563,7 +563,7 @@ INTERNAL (STRTOF) (nptr, endptr, group)
FLOAT retval;
/* Overflow or underflow. */
- errno = ERANGE;
+ __set_errno (ERANGE);
retval = (exp_negative ? 0.0 :
negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL);
@@ -631,13 +631,13 @@ INTERNAL (STRTOF) (nptr, endptr, group)
if (int_no + exponent > MAX_10_EXP + 1)
{
- errno = ERANGE;
+ __set_errno (ERANGE);
return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL;
}
if (exponent < MIN_10_EXP - (DIG + 1))
{
- errno = ERANGE;
+ __set_errno (ERANGE);
return 0.0;
}
@@ -694,7 +694,7 @@ INTERNAL (STRTOF) (nptr, endptr, group)
Check it against the maximum possible exponent. */
if (bits > MAX_EXP)
{
- errno = ERANGE;
+ __set_errno (ERANGE);
return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL;
}
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index 1481d3388e..5543ab94d1 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -31,6 +31,9 @@ Cambridge, MA 02139, USA. */
#ifndef errno
extern int errno;
#endif
+#ifndef __set_errno
+# define __set_errno(val) errno = (val)
+#endif
#ifdef HAVE_LIMITS_H
# include <limits.h>
@@ -309,7 +312,7 @@ INTERNAL (strtol) (nptr, endptr, base, group)
if (overflow)
{
- errno = ERANGE;
+ __set_errno (ERANGE);
#if UNSIGNED
return ULONG_MAX;
#else
diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c
index 8d04bb6ba0..f41106716a 100644
--- a/stdlib/test-canon.c
+++ b/stdlib/test-canon.c
@@ -148,7 +148,7 @@ main (int argc, char ** argv)
if (!tests[i].out && errno != tests[i].error)
{
printf ("%s: flunked test %d (expected errno %d, got %d)\n",
- argv[0], i, tests[i].errno, error);
+ argv[0], i, tests[i].errno, errno);
++errors;
continue;
}