aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-12-14 15:06:39 +0000
committerUlrich Drepper <drepper@redhat.com>2005-12-14 15:06:39 +0000
commit9d13fb2413921c713f83efe331e8e4d219c62c6b (patch)
tree2d44d7ac45ab2d147eb8361bbff880c365aa8ad5 /stdlib
parentb6ab06cef4670e02756bcdd4d2c33a49369a4346 (diff)
downloadglibc-9d13fb2413921c713f83efe331e8e4d219c62c6b.tar.xz
glibc-9d13fb2413921c713f83efe331e8e4d219c62c6b.zip
Moved to csu/errno-loc.c.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/getcontext.c32
-rw-r--r--stdlib/getenv.c98
-rw-r--r--stdlib/inlines.c3
-rw-r--r--stdlib/labs.c29
-rw-r--r--stdlib/ldbl2mpn.c1
-rw-r--r--stdlib/ldiv.c54
-rw-r--r--stdlib/llabs.c31
-rw-r--r--stdlib/lldiv.c57
-rw-r--r--stdlib/lshift.c87
-rw-r--r--stdlib/makecontext.c30
-rw-r--r--stdlib/mod_1.c197
-rw-r--r--stdlib/mp_clz_tab.c37
-rw-r--r--stdlib/mpn2dbl.c30
-rw-r--r--stdlib/mpn2flt.c30
-rw-r--r--stdlib/mpn2ldbl.c1
-rw-r--r--stdlib/mul.c152
-rw-r--r--stdlib/mul_1.c59
-rw-r--r--stdlib/mul_n.c401
-rw-r--r--stdlib/putenv.c72
-rw-r--r--stdlib/rshift.c88
-rw-r--r--stdlib/setcontext.c32
-rw-r--r--stdlib/setenv.c353
-rw-r--r--stdlib/strtoimax.c1
-rw-r--r--stdlib/strtol.c111
-rw-r--r--stdlib/strtol_l.c557
-rw-r--r--stdlib/strtold_l.c58
-rw-r--r--stdlib/strtoll.c34
-rw-r--r--stdlib/strtoll_l.c28
-rw-r--r--stdlib/strtoul.c21
-rw-r--r--stdlib/strtoul_l.c28
-rw-r--r--stdlib/strtoull.c34
-rw-r--r--stdlib/strtoull_l.c29
-rw-r--r--stdlib/strtoumax.c1
-rw-r--r--stdlib/sub_n.c62
-rw-r--r--stdlib/submul_1.c65
-rw-r--r--stdlib/swapcontext.c33
-rw-r--r--stdlib/system.c38
-rw-r--r--stdlib/udiv_qrnnd.c10
-rw-r--r--stdlib/wcstoimax.c1
-rw-r--r--stdlib/wcstoumax.c1
40 files changed, 2986 insertions, 0 deletions
diff --git a/stdlib/getcontext.c b/stdlib/getcontext.c
new file mode 100644
index 0000000000..e417575a58
--- /dev/null
+++ b/stdlib/getcontext.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <ucontext.h>
+
+int
+getcontext (ucp)
+ ucontext_t *ucp;
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+
+
+stub_warning (getcontext)
+#include <stub-tag.h>
diff --git a/stdlib/getenv.c b/stdlib/getenv.c
new file mode 100644
index 0000000000..6cdfe2b266
--- /dev/null
+++ b/stdlib/getenv.c
@@ -0,0 +1,98 @@
+/* Copyright (C) 1991,92,94,96,98,99,2002,2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <endian.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+/* Return the value of the environment variable NAME. This implementation
+ is tuned a bit in that it assumes no environment variable has an empty
+ name which of course should always be true. We have a special case for
+ one character names so that for the general case we can assume at least
+ two characters which we can access. By doing this we can avoid using the
+ `strncmp' most of the time. */
+char *
+getenv (name)
+ const char *name;
+{
+ size_t len = strlen (name);
+ char **ep;
+ uint16_t name_start;
+
+ if (__environ == NULL || name[0] == '\0')
+ return NULL;
+
+ if (name[1] == '\0')
+ {
+ /* The name of the variable consists of only one character. Therefore
+ the first two characters of the environment entry are this character
+ and a '=' character. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN || !_STRING_ARCH_unaligned
+ name_start = ('=' << 8) | *(const unsigned char *) name;
+#else
+# if __BYTE_ORDER == __BIG_ENDIAN
+ name_start = '=' | ((*(const unsigned char *) name) << 8);
+# else
+ #error "Funny byte order."
+# endif
+#endif
+ for (ep = __environ; *ep != NULL; ++ep)
+ {
+#if _STRING_ARCH_unaligned
+ uint16_t ep_start = *(uint16_t *) *ep;
+#else
+ uint16_t ep_start = (((unsigned char *) *ep)[0]
+ | (((unsigned char *) *ep)[1] << 8));
+#endif
+ if (name_start == ep_start)
+ return &(*ep)[2];
+ }
+ }
+ else
+ {
+#if _STRING_ARCH_unaligned
+ name_start = *(const uint16_t *) name;
+#else
+ name_start = (((const unsigned char *) name)[0]
+ | (((const unsigned char *) name)[1] << 8));
+#endif
+ len -= 2;
+ name += 2;
+
+ for (ep = __environ; *ep != NULL; ++ep)
+ {
+#if _STRING_ARCH_unaligned
+ uint16_t ep_start = *(uint16_t *) *ep;
+#else
+ uint16_t ep_start = (((unsigned char *) *ep)[0]
+ | (((unsigned char *) *ep)[1] << 8));
+#endif
+
+ if (name_start == ep_start && !strncmp (*ep + 2, name, len)
+ && (*ep)[len + 2] == '=')
+ return &(*ep)[len + 3];
+ }
+ }
+
+ return NULL;
+}
+libc_hidden_def (getenv)
diff --git a/stdlib/inlines.c b/stdlib/inlines.c
new file mode 100644
index 0000000000..5f1065ea13
--- /dev/null
+++ b/stdlib/inlines.c
@@ -0,0 +1,3 @@
+#define _FORCE_INLINES
+#define _EXTERN_INLINE /* empty */
+#include <gmp.h>
diff --git a/stdlib/labs.c b/stdlib/labs.c
new file mode 100644
index 0000000000..c568e44454
--- /dev/null
+++ b/stdlib/labs.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+#undef labs
+
+
+/* Return the absolute value of I. */
+long int
+labs (long int i)
+{
+ return i < 0 ? -i : i;
+}
diff --git a/stdlib/ldbl2mpn.c b/stdlib/ldbl2mpn.c
new file mode 100644
index 0000000000..450f9381cc
--- /dev/null
+++ b/stdlib/ldbl2mpn.c
@@ -0,0 +1 @@
+/* Empty. Not needed unless ldbl support is in. */
diff --git a/stdlib/ldiv.c b/stdlib/ldiv.c
new file mode 100644
index 0000000000..a7796d8e95
--- /dev/null
+++ b/stdlib/ldiv.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+
+/* Return the `ldiv_t' representation of NUMER over DENOM. */
+ldiv_t
+ldiv (long int numer, long int denom)
+{
+ ldiv_t result;
+
+ result.quot = numer / denom;
+ result.rem = numer % denom;
+
+ /* The ANSI standard says that |QUOT| <= |NUMER / DENOM|, where
+ NUMER / DENOM is to be computed in infinite precision. In
+ other words, we should always truncate the quotient towards
+ zero, never -infinity. Machine division and remainer may
+ work either way when one or both of NUMER or DENOM is
+ negative. If only one is negative and QUOT has been
+ truncated towards -infinity, REM will have the same sign as
+ DENOM and the opposite sign of NUMER; if both are negative
+ and QUOT has been truncated towards -infinity, REM will be
+ positive (will have the opposite sign of NUMER). These are
+ considered `wrong'. If both are NUM and DENOM are positive,
+ RESULT will always be positive. This all boils down to: if
+ NUMER >= 0, but REM < 0, we got the wrong answer. In that
+ case, to get the right answer, add 1 to QUOT and subtract
+ DENOM from REM. */
+
+ if (numer >= 0 && result.rem < 0)
+ {
+ ++result.quot;
+ result.rem -= denom;
+ }
+
+ return result;
+}
diff --git a/stdlib/llabs.c b/stdlib/llabs.c
new file mode 100644
index 0000000000..b15c347d32
--- /dev/null
+++ b/stdlib/llabs.c
@@ -0,0 +1,31 @@
+/* `long long int' absolute value.
+ Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+#undef llabs
+
+
+/* Return the absolute value of I. */
+long long int
+llabs (i)
+ long long int i;
+{
+ return i < 0 ? -i : i;
+}
diff --git a/stdlib/lldiv.c b/stdlib/lldiv.c
new file mode 100644
index 0000000000..28a016b744
--- /dev/null
+++ b/stdlib/lldiv.c
@@ -0,0 +1,57 @@
+/* `long long int' divison with remainder.
+ Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+
+/* Return the `lldiv_t' representation of NUMER over DENOM. */
+lldiv_t
+lldiv (numer, denom)
+ long long int numer;
+ long long int denom;
+{
+ lldiv_t result;
+
+ result.quot = numer / denom;
+ result.rem = numer % denom;
+
+ /* The ANSI standard says that |QUOT| <= |NUMER / DENOM|, where
+ NUMER / DENOM is to be computed in infinite precision. In
+ other words, we should always truncate the quotient towards
+ zero, never -infinity. Machine division and remainer may
+ work either way when one or both of NUMER or DENOM is
+ negative. If only one is negative and QUOT has been
+ truncated towards -infinity, REM will have the same sign as
+ DENOM and the opposite sign of NUMER; if both are negative
+ and QUOT has been truncated towards -infinity, REM will be
+ positive (will have the opposite sign of NUMER). These are
+ considered `wrong'. If both are NUM and DENOM are positive,
+ RESULT will always be positive. This all boils down to: if
+ NUMER >= 0, but REM < 0, we got the wrong answer. In that
+ case, to get the right answer, add 1 to QUOT and subtract
+ DENOM from REM. */
+
+ if (numer >= 0 && result.rem < 0)
+ {
+ ++result.quot;
+ result.rem -= denom;
+ }
+
+ return result;
+}
diff --git a/stdlib/lshift.c b/stdlib/lshift.c
new file mode 100644
index 0000000000..bedf44229f
--- /dev/null
+++ b/stdlib/lshift.c
@@ -0,0 +1,87 @@
+/* mpn_lshift -- Shift left low level.
+
+Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <gmp.h>
+#include "gmp-impl.h"
+
+/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
+ and store the USIZE least significant digits of the result at WP.
+ Return the bits shifted out from the most significant digit.
+
+ Argument constraints:
+ 1. 0 < CNT < BITS_PER_MP_LIMB
+ 2. If the result is to be written over the input, WP must be >= UP.
+*/
+
+mp_limb_t
+#if __STDC__
+mpn_lshift (register mp_ptr wp,
+ register mp_srcptr up, mp_size_t usize,
+ register unsigned int cnt)
+#else
+mpn_lshift (wp, up, usize, cnt)
+ register mp_ptr wp;
+ register mp_srcptr up;
+ mp_size_t usize;
+ register unsigned int cnt;
+#endif
+{
+ register mp_limb_t high_limb, low_limb;
+ register unsigned sh_1, sh_2;
+ register mp_size_t i;
+ mp_limb_t retval;
+
+#ifdef DEBUG
+ if (usize == 0 || cnt == 0)
+ abort ();
+#endif
+
+ sh_1 = cnt;
+#if 0
+ if (sh_1 == 0)
+ {
+ if (wp != up)
+ {
+ /* Copy from high end to low end, to allow specified input/output
+ overlapping. */