aboutsummaryrefslogtreecommitdiff
path: root/REORG.TODO/sysdeps/wordsize-32
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/sysdeps/wordsize-32')
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/Versions7
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/bits/wordsize.h21
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/divdi3-symbol-hacks.h31
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/divdi3.c342
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/llabs.c22
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/lldiv.c26
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/strtoimax.c27
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/strtoumax.c27
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/wcstoimax.c28
-rw-r--r--REORG.TODO/sysdeps/wordsize-32/wcstoumax.c28
10 files changed, 559 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/wordsize-32/Versions b/REORG.TODO/sysdeps/wordsize-32/Versions
new file mode 100644
index 0000000000..e950290065
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/Versions
@@ -0,0 +1,7 @@
+libc {
+ GLIBC_2.3 {
+ # These were erroneously omitted for 64-bit platforms in 2.3
+ # and so we don't put them in locale/Versions.
+ strtoll_l; strtoull_l;
+ }
+}
diff --git a/REORG.TODO/sysdeps/wordsize-32/bits/wordsize.h b/REORG.TODO/sysdeps/wordsize-32/bits/wordsize.h
new file mode 100644
index 0000000000..9a5b072daa
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/bits/wordsize.h
@@ -0,0 +1,21 @@
+/* Copyright (C) 1999-2017 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define __WORDSIZE 32
+#define __WORDSIZE_TIME64_COMPAT32 0
+#define __WORDSIZE32_SIZE_ULONG 0
+#define __WORDSIZE32_PTRDIFF_LONG 0
diff --git a/REORG.TODO/sysdeps/wordsize-32/divdi3-symbol-hacks.h b/REORG.TODO/sysdeps/wordsize-32/divdi3-symbol-hacks.h
new file mode 100644
index 0000000000..6c90cb796d
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/divdi3-symbol-hacks.h
@@ -0,0 +1,31 @@
+/* Hacks needed for divdi3 symbol manipulation.
+ Copyright (C) 2004-2017 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* A very dirty trick: gcc emits references to __divdi3, __udivdi3,
+ __moddi3, and __umoddi3. These functions are exported and
+ therefore we get PLTs. Unnecessarily so. Changing gcc is a big
+ task which might not be worth it so we play tricks with the
+ assembler.
+ Note: in_divdi3_c is only used to avoid symbol alias on divdi3
+ build itself. */
+#if !defined __ASSEMBLER__ && !defined in_divdi3_c && IS_IN (libc) && defined SHARED
+asm ("__divdi3 = __divdi3_internal");
+asm ("__udivdi3 = __udivdi3_internal");
+asm ("__moddi3 = __moddi3_internal");
+asm ("__umoddi3 = __umoddi3_internal");
+#endif
diff --git a/REORG.TODO/sysdeps/wordsize-32/divdi3.c b/REORG.TODO/sysdeps/wordsize-32/divdi3.c
new file mode 100644
index 0000000000..03de8215f9
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/divdi3.c
@@ -0,0 +1,342 @@
+/* 64-bit multiplication and division
+ Copyright (C) 1989, 1992-2017 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <endian.h>
+#include <stdlib.h>
+#include <bits/wordsize.h>
+
+#if __WORDSIZE != 32
+#error This is for 32-bit targets only
+#endif
+
+typedef unsigned int UQItype __attribute__ ((mode (QI)));
+typedef int SItype __attribute__ ((mode (SI)));
+typedef unsigned int USItype __attribute__ ((mode (SI)));
+typedef int DItype __attribute__ ((mode (DI)));
+typedef unsigned int UDItype __attribute__ ((mode (DI)));
+#define Wtype SItype
+#define HWtype SItype
+#define DWtype DItype
+#define UWtype USItype
+#define UHWtype USItype
+#define UDWtype UDItype
+#define W_TYPE_SIZE 32
+
+#include <stdlib/longlong.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+struct DWstruct { Wtype high, low;};
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+struct DWstruct { Wtype low, high;};
+#else
+#error Unhandled endianity
+#endif
+typedef union { struct DWstruct s; DWtype ll; } DWunion;
+
+/* Prototypes of exported functions. */
+extern DWtype __divdi3 (DWtype u, DWtype v);
+extern DWtype __moddi3 (DWtype u, DWtype v);
+extern UDWtype __udivdi3 (UDWtype u, UDWtype v);
+extern UDWtype __umoddi3 (UDWtype u, UDWtype v);
+
+static UDWtype
+__udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
+{
+ DWunion ww;
+ DWunion nn, dd;
+ DWunion rr;
+ UWtype d0, d1, n0, n1, n2;
+ UWtype q0, q1;
+ UWtype b, bm;
+
+ nn.ll = n;
+ dd.ll = d;
+
+ d0 = dd.s.low;
+ d1 = dd.s.high;
+ n0 = nn.s.low;
+ n1 = nn.s.high;
+
+#if !UDIV_NEEDS_NORMALIZATION
+ if (d1 == 0)
+ {
+ if (d0 > n1)
+ {
+ /* 0q = nn / 0D */
+
+ udiv_qrnnd (q0, n0, n1, n0, d0);
+ q1 = 0;
+
+ /* Remainder in n0. */
+ }
+ else
+ {
+ /* qq = NN / 0d */
+
+ if (d0 == 0)
+ d0 = 1 / d0; /* Divide intentionally by zero. */
+
+ udiv_qrnnd (q1, n1, 0, n1, d0);
+ udiv_qrnnd (q0, n0, n1, n0, d0);
+
+ /* Remainder in n0. */
+ }
+
+ if (rp != 0)
+ {
+ rr.s.low = n0;
+ rr.s.high = 0;
+ *rp = rr.ll;
+ }
+ }
+
+#else /* UDIV_NEEDS_NORMALIZATION */
+
+ if (d1 == 0)
+ {
+ if (d0 > n1)
+ {
+ /* 0q = nn / 0D */
+
+ count_leading_zeros (bm, d0);
+
+ if (bm != 0)
+ {
+ /* Normalize, i.e. make the most significant bit of the
+ denominator set. */
+
+ d0 = d0 << bm;
+ n1 = (n1 << bm) | (n0 >> (W_TYPE_SIZE - bm));
+ n0 = n0 << bm;
+ }
+
+ udiv_qrnnd (q0, n0, n1, n0, d0);
+ q1 = 0;
+
+ /* Remainder in n0 >> bm. */
+ }
+ else
+ {
+ /* qq = NN / 0d */
+
+ if (d0 == 0)
+ d0 = 1 / d0; /* Divide intentionally by zero. */
+
+ count_leading_zeros (bm, d0);
+
+ if (bm == 0)
+ {
+ /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
+ conclude (the most significant bit of n1 is set) /\ (the
+ leading quotient digit q1 = 1).
+
+ This special case is necessary, not an optimization.
+ (Shifts counts of W_TYPE_SIZE are undefined.) */
+
+ n1 -= d0;
+ q1 = 1;
+ }
+ else
+ {
+ /* Normalize. */
+
+ b = W_TYPE_SIZE - bm;
+
+ d0 = d0 << bm;
+ n2 = n1 >> b;
+ n1 = (n1 << bm) | (n0 >> b);
+ n0 = n0 << bm;
+
+ udiv_qrnnd (q1, n1, n2, n1, d0);
+ }
+
+ /* n1 != d0... */
+
+ udiv_qrnnd (q0, n0, n1, n0, d0);
+
+ /* Remainder in n0 >> bm. */
+ }
+
+ if (rp != 0)
+ {
+ rr.s.low = n0 >> bm;
+ rr.s.high = 0;
+ *rp = rr.ll;
+ }
+ }
+#endif /* UDIV_NEEDS_NORMALIZATION */
+
+ else
+ {
+ if (d1 > n1)
+ {
+ /* 00 = nn / DD */
+
+ q0 = 0;
+ q1 = 0;
+
+ /* Remainder in n1n0. */
+ if (rp != 0)
+ {
+ rr.s.low = n0;
+ rr.s.high = n1;
+ *rp = rr.ll;
+ }
+ }
+ else
+ {
+ /* 0q = NN / dd */
+
+ count_leading_zeros (bm, d1);
+ if (bm == 0)
+ {
+ /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
+ conclude (the most significant bit of n1 is set) /\ (the
+ quotient digit q0 = 0 or 1).
+
+ This special case is necessary, not an optimization. */
+
+ /* The condition on the next line takes advantage of that
+ n1 >= d1 (true due to program flow). */
+ if (n1 > d1 || n0 >= d0)
+ {
+ q0 = 1;
+ sub_ddmmss (n1, n0, n1, n0, d1, d0);
+ }
+ else
+ q0 = 0;
+
+ q1 = 0;
+
+ if (rp != 0)
+ {
+ rr.s.low = n0;
+ rr.s.high = n1;
+ *rp = rr.ll;
+ }
+ }
+ else
+ {
+ UWtype m1, m0;
+ /* Normalize. */
+
+ b = W_TYPE_SIZE - bm;
+
+ d1 = (d1 << bm) | (d0 >> b);
+ d0 = d0 << bm;
+ n2 = n1 >> b;
+ n1 = (n1 << bm) | (n0 >> b);
+ n0 = n0 << bm;
+
+ udiv_qrnnd (q0, n1, n2, n1, d1);
+ umul_ppmm (m1, m0, q0, d0);
+
+ if (m1 > n1 || (m1 == n1 && m0 > n0))
+ {
+ q0--;
+ sub_ddmmss (m1, m0, m1, m0, d1, d0);
+ }
+
+ q1 = 0;
+
+ /* Remainder in (n1n0 - m1m0) >> bm. */
+ if (rp != 0)
+ {
+ sub_ddmmss (n1, n0, n1, n0, m1, m0);
+ rr.s.low = (n1 << b) | (n0 >> bm);
+ rr.s.high = n1 >> bm;
+ *rp = rr.ll;
+ }
+ }
+ }
+ }
+
+ ww.s.low = q0;
+ ww.s.high = q1;
+ return ww.ll;
+}
+
+DWtype
+__divdi3 (DWtype u, DWtype v)
+{
+ Wtype c = 0;
+ DWtype w;
+
+ if (u < 0)
+ {
+ c = ~c;
+ u = -u;
+ }
+ if (v < 0)
+ {
+ c = ~c;
+ v = -v;
+ }
+ w = __udivmoddi4 (u, v, NULL);
+ if (c)
+ w = -w;
+ return w;
+}
+strong_alias (__divdi3, __divdi3_internal)
+
+DWtype
+__moddi3 (DWtype u, DWtype v)
+{
+ Wtype c = 0;
+ DWtype w;
+
+ if (u < 0)
+ {
+ c = ~c;
+ u = -u;
+ }
+ if (v < 0)
+ v = -v;
+ __udivmoddi4 (u, v, (UDWtype *) &w);
+ if (c)
+ w = -w;
+ return w;
+}
+strong_alias (__moddi3, __moddi3_internal)
+
+UDWtype
+__udivdi3 (UDWtype u, UDWtype v)
+{
+ return __udivmoddi4 (u, v, NULL);
+}
+strong_alias (__udivdi3, __udivdi3_internal)
+
+UDWtype
+__umoddi3 (UDWtype u, UDWtype v)
+{
+ UDWtype w;
+
+ __udivmoddi4 (u, v, &w);
+ return w;
+}
+strong_alias (__umoddi3, __umoddi3_internal)
+
+/* We declare these with compat_symbol so that they are not visible at
+ link time. Programs must use the functions from libgcc. */
+#ifdef SHARED
+# include <shlib-compat.h>
+compat_symbol (libc, __divdi3, __divdi3, GLIBC_2_0);
+compat_symbol (libc, __moddi3, __moddi3, GLIBC_2_0);
+compat_symbol (libc, __udivdi3, __udivdi3, GLIBC_2_0);
+compat_symbol (libc, __umoddi3, __umoddi3, GLIBC_2_0);
+#endif
diff --git a/REORG.TODO/sysdeps/wordsize-32/llabs.c b/REORG.TODO/sysdeps/wordsize-32/llabs.c
new file mode 100644
index 0000000000..ef4d4875a2
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/llabs.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 1999-2017 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <inttypes.h>
+
+#include <stdlib/llabs.c>
+
+weak_alias (llabs, imaxabs)
diff --git a/REORG.TODO/sysdeps/wordsize-32/lldiv.c b/REORG.TODO/sysdeps/wordsize-32/lldiv.c
new file mode 100644
index 0000000000..81465aa43c
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/lldiv.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999-2017 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Ugly trick ahead to make the alias work. */
+#define imaxdiv __libc_imaxdiv
+
+#include <inttypes.h>
+
+#include <stdlib/lldiv.c>
+
+#undef imaxdiv
+weak_alias (lldiv, imaxdiv)
diff --git a/REORG.TODO/sysdeps/wordsize-32/strtoimax.c b/REORG.TODO/sysdeps/wordsize-32/strtoimax.c
new file mode 100644
index 0000000000..eb01a46dc1
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/strtoimax.c
@@ -0,0 +1,27 @@
+/* Convert string to maximal integer.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <inttypes.h>
+#include <stdlib.h>
+
+intmax_t
+strtoimax (const char *__restrict nptr, char **__restrict endptr, int base)
+{
+ return __strtoll_internal (nptr, endptr, base, 0);
+}
diff --git a/REORG.TODO/sysdeps/wordsize-32/strtoumax.c b/REORG.TODO/sysdeps/wordsize-32/strtoumax.c
new file mode 100644
index 0000000000..bd3b94125b
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/strtoumax.c
@@ -0,0 +1,27 @@
+/* Convert string to maximal unsigned integer.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <inttypes.h>
+#include <stdlib.h>
+
+uintmax_t
+strtoumax (const char *__restrict nptr, char **__restrict endptr, int base)
+{
+ return __strtoull_internal (nptr, endptr, base, 0);
+}
diff --git a/REORG.TODO/sysdeps/wordsize-32/wcstoimax.c b/REORG.TODO/sysdeps/wordsize-32/wcstoimax.c
new file mode 100644
index 0000000000..de1273181c
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/wcstoimax.c
@@ -0,0 +1,28 @@
+/* Convert wide-character string to maximal integer.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <inttypes.h>
+#include <wchar.h>
+
+intmax_t
+wcstoimax (const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
+ int base)
+{
+ return __wcstoll_internal (nptr, endptr, base, 0);
+}
diff --git a/REORG.TODO/sysdeps/wordsize-32/wcstoumax.c b/REORG.TODO/sysdeps/wordsize-32/wcstoumax.c
new file mode 100644
index 0000000000..57b802a954
--- /dev/null
+++ b/REORG.TODO/sysdeps/wordsize-32/wcstoumax.c
@@ -0,0 +1,28 @@
+/* Convert wide-character string to maximal unsigned integer.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <inttypes.h>
+#include <wchar.h>
+
+uintmax_t
+wcstoumax (const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
+ int base)
+{
+ return __wcstoull_internal (nptr, endptr, base, 0);
+}