Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/__atexit.c4
-rw-r--r--newlib/libc/stdlib/__call_atexit.c4
-rw-r--r--newlib/libc/stdlib/a64l.c55
-rw-r--r--newlib/libc/stdlib/assert.c2
-rw-r--r--newlib/libc/stdlib/efgcvt.c2
-rw-r--r--newlib/libc/stdlib/envlock.c2
-rw-r--r--newlib/libc/stdlib/getopt.c503
-rw-r--r--newlib/libc/stdlib/ldtoa.c32
-rw-r--r--newlib/libc/stdlib/mallocr.c20
-rw-r--r--newlib/libc/stdlib/mlock.c2
-rw-r--r--newlib/libc/stdlib/mstats.c2
-rw-r--r--newlib/libc/stdlib/rand.c4
-rw-r--r--newlib/libc/stdlib/rand48.c2
13 files changed, 152 insertions, 482 deletions
diff --git a/newlib/libc/stdlib/__atexit.c b/newlib/libc/stdlib/__atexit.c
index 49eebb37e..04f494738 100644
--- a/newlib/libc/stdlib/__atexit.c
+++ b/newlib/libc/stdlib/__atexit.c
@@ -35,9 +35,6 @@ _DEFUN (__register_exitproc,
_GLOBAL_REENT->_atexit = p = &_GLOBAL_REENT->_atexit0;
if (p->_ind >= _ATEXIT_SIZE)
{
-#ifndef _ATEXIT_DYNAMIC_ALLOC
- return -1;
-#else
p = (struct _atexit *) malloc (sizeof *p);
if (p == NULL)
{
@@ -53,7 +50,6 @@ _DEFUN (__register_exitproc,
p->_on_exit_args._fntypes = 0;
p->_on_exit_args._is_cxa = 0;
#endif
-#endif
}
if (type != __et_atexit)
diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c
index 6fa398ae2..cea569ff4 100644
--- a/newlib/libc/stdlib/__call_atexit.c
+++ b/newlib/libc/stdlib/__call_atexit.c
@@ -61,9 +61,6 @@ _DEFUN (__call_exitprocs, (code, d),
(*((void (*)(_PTR)) fn))(args->_fnargs[n]);
}
-#ifndef _ATEXIT_DYNAMIC_ALLOC
- break;
-#else
/* Move to the next block. Free empty blocks except the last one,
which is part of _GLOBAL_REENT. */
if (p->_ind == 0 && p->_next)
@@ -82,6 +79,5 @@ _DEFUN (__call_exitprocs, (code, d),
lastp = &p->_next;
p = p->_next;
}
-#endif
}
}
diff --git a/newlib/libc/stdlib/a64l.c b/newlib/libc/stdlib/a64l.c
index 42fc2d2fa..93c8e834b 100644
--- a/newlib/libc/stdlib/a64l.c
+++ b/newlib/libc/stdlib/a64l.c
@@ -1,6 +1,6 @@
/*
FUNCTION
-<<a64l>>, <<l64a>>---convert between radix-64 ASCII string and long
+<<a64l>>,<<l64a>>---convert between radix-64 ascii string and long
INDEX
a64l
@@ -21,36 +21,31 @@ TRAD_SYNOPSIS
long <[input]>;
DESCRIPTION
-Conversion is performed between long and radix-64 characters. The
-<<l64a>> routine transforms up to 32 bits of input value starting from
-least significant bits to the most significant bits. The input value
-is split up into a maximum of 5 groups of 6 bits and possibly one
-group of 2 bits (bits 31 and 30).
-
-Each group of 6 bits forms a value from 0--63 which is translated into
-a character as follows:
-
-O+
-o 0 = '.'
-o 1 = '/'
-o 2--11 = '0' to '9'
-o 12--37 = 'A' to 'Z'
-o 38--63 = 'a' to 'z'
-O-
-
-When the remaining bits are zero or all bits have been translated, a
-null terminator is appended to the string. An input value of 0
-results in the empty string.
-
-The <<a64l>> function performs the reverse translation. Each
-character is used to generate a 6-bit value for up to 30 bits and then
-a 2-bit value to complete a 32-bit result. The null terminator means
-that the remaining digits are 0. An empty input string or NULL string
-results in 0L. An invalid string results in undefined behavior. If
-the size of a long is greater than 32 bits, the result is sign-extended.
-
+Conversion is performed between long and radix-64 characters. The <<l64a>> routine
+transforms up to 32-bits of input value starting from least significant bits to
+the most significant bits. The input value is split up into a maximum of 5
+groups of 6-bits and possibly one group of 2 bits (bits 31 and 30).
+
+Each group of 6 bits forms a value from 0-63 which is translated into a character
+as follows:
+
+ 0 = '.'
+ 1 = '/'
+ 2-11 = '0' to '9'
+ 12-37 = 'A' to 'Z'
+ 38-63 = 'a' to 'z'
+
+When remaining bits are zero or all bits have been translated, a nul terminator
+is appended to the string. An input value of 0 results in the empty string.
+
+The <<a64l>> performs the reverse translation. Each character is used to generate
+a 6-bit value for up to 30 bits and then a 2-bit value to complete a 32-bit result.
+The nul terminator means that the remaining digits are 0. An empty input string or
+NULL string results in 0L. An invalid string results in undefined behavior.
+If the size of a long is > 32 bits, the result is sign-extended.
+
RETURNS
-<<l64a>> returns a null-terminated string of 0 to 6 characters.
+<<l64a>> returns a nul-terminated string of 0 to 6 characters.
<<a64l>> returns the 32-bit translated value from the input character string.
PORTABILITY
diff --git a/newlib/libc/stdlib/assert.c b/newlib/libc/stdlib/assert.c
index c9887da5c..5b08bbaf4 100644
--- a/newlib/libc/stdlib/assert.c
+++ b/newlib/libc/stdlib/assert.c
@@ -1,6 +1,6 @@
/*
FUNCTION
-<<assert>>---macro for debugging diagnostics
+<<assert>>---Macro for Debugging Diagnostics
INDEX
assert
diff --git a/newlib/libc/stdlib/efgcvt.c b/newlib/libc/stdlib/efgcvt.c
index 9aa3b2fe7..556d22414 100644
--- a/newlib/libc/stdlib/efgcvt.c
+++ b/newlib/libc/stdlib/efgcvt.c
@@ -1,6 +1,6 @@
/*
FUNCTION
-<<ecvt>>, <<ecvtf>>, <<fcvt>>, <<fcvtf>>---double or float to string
+<<ecvt>>,<<ecvtf>>,<<fcvt>>,<<fcvtf>>---double or float to string
INDEX
ecvt
diff --git a/newlib/libc/stdlib/envlock.c b/newlib/libc/stdlib/envlock.c
index 74c85a8f5..24d0083be 100644
--- a/newlib/libc/stdlib/envlock.c
+++ b/newlib/libc/stdlib/envlock.c
@@ -1,6 +1,6 @@
/*
FUNCTION
-<<__env_lock>>, <<__env_unlock>>---lock environ variable
+<<__env_lock>>, <<__env_unlock>>--lock environ variable
INDEX
__env_lock
diff --git a/newlib/libc/stdlib/getopt.c b/newlib/libc/stdlib/getopt.c
index 10002ed6b..b38938d5f 100644
--- a/newlib/libc/stdlib/getopt.c
+++ b/newlib/libc/stdlib/getopt.c
@@ -1,406 +1,117 @@
-/****************************************************************************
+/*
+ * Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+/* static char sccsid[] = "from: @(#)getopt.c 8.2 (Berkeley) 4/2/94"; */
+static char *rcsid = "$Id$";
+#endif /* LIBC_SCCS and not lint */
-getopt.c - Read command line options
-
-AUTHOR: Gregory Pietsch
-CREATED Fri Jan 10 21:13:05 1997
-
-DESCRIPTION:
-
-The getopt() function parses the command line arguments. Its arguments argc
-and argv are the argument count and array as passed to the main() function
-on program invocation. The argument optstring is a list of available option
-characters. If such a character is followed by a colon (`:'), the option
-takes an argument, which is placed in optarg. If such a character is
-followed by two colons, the option takes an optional argument, which is
-placed in optarg. If the option does not take an argument, optarg is NULL.
-
-The external variable optind is the index of the next array element of argv
-to be processed; it communicates from one call to the next which element to
-process.
-
-The getopt_long() function works like getopt() except that it also accepts
-long options started by two dashes `--'. If these take values, it is either
-in the form
-
---arg=value
-
- or
-
---arg value
-
-It takes the additional arguments longopts which is a pointer to the first
-element of an array of type struct option. The last element of the array
-has to be filled with NULL for the name field.
-
-The longind pointer points to the index of the current long option relative
-to longopts if it is non-NULL.
-
-The getopt() function returns the option character if the option was found
-successfully, `:' if there was a missing parameter for one of the options,
-`?' for an unknown option character, and EOF for the end of the option list.
-
-The getopt_long() function's return value is described in the header file.
-
-The function getopt_long_only() is identical to getopt_long(), except that a
-plus sign `+' can introduce long options as well as `--'.
-
-The following describes how to deal with options that follow non-option
-argv-elements.
-
-If the caller did not specify anything, the default is REQUIRE_ORDER if the
-environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
-REQUIRE_ORDER means don't recognize them as options; stop option processing
-when the first non-option is seen. This is what Unix does. This mode of
-operation is selected by either setting the environment variable
-POSIXLY_CORRECT, or using `+' as the first character of the optstring
-parameter.
-
-PERMUTE is the default. We permute the contents of ARGV as we scan, so that
-eventually all the non-options are at the end. This allows options to be
-given in any order, even with programs that were not written to expect this.
-
-RETURN_IN_ORDER is an option available to programs that were written to
-expect options and other argv-elements in any order and that care about the
-ordering of the two. We describe each non-option argv-element as if it were
-the argument of an option with character code 1. Using `-' as the first
-character of the optstring parameter selects this mode of operation.
-
-The special argument `--' forces an end of option-scanning regardless of the
-value of ordering. In the case of RETURN_IN_ORDER, only `--' can cause
-getopt() and friends to return EOF with optind != argc.
-
-COPYRIGHT NOTICE AND DISCLAIMER:
-
-Copyright (C) 1997 Gregory Pietsch
-
-This file and the accompanying getopt.h header file are hereby placed in the
-public domain without restrictions. Just give the author credit, don't
-claim you wrote it or prevent anyone else from using it.
-
-Gregory Pietsch's current e-mail address:
-gpietsch@comcast.net
-****************************************************************************/
-
-/* include files */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <getopt.h>
-/* macros */
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
-/* types */
-typedef enum GETOPT_ORDERING_T
-{
- PERMUTE,
- RETURN_IN_ORDER,
- REQUIRE_ORDER
-} GETOPT_ORDERING_T;
-
-/* globally-defined variables */
-char *optarg = NULL;
-int optind = 0;
-int opterr = 1;
-int optopt = '?';
-
-/* functions */
-
-/* reverse_argv_elements: reverses num elements starting at argv */
-static void
-reverse_argv_elements (char ** argv, int num)
-{
- int i;
- char *tmp;
-
- for (i = 0; i < (num >> 1); i++)
- {
- tmp = argv[i];
- argv[i] = argv[num - i - 1];
- argv[num - i - 1] = tmp;
- }
-}
-
-/* permute: swap two blocks of argv-elements given their lengths */
-static void
-permute (char *const argv[], int len1, int len2)
-{
- reverse_argv_elements ((char **)argv, len1);
- reverse_argv_elements ((char **)argv, len1 + len2);
- reverse_argv_elements ((char **)argv, len2);
-}
-
-/* is_option: is this argv-element an option or the end of the option list? */
-static int
-is_option (char *argv_element, int only)
-{
- return ((argv_element == NULL)
- || (argv_element[0] == '-') || (only && argv_element[0] == '+'));
-}
-
-/* getopt_internal: the function that does all the dirty work */
-static int
-getopt_internal (int argc, char *const argv[], const char *shortopts,
- const struct option *longopts, int *longind, int only)
-{
- GETOPT_ORDERING_T ordering = PERMUTE;
- static size_t optwhere = 0;
- size_t permute_from = 0;
- int num_nonopts = 0;
- int optindex = 0;
- size_t match_chars = 0;
- char *possible_arg = NULL;
- int longopt_match = -1;
- int has_arg = -1;
- char *cp;
- int arg_next = 0;
-
- /* first, deal with silly parameters and easy stuff */
- if (argc == 0 || argv == NULL || (shortopts == NULL && longopts == NULL))
- return EOF;
- if (optind >= argc || argv[optind] == NULL)
- return EOF;
- if (strcmp (argv[optind], "--") == 0)
- {
- optind++;
- return EOF;
- }
- /* if this is our first time through */
- if (optind == 0)
- optind = optwhere = 1;
-
- /* define ordering */
- if (shortopts != NULL && (*shortopts == '-' || *shortopts == '+'))
- {
- ordering = (*shortopts == '-') ? RETURN_IN_ORDER : REQUIRE_ORDER;
- shortopts++;
- }
- else
- ordering = (getenv ("POSIXLY_CORRECT") != NULL) ? REQUIRE_ORDER : PERMUTE;
-
- /*
- * based on ordering, find our next option, if we're at the beginning of
- * one
- */
- if (optwhere == 1)
- {
- switch (ordering)
- {
- case PERMUTE:
- permute_from = optind;
- num_nonopts = 0;
- while (!is_option (argv[optind], only))
- {
- optind++;
- num_nonopts++;
- }
- if (argv[optind] == NULL)
- {
- /* no more options */
- optind = permute_from;
- return EOF;
- }
- else if (strcmp (argv[optind], "--") == 0)
- {
- /* no more options, but have to get `--' out of the way */
- permute (argv + permute_from, num_nonopts, 1);
- optind = permute_from + 1;
- return EOF;
- }
- break;
- case RETURN_IN_ORDER:
- if (!is_option (argv[optind], only))
- {
- optarg = argv[optind++];
- return (optopt = 1);
- }
- break;
- case REQUIRE_ORDER:
- if (!is_option (argv[optind], only))
- return EOF;
- break;
- }
- }
- /* we've got an option, so parse it */
-
- /* first, is it a long option? */
- if (longopts != NULL
- && (memcmp (argv[optind], "--", 2) == 0
- || (only && argv[optind][0] == '+')) && optwhere == 1)
- {
- /* handle long options */
- if (memcmp (argv[optind], "--", 2) == 0)
- optwhere = 2;
- longopt_match = -1;
- possible_arg = strchr (argv[optind] + optwhere, '=');
- if (possible_arg == NULL)
- {
- /* no =, so next argv might be arg */
- match_chars = strlen (argv[optind]);
- possible_arg = argv[optind] + match_chars;
- match_chars = match_chars - optwhere;
- }
- else
- match_chars = (possible_arg - argv[optind]) - optwhere;
- for (optindex = 0; longopts[optindex].name != NULL; optindex++)
- {
- if (memcmp (argv[optind] + optwhere,
- longopts[optindex].name, match_chars) == 0)
- {
- /* do we have an exact match? */
- if (match_chars == (int) (strlen (longopts[optindex].name)))
- {
- longopt_match = optindex;
- break;
- }
- /* do any characters match? */
- else
- {
- if (longopt_match < 0)
- longopt_match = optindex;
- else
- {
- /* we have ambiguous options */
- if (opterr)
- fprintf (stderr, "%s: option `%s' is ambiguous "
- "(could be `--%s' or `--%s')\n",
- argv[0],
- argv[optind],
- longopts[longopt_match].name,
- longopts[optindex].name);
- return (optopt = '?');
- }
- }
- }
- }
- if (longopt_match >= 0)
- has_arg = longopts[longopt_match].has_arg;
- }
- /* if we didn't find a long option, is it a short option? */
- if (longopt_match < 0 && shortopts != NULL)
- {
- cp = strchr (shortopts, argv[optind][optwhere]);
- if (cp == NULL)
- {
- /* couldn't find option in shortopts */
- if (opterr)
- fprintf (stderr,
- "%s: invalid option -- `-%c'\n",
- argv[0], argv[optind][optwhere]);
- optwhere++;
- if (argv[optind][optwhere] == '\0')
- {
- optind++;
- optwhere = 1;
- }
- return (optopt = '?');
- }
- has_arg = ((cp[1] == ':')
- ? ((cp[2] == ':') ? OPTIONAL_ARG : REQUIRED_ARG) : NO_ARG);
- possible_arg = argv[optind] + optwhere + 1;
- optopt = *cp;
- }
- /* get argument and reset optwhere */
- arg_next = 0;
- switch (has_arg)
- {
- case OPTIONAL_ARG:
- if (*possible_arg == '=')
- possible_arg++;
- if (*possible_arg != '\0')
- {
- optarg = possible_arg;
- optwhere = 1;
- }
- else
- optarg = NULL;
- break;
- case REQUIRED_ARG:
- if (*possible_arg == '=')
- possible_arg++;
- if (*possible_arg != '\0')
- {
- optarg = possible_arg;
- optwhere = 1;
- }
- else if (optind + 1 >= argc)
- {
- if (opterr)
- {
- fprintf (stderr, "%s: argument required for option `", argv[0]);
- if (longopt_match >= 0)
- fprintf (stderr, "--%s'\n", longopts[longopt_match].name);
- else
- fprintf (stderr, "-%c'\n", *cp);
- }
- optind++;
- return (optopt = ':');
- }
- else
- {
- optarg = argv[optind + 1];
- arg_next = 1;
- optwhere = 1;
- }
- break;
- case NO_ARG:
- if (longopt_match < 0)
- {
- optwhere++;
- if (argv[optind][optwhere] == '\0')
- optwhere = 1;
- }
- else
- optwhere = 1;
- optarg = NULL;
- break;
- }
-
- /* do we have to permute or otherwise modify optind? */
- if (ordering == PERMUTE && optwhere == 1 && num_nonopts != 0)
- {
- permute (argv + permute_from, num_nonopts, 1 + arg_next);
- optind = permute_from + 1 + arg_next;
- }
- else if (optwhere == 1)
- optind = optind + 1 + arg_next;
-
- /* finally return */
- if (longopt_match >= 0)
- {
- if (longind != NULL)
- *longind = longopt_match;
- if (longopts[longopt_match].flag != NULL)
- {
- *(longopts[longopt_match].flag) = longopts[longopt_match].val;
- return 0;
- }
- else
- return longopts[longopt_match].val;
- }
- else
- return optopt;
-}
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
int
-getopt (int argc, char *const argv[], const char *optstring)
+getopt(nargc, nargv, ostr)
+ int nargc;
+ char * const *nargv;
+ const char *ostr;
{
- return getopt_internal (argc, argv, optstring, NULL, NULL, 0);
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ return (-1);
+ }
+ if (place[1] && *++place == '-') { /* found "--" */
+ ++optind;
+ place = EMSG;
+ return (-1);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int)*place++) == (int)':' ||
+ !(oli = strchr(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means -1.
+ */
+ if (optopt == (int)'-')
+ return (-1);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void)fprintf(stderr,
+ "%s: illegal option -- %c\n", nargv[0], optopt);
+ return (BADCH);
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ }
+ else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ nargv[0], optopt);
+ return (BADCH);
+ }
+ else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* dump back option letter */
}
-
-int
-getopt_long (int argc, char *const argv[], const char *shortopts,
- const struct option *longopts, int *longind)
-{
- return getopt_internal (argc, argv, shortopts, longopts, longind, 0);
-}
-
-int
-getopt_long_only (int argc, char *const argv[], const char *shortopts,
- const struct option *longopts, int *longind)
-{
- return getopt_internal (argc, argv, shortopts, longopts, longind, 1);
-}
-
-/* end of file GETOPT.C */
diff --git a/newlib/libc/stdlib/ldtoa.c b/newlib/libc/stdlib/ldtoa.c
index 6a29dda9b..7af35d5e8 100644
--- a/newlib/libc/stdlib/ldtoa.c
+++ b/newlib/libc/stdlib/ldtoa.c
@@ -80,12 +80,6 @@ static void einfin(register short unsigned int *x, register LDPARMS *ldp);
static void efloor(short unsigned int *x, short unsigned int *y, LDPARMS *ldp);
static void etoasc(short unsigned int *x, char *string, int ndigs, int outformat, LDPARMS *ldp);
-union uconv
-{
- unsigned short pe;
- long double d;
-};
-
#if LDBL_MANT_DIG == 24
static void e24toe(short unsigned int *pe, short unsigned int *y, LDPARMS *ldp);
#elif LDBL_MANT_DIG == 53
@@ -2718,8 +2712,6 @@ LDPARMS rnd;
LDPARMS *ldp = &rnd;
char *outstr;
char outbuf[NDEC + MAX_EXP_DIGITS + 10];
-union uconv du;
-du.d = d;
orig_ndigits = ndigits;
rnd.rlast = -1;
@@ -2737,13 +2729,13 @@ if (_REENT_MP_RESULT(ptr))
}
#if LDBL_MANT_DIG == 24
-e24toe( &du.pe, e, ldp );
+e24toe( (unsigned short *)&d, e, ldp );
#elif LDBL_MANT_DIG == 53
-e53toe( &du.pe, e, ldp );
+e53toe( (unsigned short *)&d, e, ldp );
#elif LDBL_MANT_DIG == 64
-e64toe( &du.pe, e, ldp );
+e64toe( (unsigned short *)&d, e, ldp );
#else
-e113toe( &du.pe, e, ldp );
+e113toe( (unsigned short *)&d, e, ldp );
#endif
if( eisneg(e) )
@@ -2872,16 +2864,14 @@ LDPARMS *ldp = &rnd;
rnd.rlast = -1;
rnd.rndprc = NBITS;
-union uconv du;
-du.d = *d;
#if LDBL_MANT_DIG == 24
-e24toe( &du.pe, e, ldp );
+e24toe( (unsigned short *)d, e, ldp );
#elif LDBL_MANT_DIG == 53
-e53toe( &du.pe, e, ldp );
+e53toe( (unsigned short *)d, e, ldp );
#elif LDBL_MANT_DIG == 64
-e64toe( &du.pe, e, ldp );
+e64toe( (unsigned short *)d, e, ldp );
#else
-e113toe( &du.pe, e, ldp );
+e113toe( (unsigned short *)d, e, ldp );
#endif
if( (e[NE-1] & 0x7fff) == 0x7fff )
@@ -3230,7 +3220,7 @@ ldp->outexpon = expon;
long double _strtold (char *s, char **se)
{
- union uconv x;
+ long double x;
LDPARMS rnd;
LDPARMS *ldp = &rnd;
int lenldstr;
@@ -3238,10 +3228,10 @@ long double _strtold (char *s, char **se)
rnd.rlast = -1;
rnd.rndprc = NBITS;
- lenldstr = asctoeg( s, &x.pe, LDBL_MANT_DIG, ldp );
+ lenldstr = asctoeg( s, (unsigned short *)&x, LDBL_MANT_DIG, ldp );
if (se)
*se = s + lenldstr;
- return x.d;
+ return x;
}
#define REASONABLE_LEN 200
diff --git a/newlib/libc/stdlib/mallocr.c b/newlib/libc/stdlib/mallocr.c
index cfa25545f..71886c14f 100644
--- a/newlib/libc/stdlib/mallocr.c
+++ b/newlib/libc/stdlib/mallocr.c
@@ -268,7 +268,6 @@ extern "C" {
#include <stdio.h> /* needed for malloc_stats */
#include <limits.h> /* needed for overflow checks */
-#include <errno.h> /* needed to set errno to ENOMEM */
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
@@ -336,7 +335,6 @@ extern void __malloc_unlock();
#define RDECL struct _reent *reent_ptr;
#endif
-#define RERRNO reent_ptr->_errno
#define RCALL reent_ptr,
#define RONECALL reent_ptr
@@ -346,7 +344,6 @@ extern void __malloc_unlock();
#define RARG
#define RONEARG
#define RDECL
-#define RERRNO errno
#define RCALL
#define RONECALL
@@ -490,10 +487,6 @@ extern void __malloc_unlock();
#define HAVE_MEMCPY
-/* Although the original macro is called USE_MEMCPY, newlib actually
- uses memmove to handle cases whereby a platform's memcpy implementation
- copies backwards and thus destructive overlap may occur in realloc
- whereby we are reclaiming free memory prior to the old allocation. */
#ifndef USE_MEMCPY
#ifdef HAVE_MEMCPY
#define USE_MEMCPY 1
@@ -507,11 +500,9 @@ extern void __malloc_unlock();
#if __STD_C
void* memset(void*, int, size_t);
void* memcpy(void*, const void*, size_t);
-void* memmove(void*, const void*, size_t);
#else
Void_t* memset();
Void_t* memcpy();
-Void_t* memmove();
#endif
#endif
@@ -553,7 +544,7 @@ do { \
*mcdst++ = *mcsrc++; \
*mcdst++ = *mcsrc++; \
*mcdst = *mcsrc ; \
- } else memmove(dest, src, mcsz); \
+ } else memcpy(dest, src, mcsz); \
} while(0)
#else /* !USE_MEMCPY */
@@ -2344,10 +2335,7 @@ Void_t* mALLOc(RARG bytes) RDECL size_t bytes;
/* Check for overflow and just fail, if so. */
if (nb > INT_MAX || nb < bytes)
- {
- RERRNO = ENOMEM;
return 0;
- }
MALLOC_LOCK;
@@ -2810,10 +2798,7 @@ Void_t* rEALLOc(RARG oldmem, bytes) RDECL Void_t* oldmem; size_t bytes;
/* Check for overflow and just fail, if so. */
if (nb > INT_MAX || nb < bytes)
- {
- RERRNO = ENOMEM;
return 0;
- }
#if HAVE_MMAP
if (chunk_is_mmapped(oldp))
@@ -3046,10 +3031,7 @@ Void_t* mEMALIGn(RARG alignment, bytes) RDECL size_t alignment; size_t bytes;
/* Check for overflow. */
if (nb > INT_MAX || nb < bytes)
- {
- RERRNO = ENOMEM;
return 0;
- }
m = (char*)(mALLOc(RCALL nb + alignment + MINSIZE));
diff --git a/newlib/libc/stdlib/mlock.c b/newlib/libc/stdlib/mlock.c
index 888c986a9..378b4e691 100644
--- a/newlib/libc/stdlib/mlock.c
+++ b/newlib/libc/stdlib/mlock.c
@@ -1,7 +1,7 @@
#ifndef MALLOC_PROVIDED
/*
FUNCTION
-<<__malloc_lock>>, <<__malloc_unlock>>---lock malloc pool
+<<__malloc_lock>>, <<__malloc_unlock>>--lock malloc pool
INDEX
__malloc_lock
diff --git a/newlib/libc/stdlib/mstats.c b/newlib/libc/stdlib/mstats.c
index ba89f494d..42b5db2fe 100644
--- a/newlib/libc/stdlib/mstats.c
+++ b/newlib/libc/stdlib/mstats.c
@@ -10,7 +10,7 @@ int _dummy_mstats = 1;
/*
FUNCTION
-<<mallinfo>>, <<malloc_stats>>, <<mallopt>>---malloc support
+<<mallinfo>>, <<malloc_stats>>, <<mallopt>>--malloc support
INDEX
mallinfo
diff --git a/newlib/libc/stdlib/rand.c b/newlib/libc/stdlib/rand.c
index 6a46aa807..4f5a60796 100644
--- a/newlib/libc/stdlib/rand.c
+++ b/newlib/libc/stdlib/rand.c
@@ -51,8 +51,8 @@ number between <<0>> and <<RAND_MAX>> (inclusive).
<<srand>> does not return a result.
NOTES
-<<rand>> and <<srand>> are unsafe for multi-threaded applications.
-<<rand_r>> is thread-safe and should be used instead.
+<<rand>> and <<srand>> are unsafe for multi-thread applications.
+<<rand_r>> is MT-Safe and should be used instead.
PORTABILITY
diff --git a/newlib/libc/stdlib/rand48.c b/newlib/libc/stdlib/rand48.c
index af2be3c07..17fd04e92 100644
--- a/newlib/libc/stdlib/rand48.c
+++ b/newlib/libc/stdlib/rand48.c
@@ -13,7 +13,7 @@
/*
FUNCTION
- <<rand48>>, <<drand48>>, <<erand48>>, <<lrand48>>, <<nrand48>>, <<mrand48>>, <<jrand48>>, <<srand48>>, <<seed48>>, <<lcong48>>---pseudo-random number generators and initialization routines
+ <<rand48>>, <<drand48>>, <<erand48>>, <<lrand48>>, <<nrand48>>, <<mrand48>>, <<jrand48>>, <<srand48>>, <<seed48>>, <<lcong48>> ---pseudo random number generators and initialization routines
INDEX
rand48