akaros/tools/compilers/gcc-glibc/glibc-2.19-riscv.patch
<<
>>
Prefs
   1diff -ruN glibc-2.19/scripts/config.sub glibc-2.19-riscv/scripts/config.sub
   2--- glibc-2.19/scripts/config.sub       2014-02-07 01:04:38.000000000 -0800
   3+++ glibc-2.19-riscv/scripts/config.sub 2014-12-09 16:55:55.061008453 -0800
   4@@ -301,6 +301,7 @@
   5        | pdp10 | pdp11 | pj | pjl \
   6        | powerpc | powerpc64 | powerpc64le | powerpcle \
   7        | pyramid \
   8+       | riscv \
   9        | rl78 | rx \
  10        | score \
  11        | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
  12Binary files glibc-2.19/scripts/.config.sub.rej.swp and glibc-2.19-riscv/scripts/.config.sub.rej.swp differ
  13diff -ruN glibc-2.19/sysdeps/riscv/abort-instr.h glibc-2.19-riscv/sysdeps/riscv/abort-instr.h
  14--- glibc-2.19/sysdeps/riscv/abort-instr.h      1969-12-31 16:00:00.000000000 -0800
  15+++ glibc-2.19-riscv/sysdeps/riscv/abort-instr.h        2014-12-09 16:55:03.152727766 -0800
  16@@ -0,0 +1,2 @@
  17+/* An instruction which should crash any program is a breakpoint.  */
  18+#define ABORT_INSTRUCTION asm ("unimp")
  19diff -ruN glibc-2.19/sysdeps/riscv/bits/atomic.h glibc-2.19-riscv/sysdeps/riscv/bits/atomic.h
  20--- glibc-2.19/sysdeps/riscv/bits/atomic.h      1969-12-31 16:00:00.000000000 -0800
  21+++ glibc-2.19-riscv/sysdeps/riscv/bits/atomic.h        2014-12-09 16:55:03.152727766 -0800
  22@@ -0,0 +1,119 @@
  23+/* Low-level functions for atomic operations. Mips version.
  24+   Copyright (C) 2005 Free Software Foundation, Inc.
  25+   This file is part of the GNU C Library.
  26+
  27+   The GNU C Library is free software; you can redistribute it and/or
  28+   modify it under the terms of the GNU Lesser General Public
  29+   License as published by the Free Software Foundation; either
  30+   version 2.1 of the License, or (at your option) any later version.
  31+
  32+   The GNU C Library is distributed in the hope that it will be useful,
  33+   but WITHOUT ANY WARRANTY; without even the implied warranty of
  34+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  35+   Lesser General Public License for more details.
  36+
  37+   You should have received a copy of the GNU Lesser General Public
  38+   License along with the GNU C Library; if not, write to the Free
  39+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  40+   02111-1307 USA.  */
  41+
  42+#ifndef _MIPS_BITS_ATOMIC_H
  43+#define _MIPS_BITS_ATOMIC_H 1
  44+
  45+#include <inttypes.h>
  46+#include <sgidefs.h>
  47+
  48+typedef int32_t atomic32_t;
  49+typedef uint32_t uatomic32_t;
  50+typedef int_fast32_t atomic_fast32_t;
  51+typedef uint_fast32_t uatomic_fast32_t;
  52+
  53+typedef int64_t atomic64_t;
  54+typedef uint64_t uatomic64_t;
  55+typedef int_fast64_t atomic_fast64_t;
  56+typedef uint_fast64_t uatomic_fast64_t;
  57+
  58+typedef intptr_t atomicptr_t;
  59+typedef uintptr_t uatomicptr_t;
  60+typedef intmax_t atomic_max_t;
  61+typedef uintmax_t uatomic_max_t;
  62+
  63+/* Atomic compare and exchange. */
  64+
  65+#define atomic_compare_and_exchange_val_acq(mem, newval, oldval)         \
  66+  ({ __sync_synchronize();                      \
  67+     __sync_val_compare_and_swap(mem, oldval, newval); })
  68+
  69+#define atomic_compare_and_exchange_val_rel(mem, newval, oldval)         \
  70+  ({ typeof(*mem) __prev;                       \
  71+     __prev = __sync_val_compare_and_swap(mem, value);  \
  72+     __sync_synchronize();                      \
  73+     __prev; })
  74+
  75+/* Atomic exchange (without compare).  */
  76+
  77+#define atomic_exchange_acq(mem, value)         \
  78+  ({ __sync_synchronize();                      \
  79+     __sync_lock_test_and_set(mem, value); })
  80+
  81+#define atomic_exchange_rel(mem, value)         \
  82+  ({ typeof(*mem) __prev;                       \
  83+     __prev = __sync_lock_test_and_set(mem, value);  \
  84+     __sync_synchronize();                      \
  85+     __prev; })
  86+
  87+
  88+/* Atomically add value and return the previous (unincremented) value.  */
  89+
  90+/* ??? Barrier semantics for atomic_exchange_and_add appear to be 
  91+   undefined.  Use full barrier for now, as that's safe.  */
  92+#define atomic_exchange_and_add(mem, value)             \
  93+  ({ typeof(*mem) __prev;                               \
  94+     __sync_synchronize();                              \
  95+     __prev = __sync_fetch_and_add(mem, value);         \
  96+     __sync_synchronize();                              \
  97+     __prev; })
  98+
  99+#define catomic_exchange_and_add(mem, value)           \
 100+  atomic_exchange_and_add(mem, value)
 101+
 102+#define atomic_bit_test_set(mem, bit)                   \
 103+  ({ typeof(*mem) __prev;                               \
 104+     typeof(*mem) __mask = (typeof(*mem))1 << (bit);    \
 105+     __sync_synchronize();                              \
 106+     __prev = __sync_fetch_and_or(mem, __mask);         \
 107+     __sync_synchronize();                              \
 108+     __prev & __mask; })
 109+
 110+#define asm_maxmin(which, size, res, mem, value) \
 111+  asm ("amo" which "." size "\t%0, %1, 0(%2)" : "=r"(res) : "r"(value), "r"(mem) : "memory")
 112+
 113+#define atomic_max(mem, value)                         \
 114+  ({  typeof(*mem) __prev;                             \
 115+      __sync_synchronize();                                    \
 116+      if (sizeof(*mem) == 4)                           \
 117+       asm_maxmin("maxu", "s", __prev, mem, value);    \
 118+      else if(sizeof(*mem) == 8)                       \
 119+       asm_maxmin("maxu", "d", __prev, mem, value);    \
 120+      else                                             \
 121+       abort();                                        \
 122+     __sync_synchronize();                              \
 123+     __prev; })
 124+
 125+#define catomic_max(mem, value) atomic_max(mem, value)
 126+
 127+#define atomic_min(mem, value)                         \
 128+  ({  typeof(*mem) __prev;                             \
 129+      __sync_synchronize();                                    \
 130+      if (sizeof(*mem) == 4)                           \
 131+       asm_maxmin("minu", "s", __prev, mem, value);    \
 132+      else if(sizeof(*mem) == 8)                       \
 133+       asm_maxmin("minu", "d", __prev, mem, value);    \
 134+      else                                             \
 135+       abort();                                        \
 136+     __sync_synchronize();                              \
 137+     __prev; })
 138+
 139+#define atomic_full_barrier() __sync_synchronize()
 140+
 141+#endif /* bits/atomic.h */
 142diff -ruN glibc-2.19/sysdeps/riscv/bits/dlfcn.h glibc-2.19-riscv/sysdeps/riscv/bits/dlfcn.h
 143--- glibc-2.19/sysdeps/riscv/bits/dlfcn.h       1969-12-31 16:00:00.000000000 -0800
 144+++ glibc-2.19-riscv/sysdeps/riscv/bits/dlfcn.h 2014-12-09 16:55:03.152727766 -0800
 145@@ -0,0 +1,66 @@
 146+/* System dependent definitions for run-time dynamic loading.
 147+   Copyright (C) 1996, 1997, 1999, 2000, 2001, 2004
 148+       Free Software Foundation, Inc.
 149+   This file is part of the GNU C Library.
 150+
 151+   The GNU C Library is free software; you can redistribute it and/or
 152+   modify it under the terms of the GNU Lesser General Public
 153+   License as published by the Free Software Foundation; either
 154+   version 2.1 of the License, or (at your option) any later version.
 155+
 156+   The GNU C Library is distributed in the hope that it will be useful,
 157+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 158+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 159+   Lesser General Public License for more details.
 160+
 161+   You should have received a copy of the GNU Lesser General Public
 162+   License along with the GNU C Library; if not, write to the Free
 163+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 164+   02111-1307 USA.  */
 165+
 166+#ifndef _DLFCN_H
 167+# error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
 168+#endif
 169+
 170+/* The MODE argument to `dlopen' contains one of the following: */
 171+#define RTLD_LAZY      0x0001  /* Lazy function call binding.  */
 172+#define RTLD_NOW       0x0002  /* Immediate function call binding.  */
 173+#define RTLD_BINDING_MASK  0x3 /* Mask of binding time value.  */
 174+#define RTLD_NOLOAD    0x00008 /* Do not load the object.  */
 175+#define RTLD_DEEPBIND  0x00010 /* Use deep binding.  */
 176+
 177+/* If the following bit is set in the MODE argument to `dlopen',
 178+   the symbols of the loaded object and its dependencies are made
 179+   visible as if the object were linked directly into the program.  */
 180+#define RTLD_GLOBAL    0x0004
 181+
 182+/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.
 183+   The implementation does this by default and so we can define the
 184+   value to zero.  */
 185+#define RTLD_LOCAL      0
 186+
 187+/* Do not delete object when closed.  */
 188+#define RTLD_NODELETE  0x01000
 189+
 190+#ifdef __USE_GNU
 191+/* To support profiling of shared objects it is a good idea to call
 192+   the function found using `dlsym' using the following macro since
 193+   these calls do not use the PLT.  But this would mean the dynamic
 194+   loader has no chance to find out when the function is called.  The
 195+   macro applies the necessary magic so that profiling is possible.
 196+   Rewrite
 197+       foo = (*fctp) (arg1, arg2);
 198+   into
 199+        foo = DL_CALL_FCT (fctp, (arg1, arg2));
 200+*/
 201+# define DL_CALL_FCT(fctp, args) \
 202+  (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)
 203+
 204+__BEGIN_DECLS
 205+
 206+/* This function calls the profiling functions.  */
 207+extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW;
 208+
 209+__END_DECLS
 210+
 211+#endif
 212diff -ruN glibc-2.19/sysdeps/riscv/bits/endian.h glibc-2.19-riscv/sysdeps/riscv/bits/endian.h
 213--- glibc-2.19/sysdeps/riscv/bits/endian.h      1969-12-31 16:00:00.000000000 -0800
 214+++ glibc-2.19-riscv/sysdeps/riscv/bits/endian.h        2014-12-09 16:55:03.152727766 -0800
 215@@ -0,0 +1,13 @@
 216+/* The MIPS architecture has selectable endianness.
 217+   This file is for a machine using big-endian mode.  */
 218+
 219+#ifndef _ENDIAN_H
 220+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
 221+#endif
 222+
 223+#if __RISCVEB
 224+# define __BYTE_ORDER __BIG_ENDIAN
 225+#endif
 226+#if __RISCVEL
 227+# define __BYTE_ORDER __LITTLE_ENDIAN
 228+#endif
 229diff -ruN glibc-2.19/sysdeps/riscv/bits/fenv.h glibc-2.19-riscv/sysdeps/riscv/bits/fenv.h
 230--- glibc-2.19/sysdeps/riscv/bits/fenv.h        1969-12-31 16:00:00.000000000 -0800
 231+++ glibc-2.19-riscv/sysdeps/riscv/bits/fenv.h  2014-12-09 16:55:03.152727766 -0800
 232@@ -0,0 +1,77 @@
 233+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
 234+   This file is part of the GNU C Library.
 235+
 236+   The GNU C Library is free software; you can redistribute it and/or
 237+   modify it under the terms of the GNU Lesser General Public
 238+   License as published by the Free Software Foundation; either
 239+   version 2.1 of the License, or (at your option) any later version.
 240+
 241+   The GNU C Library is distributed in the hope that it will be useful,
 242+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 243+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 244+   Lesser General Public License for more details.
 245+
 246+   You should have received a copy of the GNU Lesser General Public
 247+   License along with the GNU C Library; if not, write to the Free
 248+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 249+   02111-1307 USA.  */
 250+
 251+#ifndef _FENV_H
 252+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
 253+#endif
 254+
 255+
 256+/* Define bits representing the exception.  We use the bit positions
 257+   of the appropriate bits in the FPU control word.  */
 258+enum
 259+  {
 260+    FE_INEXACT = 0x04,
 261+#define FE_INEXACT     FE_INEXACT
 262+    FE_UNDERFLOW = 0x08,
 263+#define FE_UNDERFLOW   FE_UNDERFLOW
 264+    FE_OVERFLOW = 0x10,
 265+#define FE_OVERFLOW    FE_OVERFLOW
 266+    FE_DIVBYZERO = 0x20,
 267+#define FE_DIVBYZERO   FE_DIVBYZERO
 268+    FE_INVALID = 0x40,
 269+#define FE_INVALID     FE_INVALID
 270+  };
 271+
 272+#define FE_ALL_EXCEPT \
 273+       (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
 274+
 275+/* The MIPS FPU supports all of the four defined rounding modes.  We
 276+   use again the bit positions in the FPU control word as the values
 277+   for the appropriate macros.  */
 278+enum
 279+  {
 280+    FE_TONEAREST = 0x0,
 281+#define FE_TONEAREST   FE_TONEAREST
 282+    FE_TOWARDZERO = 0x1,
 283+#define FE_TOWARDZERO  FE_TOWARDZERO
 284+    FE_UPWARD = 0x2,
 285+#define FE_UPWARD      FE_UPWARD
 286+    FE_DOWNWARD = 0x3
 287+#define FE_DOWNWARD    FE_DOWNWARD
 288+  };
 289+
 290+
 291+/* Type representing exception flags.  */
 292+typedef unsigned short int fexcept_t;
 293+
 294+
 295+/* Type representing floating-point environment.  This function corresponds
 296+   to the layout of the block written by the `fstenv'.  */
 297+typedef struct
 298+  {
 299+    unsigned int __fp_control_register;
 300+  }
 301+fenv_t;
 302+
 303+/* If the default argument is used we use this value.  */
 304+#define FE_DFL_ENV     ((__const fenv_t *) -1)
 305+
 306+#ifdef __USE_GNU
 307+/* Floating-point environment where none of the exception is masked.  */
 308+# define FE_NOMASK_ENV  ((__const fenv_t *) -2)
 309+#endif
 310diff -ruN glibc-2.19/sysdeps/riscv/bits/ipctypes.h glibc-2.19-riscv/sysdeps/riscv/bits/ipctypes.h
 311--- glibc-2.19/sysdeps/riscv/bits/ipctypes.h    1969-12-31 16:00:00.000000000 -0800
 312+++ glibc-2.19-riscv/sysdeps/riscv/bits/ipctypes.h      2014-12-09 16:55:03.152727766 -0800
 313@@ -0,0 +1,32 @@
 314+/* bits/ipctypes.h -- Define some types used by SysV IPC/MSG/SHM.  MIPS version
 315+   Copyright (C) 2002 Free Software Foundation, Inc.
 316+   This file is part of the GNU C Library.
 317+
 318+   The GNU C Library is free software; you can redistribute it and/or
 319+   modify it under the terms of the GNU Lesser General Public
 320+   License as published by the Free Software Foundation; either
 321+   version 2.1 of the License, or (at your option) any later version.
 322+
 323+   The GNU C Library is distributed in the hope that it will be useful,
 324+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 325+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 326+   Lesser General Public License for more details.
 327+
 328+   You should have received a copy of the GNU Lesser General Public
 329+   License along with the GNU C Library; if not, write to the Free
 330+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 331+   02111-1307 USA.  */
 332+
 333+/*
 334+ * Never include <bits/ipctypes.h> directly.
 335+ */
 336+
 337+#ifndef _BITS_IPCTYPES_H
 338+#define _BITS_IPCTYPES_H       1
 339+
 340+#include <bits/types.h>
 341+
 342+typedef __SLONG32_TYPE __ipc_pid_t;
 343+
 344+
 345+#endif /* bits/ipctypes.h */
 346diff -ruN glibc-2.19/sysdeps/riscv/bits/link.h glibc-2.19-riscv/sysdeps/riscv/bits/link.h
 347--- glibc-2.19/sysdeps/riscv/bits/link.h        1969-12-31 16:00:00.000000000 -0800
 348+++ glibc-2.19-riscv/sysdeps/riscv/bits/link.h  2014-12-09 16:55:03.152727766 -0800
 349@@ -0,0 +1,76 @@
 350+/* Copyright (C) 2005, 2009 Free Software Foundation, Inc.
 351+   This file is part of the GNU C Library.
 352+
 353+   The GNU C Library is free software; you can redistribute it and/or
 354+   modify it under the terms of the GNU Lesser General Public
 355+   License as published by the Free Software Foundation; either
 356+   version 2.1 of the License, or (at your option) any later version.
 357+
 358+   The GNU C Library is distributed in the hope that it will be useful,
 359+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 360+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 361+   Lesser General Public License for more details.
 362+
 363+   You should have received a copy of the GNU Lesser General Public
 364+   License along with the GNU C Library; if not, write to the Free
 365+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 366+   02111-1307 USA.  */
 367+
 368+#ifndef        _LINK_H
 369+# error "Never include <bits/link.h> directly; use <link.h> instead."
 370+#endif
 371+
 372+typedef struct La_mips_64_regs
 373+{
 374+  unsigned long lr_reg[8]; /* $a0 through $a7 */
 375+  double lr_fpreg[8]; /* $f4 throgh $f11 */
 376+  unsigned long lr_ra;
 377+  unsigned long lr_sp;
 378+} La_mips_64_regs;
 379+
 380+/* Return values for calls from PLT on MIPS.  */
 381+typedef struct La_mips_64_retval
 382+{
 383+  unsigned long lrv_v0;
 384+  unsigned long lrv_v1;
 385+  double lrv_fv0;
 386+  double lrv_fv1;
 387+} La_mips_64_retval;
 388+
 389+__BEGIN_DECLS
 390+
 391+#if _RISCV_SIM == _ABI32
 392+
 393+extern Elf32_Addr la_mips_n32_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
 394+                                           uintptr_t *__refcook,
 395+                                           uintptr_t *__defcook,
 396+                                           La_mips_64_regs *__regs,
 397+                                           unsigned int *__flags,
 398+                                           const char *__symname,
 399+                                           long int *__framesizep);
 400+extern unsigned int la_mips_n32_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
 401+                                            uintptr_t *__refcook,
 402+                                            uintptr_t *__defcook,
 403+                                            const La_mips_64_regs *__inregs,
 404+                                            La_mips_64_retval *__outregs,
 405+                                            const char *__symname);
 406+
 407+#else
 408+
 409+extern Elf64_Addr la_mips_n64_gnu_pltenter (Elf64_Sym *__sym, unsigned int __ndx,
 410+                                           uintptr_t *__refcook,
 411+                                           uintptr_t *__defcook,
 412+                                           La_mips_64_regs *__regs,
 413+                                           unsigned int *__flags,
 414+                                           const char *__symname,
 415+                                           long int *__framesizep);
 416+extern unsigned int la_mips_n64_gnu_pltexit (Elf64_Sym *__sym, unsigned int __ndx,
 417+                                            uintptr_t *__refcook,
 418+                                            uintptr_t *__defcook,
 419+                                            const La_mips_64_regs *__inregs,
 420+                                            La_mips_64_retval *__outregs,
 421+                                            const char *__symname);
 422+
 423+#endif
 424+
 425+__END_DECLS
 426diff -ruN glibc-2.19/sysdeps/riscv/bits/linkmap.h glibc-2.19-riscv/sysdeps/riscv/bits/linkmap.h
 427--- glibc-2.19/sysdeps/riscv/bits/linkmap.h     1969-12-31 16:00:00.000000000 -0800
 428+++ glibc-2.19-riscv/sysdeps/riscv/bits/linkmap.h       2014-12-09 16:55:03.152727766 -0800
 429@@ -0,0 +1,4 @@
 430+struct link_map_machine
 431+  {
 432+    ElfW(Addr) plt; /* Address of .plt */
 433+  };
 434diff -ruN glibc-2.19/sysdeps/riscv/bits/mathdef.h glibc-2.19-riscv/sysdeps/riscv/bits/mathdef.h
 435--- glibc-2.19/sysdeps/riscv/bits/mathdef.h     1969-12-31 16:00:00.000000000 -0800
 436+++ glibc-2.19-riscv/sysdeps/riscv/bits/mathdef.h       2014-12-09 16:55:03.152727766 -0800
 437@@ -0,0 +1,45 @@
 438+/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2007
 439+       Free Software Foundation, Inc.
 440+   This file is part of the GNU C Library.
 441+
 442+   The GNU C Library is free software; you can redistribute it and/or
 443+   modify it under the terms of the GNU Lesser General Public
 444+   License as published by the Free Software Foundation; either
 445+   version 2.1 of the License, or (at your option) any later version.
 446+
 447+   The GNU C Library is distributed in the hope that it will be useful,
 448+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 449+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 450+   Lesser General Public License for more details.
 451+
 452+   You should have received a copy of the GNU Lesser General Public
 453+   License along with the GNU C Library; if not, write to the Free
 454+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 455+   02111-1307 USA.  */
 456+
 457+#if !defined _MATH_H && !defined _COMPLEX_H
 458+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
 459+#endif
 460+
 461+#include <sgidefs.h>
 462+
 463+#if defined  __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
 464+# define _MATH_H_MATHDEF       1
 465+
 466+/* MIPS has `float' and `double' operations.  */
 467+typedef float float_t;         /* `float' expressions are evaluated as
 468+                                  `float'.  */
 469+typedef double double_t;       /* `double' expressions are evaluated as
 470+                                  `double'.  */
 471+
 472+/* The values returned by `ilogb' for 0 and NaN respectively.  */
 473+# define FP_ILOGB0     (-2147483647)
 474+# define FP_ILOGBNAN   2147483647
 475+
 476+#endif /* ISO C99 */
 477+
 478+#if ! defined __NO_LONG_DOUBLE_MATH && _RISCV_SIM == _ABI32
 479+/* Signal that we do not really have a `long double'.  This disables the
 480+   declaration of all the `long double' function variants.  */
 481+# define __NO_LONG_DOUBLE_MATH 1
 482+#endif
 483diff -ruN glibc-2.19/sysdeps/riscv/bits/nan.h glibc-2.19-riscv/sysdeps/riscv/bits/nan.h
 484--- glibc-2.19/sysdeps/riscv/bits/nan.h 1969-12-31 16:00:00.000000000 -0800
 485+++ glibc-2.19-riscv/sysdeps/riscv/bits/nan.h   2014-12-09 16:55:03.156727789 -0800
 486@@ -0,0 +1,56 @@
 487+/* `NAN' constant for IEEE 754 machines.
 488+   Copyright (C) 1992, 1996, 1997, 1999, 2002, 2004
 489+   Free Software Foundation, Inc.
 490+   This file is part of the GNU C Library.
 491+
 492+   The GNU C Library is free software; you can redistribute it and/or
 493+   modify it under the terms of the GNU Lesser General Public
 494+   License as published by the Free Software Foundation; either
 495+   version 2.1 of the License, or (at your option) any later version.
 496+
 497+   The GNU C Library is distributed in the hope that it will be useful,
 498+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 499+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 500+   Lesser General Public License for more details.
 501+
 502+   You should have received a copy of the GNU Lesser General Public
 503+   License along with the GNU C Library; if not, write to the Free
 504+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 505+   02111-1307 USA.  */
 506+
 507+#ifndef _MATH_H
 508+# error "Never use <bits/nan.h> directly; include <math.h> instead."
 509+#endif
 510+
 511+
 512+/* IEEE Not A Number (QNaN). Note that MIPS has the QNaN and SNaN patterns
 513+   reversed compared to most other architectures. The IEEE spec left
 514+   the definition of this open to implementations, and for MIPS the top
 515+   bit of the mantissa must be SET to indicate a SNaN.  */
 516+
 517+#if __GNUC_PREREQ(3,3)
 518+
 519+# define NAN   (__builtin_nanf(""))
 520+
 521+#elif defined __GNUC__
 522+
 523+# define NAN \
 524+  (__extension__                                                            \
 525+   ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; })  \
 526+    { __l: 0x7fbfffffUL }).__d)
 527+
 528+#else
 529+
 530+# include <endian.h>
 531+
 532+# if __BYTE_ORDER == __BIG_ENDIAN
 533+#  define __nan_bytes          { 0x7f, 0xbf, 0xff, 0xff }
 534+# endif
 535+# if __BYTE_ORDER == __LITTLE_ENDIAN
 536+#  define __nan_bytes          { 0xff, 0xff, 0xbf, 0x7f }
 537+# endif
 538+
 539+static union { unsigned char __c[4]; float __d; } __nan_union = { __nan_bytes };
 540+# define NAN   (__nan_union.__d)
 541+
 542+#endif /* GCC.  */
 543diff -ruN glibc-2.19/sysdeps/riscv/bits/setjmp.h glibc-2.19-riscv/sysdeps/riscv/bits/setjmp.h
 544--- glibc-2.19/sysdeps/riscv/bits/setjmp.h      1969-12-31 16:00:00.000000000 -0800
 545+++ glibc-2.19-riscv/sysdeps/riscv/bits/setjmp.h        2014-12-09 16:55:03.156727789 -0800
 546@@ -0,0 +1,43 @@
 547+/* Define the machine-dependent type `jmp_buf'.  RISC-V version.
 548+   Copyright (C) 1992,1993,1995,1997,2000,2002,2003,2004,2005,2006
 549+       Free Software Foundation, Inc.
 550+   This file is part of the GNU C Library.
 551+
 552+   The GNU C Library is free software; you can redistribute it and/or
 553+   modify it under the terms of the GNU Lesser General Public
 554+   License as published by the Free Software Foundation; either
 555+   version 2.1 of the License, or (at your option) any later version.
 556+
 557+   The GNU C Library is distributed in the hope that it will be useful,
 558+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 559+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 560+   Lesser General Public License for more details.
 561+
 562+   You should have received a copy of the GNU Lesser General Public
 563+   License along with the GNU C Library; if not, write to the Free
 564+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 565+   02111-1307 USA.  */
 566+
 567+#ifndef _RISCV_BITS_SETJMP_H
 568+#define _RISCV_BITS_SETJMP_H
 569+
 570+typedef struct __jmp_buf_internal_tag
 571+  {
 572+    /* Program counter.  */
 573+    long __pc;
 574+    /* Callee-saved registers. */
 575+    long __regs[12];
 576+    /* Stack pointer.  */
 577+    long __sp;
 578+    /* Thread pointer. */
 579+    long __tp;
 580+    /* Floating point status register.  */
 581+    long __fsr;
 582+
 583+    /* Callee-saved floating point registers.
 584+       Note that there are an even number of preceding words in this struct,
 585+       so no padding will be inserted before __fpregs, even for RV32. */
 586+    double __fpregs[16];
 587+  } __jmp_buf[1];
 588+
 589+#endif /* _RISCV_BITS_SETJMP_H */
 590diff -ruN glibc-2.19/sysdeps/riscv/bits/string.h glibc-2.19-riscv/sysdeps/riscv/bits/string.h
 591--- glibc-2.19/sysdeps/riscv/bits/string.h      1969-12-31 16:00:00.000000000 -0800
 592+++ glibc-2.19-riscv/sysdeps/riscv/bits/string.h        2014-12-09 16:55:03.156727789 -0800
 593@@ -0,0 +1,47 @@
 594+/* This file should provide inline versions of string functions.
 595+
 596+   Surround GCC-specific parts with #ifdef __GNUC__, and use `__extern_inline'.
 597+
 598+   This file should define __STRING_INLINES if functions are actually defined
 599+   as inlines.  */
 600+
 601+#ifndef _BITS_STRING_H
 602+#define _BITS_STRING_H 1
 603+
 604+#if defined(__GNUC__) && !defined(__cplusplus)
 605+
 606+#define _HAVE_STRING_ARCH_memcpy 1
 607+#define __use_memcpy_align(k, d, s, n) \
 608+  (__builtin_constant_p(n) && (n) % (k) == 0 && (n) <= 64 && \
 609+   __alignof__(d) >= (k) && __alignof__(s) >= (k))
 610+#define memcpy(d, s, n) \
 611+  (__use_memcpy_align(8, d, s, n) ? __memcpy_align8(d, s, n) : \
 612+   __use_memcpy_align(4, d, s, n) ? __memcpy_align4(d, s, n) : \
 613+   __memcpy_g(d, s, n))
 614+
 615+#define __declare_memcpy_align(size, type) \
 616+  static inline void *__memcpy_align ## size(void *__restrict __dest, \
 617+                        __const void *__restrict __src, size_t __n) { \
 618+    type *__d = (type*)__dest; \
 619+    const type *__s = (const type*)__src, *__e = (const type*)(__src + __n); \
 620+    while (__s < __e) { \
 621+      type __t = *__s; \
 622+      __d++, __s++; \
 623+      *(__d-1) = __t; \
 624+    } \
 625+    return __dest; \
 626+  }
 627+__declare_memcpy_align(8, long long)
 628+__declare_memcpy_align(4, int)
 629+
 630+#ifdef _LIBC
 631+extern void *__memcpy_g (void *__restrict __dest,
 632+                         __const void *__restrict __src, size_t __n);
 633+libc_hidden_proto (__memcpy_g)
 634+#else
 635+# define __memcpy_g memcpy
 636+#endif
 637+
 638+#endif /* __GNUC__ && !__cplusplus */
 639+
 640+#endif /* bits/string.h */
 641diff -ruN glibc-2.19/sysdeps/riscv/bits/wordsize.h glibc-2.19-riscv/sysdeps/riscv/bits/wordsize.h
 642--- glibc-2.19/sysdeps/riscv/bits/wordsize.h    1969-12-31 16:00:00.000000000 -0800
 643+++ glibc-2.19-riscv/sysdeps/riscv/bits/wordsize.h      2014-12-09 16:55:03.156727789 -0800
 644@@ -0,0 +1,22 @@
 645+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 646+   This file is part of the GNU C Library.
 647+
 648+   The GNU C Library is free software; you can redistribute it and/or
 649+   modify it under the terms of the GNU Lesser General Public
 650+   License as published by the Free Software Foundation; either
 651+   version 2.1 of the License, or (at your option) any later version.
 652+
 653+   The GNU C Library is distributed in the hope that it will be useful,
 654+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 655+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 656+   Lesser General Public License for more details.
 657+
 658+   You should have received a copy of the GNU Lesser General Public
 659+   License along with the GNU C Library; if not, write to the Free
 660+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 661+   02111-1307 USA.  */
 662+
 663+#define __WORDSIZE     _RISCV_SZPTR
 664+#if _RISCV_SIM == _ABI64
 665+# define __WORDSIZE_COMPAT32   1
 666+#endif
 667diff -ruN glibc-2.19/sysdeps/riscv/bsd-_setjmp.c glibc-2.19-riscv/sysdeps/riscv/bsd-_setjmp.c
 668--- glibc-2.19/sysdeps/riscv/bsd-_setjmp.c      1969-12-31 16:00:00.000000000 -0800
 669+++ glibc-2.19-riscv/sysdeps/riscv/bsd-_setjmp.c        2014-12-09 16:55:03.156727789 -0800
 670@@ -0,0 +1 @@
 671+/* _setjmp is implemented in setjmp.S */
 672diff -ruN glibc-2.19/sysdeps/riscv/bsd-setjmp.c glibc-2.19-riscv/sysdeps/riscv/bsd-setjmp.c
 673--- glibc-2.19/sysdeps/riscv/bsd-setjmp.c       1969-12-31 16:00:00.000000000 -0800
 674+++ glibc-2.19-riscv/sysdeps/riscv/bsd-setjmp.c 2014-12-09 16:55:03.156727789 -0800
 675@@ -0,0 +1 @@
 676+/* setjmp is implemented in setjmp.S */
 677diff -ruN glibc-2.19/sysdeps/riscv/dl-dtprocnum.h glibc-2.19-riscv/sysdeps/riscv/dl-dtprocnum.h
 678--- glibc-2.19/sysdeps/riscv/dl-dtprocnum.h     1969-12-31 16:00:00.000000000 -0800
 679+++ glibc-2.19-riscv/sysdeps/riscv/dl-dtprocnum.h       2014-12-09 16:55:03.156727789 -0800
 680@@ -0,0 +1,22 @@
 681+/* Configuration of lookup functions.  MIPS version.
 682+   Copyright (C) 2000 Free Software Foundation, Inc.
 683+   This file is part of the GNU C Library.
 684+
 685+   The GNU C Library is free software; you can redistribute it and/or
 686+   modify it under the terms of the GNU Lesser General Public
 687+   License as published by the Free Software Foundation; either
 688+   version 2.1 of the License, or (at your option) any later version.
 689+
 690+   The GNU C Library is distributed in the hope that it will be useful,
 691+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 692+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 693+   Lesser General Public License for more details.
 694+
 695+   You should have received a copy of the GNU Lesser General Public
 696+   License along with the GNU C Library; if not, write to the Free
 697+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 698+   02111-1307 USA.  */
 699+
 700+/* Number of extra dynamic section entries for this architecture.  By
 701+   default there are none.  */
 702+#define DT_THISPROCNUM DT_MIPS_NUM
 703diff -ruN glibc-2.19/sysdeps/riscv/dl-lookup.c glibc-2.19-riscv/sysdeps/riscv/dl-lookup.c
 704--- glibc-2.19/sysdeps/riscv/dl-lookup.c        1969-12-31 16:00:00.000000000 -0800
 705+++ glibc-2.19-riscv/sysdeps/riscv/dl-lookup.c  2014-12-09 16:55:03.156727789 -0800
 706@@ -0,0 +1,1033 @@
 707+/* Look up a symbol in the loaded objects.
 708+   MIPS/Linux version - special handling of non-PIC undefined symbol rules.
 709+   Copyright (C) 1995-2005, 2006, 2007, 2009, 2010
 710+   Free Software Foundation, Inc.
 711+   This file is part of the GNU C Library.
 712+
 713+   The GNU C Library is free software; you can redistribute it and/or
 714+   modify it under the terms of the GNU Lesser General Public
 715+   License as published by the Free Software Foundation; either
 716+   version 2.1 of the License, or (at your option) any later version.
 717+
 718+   The GNU C Library is distributed in the hope that it will be useful,
 719+   but WITHOUT ANY WARRANTY; without even the implied warranty of
 720+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 721+   Lesser General Public License for more details.
 722+
 723+   You should have received a copy of the GNU Lesser General Public
 724+   License along with the GNU C Library; if not, write to the Free
 725+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 726+   02111-1307 USA.  */
 727+
 728+#include <alloca.h>
 729+#include <libintl.h>
 730+#include <stdlib.h>
 731+#include <string.h>
 732+#include <unistd.h>
 733+#include <ldsodefs.h>
 734+#include <dl-hash.h>
 735+#include <dl-machine.h>
 736+#include <sysdep-cancel.h>
 737+#include <bits/libc-lock.h>
 738+#include <tls.h>
 739+
 740+#include <assert.h>
 741+
 742+#define VERSTAG(tag)   (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (tag))
 743+
 744+/* We need this string more than once.  */
 745+static const char undefined_msg[] = "undefined symbol: ";
 746+
 747+
 748+struct sym_val
 749+  {
 750+    const ElfW(Sym) *s;
 751+    struct link_map *m;
 752+  };
 753+
 754+
 755+#define make_string(string, rest...) \
 756+  ({                                                                         \
 757+    const char *all[] = { string, ## rest };                                 \
 758+    size_t len, cnt;                                                         \
 759+    char *result, *cp;                                                       \
 760+                                                                             \
 761+    len = 1;                                                                 \
 762+    for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt)               \
 763+      len += strlen (all[cnt]);                                                      \
 764+                                                                             \
 765+    cp = result = alloca (len);                                                      \
 766+    for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt)               \
 767+      cp = __stpcpy (cp, all[cnt]);                                          \
 768+                                                                             \
 769+    result;                                                                  \
 770+  })
 771+
 772+/* Statistics function.  */
 773+#ifdef SHARED
 774+# define bump_num_relocations() ++GL(dl_num_relocations)
 775+#else
 776+# define bump_num_relocations() ((void) 0)
 777+#endif
 778+
 779+
 780+/* Inner part of the lookup functions.  We return a value > 0 if we
 781+   found the symbol, the value 0 if nothing is found and < 0 if
 782+   something bad happened.  */
 783+static int
 784+__attribute_noinline__
 785+do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
 786+            unsigned long int *old_hash, const ElfW(Sym) *ref,
 787+            struct sym_val *result, struct r_scope_elem *scope, size_t i,
 788+            const struct r_found_version *const version, int flags,
 789+            struct link_map *skip, int type_class, struct link_map *undef_map)
 790+{
 791+  size_t n = scope->r_nlist;
 792+  /* Make sure we read the value before proceeding.  Otherwise we
 793+     might use r_list pointing to the initial scope and r_nlist being
 794+     the value after a resize.  That is the only path in dl-open.c not
 795+     protected by GSCOPE.  A read barrier here might be to expensive.  */
 796+  __asm volatile ("" : "+r" (n), "+m" (scope->r_list));
 797+  struct link_map **list = scope->r_list;
 798+
 799+  do
 800+    {
 801+      /* These variables are used in the nested function.  */
 802+      Elf_Symndx symidx;
 803+      int num_versions = 0;
 804+      const ElfW(Sym) *versioned_sym = NULL;
 805+
 806+      const struct link_map *map = list[i]->l_real;
 807+
 808+      /* Here come the extra test needed for `_dl_lookup_symbol_skip'.  */
 809+      if (map == skip)
 810+       continue;
 811+
 812+      /* Don't search the executable when resolving a copy reloc.  */
 813+      if ((type_class & ELF_RTYPE_CLASS_COPY) && map->l_type == lt_executable)
 814+       continue;
 815+
 816+      /* Do not look into objects which are going to be removed.  */
 817+      if (map->l_removed)
 818+       continue;
 819+
 820+      /* Print some debugging info if wanted.  */
 821+      if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0))
 822+       _dl_debug_printf ("symbol=%s;  lookup in file=%s [%lu]\n",
 823+                         undef_name,
 824+                         map->l_name[0] ? map->l_name : rtld_progname,
 825+                         map->l_ns);
 826+
 827+      /* If the hash table is empty there is nothing to do here.  */
 828+      if (map->l_nbuckets == 0)
 829+       continue;
 830+
 831+      /* The tables for this map.  */
 832+      const ElfW(Sym) *symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
 833+      const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 834+
 835+
 836+      /* Nested routine to check whether the symbol matches.  */
 837+      const ElfW(Sym) *
 838+      __attribute_noinline__
 839+      check_match (const ElfW(Sym) *sym)
 840+      {
 841+       unsigned int stt = ELFW(ST_TYPE) (sym->st_info);
 842+       assert (ELF_RTYPE_CLASS_PLT == 1);
 843+       /* The semantics of zero/non-zero values of undefined symbols
 844+          differs depending on whether the non-PIC ABI is in use.
 845+          Under the non-PIC ABI, a non-zero value indicates that
 846+          there is an address reference to the symbol and thus it
 847+          must always be resolved (except when resolving a jump slot
 848+          relocation) to the PLT entry whose address is provided as
 849+          the symbol's value; a zero value indicates that this
 850+          canonical-address behaviour is not required.  Yet under the
 851+          classic MIPS psABI, a zero value indicates that there is an
 852+          address reference to the function and the dynamic linker
 853+          must resolve the symbol immediately upon loading.  To avoid
 854+          conflict, symbols for which the dynamic linker must assume
 855+          the non-PIC ABI semantics are marked with the STO_MIPS_PLT
 856+          flag.  */
 857+       if (__builtin_expect ((sym->st_value == 0 /* No value.  */
 858+                              && stt != STT_TLS)
 859+                             || (sym->st_shndx == SHN_UNDEF
 860+                                 && !(sym->st_other & STO_MIPS_PLT))
 861+                             || (type_class & (sym->st_shndx == SHN_UNDEF)),
 862+                             0))
 863+         return NULL;
 864+
 865+       /* Ignore all but STT_NOTYPE, STT_OBJECT, STT_FUNC,
 866+          STT_COMMON, STT_TLS, and STT_GNU_IFUNC since these are no
 867+          code/data definitions.  */
 868+#define ALLOWED_STT \
 869+       ((1 << STT_NOTYPE) | (1 << STT_OBJECT) | (1 << STT_FUNC) \
 870+        | (1 << STT_COMMON) | (1 << STT_TLS) | (1 << STT_GNU_IFUNC))
 871+       if (__builtin_expect (((1 << stt) & ALLOWED_STT) == 0, 0))
 872+         return NULL;
 873+
 874+       if (sym != ref && strcmp (strtab + sym->st_name, undef_name))
 875+         /* Not the symbol we are looking for.  */
 876+         return NULL;
 877+
 878+       const ElfW(Half) *verstab = map->l_versyms;
 879+       if (version != NULL)
 880+         {
 881+           if (__builtin_expect (verstab == NULL, 0))
 882+             {
 883+               /* We need a versioned symbol but haven't found any.  If
 884+                  this is the object which is referenced in the verneed
 885+                  entry it is a bug in the library since a symbol must
 886+                  not simply disappear.
 887+
 888+                  It would also be a bug in the object since it means that
 889+                  the list of required versions is incomplete and so the
 890+                  tests in dl-version.c haven't found a problem.*/
 891+               assert (version->filename == NULL
 892+                       || ! _dl_name_match_p (version->filename, map));
 893+
 894+               /* Otherwise we accept the symbol.  */
 895+             }
 896+           else
 897+             {
 898+               /* We can match the version information or use the
 899+                  default one if it is not hidden.  */
 900+               ElfW(Half) ndx = verstab[symidx] & 0x7fff;
 901+               if ((map->l_versions[ndx].hash != version->hash
 902+                    || strcmp (map->l_versions[ndx].name, version->name))
 903+                   && (version->hidden || map->l_versions[ndx].hash
 904+                       || (verstab[symidx] & 0x8000)))
 905+                 /* It's not the version we want.  */
 906+                 return NULL;
 907+             }
 908+         }
 909+       else
 910+         {
 911+           /* No specific version is selected.  There are two ways we
 912+              can got here:
 913+
 914+              - a binary which does not include versioning information
 915+              is loaded
 916+
 917+              - dlsym() instead of dlvsym() is used to get a symbol which
 918+              might exist in more than one form
 919+
 920+              If the library does not provide symbol version information
 921+              there is no problem at at: we simply use the symbol if it
 922+              is defined.
 923+
 924+              These two lookups need to be handled differently if the
 925+              library defines versions.  In the case of the old
 926+              unversioned application the oldest (default) version
 927+              should be used.  In case of a dlsym() call the latest and
 928+              public interface should be returned.  */
 929+           if (verstab != NULL)
 930+             {
 931+               if ((verstab[symidx] & 0x7fff)
 932+                   >= ((flags & DL_LOOKUP_RETURN_NEWEST) ? 2 : 3))
 933+                 {
 934+                   /* Don't accept hidden symbols.  */
 935+                   if ((verstab[symidx] & 0x8000) == 0
 936+                       && num_versions++ == 0)
 937+                     /* No version so far.  */
 938+                     versioned_sym = sym;
 939+
 940+                   return NULL;
 941+                 }
 942+             }
 943+         }
 944+
 945+       /* There cannot be another entry for this symbol so stop here.  */
 946+       return sym;
 947+      }
 948+
 949+      const ElfW(Sym) *sym;
 950+      const ElfW(Addr) *bitmask = map->l_gnu_bitmask;
 951+      if (__builtin_expect (bitmask != NULL, 1))
 952+       {
 953+         ElfW(Addr) bitmask_word
 954+           = bitmask[(new_hash / __ELF_NATIVE_CLASS)
 955+                     & map->l_gnu_bitmask_idxbits];
 956+
 957+         unsigned int hashbit1 = new_hash & (__ELF_NATIVE_CLASS - 1);
 958+         unsigned int hashbit2 = ((new_hash >> map->l_gnu_shift)
 959+                                  & (__ELF_NATIVE_CLASS - 1));
 960+
 961+         if (__builtin_expect ((bitmask_word >> hashbit1)
 962+                               & (bitmask_word >> hashbit2) & 1, 0))
 963+           {
 964+             Elf32_Word bucket = map->l_gnu_buckets[new_hash
 965+                                                    % map->l_nbuckets];
 966+             if (bucket != 0)
 967+               {
 968+                 const Elf32_Word *hasharr = &map->l_gnu_chain_zero[bucket];
 969+
 970+                 do
 971+                   if (((*hasharr ^ new_hash) >> 1) == 0)
 972+                     {
 973+                       symidx = hasharr - map->l_gnu_chain_zero;
 974+                       sym = check_match (&symtab[symidx]);
 975+                       if (sym != NULL)
 976+                         goto found_it;
 977+                     }
 978+                 while ((*hasharr++ & 1u) == 0);
 979+               }
 980+           }
 981+         /* No symbol found.  */
 982+         symidx = SHN_UNDEF;
 983+       }
 984+      else
 985+       {
 986+         if (*old_hash == 0xffffffff)
 987+           *old_hash = _dl_elf_hash (undef_name);
 988+
 989+         /* Use the old SysV-style hash table.  Search the appropriate
 990+            hash bucket in this object's symbol table for a definition
 991+            for the same symbol name.  */
 992+         for (symidx = map->l_buckets[*old_hash % map->l_nbuckets];
 993+              symidx != STN_UNDEF;
 994+              symidx = map->l_chain[symidx])
 995+           {
 996+             sym = check_match (&symtab[symidx]);
 997+             if (sym != NULL)
 998+               goto found_it;
 999+           }
1000+       }
1001+
1002+      /* If we have seen exactly one versioned symbol while we are
1003+        looking for an unversioned symbol and the version is not the
1004+        default version we still accept this symbol since there are
1005+        no possible ambiguities.  */
1006+      sym = num_versions == 1 ? versioned_sym : NULL;
1007+
1008+      if (sym != NULL)
1009+       {
1010+       found_it:
1011+         switch (__builtin_expect (ELFW(ST_BIND) (sym->st_info), STB_GLOBAL))
1012+           {
1013+           case STB_WEAK:
1014+             /* Weak definition.  Use this value if we don't find another.  */
1015+             if (__builtin_expect (GLRO(dl_dynamic_weak), 0))
1016+               {
1017+                 if (! result->s)
1018+                   {
1019+                     result->s = sym;
1020+                     result->m = (struct link_map *) map;
1021+                   }
1022+                 break;
1023+               }
1024+             /* FALLTHROUGH */
1025+           case STB_GLOBAL:
1026+           success:
1027+             /* Global definition.  Just what we need.  */
1028+             result->s = sym;
1029+             result->m = (struct link_map *) map;
1030+             return 1;
1031+
1032+           case STB_GNU_UNIQUE:;
1033+             /* We have to determine whether we already found a
1034+                symbol with this name before.  If not then we have to
1035+                add it to the search table.  If we already found a
1036+                definition we have to use it.  */
1037+             void enter (struct unique_sym *table, size_t size,
1038+                         unsigned int hash, const char *name,
1039+                         const ElfW(Sym) *sym, struct link_map *map)
1040+             {
1041+               size_t idx = hash % size;
1042+               size_t hash2 = 1 + hash % (size - 2);
1043+               while (1)
1044+                 {
1045+                   if (table[idx].name == NULL)
1046+                     {
1047+                       table[idx].hashval = hash;
1048+                       table[idx].name = name;
1049+                       if ((type_class & ELF_RTYPE_CLASS_COPY) != 0)
1050+                         {
1051+                           table[idx].sym = ref;
1052+                           table[idx].map = undef_map;
1053+                         }
1054+                       else
1055+                         {
1056+                           table[idx].sym = sym;
1057+                           table[idx].map = map;
1058+
1059+                           if (map->l_type == lt_loaded)
1060+                             /* Make sure we don't unload this object by
1061+                                setting the appropriate flag.  */
1062+                             map->l_flags_1 |= DF_1_NODELETE;
1063+                         }
1064+
1065+                       return;
1066+                     }
1067+
1068+                   idx += hash2;
1069+                   if (idx >= size)
1070+                     idx -= size;
1071+                 }
1072+             }
1073+
1074+             struct unique_sym_table *tab
1075+               = &GL(dl_ns)[map->l_ns]._ns_unique_sym_table;
1076+
1077+             __rtld_lock_lock_recursive (tab->lock);
1078+
1079+             struct unique_sym *entries = tab->entries;
1080+             size_t size = tab->size;
1081+             if (entries != NULL)
1082+               {
1083+                 size_t idx = new_hash % size;
1084+                 size_t hash2 = 1 + new_hash % (size - 2);
1085+                 while (1)
1086+                   {
1087+                     if (entries[idx].hashval == new_hash
1088+                         && strcmp (entries[idx].name, undef_name) == 0)
1089+                       {
1090+                         result->s = entries[idx].sym;
1091+                         result->m = (struct link_map *) entries[idx].map;
1092+                         __rtld_lock_unlock_recursive (tab->lock);
1093+                         return 1;
1094+                       }
1095+
1096+                     if (entries[idx].name == NULL)
1097+                       break;
1098+
1099+                     idx += hash2;
1100+                     if (idx >= size)
1101+                       idx -= size;
1102+                   }
1103+
1104+                 if (size * 3 <= tab->n_elements * 4)
1105+                   {
1106+                     /* Expand the table.  */
1107+#ifdef RTLD_CHECK_FOREIGN_CALL
1108+                     /* This must not happen during runtime relocations.  */
1109+                     assert (!RTLD_CHECK_FOREIGN_CALL);
1110+#endif
1111+                     size_t newsize = _dl_higher_prime_number (size + 1);
1112+                     struct unique_sym *newentries
1113+                       = calloc (sizeof (struct unique_sym), newsize);
1114+                     if (newentries == NULL)
1115+                       {
1116+                       nomem:
1117+                         __rtld_lock_unlock_recursive (tab->lock);
1118+                         _dl_fatal_printf ("out of memory\n");
1119+                       }
1120+
1121+                     for (idx = 0; idx < size; ++idx)
1122+                       if (entries[idx].name != NULL)
1123+                         enter (newentries, newsize, entries[idx].hashval,
1124+                                entries[idx].name, entries[idx].sym,
1125+                                entries[idx].map);
1126+
1127+                     tab->free (entries);
1128+                     tab->size = newsize;
1129+                     size = newsize;
1130+                     entries = tab->entries = newentries;
1131+                     tab->free = free;
1132+                   }
1133+               }
1134+             else
1135+               {
1136+#ifdef RTLD_CHECK_FOREIGN_CALL
1137+                 /* This must not happen during runtime relocations.  */
1138+                 assert (!RTLD_CHECK_FOREIGN_CALL);
1139+#endif
1140+
1141+#ifdef SHARED
1142+                 /* If tab->entries is NULL, but tab->size is not, it means
1143+                    this is the second, conflict finding, lookup for
1144+                    LD_TRACE_PRELINKING in _dl_debug_bindings.  Don't
1145+                    allocate anything and don't enter anything into the
1146+                    hash table.  */
1147+                 if (__builtin_expect (tab->size, 0))
1148+                   {
1149+                     assert (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK);
1150+                     __rtld_lock_unlock_recursive (tab->lock);
1151+                     goto success;
1152+                   }
1153+#endif
1154+
1155+#define INITIAL_NUNIQUE_SYM_TABLE 31
1156+                 size = INITIAL_NUNIQUE_SYM_TABLE;
1157+                 entries = calloc (sizeof (struct unique_sym), size);
1158+                 if (entries == NULL)
1159+                   goto nomem;
1160+
1161+                 tab->entries = entries;
1162+                 tab->size = size;
1163+                 tab->free = free;
1164+               }
1165+
1166+             enter (entries, size, new_hash, strtab + sym->st_name, sym,
1167+                    (struct link_map *) map);
1168+             ++tab->n_elements;
1169+
1170+             __rtld_lock_unlock_recursive (tab->lock);
1171+
1172+             goto success;
1173+
1174+           default:
1175+             /* Local symbols are ignored.  */
1176+             break;
1177+           }
1178+       }
1179+
1180+      /* If this current map is the one mentioned in the verneed entry
1181+        and we have not found a weak entry, it is a bug.  */
1182+      if (symidx == STN_UNDEF && version != NULL && version->filename != NULL
1183+         && __builtin_expect (_dl_name_match_p (version->filename, map), 0))
1184+       return -1;
1185+    }
1186+  while (++i < n);
1187+
1188+  /* We have not found anything until now.  */
1189+  return 0;
1190+}
1191+
1192+
1193+static uint_fast32_t
1194+dl_new_hash (const char *s)
1195+{
1196+  uint_fast32_t h = 5381;
1197+  for (unsigned char c = *s; c != '\0'; c = *++s)
1198+    h = h * 33 + c;
1199+  return h & 0xffffffff;
1200+}
1201+
1202+
1203+/* Add extra dependency on MAP to UNDEF_MAP.  */
1204+static int
1205+internal_function
1206+add_dependency (struct link_map *undef_map, struct link_map *map, int flags)
1207+{
1208+  struct link_map *runp;
1209+  unsigned int i;
1210+  int result = 0;
1211+
1212+  /* Avoid self-references and references to objects which cannot be
1213+     unloaded anyway.  */
1214+  if (undef_map == map)
1215+    return 0;
1216+
1217+  /* Avoid references to objects which cannot be unloaded anyway.  */
1218+  assert (map->l_type == lt_loaded);
1219+  if ((map->l_flags_1 & DF_1_NODELETE) != 0)
1220+    return 0;
1221+
1222+  struct link_map_reldeps *l_reldeps
1223+    = atomic_forced_read (undef_map->l_reldeps);
1224+
1225+  /* Make sure l_reldeps is read before l_initfini.  */
1226+  atomic_read_barrier ();
1227+
1228+  /* Determine whether UNDEF_MAP already has a reference to MAP.  First
1229+     look in the normal dependencies.  */
1230+  struct link_map **l_initfini = atomic_forced_read (undef_map->l_initfini);
1231+  if (l_initfini != NULL)
1232+    {
1233+      for (i = 0; l_initfini[i] != NULL; ++i)
1234+       if (l_initfini[i] == map)
1235+         return 0;
1236+    }
1237+
1238+  /* No normal dependency.  See whether we already had to add it
1239+     to the special list of dynamic dependencies.  */
1240+  unsigned int l_reldepsact = 0;
1241+  if (l_reldeps != NULL)
1242+    {
1243+      struct link_map **list = &l_reldeps->list[0];
1244+      l_reldepsact = l_reldeps->act;
1245+      for (i = 0; i < l_reldepsact; ++i)
1246+       if (list[i] == map)
1247+         return 0;
1248+    }
1249+
1250+  /* Save serial number of the target MAP.  */
1251+  unsigned long long serial = map->l_serial;
1252+
1253+  /* Make sure nobody can unload the object while we are at it.  */
1254+  if (__builtin_expect (flags & DL_LOOKUP_GSCOPE_LOCK, 0))
1255+    {
1256+      /* We can't just call __rtld_lock_lock_recursive (GL(dl_load_lock))
1257+        here, that can result in ABBA deadlock.  */
1258+      THREAD_GSCOPE_RESET_FLAG ();
1259+      __rtld_lock_lock_recursive (GL(dl_load_lock));
1260+      /* While MAP value won't change, after THREAD_GSCOPE_RESET_FLAG ()
1261+        it can e.g. point to unallocated memory.  So avoid the optimizer
1262+        treating the above read from MAP->l_serial as ensurance it
1263+        can safely dereference it.  */
1264+      map = atomic_forced_read (map);
1265+
1266+      /* From this point on it is unsafe to dereference MAP, until it
1267+        has been found in one of the lists.  */
1268+
1269+      /* Redo the l_initfini check in case undef_map's l_initfini
1270+        changed in the mean time.  */
1271+      if (undef_map->l_initfini != l_initfini
1272+         && undef_map->l_initfini != NULL)
1273+       {
1274+         l_initfini = undef_map->l_initfini;
1275+         for (i = 0; l_initfini[i] != NULL; ++i)
1276+           if (l_initfini[i] == map)
1277+             goto out_check;
1278+       }
1279+
1280+      /* Redo the l_reldeps check if undef_map's l_reldeps changed in
1281+        the mean time.  */
1282+      if (undef_map->l_reldeps != NULL)
1283+       {
1284+         if (undef_map->l_reldeps != l_reldeps)
1285+           {
1286+             struct link_map **list = &undef_map->l_reldeps->list[0];
1287+             l_reldepsact = undef_map->l_reldeps->act;
1288+             for (i = 0; i < l_reldepsact; ++i)
1289+               if (list[i] == map)
1290+                 goto out_check;
1291+           }
1292+         else if (undef_map->l_reldeps->act > l_reldepsact)
1293+           {
1294+             struct link_map **list
1295+               = &undef_map->l_reldeps->list[0];
1296+             i = l_reldepsact;
1297+             l_reldepsact = undef_map->l_reldeps->act;
1298+             for (; i < l_reldepsact; ++i)
1299+               if (list[i] == map)
1300+                 goto out_check;
1301+           }
1302+       }
1303+    }
1304+  else
1305+    __rtld_lock_lock_recursive (GL(dl_load_lock));
1306+
1307+  /* The object is not yet in the dependency list.  Before we add
1308+     it make sure just one more time the object we are about to
1309+     reference is still available.  There is a brief period in
1310+     which the object could have been removed since we found the
1311+     definition.  */
1312+  runp = GL(dl_ns)[undef_map->l_ns]._ns_loaded;
1313+  while (runp != NULL && runp != map)
1314+    runp = runp->l_next;
1315+
1316+  if (runp != NULL)
1317+    {
1318+      /* The object is still available.  */
1319+
1320+      /* MAP could have been dlclosed, freed and then some other dlopened
1321+        library could have the same link_map pointer.  */
1322+      if (map->l_serial != serial)
1323+       goto out_check;
1324+
1325+      /* Redo the NODELETE check, as when dl_load_lock wasn't held
1326+        yet this could have changed.  */
1327+      if ((map->l_flags_1 & DF_1_NODELETE) != 0)
1328+       goto out;
1329+
1330+      /* If the object with the undefined reference cannot be removed ever
1331+        just make sure the same is true for the object which contains the
1332+        definition.  */
1333+      if (undef_map->l_type != lt_loaded
1334+         || (undef_map->l_flags_1 & DF_1_NODELETE) != 0)
1335+       {
1336+         map->l_flags_1 |= DF_1_NODELETE;
1337+         goto out;
1338+       }
1339+
1340+      /* Add the reference now.  */
1341+      if (__builtin_expect (l_reldepsact >= undef_map->l_reldepsmax, 0))
1342+       {
1343+         /* Allocate more memory for the dependency list.  Since this
1344+            can never happen during the startup phase we can use
1345+            `realloc'.  */
1346+         struct link_map_reldeps *newp;
1347+         unsigned int max
1348+           = undef_map->l_reldepsmax ? undef_map->l_reldepsmax * 2 : 10;
1349+
1350+#ifdef RTLD_PREPARE_FOREIGN_CALL
1351+         RTLD_PREPARE_FOREIGN_CALL;
1352+#endif
1353+
1354+         newp = malloc (sizeof (*newp) + max * sizeof (struct link_map *));
1355+         if (newp == NULL)
1356+           {
1357+             /* If we didn't manage to allocate memory for the list this is
1358+                no fatal problem.  We simply make sure the referenced object
1359+                cannot be unloaded.  This is semantically the correct
1360+                behavior.  */
1361+             map->l_flags_1 |= DF_1_NODELETE;
1362+             goto out;
1363+           }
1364+         else
1365+           {
1366+             if (l_reldepsact)
1367+               memcpy (&newp->list[0], &undef_map->l_reldeps->list[0],
1368+                       l_reldepsact * sizeof (struct link_map *));
1369+             newp->list[l_reldepsact] = map;
1370+             newp->act = l_reldepsact + 1;
1371+             atomic_write_barrier ();
1372+             void *old = undef_map->l_reldeps;
1373+             undef_map->l_reldeps = newp;
1374+             undef_map->l_reldepsmax = max;
1375+             if (old)
1376+               _dl_scope_free (old);
1377+           }
1378+       }
1379+      else
1380+       {
1381+         undef_map->l_reldeps->list[l_reldepsact] = map;
1382+         atomic_write_barrier ();
1383+         undef_map->l_reldeps->act = l_reldepsact + 1;
1384+       }
1385+
1386+      /* Display information if we are debugging.  */
1387+      if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
1388+       _dl_debug_printf ("\
1389+\nfile=%s [%lu];  needed by %s [%lu] (relocation dependency)\n\n",
1390+                         map->l_name[0] ? map->l_name : rtld_progname,
1391+                         map->l_ns,
1392+                         undef_map->l_name[0]
1393+                         ? undef_map->l_name : rtld_progname,
1394+                         undef_map->l_ns);
1395+    }
1396+  else
1397+    /* Whoa, that was bad luck.  We have to search again.  */
1398+    result = -1;
1399+
1400+ out:
1401+  /* Release the lock.  */
1402+  __rtld_lock_unlock_recursive (GL(dl_load_lock));
1403+
1404+  if (__builtin_expect (flags & DL_LOOKUP_GSCOPE_LOCK, 0))
1405+    THREAD_GSCOPE_SET_FLAG ();
1406+
1407+  return result;
1408+
1409+ out_check:
1410+  if (map->l_serial != serial)
1411+    result = -1;
1412+  goto out;
1413+}
1414+
1415+static void
1416+internal_function
1417+_dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
1418+                   const ElfW(Sym) **ref, struct sym_val *value,
1419+                   const struct r_found_version *version, int type_class,
1420+                   int protected);
1421+
1422+
1423+/* Search loaded objects' symbol tables for a definition of the symbol
1424+   UNDEF_NAME, perhaps with a requested version for the symbol.
1425+
1426+   We must never have calls to the audit functions inside this function
1427+   or in any function which gets called.  If this would happen the audit
1428+   code might create a thread which can throw off all the scope locking.  */
1429+lookup_t
1430+internal_function
1431+_dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
1432+                    const ElfW(Sym) **ref,
1433+                    struct r_scope_elem *symbol_scope[],
1434+                    const struct r_found_version *version,
1435+                    int type_class, int flags, struct link_map *skip_map)
1436+{
1437+  const uint_fast32_t new_hash = dl_new_hash (undef_name);
1438+  unsigned long int old_hash = 0xffffffff;
1439+  struct sym_val current_value = { NULL, NULL };
1440+  struct r_scope_elem **scope = symbol_scope;
1441+
1442+  bump_num_relocations ();
1443+
1444+  /* No other flag than DL_LOOKUP_ADD_DEPENDENCY or DL_LOOKUP_GSCOPE_LOCK
1445+     is allowed if we look up a versioned symbol.  */
1446+  assert (version == NULL
1447+         || (flags & ~(DL_LOOKUP_ADD_DEPENDENCY | DL_LOOKUP_GSCOPE_LOCK))
1448+            == 0);
1449+
1450+  size_t i = 0;
1451+  if (__builtin_expect (skip_map != NULL, 0))
1452+    /* Search the relevant loaded objects for a definition.  */
1453+    while ((*scope)->r_list[i] != skip_map)
1454+      ++i;
1455+
1456+  /* Search the relevant loaded objects for a definition.  */
1457+  for (size_t start = i; *scope != NULL; start = 0, ++scope)
1458+    {
1459+      int res = do_lookup_x (undef_name, new_hash, &old_hash, *ref,
1460+                            &current_value, *scope, start, version, flags,
1461+                            skip_map, type_class, undef_map);
1462+      if (res > 0)
1463+       break;
1464+
1465+      if (__builtin_expect (res, 0) < 0 && skip_map == NULL)
1466+       {
1467+         /* Oh, oh.  The file named in the relocation entry does not
1468+            contain the needed symbol.  This code is never reached
1469+            for unversioned lookups.  */
1470+         assert (version != NULL);
1471+         const char *reference_name = undef_map ? undef_map->l_name : NULL;
1472+
1473+         /* XXX We cannot translate the message.  */
1474+         _dl_signal_cerror (0, (reference_name[0]
1475+                                ? reference_name
1476+                                : (rtld_progname ?: "<main program>")),
1477+                            N_("relocation error"),
1478+                            make_string ("symbol ", undef_name, ", version ",
1479+                                         version->name,
1480+                                         " not defined in file ",
1481+                                         version->filename,
1482+                                         " with link time reference",
1483+                                         res == -2
1484+                                         ? " (no version symbols)" : ""));
1485+         *ref = NULL;
1486+         return 0;
1487+       }
1488+    }
1489+
1490+  if (__builtin_expect (current_value.s == NULL, 0))
1491+    {
1492+      if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
1493+         && skip_map == NULL)
1494+       {
1495+         /* We could find no value for a strong reference.  */
1496+         const char *reference_name = undef_map ? undef_map->l_name : "";
1497+         const char *versionstr = version ? ", version " : "";
1498+         const char *versionname = (version && version->name
1499+                                    ? version->name : "");
1500+
1501+         /* XXX We cannot translate the message.  */
1502+         _dl_signal_cerror (0, (reference_name[0]
1503+                                ? reference_name
1504+                                : (rtld_progname ?: "<main program>")),
1505+                            N_("symbol lookup error"),
1506+                            make_string (undefined_msg, undef_name,
1507+                                         versionstr, versionname));
1508+       }
1509+      *ref = NULL;
1510+      return 0;
1511+    }
1512+
1513+  int protected = (*ref
1514+                  && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED);
1515+  if (__builtin_expect (protected != 0, 0))
1516+    {
1517+      /* It is very tricky.  We need to figure out what value to
1518+        return for the protected symbol.  */
1519+      if (type_class == ELF_RTYPE_CLASS_PLT)
1520+       {
1521+         if (current_value.s != NULL && current_value.m != undef_map)
1522+           {
1523+             current_value.s = *ref;
1524+             current_value.m = undef_map;
1525+           }
1526+       }
1527+      else
1528+       {
1529+         struct sym_val protected_value = { NULL, NULL };
1530+
1531+         for (scope = symbol_scope; *scope != NULL; i = 0, ++scope)
1532+           if (do_lookup_x (undef_name, new_hash, &old_hash, *ref,
1533+                            &protected_value, *scope, i, version, flags,
1534+                            skip_map, ELF_RTYPE_CLASS_PLT, NULL) != 0)
1535+             break;
1536+
1537+         if (protected_value.s != NULL && protected_value.m != undef_map)
1538+           {
1539+             current_value.s = *ref;
1540+             current_value.m = undef_map;
1541+           }
1542+       }
1543+    }
1544+
1545+  /* We have to check whether this would bind UNDEF_MAP to an object
1546+     in the global scope which was dynamically loaded.  In this case
1547+     we have to prevent the latter from being unloaded unless the
1548+     UNDEF_MAP object is also unloaded.  */
1549+  if (__builtin_expect (current_value.m->l_type == lt_loaded, 0)
1550+      /* Don't do this for explicit lookups as opposed to implicit
1551+        runtime lookups.  */
1552+      && (flags & DL_LOOKUP_ADD_DEPENDENCY) != 0
1553+      /* Add UNDEF_MAP to the dependencies.  */
1554+      && add_dependency (undef_map, current_value.m, flags) < 0)
1555+      /* Something went wrong.  Perhaps the object we tried to reference
1556+        was just removed.  Try finding another definition.  */
1557+      return _dl_lookup_symbol_x (undef_name, undef_map, ref,
1558+                                 (flags & DL_LOOKUP_GSCOPE_LOCK)
1559+                                 ? undef_map->l_scope : symbol_scope,
1560+                                 version, type_class, flags, skip_map);
1561+
1562+  /* The object is used.  */
1563+  if (__builtin_expect (current_value.m->l_used == 0, 0))
1564+    current_value.m->l_used = 1;
1565+
1566+  if (__builtin_expect (GLRO(dl_debug_mask)
1567+                       & (DL_DEBUG_BINDINGS|DL_DEBUG_PRELINK), 0))
1568+    _dl_debug_bindings (undef_name, undef_map, ref,
1569+                       &current_value, version, type_class, protected);
1570+
1571+  *ref = current_value.s;
1572+  return LOOKUP_VALUE (current_value.m);
1573+}
1574+
1575+
1576+/* Cache the location of MAP's hash table.  */
1577+
1578+void
1579+internal_function
1580+_dl_setup_hash (struct link_map *map)
1581+{
1582+  Elf_Symndx *hash;
1583+  Elf_Symndx nchain;
1584+
1585+  if (__builtin_expect (map->l_info[DT_ADDRTAGIDX (DT_GNU_HASH) + DT_NUM
1586+                                   + DT_THISPROCNUM + DT_VERSIONTAGNUM
1587+                                   + DT_EXTRANUM + DT_VALNUM] != NULL, 1))
1588+    {
1589+      Elf32_Word *hash32
1590+       = (void *) D_PTR (map, l_info[DT_ADDRTAGIDX (DT_GNU_HASH) + DT_NUM
1591+                                     + DT_THISPROCNUM + DT_VERSIONTAGNUM
1592+                                     + DT_EXTRANUM + DT_VALNUM]);
1593+      map->l_nbuckets = *hash32++;
1594+      Elf32_Word symbias = *hash32++;
1595+      Elf32_Word bitmask_nwords = *hash32++;
1596+      /* Must be a power of two.  */
1597+      assert ((bitmask_nwords & (bitmask_nwords - 1)) == 0);
1598+      map->l_gnu_bitmask_idxbits = bitmask_nwords - 1;
1599+      map->l_gnu_shift = *hash32++;
1600+
1601+      map->l_gnu_bitmask = (ElfW(Addr) *) hash32;
1602+      hash32 += __ELF_NATIVE_CLASS / 32 * bitmask_nwords;
1603+
1604+      map->l_gnu_buckets = hash32;
1605+      hash32 += map->l_nbuckets;
1606+      map->l_gnu_chain_zero = hash32 - symbias;
1607+      return;
1608+    }
1609+
1610+  if (!map->l_info[DT_HASH])
1611+    return;
1612+  hash = (void *) D_PTR (map, l_info[DT_HASH]);
1613+
1614+  map->l_nbuckets = *hash++;
1615+  nchain = *hash++;
1616+  map->l_buckets = hash;
1617+  hash += map->l_nbuckets;
1618+  map->l_chain = hash;
1619+}
1620+
1621+
1622+static void
1623+internal_function
1624+_dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
1625+                   const ElfW(Sym) **ref, struct sym_val *value,
1626+                   const struct r_found_version *version, int type_class,
1627+                   int protected)
1628+{
1629+  const char *reference_name = undef_map->l_name;
1630+
1631+  if (GLRO(dl_debug_mask) & DL_DEBUG_BINDINGS)
1632+    {
1633+      _dl_debug_printf ("binding file %s [%lu] to %s [%lu]: %s symbol `%s'",
1634+                       (reference_name[0]
1635+                        ? reference_name
1636+                        : (rtld_progname ?: "<main program>")),
1637+                       undef_map->l_ns,
1638+                       value->m->l_name[0] ? value->m->l_name : rtld_progname,
1639+                       value->m->l_ns,
1640+                       protected ? "protected" : "normal", undef_name);
1641+      if (version)
1642+       _dl_debug_printf_c (" [%s]\n", version->name);
1643+      else
1644+       _dl_debug_printf_c ("\n");
1645+    }
1646+#ifdef SHARED
1647+  if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK)
1648+    {
1649+      int conflict = 0;
1650+      struct sym_val val = { NULL, NULL };
1651+
1652+      if ((GLRO(dl_trace_prelink_map) == NULL
1653+          || GLRO(dl_trace_prelink_map) == GL(dl_ns)[LM_ID_BASE]._ns_loaded)
1654+         && undef_map != GL(dl_ns)[LM_ID_BASE]._ns_loaded)
1655+       {
1656+         const uint_fast32_t new_hash = dl_new_hash (undef_name);
1657+         unsigned long int old_hash = 0xffffffff;
1658+         struct unique_sym *saved_entries
1659+           = GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries;
1660+
1661+         GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries = NULL;
1662+         do_lookup_x (undef_name, new_hash, &old_hash, *ref, &val,
1663+                      undef_map->l_local_scope[0], 0, version, 0, NULL,
1664+                      type_class, undef_map);
1665+         if (val.s != value->s || val.m != value->m)
1666+           conflict = 1;
1667+         else if (__builtin_expect (undef_map->l_symbolic_in_local_scope, 0)
1668+                  && val.s
1669+                  && __builtin_expect (ELFW(ST_BIND) (val.s->st_info),
1670+                                       STB_GLOBAL) == STB_GNU_UNIQUE)
1671+           {
1672+             /* If it is STB_GNU_UNIQUE and undef_map's l_local_scope
1673+                contains any DT_SYMBOLIC libraries, unfortunately there
1674+                can be conflicts even if the above is equal.  As symbol
1675+                resolution goes from the last library to the first and
1676+                if a STB_GNU_UNIQUE symbol is found in some late DT_SYMBOLIC
1677+                library, it would be the one that is looked up.  */
1678+             struct sym_val val2 = { NULL, NULL };
1679+             size_t n;
1680+             struct r_scope_elem *scope = undef_map->l_local_scope[0];
1681+
1682+             for (n = 0; n < scope->r_nlist; n++)
1683+               if (scope->r_list[n] == val.m)
1684+                 break;
1685+
1686+             for (n++; n < scope->r_nlist; n++)
1687+               if (scope->r_list[n]->l_info[DT_SYMBOLIC] != NULL
1688+                   && do_lookup_x (undef_name, new_hash, &old_hash, *ref,
1689+                                   &val2,
1690+                                   &scope->r_list[n]->l_symbolic_searchlist,
1691+                                   0, version, 0, NULL, type_class,
1692+                                   undef_map) > 0)
1693+                 {
1694+                   conflict = 1;
1695+                   val = val2;
1696+                   break;
1697+                 }
1698+           }
1699+         GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries = saved_entries;
1700+       }
1701+
1702+      if (value->s)
1703+       {
1704+         if (__builtin_expect (ELFW(ST_TYPE) (value->s->st_info)
1705+                               == STT_TLS, 0))
1706+           type_class = 4;
1707+         else if (__builtin_expect (ELFW(ST_TYPE) (value->s->st_info)
1708+                                    == STT_GNU_IFUNC, 0))
1709+           type_class |= 8;
1710+       }
1711+
1712+      if (conflict
1713+         || GLRO(dl_trace_prelink_map) == undef_map
1714+         || GLRO(dl_trace_prelink_map) == NULL
1715+         || type_class >= 4)
1716+       {
1717+         _dl_printf ("%s 0x%0*Zx 0x%0*Zx -> 0x%0*Zx 0x%0*Zx ",
1718+                     conflict ? "conflict" : "lookup",
1719+                     (int) sizeof (ElfW(Addr)) * 2,
1720+                     (size_t) undef_map->l_map_start,
1721+                     (int) sizeof (ElfW(Addr)) * 2,
1722+                     (size_t) (((ElfW(Addr)) *ref) - undef_map->l_map_start),
1723+                     (int) sizeof (ElfW(Addr)) * 2,
1724+                     (size_t) (value->s ? value->m->l_map_start : 0),
1725+                     (int) sizeof (ElfW(Addr)) * 2,
1726+                     (size_t) (value->s ? value->s->st_value : 0));
1727+
1728+         if (conflict)
1729+           _dl_printf ("x 0x%0*Zx 0x%0*Zx ",
1730+                       (int) sizeof (ElfW(Addr)) * 2,
1731+                       (size_t) (val.s ? val.m->l_map_start : 0),
1732+                       (int) sizeof (ElfW(Addr)) * 2,
1733+                       (size_t) (val.s ? val.s->st_value : 0));
1734+
1735+         _dl_printf ("/%x %s\n", type_class, undef_name);
1736+       }
1737+    }
1738+#endif
1739+}
1740diff -ruN glibc-2.19/sysdeps/riscv/dl-machine.h glibc-2.19-riscv/sysdeps/riscv/dl-machine.h
1741--- glibc-2.19/sysdeps/riscv/dl-machine.h       1969-12-31 16:00:00.000000000 -0800
1742+++ glibc-2.19-riscv/sysdeps/riscv/dl-machine.h 2014-12-09 16:55:03.156727789 -0800
1743@@ -0,0 +1,717 @@
1744+/* Machine-dependent ELF dynamic relocation inline functions.  MIPS version.
1745+   Copyright (C) 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007
1746+   Free Software Foundation, Inc.
1747+   This file is part of the GNU C Library.
1748+   Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
1749+
1750+   The GNU C Library is free software; you can redistribute it and/or
1751+   modify it under the terms of the GNU Lesser General Public
1752+   License as published by the Free Software Foundation; either
1753+   version 2.1 of the License, or (at your option) any later version.
1754+
1755+   The GNU C Library is distributed in the hope that it will be useful,
1756+   but WITHOUT ANY WARRANTY; without even the implied warranty of
1757+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1758+   Lesser General Public License for more details.
1759+
1760+   You should have received a copy of the GNU Lesser General Public
1761+   License along with the GNU C Library; if not, write to the Free
1762+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1763+   02111-1307 USA.  */
1764+
1765+/*  FIXME: Profiling of shared libraries is not implemented yet.  */
1766+#ifndef dl_machine_h
1767+#define dl_machine_h
1768+
1769+#define ELF_MACHINE_NAME "RISC-V"
1770+
1771+#include <entry.h>
1772+
1773+#ifndef ENTRY_POINT
1774+#error ENTRY_POINT needs to be defined for MIPS.
1775+#endif
1776+
1777+#include <sys/asm.h>
1778+#include <dl-tls.h>
1779+
1780+#ifndef _RTLD_PROLOGUE
1781+# define _RTLD_PROLOGUE(entry)                                         \
1782+       ".globl\t" __STRING(entry) "\n\t"                               \
1783+       ".type\t" __STRING(entry) ", @function\n"                       \
1784+       __STRING(entry) ":\n\t"
1785+#endif
1786+
1787+#ifndef _RTLD_EPILOGUE
1788+# define _RTLD_EPILOGUE(entry)                                         \
1789+       ".size\t" __STRING(entry) ", . - " __STRING(entry) "\n\t"
1790+#endif
1791+
1792+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.
1793+   This only makes sense on MIPS when using PLTs, so choose the
1794+   PLT relocation (not encountered when not using PLTs).  */
1795+#define ELF_MACHINE_JMP_SLOT                   R_MIPS_JUMP_SLOT
1796+#define elf_machine_type_class(type) \
1797+  ((((type) == ELF_MACHINE_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)    \
1798+   | (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
1799+
1800+#define ELF_MACHINE_PLT_REL 1
1801+
1802+/* Translate a processor specific dynamic tag to the index
1803+   in l_info array.  */
1804+#define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM)
1805+
1806+/* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in
1807+   with the run-time address of the r_debug structure  */
1808+#define ELF_MACHINE_DEBUG_SETUP(l,r) \
1809+do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
1810+       *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \
1811+       (ElfW(Addr)) (r); \
1812+   } while (0)
1813+
1814+/* Return nonzero iff ELF header is compatible with the running host.  */
1815+static inline int __attribute_used__
1816+elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
1817+{
1818+  return 1;
1819+}
1820+
1821+static inline ElfW(Addr) *
1822+elf_mips_got_from_gpreg (ElfW(Addr) gpreg)
1823+{
1824+  return (ElfW(Addr) *) gpreg;
1825+}
1826+
1827+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
1828+   first element of the GOT.  This must be inlined in a function which
1829+   uses global data.  */
1830+static inline ElfW(Addr)
1831+elf_machine_dynamic (void)
1832+{
1833+  ElfW(Addr) load, link, got;
1834+  asm ("   la   %0, 1f\n"
1835+       "   la   %1, _GLOBAL_OFFSET_TABLE_\n"
1836+       "1: rdpc %2"
1837+       : "=r"(link), "=r"(got), "=r"(load));
1838+
1839+  return *elf_mips_got_from_gpreg(load - link + got);
1840+}
1841+
1842+#define STRINGXP(X) __STRING(X)
1843+#define STRINGXV(X) STRINGV_(X)
1844+#define STRINGV_(...) # __VA_ARGS__
1845+
1846+/* Return the run-time load address of the shared object.  */
1847+static inline ElfW(Addr)
1848+elf_machine_load_address (void)
1849+{
1850+  ElfW(Addr) load, link;
1851+  asm ("   la   %0, 1f\n"
1852+       "1: rdpc %1\n"
1853+       : "=r"(link), "=r"(load));
1854+
1855+  return load - link;
1856+}
1857+
1858+/* The MSB of got[1] of a gnu object is set to identify gnu objects.  */
1859+#ifdef __riscv64
1860+# define ELF_MIPS_GNU_GOT1_MASK        0x8000000000000000L
1861+#else
1862+# define ELF_MIPS_GNU_GOT1_MASK        0x80000000L
1863+#endif
1864+
1865+/* We can't rely on elf_machine_got_rel because _dl_object_relocation_scope
1866+   fiddles with global data.  */
1867+#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)                    \
1868+do {                                                                   \
1869+  struct link_map *map = &bootstrap_map;                               \
1870+  ElfW(Sym) *sym;                                                      \
1871+  ElfW(Addr) *got;                                                     \
1872+  int i, n;                                                            \
1873+                                                                       \
1874+  got = (ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);                 \
1875+                                                                       \
1876+  if (__builtin_expect (map->l_addr == 0, 1))                          \
1877+    break;                                                             \
1878+                                                                       \
1879+  /* got[0] is reserved. got[1] is also reserved for the dynamic object        \
1880+     generated by gnu ld. Skip these reserved entries from             \
1881+     relocation.  */                                                   \
1882+  i = (got[1] & ELF_MIPS_GNU_GOT1_MASK)? 2 : 1;                                \
1883+  n = map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;                  \
1884+                                                                       \
1885+  /* Add the run-time displacement to all local got entries. */                \
1886+  while (i < n)                                                                \
1887+    got[i++] += map->l_addr;                                           \
1888+                                                                       \
1889+  /* Handle global got entries. */                                     \
1890+  got += n;                                                            \
1891+  sym = (ElfW(Sym) *) D_PTR(map, l_info[DT_SYMTAB])                    \
1892+       + map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;                    \
1893+  i = (map->l_info[DT_MIPS (SYMTABNO)]->d_un.d_val                     \
1894+       - map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val);                   \
1895+                                                                       \
1896+  while (i--)                                                          \
1897+    {                                                                  \
1898+      if (sym->st_shndx == SHN_UNDEF || sym->st_shndx == SHN_COMMON)   \
1899+       *got = map->l_addr + sym->st_value;                             \
1900+      else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC                        \
1901+              && *got != sym->st_value)                                \
1902+       *got += map->l_addr;                                            \
1903+      else if (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION)            \
1904+       {                                                               \
1905+         if (sym->st_other == 0)                                       \
1906+           *got += map->l_addr;                                        \
1907+       }                                                               \
1908+      else                                                             \
1909+       *got = map->l_addr + sym->st_value;                             \
1910+                                                                       \
1911+      got++;                                                           \
1912+      sym++;                                                           \
1913+    }                                                                  \
1914+} while(0)
1915+
1916+
1917+/* Mask identifying addresses reserved for the user program,
1918+   where the dynamic linker should not map anything.  */
1919+#define ELF_MACHINE_USER_ADDRESS_MASK  0x80000000UL
1920+
1921+
1922+/* Initial entry point code for the dynamic linker.
1923+   The C function `_dl_start' is the real entry point;
1924+   its return value is the user program's entry point. */
1925+
1926+#define RTLD_START asm (\
1927+       ".text\n\
1928+       " _RTLD_PROLOGUE(ENTRY_POINT) "\
1929+       # Store &_DYNAMIC in the first entry of the GOT.\n\
1930+       la a1, 1f\n\
1931+       la a2, _GLOBAL_OFFSET_TABLE_\n\
1932+       la a3, _DYNAMIC\n\
1933+       1: rdpc a0\n\
1934+       sub a0, a0, a1\n\
1935+       add a0, a0, a2\n\
1936+       " STRINGXP(REG_S) " a3, 0(a0)\n\
1937+       move a0, sp\n\
1938+       jal _dl_start\n\
1939+       # Fall through to _dl_start_user \
1940+       " _RTLD_EPILOGUE(ENTRY_POINT) "\
1941+       \n\
1942+       \n\
1943+       " _RTLD_PROLOGUE(_dl_start_user) "\
1944+       # Stash user entry point in s0.\n\
1945+       move s0, v0\n\
1946+       # See if we were run as a command with the executable file\n\
1947+       # name as an extra leading argument.\n\
1948+       la v0, _dl_skip_args\n\
1949+       lw v0, 0(v0)\n\
1950+       beqz v0, 1f\n\
1951+       # Load the original argument count.\n\
1952+       " STRINGXP(REG_L) " a0, 0(sp)\n\
1953+       # Subtract _dl_skip_args from it.\n\
1954+       sub a0, a0, v0\n\
1955+       # Adjust the stack pointer to skip _dl_skip_args words.\n\
1956+       sll v0, v0, " STRINGXP (PTRLOG) "\n\
1957+       add sp, sp, v0\n\
1958+       # Save back the modified argument count.\n\
1959+       " STRINGXP(REG_S) " a0, 0(sp)\n\
1960+1:     # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\
1961+       la a0, _rtld_local\n\
1962+       " STRINGXP(REG_L) " a0, 0(a0)\n\
1963+       " STRINGXP(REG_L) " a1, 0(sp)\n\
1964+       add a2, sp, " STRINGXP (PTRSIZE) "\n\
1965+       sll a3, a1, " STRINGXP (PTRLOG) "\n\
1966+       add a3, a3, a2\n\
1967+       add a3, a3, " STRINGXP (PTRSIZE) "\n\
1968+       # Call the function to run the initializers.\n\
1969+       jal _dl_init_internal\n\
1970+       # Pass our finalizer function to the user in v0 as per ELF ABI.\n\
1971+       la v0, _dl_fini\n\
1972+       # Jump to the user entry point.\n\
1973+       jr s0\n\t"\
1974+       _RTLD_EPILOGUE(_dl_start_user)\
1975+       ".previous"\
1976+);
1977+
1978+/* Names of the architecture-specific auditing callback functions.  */
1979+# ifdef __riscv64
1980+#  define ARCH_LA_PLTENTER mips_n64_gnu_pltenter
1981+#  define ARCH_LA_PLTEXIT mips_n64_gnu_pltexit
1982+# else
1983+#  define ARCH_LA_PLTENTER mips_n32_gnu_pltenter
1984+#  define ARCH_LA_PLTEXIT mips_n32_gnu_pltexit
1985+# endif
1986+
1987+/* For a non-writable PLT, rewrite the .got.plt entry at RELOC_ADDR to
1988+   point at the symbol with address VALUE.  For a writable PLT, rewrite
1989+   the corresponding PLT entry instead.  */
1990+static inline ElfW(Addr)
1991+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
1992+                      const ElfW(Rel) *reloc,
1993+                      ElfW(Addr) *reloc_addr, ElfW(Addr) value)
1994+{
1995+  return *reloc_addr = value;
1996+}
1997+
1998+static inline ElfW(Addr)
1999+elf_machine_plt_value (struct link_map *map, const ElfW(Rel) *reloc,
2000+                      ElfW(Addr) value)
2001+{
2002+  return value;
2003+}
2004+
2005+#endif /* !dl_machine_h */
2006+
2007+#ifdef RESOLVE_MAP
2008+
2009+/* Perform a relocation described by R_INFO at the location pointed to
2010+   by RELOC_ADDR.  SYM is the relocation symbol specified by R_INFO and
2011+   MAP is the object containing the reloc.  */
2012+
2013+auto inline void
2014+__attribute__ ((always_inline))
2015+elf_machine_reloc (struct link_map *map, ElfW(Addr) r_info,
2016+                  const ElfW(Sym) *sym, const struct r_found_version *version,
2017+                  void *reloc_addr, ElfW(Addr) r_addend, int inplace_p)
2018+{
2019+  const unsigned long int r_type = ELFW(R_TYPE) (r_info);
2020+  ElfW(Addr) *addr_field = (ElfW(Addr) *) reloc_addr;
2021+
2022+#if !defined RTLD_BOOTSTRAP && !defined SHARED
2023+  /* This is defined in rtld.c, but nowhere in the static libc.a;
2024+     make the reference weak so static programs can still link.  This
2025+     declaration cannot be done when compiling rtld.c (i.e.  #ifdef
2026+     RTLD_BOOTSTRAP) because rtld.c contains the common defn for
2027+     _dl_rtld_map, which is incompatible with a weak decl in the same
2028+     file.  */
2029+  weak_extern (GL(dl_rtld_map));
2030+#endif
2031+
2032+  switch (r_type)
2033+    {
2034+#if defined (USE_TLS) && !defined (RTLD_BOOTSTRAP)
2035+# if _RISCV_SIM == _ABI64
2036+    case R_MIPS_TLS_DTPMOD64:
2037+    case R_MIPS_TLS_DTPREL64:
2038+    case R_MIPS_TLS_TPREL64:
2039+# else
2040+    case R_MIPS_TLS_DTPMOD32:
2041+    case R_MIPS_TLS_DTPREL32:
2042+    case R_MIPS_TLS_TPREL32:
2043+# endif
2044+      {
2045+       struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
2046+
2047+       switch (r_type)
2048+         {
2049+         case R_MIPS_TLS_DTPMOD64:
2050+         case R_MIPS_TLS_DTPMOD32:
2051+           if (sym_map)
2052+             *addr_field = sym_map->l_tls_modid;
2053+           break;
2054+
2055+         case R_MIPS_TLS_DTPREL64:
2056+         case R_MIPS_TLS_DTPREL32:
2057+           if (sym)
2058+             {
2059+               if (inplace_p)
2060+                 r_addend = *addr_field;
2061+               *addr_field = r_addend + TLS_DTPREL_VALUE (sym);
2062+             }
2063+           break;
2064+
2065+         case R_MIPS_TLS_TPREL32:
2066+         case R_MIPS_TLS_TPREL64:
2067+           if (sym)
2068+             {
2069+               CHECK_STATIC_TLS (map, sym_map);
2070+               if (inplace_p)
2071+                 r_addend = *addr_field;
2072+               *addr_field = r_addend + TLS_TPREL_VALUE (sym_map, sym);
2073+             }
2074+           break;
2075+         }
2076+
2077+       break;
2078+      }
2079+#endif
2080+
2081+#if _RISCV_SIM == _ABI64
2082+    case (R_MIPS_64 << 8) | R_MIPS_REL32:
2083+#else
2084+    case R_MIPS_REL32:
2085+#endif
2086+      {
2087+       int symidx = ELFW(R_SYM) (r_info);
2088+       ElfW(Addr) reloc_value;
2089+
2090+       if (inplace_p)
2091+         /* Support relocations on mis-aligned offsets.  */
2092+         __builtin_memcpy (&reloc_value, reloc_addr, sizeof (reloc_value));
2093+       else
2094+         reloc_value = r_addend;
2095+
2096+       if (symidx)
2097+         {
2098+           const ElfW(Word) gotsym
2099+             = (const ElfW(Word)) map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;
2100+
2101+           if ((ElfW(Word))symidx < gotsym)
2102+             {
2103+               /* This wouldn't work for a symbol imported from other
2104+                  libraries for which there's no GOT entry, but MIPS
2105+                  requires every symbol referenced in a dynamic
2106+                  relocation to have a GOT entry in the primary GOT,
2107+                  so we only get here for locally-defined symbols.
2108+                  For section symbols, we should *NOT* be adding
2109+                  sym->st_value (per the definition of the meaning of
2110+                  S in reloc expressions in the ELF64 MIPS ABI),
2111+                  since it should have already been added to
2112+                  reloc_value by the linker, but older versions of
2113+                  GNU ld didn't add it, and newer versions don't emit
2114+                  useless relocations to section symbols any more, so
2115+                  it is safe to keep on adding sym->st_value, even
2116+                  though it's not ABI compliant.  Some day we should
2117+                  bite the bullet and stop doing this.  */
2118+#ifndef RTLD_BOOTSTRAP
2119+               if (map != &GL(dl_rtld_map))
2120+#endif
2121+                 reloc_value += sym->st_value + map->l_addr;
2122+             }
2123+           else
2124+             {
2125+#ifndef RTLD_BOOTSTRAP
2126+               const ElfW(Addr) *got
2127+                 = (const ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);
2128+               const ElfW(Word) local_gotno
2129+                 = (const ElfW(Word))
2130+                   map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;
2131+
2132+               reloc_value += got[symidx + local_gotno - gotsym];
2133+#endif
2134+             }
2135+         }
2136+       else
2137+#ifndef RTLD_BOOTSTRAP
2138+         if (map != &GL(dl_rtld_map))
2139+#endif
2140+           reloc_value += map->l_addr;
2141+
2142+       __builtin_memcpy (reloc_addr, &reloc_value, sizeof (reloc_value));
2143+      }
2144+      break;
2145+#ifndef RTLD_BOOTSTRAP
2146+#if _RISCV_SIM == _ABI64
2147+    case (R_MIPS_64 << 8) | R_MIPS_GLOB_DAT:
2148+#else
2149+    case R_MIPS_GLOB_DAT:
2150+#endif
2151+      {
2152+       int symidx = ELFW(R_SYM) (r_info);
2153+       const ElfW(Word) gotsym
2154+         = (const ElfW(Word)) map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;
2155+
2156+       if (__builtin_expect ((ElfW(Word)) symidx >= gotsym, 1))
2157+         {
2158+           const ElfW(Addr) *got
2159+             = (const ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);
2160+           const ElfW(Word) local_gotno
2161+             = ((const ElfW(Word))
2162+                map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val);
2163+
2164+           ElfW(Addr) reloc_value = got[symidx + local_gotno - gotsym];
2165+           __builtin_memcpy (reloc_addr, &reloc_value, sizeof (reloc_value));
2166+         }
2167+      }
2168+      break;
2169+#endif
2170+    case R_MIPS_NONE:          /* Alright, Wilbur.  */
2171+      break;
2172+
2173+    case R_MIPS_JUMP_SLOT:
2174+      {
2175+       struct link_map *sym_map;
2176+       ElfW(Addr) value;
2177+
2178+       /* The addend for a jump slot relocation must always be zero:
2179+          calls via the PLT always branch to the symbol's address and
2180+          not to the address plus a non-zero offset.  */
2181+       if (r_addend != 0)
2182+         _dl_signal_error (0, map->l_name, NULL,
2183+                           "found jump slot relocation with non-zero addend");
2184+
2185+       sym_map = RESOLVE_MAP (&sym, version, r_type);
2186+       value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
2187+       *addr_field = value;
2188+
2189+       break;
2190+      }
2191+
2192+    case R_MIPS_COPY:
2193+      {
2194+       const ElfW(Sym) *const refsym = sym;
2195+       struct link_map *sym_map;
2196+       ElfW(Addr) value;
2197+
2198+       /* Calculate the address of the symbol.  */
2199+       sym_map = RESOLVE_MAP (&sym, version, r_type);
2200+       value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
2201+
2202+       if (__builtin_expect (sym == NULL, 0))
2203+         /* This can happen in trace mode if an object could not be
2204+            found.  */
2205+         break;
2206+       if (__builtin_expect (sym->st_size > refsym->st_size, 0)
2207+           || (__builtin_expect (sym->st_size < refsym->st_size, 0)
2208+               && GLRO(dl_verbose)))
2209+         {
2210+           const char *strtab;
2211+
2212+           strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
2213+           _dl_error_printf ("\
2214+  %s: Symbol `%s' has different size in shared object, consider re-linking\n",
2215+                             rtld_progname ?: "<program name unknown>",
2216+                             strtab + refsym->st_name);
2217+         }
2218+       memcpy (reloc_addr, (void *) value,
2219+               MIN (sym->st_size, refsym->st_size));
2220+       break;
2221+      }
2222+
2223+#if _RISCV_SIM == _ABI64
2224+    case R_MIPS_64:
2225+      /* For full compliance with the ELF64 ABI, one must precede the
2226+        _REL32/_64 pair of relocations with a _64 relocation, such
2227+        that the in-place addend is read as a 64-bit value.  IRIX
2228+        didn't pick up on this requirement, so we treat the
2229+        _REL32/_64 relocation as a 64-bit relocation even if it's by
2230+        itself.  For ABI compliance, we ignore such _64 dummy
2231+        relocations.  For RELA, this may be simply removed, since
2232+        it's totally unnecessary.  */
2233+      if (ELFW(R_SYM) (r_info) == 0)
2234+       break;
2235+      /* Fall through.  */
2236+#endif
2237+    default:
2238+      _dl_reloc_bad_type (map, r_type, 0);
2239+      break;
2240+    }
2241+}
2242+
2243+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
2244+   MAP is the object containing the reloc.  */
2245+
2246+auto inline void
2247+__attribute__ ((always_inline))
2248+elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
2249+                const ElfW(Sym) *sym, const struct r_found_version *version,
2250+                void *const reloc_addr)
2251+{
2252+  elf_machine_reloc (map, reloc->r_info, sym, version, reloc_addr, 0, 1);
2253+}
2254+
2255+auto inline void
2256+__attribute__((always_inline))
2257+elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
2258+                         void *const reloc_addr)
2259+{
2260+  /* XXX Nothing to do.  There is no relative relocation, right?  */
2261+}
2262+
2263+auto inline void
2264+__attribute__((always_inline))
2265+elf_machine_lazy_rel (struct link_map *map,
2266+                     ElfW(Addr) l_addr, const ElfW(Rel) *reloc)
2267+{
2268+  ElfW(Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset);
2269+  const unsigned int r_type = ELFW(R_TYPE) (reloc->r_info);
2270+  /* Check for unexpected PLT reloc type.  */
2271+  if (__builtin_expect (r_type == R_MIPS_JUMP_SLOT, 1))
2272+    {
2273+      if (__builtin_expect (map->l_mach.plt, 0) == 0)
2274+       {
2275+         /* Nothing is required here since we only support lazy
2276+            relocation in executables.  */
2277+       }
2278+      else
2279+       *reloc_addr = map->l_mach.plt;
2280+    }
2281+  else
2282+    _dl_reloc_bad_type (map, r_type, 1);
2283+}
2284+
2285+auto inline void
2286+__attribute__ ((always_inline))
2287+elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
2288+                 const ElfW(Sym) *sym, const struct r_found_version *version,
2289+                void *const reloc_addr)
2290+{
2291+  elf_machine_reloc (map, reloc->r_info, sym, version, reloc_addr,
2292+                    reloc->r_addend, 0);
2293+}
2294+
2295+auto inline void
2296+__attribute__((always_inline))
2297+elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
2298+                          void *const reloc_addr)
2299+{
2300+}
2301+
2302+#ifndef RTLD_BOOTSTRAP
2303+/* Relocate GOT. */
2304+auto inline void
2305+__attribute__((always_inline))
2306+elf_machine_got_rel (struct link_map *map, int lazy)
2307+{
2308+  ElfW(Addr) *got;
2309+  ElfW(Sym) *sym;
2310+  const ElfW(Half) *vernum;
2311+  int i, n, symidx;
2312+
2313+#define RESOLVE_GOTSYM(sym,vernum,sym_index,reloc)                       \
2314+    ({                                                                   \
2315+      const ElfW(Sym) *ref = sym;                                        \
2316+      const struct r_found_version *version                              \
2317+        = vernum ? &map->l_versions[vernum[sym_index] & 0x7fff] : NULL;          \
2318+      struct link_map *sym_map;                                                  \
2319+      sym_map = RESOLVE_MAP (&ref, version, reloc);                      \
2320+      ref ? sym_map->l_addr + ref->st_value : 0;                         \
2321+    })
2322+
2323+  if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
2324+    vernum = (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
2325+  else
2326+    vernum = NULL;
2327+
2328+  got = (ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);
2329+
2330+  n = map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;
2331+  /* The dynamic linker's local got entries have already been relocated.  */
2332+  if (map != &GL(dl_rtld_map))
2333+    {
2334+      /* got[0] is reserved. got[1] is also reserved for the dynamic object
2335+        generated by gnu ld. Skip these reserved entries from relocation.  */
2336+      i = (got[1] & ELF_MIPS_GNU_GOT1_MASK)? 2 : 1;
2337+
2338+      /* Add the run-time displacement to all local got entries if
2339+         needed.  */
2340+      if (__builtin_expect (map->l_addr != 0, 0))
2341+       {
2342+         while (i < n)
2343+           got[i++] += map->l_addr;
2344+       }
2345+    }
2346+
2347+  /* Handle global got entries. */
2348+  got += n;
2349+  /* Keep track of the symbol index.  */
2350+  symidx = map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;
2351+  sym = (ElfW(Sym) *) D_PTR (map, l_info[DT_SYMTAB]) + symidx;
2352+  i = (map->l_info[DT_MIPS (SYMTABNO)]->d_un.d_val
2353+       - map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val);
2354+
2355+  /* This loop doesn't handle Quickstart.  */
2356+  while (i--)
2357+    {
2358+      if (sym->st_shndx == SHN_UNDEF)
2359+       {
2360+         if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC && sym->st_value
2361+             && !(sym->st_other & STO_MIPS_PLT))
2362+           {
2363+             if (lazy)
2364+               *got = sym->st_value + map->l_addr;
2365+             else
2366+               /* This is a lazy-binding stub, so we don't need the
2367+                  canonical address.  */
2368+               *got = RESOLVE_GOTSYM (sym, vernum, symidx, R_MIPS_JUMP_SLOT);
2369+           }
2370+         else
2371+           *got = RESOLVE_GOTSYM (sym, vernum, symidx, R_MIPS_32);
2372+       }
2373+      else if (sym->st_shndx == SHN_COMMON)
2374+       *got = RESOLVE_GOTSYM (sym, vernum, symidx, R_MIPS_32);
2375+      else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
2376+              && *got != sym->st_value)
2377+       {
2378+         if (lazy)
2379+           *got += map->l_addr;
2380+         else
2381+           /* This is a lazy-binding stub, so we don't need the
2382+              canonical address.  */
2383+           *got = RESOLVE_GOTSYM (sym, vernum, symidx, R_MIPS_JUMP_SLOT);
2384+       }
2385+      else if (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION)
2386+       {
2387+         if (sym->st_other == 0)
2388+           *got += map->l_addr;
2389+       }
2390+      else
2391+       *got = RESOLVE_GOTSYM (sym, vernum, symidx, R_MIPS_32);
2392+
2393+      ++got;
2394+      ++sym;
2395+      ++symidx;
2396+    }
2397+
2398+#undef RESOLVE_GOTSYM
2399+}
2400+#endif
2401+
2402+/* Set up the loaded object described by L so its stub function
2403+   will jump to the on-demand fixup code __dl_runtime_resolve.  */
2404+
2405+auto inline int
2406+__attribute__((always_inline))
2407+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
2408+{
2409+# ifndef RTLD_BOOTSTRAP
2410+  ElfW(Addr) *got;
2411+  extern void _dl_runtime_resolve (ElfW(Word));
2412+  extern void _dl_fixup (void);
2413+  extern int _dl_mips_gnu_objects;
2414+
2415+  if (lazy)
2416+    {
2417+      /* The GOT entries for functions have not yet been filled in.
2418+        Their initial contents will arrange when called to put an
2419+        offset into the .dynsym section in t8, the return address
2420+        in t7 and then jump to _GLOBAL_OFFSET_TABLE[0].  */
2421+      got = (ElfW(Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
2422+
2423+      /* This function will get called to fix up the GOT entry indicated by
2424+        the register t8, and then jump to the resolved address.  */
2425+      got[0] = (ElfW(Addr)) &_dl_runtime_resolve;
2426+
2427+      /* Store l to _GLOBAL_OFFSET_TABLE[1] for gnu object. The MSB
2428+        of got[1] of a gnu object is set to identify gnu objects.
2429+        Where we can store l for non gnu objects? XXX  */
2430+      if ((got[1] & ELF_MIPS_GNU_GOT1_MASK) != 0)
2431+       got[1] = ((ElfW(Addr)) l | ELF_MIPS_GNU_GOT1_MASK);
2432+      else
2433+       _dl_mips_gnu_objects = 0;
2434+    }
2435+
2436+  /* Relocate global offset table.  */
2437+  elf_machine_got_rel (l, lazy);
2438+
2439+  /* If using PLTs, fill in the first two entries of .got.plt.  */
2440+  if (l->l_info[DT_JMPREL] && lazy)
2441+    {
2442+      ElfW(Addr) *gotplt;
2443+      gotplt = (ElfW(Addr) *) D_PTR (l, l_info[DT_MIPS (PLTGOT)]);
2444+      /* If a library is prelinked but we have to relocate anyway,
2445+        we have to be able to undo the prelinking of .got.plt.
2446+        The prelinker saved the address of .plt for us here.  */
2447+      if (gotplt[1])
2448+       l->l_mach.plt = gotplt[1] + l->l_addr;
2449+      gotplt[0] = (ElfW(Addr)) &_dl_fixup;
2450+      gotplt[1] = (ElfW(Addr)) l;
2451+      /* Relocate subsequent .got.plt entries. */
2452+      for (gotplt += 2; *gotplt; gotplt++)
2453+       *gotplt += l->l_addr;
2454+    }
2455+
2456+# endif
2457+  return lazy;
2458+}
2459+
2460+#endif /* RESOLVE_MAP */
2461diff -ruN glibc-2.19/sysdeps/riscv/dl-tls.h glibc-2.19-riscv/sysdeps/riscv/dl-tls.h
2462--- glibc-2.19/sysdeps/riscv/dl-tls.h   1969-12-31 16:00:00.000000000 -0800
2463+++ glibc-2.19-riscv/sysdeps/riscv/dl-tls.h     2014-12-09 16:55:03.156727789 -0800
2464@@ -0,0 +1,49 @@
2465+/* Thread-local storage handling in the ELF dynamic linker.  MIPS version.
2466+   Copyright (C) 2005 Free Software Foundation, Inc.
2467+   This file is part of the GNU C Library.
2468+
2469+   The GNU C Library is free software; you can redistribute it and/or
2470+   modify it under the terms of the GNU Lesser General Public
2471+   License as published by the Free Software Foundation; either
2472+   version 2.1 of the License, or (at your option) any later version.
2473+
2474+   The GNU C Library is distributed in the hope that it will be useful,
2475+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2476+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2477+   Lesser General Public License for more details.
2478+
2479+   You should have received a copy of the GNU Lesser General Public
2480+   License along with the GNU C Library; if not, write to the Free
2481+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2482+   02111-1307 USA.  */
2483+
2484+
2485+/* Type used for the representation of TLS information in the GOT.  */
2486+typedef struct
2487+{
2488+  unsigned long int ti_module;
2489+  unsigned long int ti_offset;
2490+} tls_index;
2491+
2492+/* The thread pointer points 0x7000 past the first static TLS block.  */
2493+#define TLS_TP_OFFSET          0x7000
2494+
2495+/* Dynamic thread vector pointers point 0x8000 past the start of each
2496+   TLS block.  */
2497+#define TLS_DTV_OFFSET         0x8000
2498+
2499+/* Compute the value for a GOTTPREL reloc.  */
2500+#define TLS_TPREL_VALUE(sym_map, sym) \
2501+  ((sym_map)->l_tls_offset + (sym)->st_value - TLS_TP_OFFSET)
2502+
2503+/* Compute the value for a DTPREL reloc.  */
2504+#define TLS_DTPREL_VALUE(sym) \
2505+  ((sym)->st_value - TLS_DTV_OFFSET)
2506+
2507+extern void *__tls_get_addr (tls_index *ti);
2508+
2509+# define GET_ADDR_OFFSET       (ti->ti_offset + TLS_DTV_OFFSET)
2510+# define __TLS_GET_ADDR(__ti)  (__tls_get_addr (__ti) - TLS_DTV_OFFSET)
2511+
2512+/* Value used for dtv entries for which the allocation is delayed.  */
2513+#define TLS_DTV_UNALLOCATED    ((void *) -1l)
2514diff -ruN glibc-2.19/sysdeps/riscv/dl-trampoline.c glibc-2.19-riscv/sysdeps/riscv/dl-trampoline.c
2515--- glibc-2.19/sysdeps/riscv/dl-trampoline.c    1969-12-31 16:00:00.000000000 -0800
2516+++ glibc-2.19-riscv/sysdeps/riscv/dl-trampoline.c      2014-12-09 16:55:03.156727789 -0800
2517@@ -0,0 +1,104 @@
2518+/* PLT trampoline.  MIPS version.
2519+   Copyright (C) 1996-2001, 2002, 2003, 2004, 2005
2520+   Free Software Foundation, Inc.
2521+   This file is part of the GNU C Library.
2522+   Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
2523+
2524+   The GNU C Library is free software; you can redistribute it and/or
2525+   modify it under the terms of the GNU Lesser General Public
2526+   License as published by the Free Software Foundation; either
2527+   version 2.1 of the License, or (at your option) any later version.
2528+
2529+   The GNU C Library is distributed in the hope that it will be useful,
2530+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2531+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2532+   Lesser General Public License for more details.
2533+
2534+   You should have received a copy of the GNU Lesser General Public
2535+   License along with the GNU C Library; if not, write to the Free
2536+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2537+   02111-1307 USA.  */
2538+
2539+/*  FIXME: Profiling of shared libraries is not implemented yet.  */
2540+
2541+#include <sysdep.h>
2542+#include <link.h>
2543+#include <elf.h>
2544+#include <ldsodefs.h>
2545+#include <dl-machine.h>
2546+
2547+/* The flag _dl_mips_gnu_objects is set if all dynamic objects are
2548+   generated by the gnu linker. */
2549+int _dl_mips_gnu_objects = 1;
2550+
2551+/* Get link map for callers object containing STUB_PC.  */
2552+static inline struct link_map *
2553+elf_machine_runtime_link_map (ElfW(Addr) gpreg, ElfW(Addr) stub_pc)
2554+{
2555+  /* got[1] is reserved to keep its link map address for the shared
2556+     object generated by the gnu linker.  If all are such objects, we
2557+     can find the link map from current GPREG simply.  If not so, get
2558+     the link map for caller's object containing STUB_PC.  */
2559+
2560+  if (_dl_mips_gnu_objects)
2561+    {
2562+      ElfW(Addr) *got = elf_mips_got_from_gpreg (gpreg);
2563+      ElfW(Word) g1;
2564+
2565+      g1 = ((ElfW(Word) *) got)[1];
2566+
2567+      if ((g1 & ELF_MIPS_GNU_GOT1_MASK) != 0)
2568+       {
2569+         struct link_map *l =
2570+           (struct link_map *) (g1 & ~ELF_MIPS_GNU_GOT1_MASK);
2571+         ElfW(Addr) base, limit;
2572+         const ElfW(Phdr) *p = l->l_phdr;
2573+         ElfW(Half) this, nent = l->l_phnum;
2574+
2575+         /* For the common case of a stub being called from the containing
2576+            object, STUB_PC will point to somewhere within the object that
2577+            is described by the link map fetched via got[1].  Otherwise we
2578+            have to scan all maps.  */
2579+         for (this = 0; this < nent; this++)
2580+           {
2581+             if (p[this].p_type == PT_LOAD)
2582+               {
2583+                 base = p[this].p_vaddr + l->l_addr;
2584+                 limit = base + p[this].p_memsz;
2585+                 if (stub_pc >= base && stub_pc < limit)
2586+                   return l;
2587+               }
2588+           }
2589+       }
2590+    }
2591+
2592+    struct link_map *l;
2593+    Lmid_t nsid;
2594+
2595+    for (nsid = 0; nsid < DL_NNS; ++nsid)
2596+      for (l = GL(dl_ns)[nsid]._ns_loaded; l != NULL; l = l->l_next)
2597+       {
2598+         ElfW(Addr) base, limit;
2599+         const ElfW(Phdr) *p = l->l_phdr;
2600+         ElfW(Half) this, nent = l->l_phnum;
2601+
2602+         for (this = 0; this < nent; ++this)
2603+           {
2604+             if (p[this].p_type == PT_LOAD)
2605+               {
2606+                 base = p[this].p_vaddr + l->l_addr;
2607+                 limit = base + p[this].p_memsz;
2608+                 if (stub_pc >= base && stub_pc < limit)
2609+                   return l;
2610+               }
2611+           }
2612+       }
2613+
2614+  _dl_signal_error (0, NULL, NULL, "cannot find runtime link map");
2615+  return NULL;
2616+}
2617+
2618+void _dl_runtime_resolve(void)
2619+{
2620+  while (1);
2621+}
2622diff -ruN glibc-2.19/sysdeps/riscv/elf/configure glibc-2.19-riscv/sysdeps/riscv/elf/configure
2623--- glibc-2.19/sysdeps/riscv/elf/configure      1969-12-31 16:00:00.000000000 -0800
2624+++ glibc-2.19-riscv/sysdeps/riscv/elf/configure        2014-12-09 16:55:03.156727789 -0800
2625@@ -0,0 +1,126 @@
2626+
2627+# as_fn_set_status STATUS
2628+# -----------------------
2629+# Set $? to STATUS, without forking.
2630+as_fn_set_status ()
2631+{
2632+  return $1
2633+} # as_fn_set_status
2634+
2635+# as_fn_exit STATUS
2636+# -----------------
2637+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
2638+as_fn_exit ()
2639+{
2640+  set +e
2641+  as_fn_set_status $1
2642+  exit $1
2643+} # as_fn_exit
2644+if expr a : '\(a\)' >/dev/null 2>&1 &&
2645+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
2646+  as_expr=expr
2647+else
2648+  as_expr=false
2649+fi
2650+
2651+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
2652+  as_basename=basename
2653+else
2654+  as_basename=false
2655+fi
2656+
2657+as_me=`$as_basename -- "$0" ||
2658+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
2659+        X"$0" : 'X\(//\)$' \| \
2660+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
2661+$as_echo X/"$0" |
2662+    sed '/^.*\/\([^/][^/]*\)\/*$/{
2663+           s//\1/
2664+           q
2665+         }
2666+         /^X\/\(\/\/\)$/{
2667+           s//\1/
2668+           q
2669+         }
2670+         /^X\/\(\/\).*/{
2671+           s//\1/
2672+           q
2673+         }
2674+         s/.*/./; q'`
2675+
2676+
2677+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
2678+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
2679+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
2680+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
2681+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
2682+  sed -n '
2683+    p
2684+    /[$]LINENO/=
2685+  ' <$as_myself |
2686+    sed '
2687+      s/[$]LINENO.*/&-/
2688+      t lineno
2689+      b
2690+      :lineno
2691+      N
2692+      :loop
2693+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
2694+      t loop
2695+      s/-\n.*//
2696+    ' >$as_me.lineno &&
2697+  chmod +x "$as_me.lineno" ||
2698+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
2699+
2700+  # Don't try to exec as it changes $[0], causing all sort of problems
2701+  # (the dirname of $[0] is not the place where we might find the
2702+  # original and so on.  Autoconf is especially sensitive to this).
2703+  . "./$as_me.lineno"
2704+  # Exit status is that of the last command.
2705+  exit
2706+}
2707+
2708+# This file is generated from configure.in by Autoconf.  DO NOT EDIT!
2709+ # Local configure fragment for sysdeps/mips/elf.
2710+
2711+if test "$usetls" != no; then
2712+# Check for support of thread-local storage handling in assembler and
2713+# linker.
2714+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MIPS TLS support" >&5
2715+$as_echo_n "checking for MIPS TLS support... " >&6; }
2716+if ${libc_cv_mips_tls+:} false; then :
2717+  $as_echo_n "(cached) " >&6
2718+else
2719+  cat > conftest.s <<\EOF
2720+       .section ".tdata", "awT", %progbits
2721+       .globl foo
2722+foo:   .long   1
2723+       .section ".tbss", "awT", %nobits
2724+       .globl bar
2725+bar:   .skip   4
2726+       .text
2727+
2728+       la              v0, __tls_get_addr
2729+       la.tls.gd       a0, x
2730+       jalr            v0
2731+EOF
2732+if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'
2733+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
2734+  (eval $ac_try) 2>&5
2735+  ac_status=$?
2736+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2737+  test $ac_status = 0; }; }; then
2738+  libc_cv_mips_tls=yes
2739+else
2740+  libc_cv_mips_tls=no
2741+fi
2742+rm -f conftest*
2743+fi
2744+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mips_tls" >&5
2745+$as_echo "$libc_cv_mips_tls" >&6; }
2746+if test $libc_cv_mips_tls = yes; then
2747+  $as_echo "#define HAVE_TLS_SUPPORT 1" >>confdefs.h
2748+
2749+fi
2750+fi
2751+
2752diff -ruN glibc-2.19/sysdeps/riscv/elf/configure.in glibc-2.19-riscv/sysdeps/riscv/elf/configure.in
2753--- glibc-2.19/sysdeps/riscv/elf/configure.in   1969-12-31 16:00:00.000000000 -0800
2754+++ glibc-2.19-riscv/sysdeps/riscv/elf/configure.in     2014-12-09 16:55:03.160727813 -0800
2755@@ -0,0 +1,35 @@
2756+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2757+# Local configure fragment for sysdeps/mips/elf.
2758+
2759+if test "$usetls" != no; then
2760+# Check for support of thread-local storage handling in assembler and
2761+# linker.
2762+AC_CACHE_CHECK(for MIPS TLS support, libc_cv_mips_tls, [dnl
2763+cat > conftest.s <<\EOF
2764+       .section ".tdata", "awT", %progbits
2765+       .globl foo
2766+foo:   .long   1
2767+       .section ".tbss", "awT", %nobits
2768+       .globl bar
2769+bar:   .skip   4
2770+       .text
2771+
2772+       la              v0, __tls_get_addr
2773+       la.tls.gd       a0, x
2774+       jalr            v0
2775+EOF
2776+dnl
2777+if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
2778+  libc_cv_mips_tls=yes
2779+else
2780+  libc_cv_mips_tls=no
2781+fi
2782+rm -f conftest*])
2783+if test $libc_cv_mips_tls = yes; then
2784+  AC_DEFINE(HAVE_TLS_SUPPORT)
2785+fi
2786+fi
2787+
2788+dnl No MIPS GCC supports accessing static and hidden symbols in an
2789+dnl position independent way.
2790+dnl AC_DEFINE(PI_STATIC_AND_HIDDEN)
2791diff -ruN glibc-2.19/sysdeps/riscv/elf/start.S glibc-2.19-riscv/sysdeps/riscv/elf/start.S
2792--- glibc-2.19/sysdeps/riscv/elf/start.S        1969-12-31 16:00:00.000000000 -0800
2793+++ glibc-2.19-riscv/sysdeps/riscv/elf/start.S  2014-12-09 16:55:03.160727813 -0800
2794@@ -0,0 +1,98 @@
2795+/* Startup code compliant to the ELF Mips ABI.
2796+   Copyright (C) 1995, 1997, 2000, 2001, 2002, 2003, 2004
2797+       Free Software Foundation, Inc.
2798+   This file is part of the GNU C Library.
2799+
2800+   The GNU C Library is free software; you can redistribute it and/or
2801+   modify it under the terms of the GNU Lesser General Public
2802+   License as published by the Free Software Foundation; either
2803+   version 2.1 of the License, or (at your option) any later version.
2804+
2805+   In addition to the permissions in the GNU Lesser General Public
2806+   License, the Free Software Foundation gives you unlimited
2807+   permission to link the compiled version of this file with other
2808+   programs, and to distribute those programs without any restriction
2809+   coming from the use of this file. (The GNU Lesser General Public
2810+   License restrictions do apply in other respects; for example, they
2811+   cover modification of the file, and distribution when not linked
2812+   into another program.)
2813+
2814+   Note that people who make modified versions of this file are not
2815+   obligated to grant this special exception for their modified
2816+   versions; it is their choice whether to do so. The GNU Lesser
2817+   General Public License gives permission to release a modified
2818+   version without this exception; this exception also makes it
2819+   possible to release a modified version which carries forward this
2820+   exception.
2821+
2822+   The GNU C Library is distributed in the hope that it will be useful,
2823+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2824+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2825+   Lesser General Public License for more details.
2826+
2827+   You should have received a copy of the GNU Lesser General Public
2828+   License along with the GNU C Library; if not, write to the Free
2829+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2830+   02111-1307 USA.  */
2831+
2832+#define __ASSEMBLY__ 1
2833+#include <entry.h>
2834+#include <sgidefs.h>
2835+#include <sys/asm.h>
2836+
2837+#ifndef ENTRY_POINT
2838+#error ENTRY_POINT needs to be defined for start.S on MIPS/ELF.
2839+#endif
2840+
2841+/* This is the canonical entry point, usually the first thing in the text
2842+   segment.  The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
2843+   point runs, most registers' values are unspecified, except for:
2844+
2845+   v0 ($2)     Contains a function pointer to be registered with `atexit'.
2846+               This is how the dynamic linker arranges to have DT_FINI
2847+               functions called for shared libraries that have been loaded
2848+               before this code runs.
2849+
2850+   sp ($29)    The stack contains the arguments and environment:
2851+               0(%esp)                 argc
2852+               4(%esp)                 argv[0]
2853+               ...
2854+               (4*argc)(%esp)          NULL
2855+               (4*(argc+1))(%esp)      envp[0]
2856+               ...
2857+                                       NULL
2858+   ra ($31)    The return address register is set to zero so that programs
2859+               that search backword through stack frames recognize the last
2860+               stack frame.
2861+*/
2862+
2863+
2864+/* We need to call:
2865+   __libc_start_main (int (*main) (int, char **, char **), int argc,
2866+                     char **argv, void (*init) (void), void (*fini) (void),
2867+                     void (*rtld_fini) (void), void *stack_end)
2868+*/
2869+       
2870+       .text
2871+       .globl ENTRY_POINT
2872+       .type ENTRY_POINT,@function
2873+ENTRY_POINT:
2874+       la    a0, main
2875+       REG_L a1, 0(sp)      /* argc */
2876+       addi  a2, sp, SZREG  /* argv */
2877+       andi  sp, sp, ALMASK /* Align stack. */
2878+       la    a3, __libc_csu_init
2879+       la    a4, __libc_csu_fini
2880+       move  a5, v0  /* rtld_fini */
2881+       move  a6, sp  /* stack_end */
2882+       
2883+       la    v0, __libc_start_main
2884+       jr    v0
2885+
2886+/* Define a symbol for the first piece of initialized data.  */
2887+       .data
2888+       .globl __data_start
2889+__data_start:
2890+       .long 0
2891+       .weak data_start
2892+       data_start = __data_start
2893diff -ruN glibc-2.19/sysdeps/riscv/fpu/bits/mathinline.h glibc-2.19-riscv/sysdeps/riscv/fpu/bits/mathinline.h
2894--- glibc-2.19/sysdeps/riscv/fpu/bits/mathinline.h      1969-12-31 16:00:00.000000000 -0800
2895+++ glibc-2.19-riscv/sysdeps/riscv/fpu/bits/mathinline.h        2014-12-09 16:55:03.160727813 -0800
2896@@ -0,0 +1,52 @@
2897+/* Inline math functions for RISC-V.
2898+   Copyright (C) 2011
2899+   Free Software Foundation, Inc.
2900+   This file is part of the GNU C Library.
2901+   Contributed by Jakub Jelinek <jakub@redhat.com>.
2902+
2903+   The GNU C Library is free software; you can redistribute it and/or
2904+   modify it under the terms of the GNU Lesser General Public
2905+   License as published by the Free Software Foundation; either
2906+   version 2.1 of the License, or (at your option) any later version.
2907+
2908+   The GNU C Library is distributed in the hope that it will be useful,
2909+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2910+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2911+   Lesser General Public License for more details.
2912+
2913+   You should have received a copy of the GNU Lesser General Public
2914+   License along with the GNU C Library; if not, write to the Free
2915+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2916+   02111-1307 USA.  */
2917+
2918+#ifndef _MATH_H
2919+# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
2920+#endif
2921+
2922+#include <bits/wordsize.h>
2923+
2924+#ifdef __GNUC__
2925+
2926+#if defined __USE_ISOC99
2927+# undef isgreater
2928+# undef isgreaterequal
2929+# undef isless
2930+# undef islessequal
2931+# undef islessgreater
2932+# undef isunordered
2933+
2934+# define isgreater(x, y) ((x) > (y))
2935+# define isgreaterequal(x, y) ((x) >= (y))
2936+# define isless(x, y) ((x) < (y))
2937+# define islessequal(x, y) ((x) <= (y))
2938+# define islessgreater(x, y) (!!(isless(x, y) + isgreater(x, y)))
2939+# define isunordered(x, y) (((x) == (x)) + ((y) == (y)) < 2)
2940+
2941+#endif /* __USE_ISOC99 */
2942+
2943+#if (!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) && defined __OPTIMIZE__
2944+
2945+/* Nothing yet. */
2946+
2947+#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
2948+#endif /* __GNUC__ */
2949diff -ruN glibc-2.19/sysdeps/riscv/fpu/e_sqrt.c glibc-2.19-riscv/sysdeps/riscv/fpu/e_sqrt.c
2950--- glibc-2.19/sysdeps/riscv/fpu/e_sqrt.c       1969-12-31 16:00:00.000000000 -0800
2951+++ glibc-2.19-riscv/sysdeps/riscv/fpu/e_sqrt.c 2014-12-09 16:55:03.160727813 -0800
2952@@ -0,0 +1,26 @@
2953+/* Copyright (C) 2002 Free Software Foundation, Inc.
2954+   This file is part of the GNU C Library.
2955+   Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
2956+
2957+   The GNU C Library is free software; you can redistribute it and/or
2958+   modify it under the terms of the GNU Lesser General Public
2959+   License as published by the Free Software Foundation; either
2960+   version 2.1 of the License, or (at your option) any later version.
2961+
2962+   The GNU C Library is distributed in the hope that it will be useful,
2963+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2964+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2965+   Lesser General Public License for more details.
2966+
2967+   You should have received a copy of the GNU Lesser General Public
2968+   License along with the GNU C Library; if not, write to the Free
2969+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2970+   02111-1307 USA.  */
2971+
2972+double
2973+__ieee754_sqrt (double x)
2974+{
2975+  double z;
2976+  __asm__ ("fsqrt.d %0,%1" : "=f" (z) : "f" (x));
2977+  return z;
2978+}
2979diff -ruN glibc-2.19/sysdeps/riscv/fpu/e_sqrtf.c glibc-2.19-riscv/sysdeps/riscv/fpu/e_sqrtf.c
2980--- glibc-2.19/sysdeps/riscv/fpu/e_sqrtf.c      1969-12-31 16:00:00.000000000 -0800
2981+++ glibc-2.19-riscv/sysdeps/riscv/fpu/e_sqrtf.c        2014-12-09 16:55:03.160727813 -0800
2982@@ -0,0 +1,26 @@
2983+/* Copyright (C) 2002 Free Software Foundation, Inc.
2984+   This file is part of the GNU C Library.
2985+   Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
2986+
2987+   The GNU C Library is free software; you can redistribute it and/or
2988+   modify it under the terms of the GNU Lesser General Public
2989+   License as published by the Free Software Foundation; either
2990+   version 2.1 of the License, or (at your option) any later version.
2991+
2992+   The GNU C Library is distributed in the hope that it will be useful,
2993+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2994+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2995+   Lesser General Public License for more details.
2996+
2997+   You should have received a copy of the GNU Lesser General Public
2998+   License along with the GNU C Library; if not, write to the Free
2999+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3000+   02111-1307 USA.  */
3001+
3002+float
3003+__ieee754_sqrtf (float x)
3004+{
3005+  float z;
3006+  __asm__ ("fsqrt.s %0,%1" : "=f" (z) : "f" (x));
3007+  return z;
3008+}
3009diff -ruN glibc-2.19/sysdeps/riscv/fpu/fclrexcpt.c glibc-2.19-riscv/sysdeps/riscv/fpu/fclrexcpt.c
3010--- glibc-2.19/sysdeps/riscv/fpu/fclrexcpt.c    1969-12-31 16:00:00.000000000 -0800
3011+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fclrexcpt.c      2014-12-09 16:55:03.160727813 -0800
3012@@ -0,0 +1,47 @@
3013+/* Clear given exceptions in current floating-point environment.
3014+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
3015+   This file is part of the GNU C Library.
3016+   Contributed by Andreas Jaeger <aj@suse.de>, 1998.
3017+
3018+   The GNU C Library is free software; you can redistribute it and/or
3019+   modify it under the terms of the GNU Lesser General Public
3020+   License as published by the Free Software Foundation; either
3021+   version 2.1 of the License, or (at your option) any later version.
3022+
3023+   The GNU C Library is distributed in the hope that it will be useful,
3024+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3025+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3026+   Lesser General Public License for more details.
3027+
3028+   You should have received a copy of the GNU Lesser General Public
3029+   License along with the GNU C Library; if not, write to the Free
3030+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3031+   02111-1307 USA.  */
3032+
3033+#include <fenv.h>
3034+#include <fenv_libc.h>
3035+#include <fpu_control.h>
3036+
3037+int
3038+feclearexcept (int excepts)
3039+{
3040+  int cw;
3041+
3042+  /* Mask out unsupported bits/exceptions.  */
3043+  excepts &= FE_ALL_EXCEPT;
3044+
3045+  /* Read the complete control word.  */
3046+  _FPU_GETCW (cw);
3047+
3048+  /* Clear exception flag bits and cause bits. If the cause bit is not
3049+     cleared, the next CTC instruction (just below) will re-generate the
3050+     exception.  */
3051+
3052+  cw &= ~(excepts | (excepts << CAUSE_SHIFT));
3053+
3054+  /* Put the new data in effect.  */
3055+  _FPU_SETCW (cw);
3056+
3057+  /* Success.  */
3058+  return 0;
3059+}
3060diff -ruN glibc-2.19/sysdeps/riscv/fpu/fedisblxcpt.c glibc-2.19-riscv/sysdeps/riscv/fpu/fedisblxcpt.c
3061--- glibc-2.19/sysdeps/riscv/fpu/fedisblxcpt.c  1969-12-31 16:00:00.000000000 -0800
3062+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fedisblxcpt.c    2014-12-09 16:55:03.160727813 -0800
3063@@ -0,0 +1,42 @@
3064+/* Disable floating-point exceptions.
3065+   Copyright (C) 2000 Free Software Foundation, Inc.
3066+   This file is part of the GNU C Library.
3067+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
3068+
3069+   The GNU C Library is free software; you can redistribute it and/or
3070+   modify it under the terms of the GNU Lesser General Public
3071+   License as published by the Free Software Foundation; either
3072+   version 2.1 of the License, or (at your option) any later version.
3073+
3074+   The GNU C Library is distributed in the hope that it will be useful,
3075+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3076+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3077+   Lesser General Public License for more details.
3078+
3079+   You should have received a copy of the GNU Lesser General Public
3080+   License along with the GNU C Library; if not, write to the Free
3081+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3082+   02111-1307 USA.  */
3083+
3084+#include <fenv.h>
3085+#include <fenv_libc.h>
3086+#include <fpu_control.h>
3087+
3088+int
3089+fedisableexcept (int excepts)
3090+{
3091+  unsigned int new_exc, old_exc;
3092+
3093+  /* Get the current control word.  */
3094+  _FPU_GETCW (new_exc);
3095+
3096+  old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
3097+
3098+  excepts &= FE_ALL_EXCEPT;
3099+
3100+  new_exc &= ~(excepts << ENABLE_SHIFT);
3101+  new_exc &= ~_FPU_RESERVED;
3102+  _FPU_SETCW (new_exc);
3103+
3104+  return old_exc;
3105+}
3106diff -ruN glibc-2.19/sysdeps/riscv/fpu/feenablxcpt.c glibc-2.19-riscv/sysdeps/riscv/fpu/feenablxcpt.c
3107--- glibc-2.19/sysdeps/riscv/fpu/feenablxcpt.c  1969-12-31 16:00:00.000000000 -0800
3108+++ glibc-2.19-riscv/sysdeps/riscv/fpu/feenablxcpt.c    2014-12-09 16:55:03.160727813 -0800
3109@@ -0,0 +1,42 @@
3110+/* Enable floating-point exceptions.
3111+   Copyright (C) 2000 Free Software Foundation, Inc.
3112+   This file is part of the GNU C Library.
3113+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
3114+
3115+   The GNU C Library is free software; you can redistribute it and/or
3116+   modify it under the terms of the GNU Lesser General Public
3117+   License as published by the Free Software Foundation; either
3118+   version 2.1 of the License, or (at your option) any later version.
3119+
3120+   The GNU C Library is distributed in the hope that it will be useful,
3121+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3122+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3123+   Lesser General Public License for more details.
3124+
3125+   You should have received a copy of the GNU Lesser General Public
3126+   License along with the GNU C Library; if not, write to the Free
3127+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3128+   02111-1307 USA.  */
3129+
3130+#include <fenv.h>
3131+#include <fenv_libc.h>
3132+#include <fpu_control.h>
3133+
3134+int
3135+feenableexcept (int excepts)
3136+{
3137+  unsigned int new_exc, old_exc;
3138+
3139+  /* Get the current control word.  */
3140+  _FPU_GETCW (new_exc);
3141+
3142+  old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
3143+
3144+  excepts &= FE_ALL_EXCEPT;
3145+
3146+  new_exc |= excepts << ENABLE_SHIFT;
3147+  new_exc &= ~_FPU_RESERVED;
3148+  _FPU_SETCW (new_exc);
3149+
3150+  return old_exc;
3151+}
3152diff -ruN glibc-2.19/sysdeps/riscv/fpu/fegetenv.c glibc-2.19-riscv/sysdeps/riscv/fpu/fegetenv.c
3153--- glibc-2.19/sysdeps/riscv/fpu/fegetenv.c     1969-12-31 16:00:00.000000000 -0800
3154+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fegetenv.c       2014-12-09 16:55:03.160727813 -0800
3155@@ -0,0 +1,32 @@
3156+/* Store current floating-point environment.
3157+   Copyright (C) 1998, 1999, 2000, 2002, 2010 Free Software Foundation, Inc.
3158+   This file is part of the GNU C Library.
3159+   Contributed by Andreas Jaeger <aj@suse.de>, 1998.
3160+
3161+   The GNU C Library is free software; you can redistribute it and/or
3162+   modify it under the terms of the GNU Lesser General Public
3163+   License as published by the Free Software Foundation; either
3164+   version 2.1 of the License, or (at your option) any later version.
3165+
3166+   The GNU C Library is distributed in the hope that it will be useful,
3167+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3168+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3169+   Lesser General Public License for more details.
3170+
3171+   You should have received a copy of the GNU Lesser General Public
3172+   License along with the GNU C Library; if not, write to the Free
3173+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3174+   02111-1307 USA.  */
3175+
3176+#include <fenv.h>
3177+#include <fpu_control.h>
3178+
3179+int
3180+fegetenv (fenv_t *envp)
3181+{
3182+  _FPU_GETCW (*envp);
3183+
3184+  /* Success.  */
3185+  return 0;
3186+}
3187+libm_hidden_def (fegetenv)
3188diff -ruN glibc-2.19/sysdeps/riscv/fpu/fegetexcept.c glibc-2.19-riscv/sysdeps/riscv/fpu/fegetexcept.c
3189--- glibc-2.19/sysdeps/riscv/fpu/fegetexcept.c  1969-12-31 16:00:00.000000000 -0800
3190+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fegetexcept.c    2014-12-09 16:55:03.160727813 -0800
3191@@ -0,0 +1,34 @@
3192+/* Get enabled floating-point exceptions.
3193+   Copyright (C) 2000 Free Software Foundation, Inc.
3194+   This file is part of the GNU C Library.
3195+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
3196+
3197+   The GNU C Library is free software; you can redistribute it and/or
3198+   modify it under the terms of the GNU Lesser General Public
3199+   License as published by the Free Software Foundation; either
3200+   version 2.1 of the License, or (at your option) any later version.
3201+
3202+   The GNU C Library is distributed in the hope that it will be useful,
3203+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3204+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3205+   Lesser General Public License for more details.
3206+
3207+   You should have received a copy of the GNU Lesser General Public
3208+   License along with the GNU C Library; if not, write to the Free
3209+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3210+   02111-1307 USA.  */
3211+
3212+#include <fenv.h>
3213+#include <fenv_libc.h>
3214+#include <fpu_control.h>
3215+
3216+int
3217+fegetexcept (void)
3218+{
3219+  unsigned int exc;
3220+
3221+  /* Get the current control word.  */
3222+  _FPU_GETCW (exc);
3223+
3224+  return (exc & ENABLE_MASK) >> ENABLE_SHIFT;
3225+}
3226diff -ruN glibc-2.19/sysdeps/riscv/fpu/fegetround.c glibc-2.19-riscv/sysdeps/riscv/fpu/fegetround.c
3227--- glibc-2.19/sysdeps/riscv/fpu/fegetround.c   1969-12-31 16:00:00.000000000 -0800
3228+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fegetround.c     2014-12-09 16:55:03.160727813 -0800
3229@@ -0,0 +1,33 @@
3230+/* Return current rounding direction.
3231+   Copyright (C) 1998 Free Software Foundation, Inc.
3232+   This file is part of the GNU C Library.
3233+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
3234+
3235+   The GNU C Library is free software; you can redistribute it and/or
3236+   modify it under the terms of the GNU Lesser General Public
3237+   License as published by the Free Software Foundation; either
3238+   version 2.1 of the License, or (at your option) any later version.
3239+
3240+   The GNU C Library is distributed in the hope that it will be useful,
3241+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3242+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3243+   Lesser General Public License for more details.
3244+
3245+   You should have received a copy of the GNU Lesser General Public
3246+   License along with the GNU C Library; if not, write to the Free
3247+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3248+   02111-1307 USA.  */
3249+
3250+#include <fenv.h>
3251+#include <fpu_control.h>
3252+
3253+int
3254+fegetround (void)
3255+{
3256+  int cw;
3257+
3258+  /* Get control word.  */
3259+  _FPU_GETCW (cw);
3260+
3261+  return cw & 0x3;
3262+}
3263diff -ruN glibc-2.19/sysdeps/riscv/fpu/feholdexcpt.c glibc-2.19-riscv/sysdeps/riscv/fpu/feholdexcpt.c
3264--- glibc-2.19/sysdeps/riscv/fpu/feholdexcpt.c  1969-12-31 16:00:00.000000000 -0800
3265+++ glibc-2.19-riscv/sysdeps/riscv/fpu/feholdexcpt.c    2014-12-09 16:55:03.160727813 -0800
3266@@ -0,0 +1,40 @@
3267+/* Store current floating-point environment and clear exceptions.
3268+   Copyright (C) 2000 Free Software Foundation, Inc.
3269+   This file is part of the GNU C Library.
3270+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
3271+
3272+   The GNU C Library is free software; you can redistribute it and/or
3273+   modify it under the terms of the GNU Lesser General Public
3274+   License as published by the Free Software Foundation; either
3275+   version 2.1 of the License, or (at your option) any later version.
3276+
3277+   The GNU C Library is distributed in the hope that it will be useful,
3278+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3279+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3280+   Lesser General Public License for more details.
3281+
3282+   You should have received a copy of the GNU Lesser General Public
3283+   License along with the GNU C Library; if not, write to the Free
3284+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3285+   02111-1307 USA.  */
3286+
3287+#include <fenv.h>
3288+#include <fpu_control.h>
3289+
3290+int
3291+feholdexcept (fenv_t *envp)
3292+{
3293+  fpu_control_t cw;
3294+
3295+  /* Save the current state.  */
3296+  _FPU_GETCW (cw);
3297+  envp->__fp_control_register = cw;
3298+
3299+  /* Clear all exception enable bits and flags.  */
3300+  cw &= ~(_FPU_MASK_V|_FPU_MASK_Z|_FPU_MASK_O|_FPU_MASK_U|_FPU_MASK_I|FE_ALL_EXCEPT);
3301+  _FPU_SETCW (cw);
3302+
3303+  return 0;
3304+}
3305+
3306+libm_hidden_def (feholdexcept)
3307diff -ruN glibc-2.19/sysdeps/riscv/fpu/fenv_libc.h glibc-2.19-riscv/sysdeps/riscv/fpu/fenv_libc.h
3308--- glibc-2.19/sysdeps/riscv/fpu/fenv_libc.h    1969-12-31 16:00:00.000000000 -0800
3309+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fenv_libc.h      2014-12-09 16:55:03.160727813 -0800
3310@@ -0,0 +1,32 @@
3311+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
3312+   This file is part of the GNU C Library.
3313+   Contributed by Andreas Jaeger <aj@suse.de>.
3314+
3315+   The GNU C Library is free software; you can redistribute it and/or
3316+   modify it under the terms of the GNU Lesser General Public
3317+   License as published by the Free Software Foundation; either
3318+   version 2.1 of the License, or (at your option) any later version.
3319+
3320+   The GNU C Library is distributed in the hope that it will be useful,
3321+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3322+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3323+   Lesser General Public License for more details.
3324+
3325+   You should have received a copy of the GNU Lesser General Public
3326+   License along with the GNU C Library; if not, write to the Free
3327+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3328+   02111-1307 USA.  */
3329+
3330+#ifndef _FENV_LIBC_H
3331+#define _FENV_LIBC_H    1
3332+
3333+/* Mask for enabling exceptions and for the CAUSE bits.  */
3334+#define ENABLE_MASK    0x00F80U
3335+#define CAUSE_MASK     0x1F000U
3336+
3337+/* Shift for FE_* flags to get up to the ENABLE bits and the CAUSE bits.  */
3338+#define        ENABLE_SHIFT    5
3339+#define        CAUSE_SHIFT     10
3340+
3341+
3342+#endif /* _FENV_LIBC_H */
3343diff -ruN glibc-2.19/sysdeps/riscv/fpu/fesetenv.c glibc-2.19-riscv/sysdeps/riscv/fpu/fesetenv.c
3344--- glibc-2.19/sysdeps/riscv/fpu/fesetenv.c     1969-12-31 16:00:00.000000000 -0800
3345+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fesetenv.c       2014-12-09 16:55:03.160727813 -0800
3346@@ -0,0 +1,43 @@
3347+/* Install given floating-point environment.
3348+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
3349+   This file is part of the GNU C Library.
3350+   Contributed by Andreas Jaeger <aj@suse.de>, 1998.
3351+
3352+   The GNU C Library is free software; you can redistribute it and/or
3353+   modify it under the terms of the GNU Lesser General Public
3354+   License as published by the Free Software Foundation; either
3355+   version 2.1 of the License, or (at your option) any later version.
3356+
3357+   The GNU C Library is distributed in the hope that it will be useful,
3358+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3359+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3360+   Lesser General Public License for more details.
3361+
3362+   You should have received a copy of the GNU Lesser General Public
3363+   License along with the GNU C Library; if not, write to the Free
3364+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3365+   02111-1307 USA.  */
3366+
3367+#include <fenv.h>
3368+#include <fpu_control.h>
3369+
3370+int
3371+fesetenv (const fenv_t *envp)
3372+{
3373+  fpu_control_t cw;
3374+
3375+  /* Read first current state to flush fpu pipeline.  */
3376+  _FPU_GETCW (cw);
3377+
3378+  if (envp == FE_DFL_ENV)
3379+    _FPU_SETCW (_FPU_DEFAULT);
3380+  else if (envp == FE_NOMASK_ENV)
3381+    _FPU_SETCW (_FPU_IEEE);
3382+  else
3383+    _FPU_SETCW (envp->__fp_control_register);
3384+
3385+  /* Success.  */
3386+  return 0;
3387+}
3388+
3389+libm_hidden_def (fesetenv)
3390diff -ruN glibc-2.19/sysdeps/riscv/fpu/fesetround.c glibc-2.19-riscv/sysdeps/riscv/fpu/fesetround.c
3391--- glibc-2.19/sysdeps/riscv/fpu/fesetround.c   1969-12-31 16:00:00.000000000 -0800
3392+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fesetround.c     2014-12-09 16:55:03.160727813 -0800
3393@@ -0,0 +1,45 @@
3394+/* Set current rounding direction.
3395+   Copyright (C) 1998 Free Software Foundation, Inc.
3396+   This file is part of the GNU C Library.
3397+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
3398+
3399+   The GNU C Library is free software; you can redistribute it and/or
3400+   modify it under the terms of the GNU Lesser General Public
3401+   License as published by the Free Software Foundation; either
3402+   version 2.1 of the License, or (at your option) any later version.
3403+
3404+   The GNU C Library is distributed in the hope that it will be useful,
3405+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3406+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3407+   Lesser General Public License for more details.
3408+
3409+   You should have received a copy of the GNU Lesser General Public
3410+   License along with the GNU C Library; if not, write to the Free
3411+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3412+   02111-1307 USA.  */
3413+
3414+#include <fenv.h>
3415+#include <fpu_control.h>
3416+
3417+int
3418+fesetround (int round)
3419+{
3420+  fpu_control_t cw;
3421+
3422+  if ((round & ~0x3) != 0)
3423+    /* ROUND is no valid rounding mode.  */
3424+    return 1;
3425+
3426+  /* Get current state.  */
3427+  _FPU_GETCW (cw);
3428+
3429+  /* Set rounding bits.  */
3430+  cw &= ~0x3;
3431+  cw |= round;
3432+  /* Set new state.  */
3433+  _FPU_SETCW (cw);
3434+
3435+  return 0;
3436+}
3437+
3438+libm_hidden_def (fesetround)
3439diff -ruN glibc-2.19/sysdeps/riscv/fpu/feupdateenv.c glibc-2.19-riscv/sysdeps/riscv/fpu/feupdateenv.c
3440--- glibc-2.19/sysdeps/riscv/fpu/feupdateenv.c  1969-12-31 16:00:00.000000000 -0800
3441+++ glibc-2.19-riscv/sysdeps/riscv/fpu/feupdateenv.c    2014-12-09 16:55:03.160727813 -0800
3442@@ -0,0 +1,44 @@
3443+/* Install given floating-point environment and raise exceptions.
3444+   Copyright (C) 1998, 1999, 2000, 2002, 2010 Free Software Foundation, Inc.
3445+   This file is part of the GNU C Library.
3446+   Contributed by Andreas Jaeger <aj@suse.de>, 1998.
3447+
3448+   The GNU C Library is free software; you can redistribute it and/or
3449+   modify it under the terms of the GNU Lesser General Public
3450+   License as published by the Free Software Foundation; either
3451+   version 2.1 of the License, or (at your option) any later version.
3452+
3453+   The GNU C Library is distributed in the hope that it will be useful,
3454+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3455+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3456+   Lesser General Public License for more details.
3457+
3458+   You should have received a copy of the GNU Lesser General Public
3459+   License along with the GNU C Library; if not, write to the Free
3460+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3461+   02111-1307 USA.  */
3462+
3463+#include <fenv.h>
3464+#include <fpu_control.h>
3465+
3466+int
3467+feupdateenv (const fenv_t *envp)
3468+{
3469+  int temp;
3470+
3471+  /* Save current exceptions.  */
3472+  _FPU_GETCW (temp);
3473+  temp &= FE_ALL_EXCEPT;
3474+
3475+  /* Install new environment.  */
3476+  fesetenv (envp);
3477+
3478+  /* Raise the safed exception.  Incidently for us the implementation
3479+     defined format of the values in objects of type fexcept_t is the
3480+     same as the ones specified using the FE_* constants.  */
3481+  feraiseexcept (temp);
3482+
3483+  /* Success.  */
3484+  return 0;
3485+}
3486+libm_hidden_def (feupdateenv)
3487diff -ruN glibc-2.19/sysdeps/riscv/fpu/fgetexcptflg.c glibc-2.19-riscv/sysdeps/riscv/fpu/fgetexcptflg.c
3488--- glibc-2.19/sysdeps/riscv/fpu/fgetexcptflg.c 1969-12-31 16:00:00.000000000 -0800
3489+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fgetexcptflg.c   2014-12-09 16:55:03.160727813 -0800
3490@@ -0,0 +1,40 @@
3491+/* Store current representation for exceptions.
3492+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
3493+   This file is part of the GNU C Library.
3494+   Contributed by Andreas Jaeger <aj@suse.de>, 1998.
3495+
3496+   The GNU C Library is free software; you can redistribute it and/or
3497+   modify it under the terms of the GNU Lesser General Public
3498+   License as published by the Free Software Foundation; either
3499+   version 2.1 of the License, or (at your option) any later version.
3500+
3501+   The GNU C Library is distributed in the hope that it will be useful,
3502+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3503+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3504+   Lesser General Public License for more details.
3505+
3506+   You should have received a copy of the GNU Lesser General Public
3507+   License along with the GNU C Library; if not, write to the Free
3508+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3509+   02111-1307 USA.  */
3510+
3511+#include <fenv.h>
3512+#include <fpu_control.h>
3513+
3514+int
3515+fegetexceptflag (fexcept_t *flagp, int excepts)
3516+{
3517+  fpu_control_t temp;
3518+
3519+  /* Get the current exceptions.  */
3520+  _FPU_GETCW (temp);
3521+
3522+  /* We only save the relevant bits here. In particular, care has to be 
3523+     taken with the CAUSE bits, as an inadvertent restore later on could
3524+     generate unexpected exceptions.  */
3525+
3526+  *flagp = temp & excepts & FE_ALL_EXCEPT;
3527+
3528+  /* Success.  */
3529+  return 0;
3530+}
3531diff -ruN glibc-2.19/sysdeps/riscv/fpu/fraiseexcpt.c glibc-2.19-riscv/sysdeps/riscv/fpu/fraiseexcpt.c
3532--- glibc-2.19/sysdeps/riscv/fpu/fraiseexcpt.c  1969-12-31 16:00:00.000000000 -0800
3533+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fraiseexcpt.c    2014-12-09 16:55:03.160727813 -0800
3534@@ -0,0 +1,47 @@
3535+/* Raise given exceptions.
3536+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
3537+   This file is part of the GNU C Library.
3538+   Contributed by Andreas Jaeger <aj@suse.de>, 2000.
3539+
3540+   The GNU C Library is free software; you can redistribute it and/or
3541+   modify it under the terms of the GNU Lesser General Public
3542+   License as published by the Free Software Foundation; either
3543+   version 2.1 of the License, or (at your option) any later version.
3544+
3545+   The GNU C Library is distributed in the hope that it will be useful,
3546+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3547+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3548+   Lesser General Public License for more details.
3549+
3550+   You should have received a copy of the GNU Lesser General Public
3551+   License along with the GNU C Library; if not, write to the Free
3552+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3553+   02111-1307 USA.  */
3554+
3555+#include <fenv.h>
3556+#include <fenv_libc.h>
3557+#include <fpu_control.h>
3558+
3559+int
3560+feraiseexcept (int excepts)
3561+{
3562+  fpu_control_t cw;
3563+
3564+  /* Get current state.  */
3565+  _FPU_GETCW (cw);
3566+
3567+  /* Set flag bits (which are accumulative), and *also* set the 
3568+     cause bits. The setting of the cause bits is what actually causes
3569+     the hardware to generate the exception, if the corresponding enable
3570+     bit is set as well.  */
3571+
3572+  excepts &= FE_ALL_EXCEPT;
3573+  cw |= excepts | (excepts << CAUSE_SHIFT);
3574+
3575+  /* Set new state.  */
3576+  _FPU_SETCW (cw);
3577+
3578+  return 0;
3579+}
3580+
3581+libm_hidden_def (feraiseexcept)
3582diff -ruN glibc-2.19/sysdeps/riscv/fpu/fsetexcptflg.c glibc-2.19-riscv/sysdeps/riscv/fpu/fsetexcptflg.c
3583--- glibc-2.19/sysdeps/riscv/fpu/fsetexcptflg.c 1969-12-31 16:00:00.000000000 -0800
3584+++ glibc-2.19-riscv/sysdeps/riscv/fpu/fsetexcptflg.c   2014-12-09 16:55:03.160727813 -0800
3585@@ -0,0 +1,43 @@
3586+/* Set floating-point environment exception handling.
3587+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
3588+   This file is part of the GNU C Library.
3589+   Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
3590+
3591+   The GNU C Library is free software; you can redistribute it and/or
3592+   modify it under the terms of the GNU Lesser General Public
3593+   License as published by the Free Software Foundation; either
3594+   version 2.1 of the License, or (at your option) any later version.
3595+
3596+   The GNU C Library is distributed in the hope that it will be useful,
3597+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3598+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3599+   Lesser General Public License for more details.
3600+
3601+   You should have received a copy of the GNU Lesser General Public
3602+   License along with the GNU C Library; if not, write to the Free
3603+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3604+   02111-1307 USA.  */
3605+
3606+#include <fenv.h>
3607+#include <fpu_control.h>
3608+
3609+int
3610+fesetexceptflag (const fexcept_t *flagp, int excepts)
3611+{
3612+  fpu_control_t temp;
3613+
3614+  /* Get the current exceptions.  */
3615+  _FPU_GETCW (temp);
3616+
3617+  /* Make sure the flags we want restored are legal.  */
3618+  excepts &= FE_ALL_EXCEPT;
3619+
3620+  /* Now clear the bits called for, and copy them in from flagp. Note that
3621+     we ignore all non-flag bits from *flagp, so they don't matter.  */
3622+  temp = (temp & ~excepts) | (*flagp & excepts);
3623+
3624+  _FPU_SETCW (temp);
3625+
3626+  /* Success.  */
3627+  return 0;
3628+}
3629diff -ruN glibc-2.19/sysdeps/riscv/fpu/ftestexcept.c glibc-2.19-riscv/sysdeps/riscv/fpu/ftestexcept.c
3630--- glibc-2.19/sysdeps/riscv/fpu/ftestexcept.c  1969-12-31 16:00:00.000000000 -0800
3631+++ glibc-2.19-riscv/sysdeps/riscv/fpu/ftestexcept.c    2014-12-09 16:55:03.160727813 -0800
3632@@ -0,0 +1,34 @@
3633+/* Test exception in current environment.
3634+   Copyright (C) 1998, 2010 Free Software Foundation, Inc.
3635+   This file is part of the GNU C Library.
3636+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
3637+
3638+   The GNU C Library is free software; you can redistribute it and/or
3639+   modify it under the terms of the GNU Lesser General Public
3640+   License as published by the Free Software Foundation; either
3641+   version 2.1 of the License, or (at your option) any later version.
3642+
3643+   The GNU C Library is distributed in the hope that it will be useful,
3644+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3645+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3646+   Lesser General Public License for more details.
3647+
3648+   You should have received a copy of the GNU Lesser General Public
3649+   License along with the GNU C Library; if not, write to the Free
3650+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3651+   02111-1307 USA.  */
3652+
3653+#include <fenv.h>
3654+#include <fpu_control.h>
3655+
3656+int
3657+fetestexcept (int excepts)
3658+{
3659+  int cw;
3660+
3661+  /* Get current control word.  */
3662+  _FPU_GETCW (cw);
3663+
3664+  return cw & excepts & FE_ALL_EXCEPT;
3665+}
3666+libm_hidden_def (fetestexcept)
3667diff -ruN glibc-2.19/sysdeps/riscv/fpu/libm-test-ulps glibc-2.19-riscv/sysdeps/riscv/fpu/libm-test-ulps
3668--- glibc-2.19/sysdeps/riscv/fpu/libm-test-ulps 1969-12-31 16:00:00.000000000 -0800
3669+++ glibc-2.19-riscv/sysdeps/riscv/fpu/libm-test-ulps   2014-12-09 16:55:03.164727835 -0800
3670@@ -0,0 +1,890 @@
3671+# Begin of automatic generation
3672+
3673+# atan2
3674+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
3675+float: 3
3676+ifloat: 3
3677+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
3678+float: 3
3679+ifloat: 3
3680+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
3681+float: 1
3682+ifloat: 1
3683+
3684+# atanh
3685+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
3686+float: 1
3687+ifloat: 1
3688+
3689+# cacosh
3690+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
3691+double: 1
3692+float: 7
3693+idouble: 1
3694+ifloat: 7
3695+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
3696+double: 1
3697+float: 3
3698+idouble: 1
3699+ifloat: 3
3700+
3701+# casin
3702+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
3703+double: 1
3704+float: 1
3705+idouble: 1
3706+ifloat: 1
3707+
3708+# casinh
3709+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
3710+double: 5
3711+float: 1
3712+idouble: 5
3713+ifloat: 1
3714+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
3715+double: 3
3716+float: 6
3717+idouble: 3
3718+ifloat: 6
3719+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
3720+float: 1
3721+ifloat: 1
3722+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
3723+double: 1
3724+float: 1
3725+idouble: 1
3726+ifloat: 1
3727+
3728+# catan
3729+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
3730+float: 3
3731+ifloat: 3
3732+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
3733+double: 1
3734+float: 1
3735+idouble: 1
3736+ifloat: 1
3737+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
3738+float: 4
3739+ifloat: 4
3740+
3741+# catanh
3742+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
3743+double: 4
3744+idouble: 4
3745+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
3746+float: 4
3747+ifloat: 4
3748+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
3749+double: 1
3750+idouble: 1
3751+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
3752+float: 6
3753+ifloat: 6
3754+
3755+# cbrt
3756+Test "cbrt (-27.0) == -3.0":
3757+double: 1
3758+idouble: 1
3759+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
3760+double: 1
3761+idouble: 1
3762+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
3763+double: 1
3764+idouble: 1
3765+
3766+# ccos
3767+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
3768+float: 1
3769+ifloat: 1
3770+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
3771+double: 1
3772+float: 1
3773+idouble: 1
3774+ifloat: 1
3775+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
3776+float: 1
3777+ifloat: 1
3778+
3779+# ccosh
3780+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
3781+float: 1
3782+ifloat: 1
3783+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
3784+float: 1
3785+ifloat: 1
3786+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
3787+double: 1
3788+float: 1
3789+idouble: 1
3790+ifloat: 1
3791+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
3792+float: 1
3793+ifloat: 1
3794+
3795+# cexp
3796+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
3797+float: 1
3798+ifloat: 1
3799+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
3800+float: 1
3801+ifloat: 1
3802+
3803+# clog
3804+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
3805+float: 3
3806+ifloat: 3
3807+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
3808+float: 1
3809+ifloat: 1
3810+
3811+# clog10
3812+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
3813+float: 1
3814+ifloat: 1
3815+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
3816+float: 1
3817+ifloat: 1
3818+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
3819+double: 1
3820+float: 5
3821+idouble: 1
3822+ifloat: 5
3823+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
3824+float: 1
3825+ifloat: 1
3826+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
3827+float: 1
3828+ifloat: 1
3829+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
3830+float: 1
3831+ifloat: 1
3832+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
3833+float: 1
3834+ifloat: 1
3835+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
3836+float: 1
3837+ifloat: 1
3838+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
3839+float: 1
3840+ifloat: 1
3841+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
3842+float: 1
3843+ifloat: 1
3844+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
3845+float: 1
3846+ifloat: 1
3847+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
3848+float: 1
3849+ifloat: 1
3850+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
3851+float: 1
3852+ifloat: 1
3853+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
3854+float: 1
3855+ifloat: 1
3856+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
3857+float: 1
3858+ifloat: 1
3859+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
3860+float: 1
3861+ifloat: 1
3862+
3863+# cos
3864+Test "cos (M_PI_6l * 2.0) == 0.5":
3865+double: 1
3866+float: 1
3867+idouble: 1
3868+ifloat: 1
3869+Test "cos (M_PI_6l * 4.0) == -0.5":
3870+double: 2
3871+float: 1
3872+idouble: 2
3873+ifloat: 1
3874+Test "cos (pi/2) == 0":
3875+double: 1
3876+float: 1
3877+idouble: 1
3878+ifloat: 1
3879+
3880+# cpow
3881+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
3882+float: 1
3883+ifloat: 1
3884+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
3885+float: 1
3886+ifloat: 1
3887+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
3888+double: 1
3889+float: 4
3890+idouble: 1
3891+ifloat: 4
3892+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
3893+double: 2
3894+float: 3
3895+idouble: 2
3896+ifloat: 3
3897+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
3898+double: 1
3899+float: 4
3900+idouble: 1
3901+ifloat: 4
3902+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
3903+float: 2
3904+ifloat: 2
3905+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
3906+double: 2
3907+float: 2
3908+idouble: 2
3909+ifloat: 2
3910+
3911+# csinh
3912+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
3913+double: 1
3914+idouble: 1
3915+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
3916+float: 1
3917+ifloat: 1
3918+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
3919+float: 1
3920+ifloat: 1
3921+
3922+# csqrt
3923+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
3924+float: 1
3925+ifloat: 1
3926+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
3927+float: 1
3928+ifloat: 1
3929+
3930+# ctan
3931+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
3932+double: 1
3933+idouble: 1
3934+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
3935+double: 1
3936+idouble: 1
3937+
3938+# ctanh
3939+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
3940+double: 1
3941+float: 2
3942+idouble: 1
3943+ifloat: 2
3944+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
3945+float: 1
3946+ifloat: 1
3947+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
3948+double: 1
3949+idouble: 1
3950+
3951+# erf
3952+Test "erf (1.25) == 0.922900128256458230136523481197281140":
3953+double: 1
3954+idouble: 1
3955+
3956+# erfc
3957+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
3958+double: 1
3959+idouble: 1
3960+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
3961+double: 1
3962+idouble: 1
3963+
3964+# exp10
3965+Test "exp10 (-1) == 0.1":
3966+double: 2
3967+float: 1
3968+idouble: 2
3969+ifloat: 1
3970+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
3971+double: 1
3972+float: 1
3973+idouble: 1
3974+ifloat: 1
3975+Test "exp10 (3) == 1000":
3976+double: 6
3977+float: 2
3978+idouble: 6
3979+ifloat: 2
3980+
3981+# expm1
3982+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
3983+double: 1
3984+idouble: 1
3985+Test "expm1 (1) == M_El - 1.0":
3986+float: 1
3987+ifloat: 1
3988+
3989+# hypot
3990+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
3991+float: 1
3992+ifloat: 1
3993+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
3994+float: 1
3995+ifloat: 1
3996+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
3997+float: 1
3998+ifloat: 1
3999+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
4000+float: 1
4001+ifloat: 1
4002+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
4003+float: 1
4004+ifloat: 1
4005+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
4006+float: 1
4007+ifloat: 1
4008+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
4009+float: 1
4010+ifloat: 1
4011+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
4012+float: 1
4013+ifloat: 1
4014+
4015+# j0
4016+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
4017+double: 1
4018+float: 1
4019+idouble: 1
4020+ifloat: 1
4021+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
4022+float: 1
4023+ifloat: 1
4024+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
4025+double: 2
4026+float: 1
4027+idouble: 2
4028+ifloat: 1
4029+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
4030+float: 2
4031+ifloat: 2
4032+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
4033+double: 1
4034+float: 1
4035+idouble: 1
4036+ifloat: 1
4037+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
4038+float: 1
4039+ifloat: 1
4040+
4041+# j1
4042+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
4043+float: 2
4044+ifloat: 2
4045+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
4046+double: 1
4047+idouble: 1
4048+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
4049+double: 1
4050+idouble: 1
4051+
4052+# jn
4053+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
4054+double: 1
4055+float: 1
4056+idouble: 1
4057+ifloat: 1
4058+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
4059+float: 1
4060+ifloat: 1
4061+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
4062+double: 2
4063+float: 1
4064+idouble: 2
4065+ifloat: 1
4066+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
4067+float: 2
4068+ifloat: 2
4069+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
4070+double: 1
4071+float: 1
4072+idouble: 1
4073+ifloat: 1
4074+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
4075+float: 1
4076+ifloat: 1
4077+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
4078+float: 2
4079+ifloat: 2
4080+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
4081+double: 1
4082+idouble: 1
4083+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
4084+double: 1
4085+idouble: 1
4086+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
4087+double: 1
4088+float: 1
4089+idouble: 1
4090+ifloat: 1
4091+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
4092+double: 1
4093+float: 1
4094+idouble: 1
4095+ifloat: 1
4096+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
4097+double: 4
4098+float: 3
4099+idouble: 4
4100+ifloat: 3
4101+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
4102+float: 4
4103+ifloat: 4
4104+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
4105+double: 1
4106+float: 1
4107+idouble: 1
4108+ifloat: 1
4109+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
4110+double: 1
4111+float: 1
4112+idouble: 1
4113+ifloat: 1
4114+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
4115+double: 3
4116+float: 1
4117+idouble: 3
4118+ifloat: 1
4119+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
4120+double: 1
4121+float: 2
4122+idouble: 1
4123+ifloat: 2
4124+
4125+# lgamma
4126+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
4127+double: 1
4128+float: 1
4129+idouble: 1
4130+ifloat: 1
4131+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
4132+double: 1
4133+float: 2
4134+idouble: 1
4135+ifloat: 2
4136+
4137+# log10
4138+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
4139+double: 1
4140+float: 2
4141+idouble: 1
4142+ifloat: 2
4143+Test "log10 (e) == log10(e)":
4144+float: 1
4145+ifloat: 1
4146+
4147+# log1p
4148+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
4149+float: 1
4150+ifloat: 1
4151+
4152+# sincos
4153+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
4154+double: 1
4155+float: 1
4156+idouble: 1
4157+ifloat: 1
4158+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
4159+double: 1
4160+float: 1
4161+idouble: 1
4162+ifloat: 1
4163+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
4164+double: 1
4165+float: 1
4166+idouble: 1
4167+ifloat: 1
4168+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
4169+float: 1
4170+ifloat: 1
4171+
4172+# tan
4173+Test "tan (pi/4) == 1":
4174+double: 1
4175+idouble: 1
4176+
4177+# tgamma
4178+Test "tgamma (-0.5) == -2 sqrt (pi)":
4179+double: 1
4180+float: 1
4181+idouble: 1
4182+ifloat: 1
4183+Test "tgamma (0.5) == sqrt (pi)":
4184+float: 1
4185+ifloat: 1
4186+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
4187+double: 1
4188+float: 1
4189+idouble: 1
4190+ifloat: 1
4191+
4192+# y0
4193+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
4194+double: 2
4195+float: 1
4196+idouble: 2
4197+ifloat: 1
4198+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
4199+double: 2
4200+float: 1
4201+idouble: 2
4202+ifloat: 1
4203+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
4204+float: 1
4205+ifloat: 1
4206+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
4207+double: 1
4208+float: 1
4209+idouble: 1
4210+ifloat: 1
4211+
4212+# y1
4213+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
4214+double: 1
4215+idouble: 1
4216+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
4217+float: 1
4218+ifloat: 1
4219+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
4220+double: 3
4221+float: 1
4222+idouble: 3
4223+ifloat: 1
4224+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
4225+double: 1
4226+float: 1
4227+idouble: 1
4228+ifloat: 1
4229+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
4230+double: 1
4231+float: 2
4232+idouble: 1
4233+ifloat: 2
4234+
4235+# yn
4236+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
4237+double: 2
4238+float: 1
4239+idouble: 2
4240+ifloat: 1
4241+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
4242+double: 2
4243+float: 1
4244+idouble: 2
4245+ifloat: 1
4246+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
4247+float: 1
4248+ifloat: 1
4249+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
4250+double: 1
4251+float: 1
4252+idouble: 1
4253+ifloat: 1
4254+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
4255+double: 1
4256+idouble: 1
4257+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
4258+float: 1
4259+ifloat: 1
4260+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
4261+double: 3
4262+float: 1
4263+idouble: 3
4264+ifloat: 1
4265+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
4266+double: 1
4267+float: 1
4268+idouble: 1
4269+ifloat: 1
4270+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
4271+double: 1
4272+float: 2
4273+idouble: 1
4274+ifloat: 2
4275+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
4276+double: 1
4277+idouble: 1
4278+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
4279+double: 1
4280+float: 1
4281+idouble: 1
4282+ifloat: 1
4283+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
4284+double: 1
4285+idouble: 1
4286+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
4287+double: 1
4288+float: 1
4289+idouble: 1
4290+ifloat: 1
4291+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
4292+double: 2
4293+idouble: 2
4294+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
4295+double: 1
4296+idouble: 1
4297+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
4298+double: 1
4299+float: 1
4300+idouble: 1
4301+ifloat: 1
4302+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
4303+double: 1
4304+float: 1
4305+idouble: 1
4306+ifloat: 1
4307+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
4308+double: 1
4309+idouble: 1
4310+
4311+# Maximal error of functions:
4312+Function: "atan2":
4313+float: 3
4314+ifloat: 3
4315+
4316+Function: "atanh":
4317+float: 1
4318+ifloat: 1
4319+
4320+Function: Real part of "cacosh":
4321+double: 1
4322+float: 7
4323+idouble: 1
4324+ifloat: 7
4325+
4326+Function: Imaginary part of "cacosh":
4327+double: 1
4328+float: 3
4329+idouble: 1
4330+ifloat: 3
4331+
4332+Function: Real part of "casin":
4333+double: 1
4334+float: 1
4335+idouble: 1
4336+ifloat: 1
4337+
4338+Function: Real part of "casinh":
4339+double: 5
4340+float: 1
4341+idouble: 5
4342+ifloat: 1
4343+
4344+Function: Imaginary part of "casinh":
4345+double: 3
4346+float: 6
4347+idouble: 3
4348+ifloat: 6
4349+
4350+Function: Real part of "catan":
4351+float: 4
4352+ifloat: 4
4353+
4354+Function: Imaginary part of "catan":
4355+double: 1
4356+float: 1
4357+idouble: 1
4358+ifloat: 1
4359+
4360+Function: Real part of "catanh":
4361+double: 4
4362+idouble: 4
4363+
4364+Function: Imaginary part of "catanh":
4365+float: 6
4366+ifloat: 6
4367+
4368+Function: "cbrt":
4369+double: 1
4370+idouble: 1
4371+
4372+Function: Real part of "ccos":
4373+double: 1
4374+float: 1
4375+idouble: 1
4376+ifloat: 1
4377+
4378+Function: Imaginary part of "ccos":
4379+float: 1
4380+ifloat: 1
4381+
4382+Function: Real part of "ccosh":
4383+double: 1
4384+float: 1
4385+idouble: 1
4386+ifloat: 1
4387+
4388+Function: Imaginary part of "ccosh":
4389+float: 1
4390+ifloat: 1
4391+
4392+Function: Real part of "cexp":
4393+float: 1
4394+ifloat: 1
4395+
4396+Function: Imaginary part of "cexp":
4397+float: 1
4398+ifloat: 1
4399+
4400+Function: Real part of "clog":
4401+float: 1
4402+ifloat: 1
4403+
4404+Function: Imaginary part of "clog":
4405+float: 3
4406+ifloat: 3
4407+
4408+Function: Real part of "clog10":
4409+float: 1
4410+ifloat: 1
4411+
4412+Function: Imaginary part of "clog10":
4413+double: 1
4414+float: 5
4415+idouble: 1
4416+ifloat: 5
4417+
4418+Function: "cos":
4419+double: 2
4420+float: 1
4421+idouble: 2
4422+ifloat: 1
4423+
4424+Function: Real part of "cpow":
4425+double: 2
4426+float: 4
4427+idouble: 2
4428+ifloat: 4
4429+
4430+Function: Imaginary part of "cpow":
4431+double: 2
4432+float: 2
4433+idouble: 2
4434+ifloat: 2
4435+
4436+Function: Real part of "csinh":
4437+float: 1
4438+ifloat: 1
4439+
4440+Function: Imaginary part of "csinh":
4441+double: 1
4442+float: 1
4443+idouble: 1
4444+ifloat: 1
4445+
4446+Function: Real part of "csqrt":
4447+float: 1
4448+ifloat: 1
4449+
4450+Function: Real part of "ctan":
4451+double: 1
4452+idouble: 1
4453+
4454+Function: Imaginary part of "ctan":
4455+double: 1
4456+idouble: 1
4457+
4458+Function: Real part of "ctanh":
4459+double: 1
4460+float: 2
4461+idouble: 1
4462+ifloat: 2
4463+
4464+Function: Imaginary part of "ctanh":
4465+float: 1
4466+ifloat: 1
4467+
4468+Function: "erf":
4469+double: 1
4470+idouble: 1
4471+
4472+Function: "erfc":
4473+double: 1
4474+idouble: 1
4475+
4476+Function: "exp10":
4477+double: 6
4478+float: 2
4479+idouble: 6
4480+ifloat: 2
4481+
4482+Function: "expm1":
4483+double: 1
4484+float: 1
4485+idouble: 1
4486+ifloat: 1
4487+
4488+Function: "hypot":
4489+float: 1
4490+ifloat: 1
4491+
4492+Function: "j0":
4493+double: 2
4494+float: 2
4495+idouble: 2
4496+ifloat: 2
4497+
4498+Function: "j1":
4499+double: 1
4500+float: 2
4501+idouble: 1
4502+ifloat: 2
4503+
4504+Function: "jn":
4505+double: 4
4506+float: 4
4507+idouble: 4
4508+ifloat: 4
4509+
4510+Function: "lgamma":
4511+double: 1
4512+float: 2
4513+idouble: 1
4514+ifloat: 2
4515+
4516+Function: "log10":
4517+double: 1
4518+float: 2
4519+idouble: 1
4520+ifloat: 2
4521+
4522+Function: "log1p":
4523+float: 1
4524+ifloat: 1
4525+
4526+Function: "sincos":
4527+double: 1
4528+float: 1
4529+idouble: 1
4530+ifloat: 1
4531+
4532+Function: "tan":
4533+double: 1
4534+idouble: 1
4535+
4536+Function: "tgamma":
4537+double: 1
4538+float: 1
4539+idouble: 1
4540+ifloat: 1
4541+
4542+Function: "y0":
4543+double: 2
4544+float: 1
4545+idouble: 2
4546+ifloat: 1
4547+
4548+Function: "y1":
4549+double: 3
4550+float: 2
4551+idouble: 3
4552+ifloat: 2
4553+
4554+Function: "yn":
4555+double: 3
4556+float: 2
4557+idouble: 3
4558+ifloat: 2
4559+
4560+# end of automatic generation
4561diff -ruN glibc-2.19/sysdeps/riscv/fpu_control.h glibc-2.19-riscv/sysdeps/riscv/fpu_control.h
4562--- glibc-2.19/sysdeps/riscv/fpu_control.h      1969-12-31 16:00:00.000000000 -0800
4563+++ glibc-2.19-riscv/sysdeps/riscv/fpu_control.h        2014-12-09 16:55:03.164727835 -0800
4564@@ -0,0 +1,112 @@
4565+/* FPU control word bits.  Mips version.
4566+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006, 2008
4567+   Free Software Foundation, Inc.
4568+   This file is part of the GNU C Library.
4569+   Contributed by Olaf Flebbe and Ralf Baechle.
4570+
4571+   The GNU C Library is free software; you can redistribute it and/or
4572+   modify it under the terms of the GNU Lesser General Public
4573+   License as published by the Free Software Foundation; either
4574+   version 2.1 of the License, or (at your option) any later version.
4575+
4576+   The GNU C Library is distributed in the hope that it will be useful,
4577+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4578+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4579+   Lesser General Public License for more details.
4580+
4581+   You should have received a copy of the GNU Lesser General Public
4582+   License along with the GNU C Library; if not, write to the Free
4583+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4584+   02111-1307 USA.  */
4585+
4586+#ifndef _FPU_CONTROL_H
4587+#define _FPU_CONTROL_H
4588+
4589+/* MIPS FPU floating point control register bits.
4590+ *
4591+ * 31-25  -> floating point conditions code bits 7-1.  These bits are only
4592+ *           available in MIPS IV.
4593+ * 24     -> flush denormalized results to zero instead of
4594+ *           causing unimplemented operation exception.  This bit is only
4595+ *           available for MIPS III and newer.
4596+ * 23     -> Condition bit
4597+ * 22-18  -> reserved (read as 0, write with 0)
4598+ * 17     -> cause bit for unimplemented operation
4599+ * 16     -> cause bit for invalid exception
4600+ * 15     -> cause bit for division by zero exception
4601+ * 14     -> cause bit for overflow exception
4602+ * 13     -> cause bit for underflow exception
4603+ * 12     -> cause bit for inexact exception
4604+ * 11     -> enable exception for invalid exception
4605+ * 10     -> enable exception for division by zero exception
4606+ *  9     -> enable exception for overflow exception
4607+ *  8     -> enable exception for underflow exception
4608+ *  7     -> enable exception for inexact exception
4609+ *  6     -> flag invalid exception
4610+ *  5     -> flag division by zero exception
4611+ *  4     -> flag overflow exception
4612+ *  3     -> flag underflow exception
4613+ *  2     -> flag inexact exception
4614+ *  1-0   -> rounding control
4615+ *
4616+ *
4617+ * Rounding Control:
4618+ * 00 - rounding to nearest (RN)
4619+ * 01 - rounding toward zero (RZ)
4620+ * 10 - rounding (up) toward plus infinity (RP)
4621+ * 11 - rounding (down)toward minus infinity (RM)
4622+ */
4623+
4624+#include <features.h>
4625+
4626+#ifdef __mips_soft_float
4627+
4628+#define _FPU_RESERVED 0xffffffff
4629+#define _FPU_DEFAULT  0x00000000
4630+typedef unsigned int fpu_control_t;
4631+#define _FPU_GETCW(cw) 0
4632+#define _FPU_SETCW(cw) do { } while (0)
4633+extern fpu_control_t __fpu_control;
4634+
4635+#else /* __mips_soft_float */
4636+
4637+/* masking of interrupts */
4638+#define _FPU_MASK_V     0x0800  /* Invalid operation */
4639+#define _FPU_MASK_Z     0x0400  /* Division by zero  */
4640+#define _FPU_MASK_O     0x0200  /* Overflow          */
4641+#define _FPU_MASK_U     0x0100  /* Underflow         */
4642+#define _FPU_MASK_I     0x0080  /* Inexact operation */
4643+
4644+/* flush denormalized numbers to zero */
4645+#define _FPU_FLUSH_TZ   0x1000000
4646+
4647+/* rounding control */
4648+#define _FPU_RC_NEAREST 0x0     /* RECOMMENDED */
4649+#define _FPU_RC_ZERO    0x1
4650+#define _FPU_RC_UP      0x2
4651+#define _FPU_RC_DOWN    0x3
4652+
4653+#define _FPU_RESERVED 0xfe3c0000  /* Reserved bits in cw */
4654+
4655+
4656+/* The fdlibm code requires strict IEEE double precision arithmetic,
4657+   and no interrupts for exceptions, rounding to nearest.  */
4658+
4659+#define _FPU_DEFAULT  0x00000000
4660+
4661+/* IEEE:  same as above, but exceptions */
4662+#define _FPU_IEEE     0x00000F80
4663+
4664+/* Type of the control word.  */
4665+typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
4666+
4667+/* Macros for accessing the hardware control word.  */
4668+#define _FPU_GETCW(cw) __asm__ volatile ("mffsr %0" : "=r" (cw))
4669+#define _FPU_SETCW(cw) __asm__ volatile ("mtfsr %0" : : "r" (cw))
4670+
4671+/* Default control word set at startup.  */
4672+extern fpu_control_t __fpu_control;
4673+
4674+#endif /* __mips_soft_float */
4675+
4676+#endif /* fpu_control.h */
4677diff -ruN glibc-2.19/sysdeps/riscv/gccframe.h glibc-2.19-riscv/sysdeps/riscv/gccframe.h
4678--- glibc-2.19/sysdeps/riscv/gccframe.h 1969-12-31 16:00:00.000000000 -0800
4679+++ glibc-2.19-riscv/sysdeps/riscv/gccframe.h   2014-12-09 16:55:03.164727835 -0800
4680@@ -0,0 +1,22 @@
4681+/* Definition of object in frame unwind info.  mips version.
4682+   Copyright (C) 2001 Free Software Foundation, Inc.
4683+   This file is part of the GNU C Library.
4684+
4685+   The GNU C Library is free software; you can redistribute it and/or
4686+   modify it under the terms of the GNU Lesser General Public
4687+   License as published by the Free Software Foundation; either
4688+   version 2.1 of the License, or (at your option) any later version.
4689+
4690+   The GNU C Library is distributed in the hope that it will be useful,
4691+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4692+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4693+   Lesser General Public License for more details.
4694+
4695+   You should have received a copy of the GNU Lesser General Public
4696+   License along with the GNU C Library; if not, write to the Free
4697+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4698+   02111-1307 USA.  */
4699+
4700+#define FIRST_PSEUDO_REGISTER 76
4701+
4702+#include <sysdeps/generic/gccframe.h>
4703diff -ruN glibc-2.19/sysdeps/riscv/ieee754.h glibc-2.19-riscv/sysdeps/riscv/ieee754.h
4704--- glibc-2.19/sysdeps/riscv/ieee754.h  1969-12-31 16:00:00.000000000 -0800
4705+++ glibc-2.19-riscv/sysdeps/riscv/ieee754.h    2014-12-09 16:55:03.164727835 -0800
4706@@ -0,0 +1,325 @@
4707+/* Copyright (C) 1992, 1995, 1996, 1999, 2002, 2003
4708+       Free Software Foundation, Inc.
4709+   This file is part of the GNU C Library.
4710+
4711+   The GNU C Library is free software; you can redistribute it and/or
4712+   modify it under the terms of the GNU Lesser General Public
4713+   License as published by the Free Software Foundation; either
4714+   version 2.1 of the License, or (at your option) any later version.
4715+
4716+   The GNU C Library is distributed in the hope that it will be useful,
4717+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4718+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4719+   Lesser General Public License for more details.
4720+
4721+   You should have received a copy of the GNU Lesser General Public
4722+   License along with the GNU C Library; if not, write to the Free
4723+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4724+   02111-1307 USA.  */
4725+
4726+#ifndef _IEEE754_H
4727+
4728+#define _IEEE754_H 1
4729+#include <features.h>
4730+
4731+#include <endian.h>
4732+
4733+#include <float.h>
4734+
4735+__BEGIN_DECLS
4736+
4737+union ieee754_float
4738+  {
4739+    float f;
4740+
4741+    /* This is the IEEE 754 single-precision format.  */
4742+    struct
4743+      {
4744+#if    __BYTE_ORDER == __BIG_ENDIAN
4745+       unsigned int negative:1;
4746+       unsigned int exponent:8;
4747+       unsigned int mantissa:23;
4748+#endif                         /* Big endian.  */
4749+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4750+       unsigned int mantissa:23;
4751+       unsigned int exponent:8;
4752+       unsigned int negative:1;
4753+#endif                         /* Little endian.  */
4754+      } ieee;
4755+
4756+    /* This format makes it easier to see if a NaN is a signalling NaN.  */
4757+    struct
4758+      {
4759+#if    __BYTE_ORDER == __BIG_ENDIAN
4760+       unsigned int negative:1;
4761+       unsigned int exponent:8;
4762+       unsigned int quiet_nan:1;
4763+       unsigned int mantissa:22;
4764+#endif                         /* Big endian.  */
4765+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4766+       unsigned int mantissa:22;
4767+       unsigned int quiet_nan:1;
4768+       unsigned int exponent:8;
4769+       unsigned int negative:1;
4770+#endif                         /* Little endian.  */
4771+      } ieee_nan;
4772+  };
4773+
4774+#define IEEE754_FLOAT_BIAS     0x7f /* Added to exponent.  */
4775+
4776+
4777+union ieee754_double
4778+  {
4779+    double d;
4780+
4781+    /* This is the IEEE 754 double-precision format.  */
4782+    struct
4783+      {
4784+#if    __BYTE_ORDER == __BIG_ENDIAN
4785+       unsigned int negative:1;
4786+       unsigned int exponent:11;
4787+       /* Together these comprise the mantissa.  */
4788+       unsigned int mantissa0:20;
4789+       unsigned int mantissa1:32;
4790+#endif                         /* Big endian.  */
4791+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4792+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
4793+       unsigned int mantissa0:20;
4794+       unsigned int exponent:11;
4795+       unsigned int negative:1;
4796+       unsigned int mantissa1:32;
4797+# else
4798+       /* Together these comprise the mantissa.  */
4799+       unsigned int mantissa1:32;
4800+       unsigned int mantissa0:20;
4801+       unsigned int exponent:11;
4802+       unsigned int negative:1;
4803+# endif
4804+#endif                         /* Little endian.  */
4805+      } ieee;
4806+
4807+    /* This format makes it easier to see if a NaN is a signalling NaN.  */
4808+    struct
4809+      {
4810+#if    __BYTE_ORDER == __BIG_ENDIAN
4811+       unsigned int negative:1;
4812+       unsigned int exponent:11;
4813+       unsigned int quiet_nan:1;
4814+       /* Together these comprise the mantissa.  */
4815+       unsigned int mantissa0:19;
4816+       unsigned int mantissa1:32;
4817+#else
4818+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
4819+       unsigned int mantissa0:19;
4820+       unsigned int quiet_nan:1;
4821+       unsigned int exponent:11;
4822+       unsigned int negative:1;
4823+       unsigned int mantissa1:32;
4824+# else
4825+       /* Together these comprise the mantissa.  */
4826+       unsigned int mantissa1:32;
4827+       unsigned int mantissa0:19;
4828+       unsigned int quiet_nan:1;
4829+       unsigned int exponent:11;
4830+       unsigned int negative:1;
4831+# endif
4832+#endif
4833+      } ieee_nan;
4834+  };
4835+
4836+#define IEEE754_DOUBLE_BIAS    0x3ff /* Added to exponent.  */
4837+
4838+#if LDBL_MANT_DIG == 113
4839+
4840+union ieee854_long_double
4841+  {
4842+    long double d;
4843+
4844+    /* This is the IEEE 854 quad-precision format.  */
4845+    struct
4846+      {
4847+#if    __BYTE_ORDER == __BIG_ENDIAN
4848+       unsigned int negative:1;
4849+       unsigned int exponent:15;
4850+       /* Together these comprise the mantissa.  */
4851+       unsigned int mantissa0:16;
4852+       unsigned int mantissa1:32;
4853+       unsigned int mantissa2:32;
4854+       unsigned int mantissa3:32;
4855+#endif                         /* Big endian.  */
4856+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4857+       /* Together these comprise the mantissa.  */
4858+       unsigned int mantissa3:32;
4859+       unsigned int mantissa2:32;
4860+       unsigned int mantissa1:32;
4861+       unsigned int mantissa0:16;
4862+       unsigned int exponent:15;
4863+       unsigned int negative:1;
4864+#endif                         /* Little endian.  */
4865+      } ieee;
4866+
4867+    /* This format makes it easier to see if a NaN is a signalling NaN.  */
4868+    struct
4869+      {
4870+#if    __BYTE_ORDER == __BIG_ENDIAN
4871+       unsigned int negative:1;
4872+       unsigned int exponent:15;
4873+       unsigned int quiet_nan:1;
4874+       /* Together these comprise the mantissa.  */
4875+       unsigned int mantissa0:15;
4876+       unsigned int mantissa1:32;
4877+       unsigned int mantissa2:32;
4878+       unsigned int mantissa3:32;
4879+#endif                         /* Big endian.  */
4880+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4881+       /* Together these comprise the mantissa.  */
4882+       unsigned int mantissa3:32;
4883+       unsigned int mantissa2:32;
4884+       unsigned int mantissa1:32;
4885+       unsigned int mantissa0:15;
4886+       unsigned int quiet_nan:1;
4887+       unsigned int exponent:15;
4888+       unsigned int negative:1;
4889+#endif                         /* Little endian.  */
4890+      } ieee_nan;
4891+  };
4892+
4893+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff /* Added to exponent.  */
4894+
4895+#elif LDBL_MANT_DIG == 64
4896+
4897+union ieee854_long_double
4898+  {
4899+    long double d;
4900+
4901+    /* This is the IEEE 854 double-extended-precision format.  */
4902+    struct
4903+      {
4904+#if    __BYTE_ORDER == __BIG_ENDIAN
4905+       unsigned int negative:1;
4906+       unsigned int exponent:15;
4907+       unsigned int empty:16;
4908+       unsigned int mantissa0:32;
4909+       unsigned int mantissa1:32;
4910+#endif
4911+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4912+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
4913+       unsigned int exponent:15;
4914+       unsigned int negative:1;
4915+       unsigned int empty:16;
4916+       unsigned int mantissa0:32;
4917+       unsigned int mantissa1:32;
4918+# else
4919+       unsigned int mantissa1:32;
4920+       unsigned int mantissa0:32;
4921+       unsigned int exponent:15;
4922+       unsigned int negative:1;
4923+       unsigned int empty:16;
4924+# endif
4925+#endif
4926+      } ieee;
4927+
4928+    /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
4929+    struct
4930+      {
4931+#if    __BYTE_ORDER == __BIG_ENDIAN
4932+       unsigned int negative:1;
4933+       unsigned int exponent:15;
4934+       unsigned int empty:16;
4935+       unsigned int one:1;
4936+       unsigned int quiet_nan:1;
4937+       unsigned int mantissa0:30;
4938+       unsigned int mantissa1:32;
4939+#endif
4940+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4941+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
4942+       unsigned int exponent:15;
4943+       unsigned int negative:1;
4944+       unsigned int empty:16;
4945+       unsigned int mantissa0:30;
4946+       unsigned int quiet_nan:1;
4947+       unsigned int one:1;
4948+       unsigned int mantissa1:32;
4949+# else
4950+       unsigned int mantissa1:32;
4951+       unsigned int mantissa0:30;
4952+       unsigned int quiet_nan:1;
4953+       unsigned int one:1;
4954+       unsigned int exponent:15;
4955+       unsigned int negative:1;
4956+       unsigned int empty:16;
4957+# endif
4958+#endif
4959+      } ieee_nan;
4960+  };
4961+
4962+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
4963+
4964+#elif LDBL_MANT_DIG == 53
4965+
4966+union ieee854_long_double
4967+  {
4968+    long double d;
4969+
4970+    /* This is the IEEE 754 double-precision format.  */
4971+    struct
4972+      {
4973+#if    __BYTE_ORDER == __BIG_ENDIAN
4974+       unsigned int negative:1;
4975+       unsigned int exponent:11;
4976+       /* Together these comprise the mantissa.  */
4977+       unsigned int mantissa0:20;
4978+       unsigned int mantissa1:32;
4979+#endif                         /* Big endian.  */
4980+#if    __BYTE_ORDER == __LITTLE_ENDIAN
4981+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
4982+       unsigned int mantissa0:20;
4983+       unsigned int exponent:11;
4984+       unsigned int negative:1;
4985+       unsigned int mantissa1:32;
4986+# else
4987+       /* Together these comprise the mantissa.  */
4988+       unsigned int mantissa1:32;
4989+       unsigned int mantissa0:20;
4990+       unsigned int exponent:11;
4991+       unsigned int negative:1;
4992+# endif
4993+#endif                         /* Little endian.  */
4994+      } ieee;
4995+
4996+    /* This format makes it easier to see if a NaN is a signalling NaN.  */
4997+    struct
4998+      {
4999+#if    __BYTE_ORDER == __BIG_ENDIAN
5000+       unsigned int negative:1;
5001+       unsigned int exponent:11;
5002+       unsigned int quiet_nan:1;
5003+       /* Together these comprise the mantissa.  */
5004+       unsigned int mantissa0:19;
5005+       unsigned int mantissa1:32;
5006+#else
5007+# if   __FLOAT_WORD_ORDER == __BIG_ENDIAN
5008+       unsigned int mantissa0:19;
5009+       unsigned int quiet_nan:1;
5010+       unsigned int exponent:11;
5011+       unsigned int negative:1;
5012+       unsigned int mantissa1:32;
5013+# else
5014+       /* Together these comprise the mantissa.  */
5015+       unsigned int mantissa1:32;
5016+       unsigned int mantissa0:19;
5017+       unsigned int quiet_nan:1;
5018+       unsigned int exponent:11;
5019+       unsigned int negative:1;
5020+# endif
5021+#endif
5022+      } ieee_nan;
5023+  };
5024+
5025+#define IEEE854_LONG_DOUBLE_BIAS       0x3ff /* Added to exponent.  */
5026+
5027+#endif /* LDBL_MANT_DIG == 53 */
5028+
5029+__END_DECLS
5030+
5031+#endif /* ieee754.h */
5032diff -ruN glibc-2.19/sysdeps/riscv/Implies glibc-2.19-riscv/sysdeps/riscv/Implies
5033--- glibc-2.19/sysdeps/riscv/Implies    1969-12-31 16:00:00.000000000 -0800
5034+++ glibc-2.19-riscv/sysdeps/riscv/Implies      2014-12-09 16:55:03.152727766 -0800
5035@@ -0,0 +1,5 @@
5036+ieee754/flt-32
5037+ieee754/dbl-64
5038+
5039+# This needs to change to support rv32
5040+riscv/rv64
5041diff -ruN glibc-2.19/sysdeps/riscv/init-first.c glibc-2.19-riscv/sysdeps/riscv/init-first.c
5042--- glibc-2.19/sysdeps/riscv/init-first.c       1969-12-31 16:00:00.000000000 -0800
5043+++ glibc-2.19-riscv/sysdeps/riscv/init-first.c 2014-12-09 16:55:03.164727835 -0800
5044@@ -0,0 +1,66 @@
5045+/* Initialization code run first thing by the ELF startup code.  For mips/Unix.
5046+   Copyright (C) 1996, 1997, 2010 Free Software Foundation, Inc.
5047+   This file is part of the GNU C Library.
5048+
5049+   The GNU C Library is free software; you can redistribute it and/or
5050+   modify it under the terms of the GNU Lesser General Public
5051+   License as published by the Free Software Foundation; either
5052+   version 2.1 of the License, or (at your option) any later version.
5053+
5054+   The GNU C Library is distributed in the hope that it will be useful,
5055+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5056+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5057+   Lesser General Public License for more details.
5058+
5059+   You should have received a copy of the GNU Lesser General Public
5060+   License along with the GNU C Library; if not, write to the Free
5061+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5062+   02111-1307 USA.  */
5063+
5064+#include <unistd.h>
5065+
5066+extern void __libc_init (int, char **, char **);
5067+extern void __libc_global_ctors (void);
5068+
5069+
5070+static void
5071+init (int *data)
5072+{
5073+  int argc = *data;
5074+  char **argv = (void *) (data + 1);
5075+  char **envp = &argv[argc + 1];
5076+
5077+  __environ = envp;
5078+  __libc_init (argc, argv, envp);
5079+}
5080+
5081+#ifdef SHARED
5082+/* This function is called to initialize the shared C library.
5083+   It is called just before the user _start code from mips/elf/start.S,
5084+   with the stack set up as that code gets it.  */
5085+
5086+/* NOTE!  The linker notices the magical name `_init' and sets the DT_INIT
5087+   pointer in the dynamic section based solely on that.  It is convention
5088+   for this function to be in the `.init' section, but the symbol name is
5089+   the only thing that really matters!!  */
5090+/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/
5091+
5092+void
5093+_init (int argc, ...)
5094+{
5095+  init (&argc);
5096+
5097+#ifndef NO_CTORS_DTORS_SECTIONS
5098+  __libc_global_ctors ();
5099+#endif
5100+}
5101+#endif
5102+
5103+
5104+void
5105+__libc_init_first (int argc __attribute__ ((unused)), ...)
5106+{
5107+#ifndef SHARED
5108+  init (&argc);
5109+#endif
5110+}
5111diff -ruN glibc-2.19/sysdeps/riscv/jmpbuf-unwind.h glibc-2.19-riscv/sysdeps/riscv/jmpbuf-unwind.h
5112--- glibc-2.19/sysdeps/riscv/jmpbuf-unwind.h    1969-12-31 16:00:00.000000000 -0800
5113+++ glibc-2.19-riscv/sysdeps/riscv/jmpbuf-unwind.h      2014-12-09 16:55:03.164727835 -0800
5114@@ -0,0 +1,46 @@
5115+/* Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
5116+   This file is part of the GNU C Library.
5117+
5118+   The GNU C Library is free software; you can redistribute it and/or
5119+   modify it under the terms of the GNU Lesser General Public
5120+   License as published by the Free Software Foundation; either
5121+   version 2.1 of the License, or (at your option) any later version.
5122+
5123+   The GNU C Library is distributed in the hope that it will be useful,
5124+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5125+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5126+   Lesser General Public License for more details.
5127+
5128+   You should have received a copy of the GNU Lesser General Public
5129+   License along with the GNU C Library; if not, write to the Free
5130+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5131+   02111-1307 USA.  */
5132+
5133+#include <setjmp.h>
5134+#include <stdint.h>
5135+#include <unwind.h>
5136+#include <sysdep.h>
5137+
5138+/* Test if longjmp to JMPBUF would unwind the frame
5139+   containing a local variable at ADDRESS.  */
5140+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle)             \
5141+  ((void *) (address) < (void *) demangle ((jmpbuf)[0].__sp))
5142+
5143+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
5144+  _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
5145+
5146+static inline uintptr_t __attribute__ ((unused))
5147+_jmpbuf_sp (__jmp_buf regs)
5148+{
5149+  uintptr_t sp = regs[0].__sp;
5150+#ifdef PTR_DEMANGLE
5151+  PTR_DEMANGLE (sp);
5152+#endif
5153+  return sp;
5154+}
5155+
5156+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
5157+  ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
5158+
5159+/* We use the normal longjmp for unwinding.  */
5160+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
5161diff -ruN glibc-2.19/sysdeps/riscv/ldsodefs.h glibc-2.19-riscv/sysdeps/riscv/ldsodefs.h
5162--- glibc-2.19/sysdeps/riscv/ldsodefs.h 1969-12-31 16:00:00.000000000 -0800
5163+++ glibc-2.19-riscv/sysdeps/riscv/ldsodefs.h   2014-12-09 16:55:03.164727835 -0800
5164@@ -0,0 +1,150 @@
5165+/* Run-time dynamic linker data structures for loaded ELF shared objects.
5166+   Copyright (C) 2000, 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
5167+   This file is part of the GNU C Library.
5168+
5169+   The GNU C Library is free software; you can redistribute it and/or
5170+   modify it under the terms of the GNU Lesser General Public
5171+   License as published by the Free Software Foundation; either
5172+   version 2.1 of the License, or (at your option) any later version.
5173+
5174+   The GNU C Library is distributed in the hope that it will be useful,
5175+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5176+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5177+   Lesser General Public License for more details.
5178+
5179+   You should have received a copy of the GNU Lesser General Public
5180+   License along with the GNU C Library; if not, write to the Free
5181+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5182+   02111-1307 USA.  */
5183+
5184+#ifndef _MIPS_LDSODEFS_H
5185+#define _MIPS_LDSODEFS_H 1
5186+
5187+#include <elf.h>
5188+
5189+struct La_mips_32_regs;
5190+struct La_mips_32_retval;
5191+struct La_mips_64_regs;
5192+struct La_mips_64_retval;
5193+
5194+#define ARCH_PLTENTER_MEMBERS                                              \
5195+    Elf32_Addr (*mips_o32_gnu_pltenter) (Elf32_Sym *, unsigned int,        \
5196+                                        uintptr_t *, uintptr_t *,          \
5197+                                        const struct La_mips_32_regs *,    \
5198+                                        unsigned int *, const char *name,  \
5199+                                        long int *framesizep);             \
5200+    Elf32_Addr (*mips_n32_gnu_pltenter) (Elf32_Sym *, unsigned int,        \
5201+                                        uintptr_t *, uintptr_t *,          \
5202+                                        const struct La_mips_64_regs *,    \
5203+                                        unsigned int *, const char *name,  \
5204+                                        long int *framesizep);             \
5205+    Elf64_Addr (*mips_n64_gnu_pltenter) (Elf64_Sym *, unsigned int,        \
5206+                                        uintptr_t *, uintptr_t *,          \
5207+                                        const struct La_mips_64_regs *,    \
5208+                                        unsigned int *, const char *name,  \
5209+                                        long int *framesizep);
5210+
5211+#define ARCH_PLTEXIT_MEMBERS                                               \
5212+    unsigned int (*mips_o32_gnu_pltexit) (Elf32_Sym *, unsigned int,       \
5213+                                         uintptr_t *, uintptr_t *,         \
5214+                                         const struct La_mips_32_regs *,   \
5215+                                         struct La_mips_32_retval *,       \
5216+                                         const char *);                    \
5217+    unsigned int (*mips_n32_gnu_pltexit) (Elf32_Sym *, unsigned int,       \
5218+                                         uintptr_t *, uintptr_t *,         \
5219+                                         const struct La_mips_64_regs *,   \
5220+                                         struct La_mips_64_retval *,       \
5221+                                         const char *);                    \
5222+    unsigned int (*mips_n64_gnu_pltexit) (Elf64_Sym *, unsigned int,       \
5223+                                         uintptr_t *, uintptr_t *,         \
5224+                                         const struct La_mips_64_regs *,   \
5225+                                         struct La_mips_64_retval *,       \
5226+                                         const char *);
5227+
5228+/* The MIPS ABI specifies that the dynamic section has to be read-only.  */
5229+
5230+#define DL_RO_DYN_SECTION 1
5231+
5232+#include_next <ldsodefs.h>
5233+
5234+/* The 64-bit MIPS ELF ABI uses an unusual reloc format.  Each
5235+   relocation entry specifies up to three actual relocations, all at
5236+   the same address.  The first relocation which required a symbol
5237+   uses the symbol in the r_sym field.  The second relocation which
5238+   requires a symbol uses the symbol in the r_ssym field.  If all
5239+   three relocations require a symbol, the third one uses a zero
5240+   value.
5241+
5242+   We define these structures in internal headers because we're not
5243+   sure we want to make them part of the ABI yet.  Eventually, some of
5244+   this may move into elf/elf.h.  */
5245+
5246+/* An entry in a 64 bit SHT_REL section.  */
5247+
5248+typedef struct
5249+{
5250+  Elf32_Word    r_sym;         /* Symbol index */
5251+  unsigned char r_ssym;                /* Special symbol for 2nd relocation */
5252+  unsigned char r_type3;       /* 3rd relocation type */
5253+  unsigned char r_type2;       /* 2nd relocation type */
5254+  unsigned char r_type1;       /* 1st relocation type */
5255+} _Elf64_Mips_R_Info;
5256+
5257+typedef union
5258+{
5259+  Elf64_Xword  r_info_number;
5260+  _Elf64_Mips_R_Info r_info_fields;
5261+} _Elf64_Mips_R_Info_union;
5262+
5263+typedef struct
5264+{
5265+  Elf64_Addr   r_offset;               /* Address */
5266+  _Elf64_Mips_R_Info_union r_info;     /* Relocation type and symbol index */
5267+} Elf64_Mips_Rel;
5268+
5269+typedef struct
5270+{
5271+  Elf64_Addr   r_offset;               /* Address */
5272+  _Elf64_Mips_R_Info_union r_info;     /* Relocation type and symbol index */
5273+  Elf64_Sxword r_addend;               /* Addend */
5274+} Elf64_Mips_Rela;
5275+
5276+#define ELF64_MIPS_R_SYM(i) \
5277+  ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
5278+#define ELF64_MIPS_R_TYPE(i) \
5279+  (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \
5280+   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
5281+                  ).r_info_fields.r_type2 << 8) \
5282+   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
5283+                  ).r_info_fields.r_type3 << 16) \
5284+   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
5285+                  ).r_info_fields.r_ssym << 24))
5286+#define ELF64_MIPS_R_INFO(sym, type) \
5287+  (__extension__ (_Elf64_Mips_R_Info_union) \
5288+   (__extension__ (_Elf64_Mips_R_Info) \
5289+   { (sym), ELF64_MIPS_R_SSYM (type), \
5290+       ELF64_MIPS_R_TYPE3 (type), \
5291+       ELF64_MIPS_R_TYPE2 (type), \
5292+       ELF64_MIPS_R_TYPE1 (type) \
5293+   }).r_info_number)
5294+/* These macros decompose the value returned by ELF64_MIPS_R_TYPE, and
5295+   compose it back into a value that it can be used as an argument to
5296+   ELF64_MIPS_R_INFO.  */
5297+#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
5298+#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
5299+#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
5300+#define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff)
5301+#define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \
5302+  ((type1) \
5303+   | ((Elf32_Word)(type2) << 8) \
5304+   | ((Elf32_Word)(type3) << 16) \
5305+   | ((Elf32_Word)(ssym) << 24))
5306+
5307+#undef ELF64_R_SYM
5308+#define ELF64_R_SYM(i) ELF64_MIPS_R_SYM (i)
5309+#undef ELF64_R_TYPE
5310+#define ELF64_R_TYPE(i) ELF64_MIPS_R_TYPE (i)
5311+#undef ELF64_R_INFO
5312+#define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO ((sym), (type))
5313+
5314+#endif
5315diff -ruN glibc-2.19/sysdeps/riscv/libc-tls.c glibc-2.19-riscv/sysdeps/riscv/libc-tls.c
5316--- glibc-2.19/sysdeps/riscv/libc-tls.c 1969-12-31 16:00:00.000000000 -0800
5317+++ glibc-2.19-riscv/sysdeps/riscv/libc-tls.c   2014-12-09 16:55:03.164727835 -0800
5318@@ -0,0 +1,37 @@
5319+/* Thread-local storage handling in the ELF dynamic linker.  MIPS version.
5320+   Copyright (C) 2005 Free Software Foundation, Inc.
5321+   This file is part of the GNU C Library.
5322+
5323+   The GNU C Library is free software; you can redistribute it and/or
5324+   modify it under the terms of the GNU Lesser General Public
5325+   License as published by the Free Software Foundation; either
5326+   version 2.1 of the License, or (at your option) any later version.
5327+
5328+   The GNU C Library is distributed in the hope that it will be useful,
5329+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5330+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5331+   Lesser General Public License for more details.
5332+
5333+   You should have received a copy of the GNU Lesser General Public
5334+   License along with the GNU C Library; if not, write to the Free
5335+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5336+   02111-1307 USA.  */
5337+
5338+#include <csu/libc-tls.c>
5339+#include <dl-tls.h>
5340+
5341+#if USE_TLS
5342+
5343+/* On MIPS, linker optimizations are not required, so __tls_get_addr
5344+   can be called even in statically linked binaries.  In this case module
5345+   must be always 1 and PT_TLS segment exist in the binary, otherwise it
5346+   would not link.  */
5347+
5348+void *
5349+__tls_get_addr (tls_index *ti)
5350+{
5351+  dtv_t *dtv = THREAD_DTV ();
5352+  return (char *) dtv[1].pointer.val + GET_ADDR_OFFSET;
5353+}
5354+
5355+#endif
5356diff -ruN glibc-2.19/sysdeps/riscv/__longjmp.S glibc-2.19-riscv/sysdeps/riscv/__longjmp.S
5357--- glibc-2.19/sysdeps/riscv/__longjmp.S        1969-12-31 16:00:00.000000000 -0800
5358+++ glibc-2.19-riscv/sysdeps/riscv/__longjmp.S  2014-12-09 16:55:03.152727766 -0800
5359@@ -0,0 +1,67 @@
5360+/* Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004
5361+       Free Software Foundation, Inc.
5362+   This file is part of the GNU C Library.
5363+
5364+   The GNU C Library is free software; you can redistribute it and/or
5365+   modify it under the terms of the GNU Lesser General Public
5366+   License as published by the Free Software Foundation; either
5367+   version 2.1 of the License, or (at your option) any later version.
5368+
5369+   The GNU C Library is distributed in the hope that it will be useful,
5370+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5371+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5372+   Lesser General Public License for more details.
5373+
5374+   You should have received a copy of the GNU Lesser General Public
5375+   License along with the GNU C Library; if not, write to the Free
5376+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5377+   02111-1307 USA.  */
5378+
5379+#include <sysdep.h>
5380+#include <sys/asm.h>
5381+
5382+ENTRY (__longjmp)
5383+       REG_L ra,  0*SZREG(a0)
5384+       REG_L s0,  1*SZREG(a0)
5385+       REG_L s1,  2*SZREG(a0)
5386+       REG_L s2,  3*SZREG(a0)
5387+       REG_L s3,  4*SZREG(a0)
5388+       REG_L s4,  5*SZREG(a0)
5389+       REG_L s5,  6*SZREG(a0)
5390+       REG_L s6,  7*SZREG(a0)
5391+       REG_L s7,  8*SZREG(a0)
5392+       REG_L s8,  9*SZREG(a0)
5393+       REG_L s9, 10*SZREG(a0)
5394+       REG_L s10,11*SZREG(a0)
5395+       REG_L s11,12*SZREG(a0)
5396+       REG_L sp, 13*SZREG(a0)
5397+       REG_L tp, 14*SZREG(a0)
5398+
5399+#ifdef __riscv_hard_float
5400+       REG_L a3, 15*SZREG(a0)
5401+
5402+       fld  fs0, 16*SZREG+ 0*8(a0)
5403+       fld  fs1, 16*SZREG+ 1*8(a0)
5404+       fld  fs2, 16*SZREG+ 2*8(a0)
5405+       fld  fs3, 16*SZREG+ 3*8(a0)
5406+       fld  fs4, 16*SZREG+ 4*8(a0)
5407+       fld  fs5, 16*SZREG+ 5*8(a0)
5408+       fld  fs6, 16*SZREG+ 6*8(a0)
5409+       fld  fs7, 16*SZREG+ 7*8(a0)
5410+       fld  fs8, 16*SZREG+ 8*8(a0)
5411+       fld  fs9, 16*SZREG+ 9*8(a0)
5412+       fld  fs10,16*SZREG+10*8(a0)
5413+       fld  fs11,16*SZREG+11*8(a0)
5414+       fld  fs12,16*SZREG+12*8(a0)
5415+       fld  fs13,16*SZREG+13*8(a0)
5416+       fld  fs14,16*SZREG+14*8(a0)
5417+       fld  fs15,16*SZREG+15*8(a0)
5418+
5419+       mtfsr a3
5420+#endif
5421+
5422+       sltu a3, a1, 1    # a3 = (a1 == 0)
5423+       add  v0, a3, a1   # v0 = (a1 == 0 ? 1 : a1)
5424+       ret
5425+
5426+END(__longjmp)
5427diff -ruN glibc-2.19/sysdeps/riscv/Makefile glibc-2.19-riscv/sysdeps/riscv/Makefile
5428--- glibc-2.19/sysdeps/riscv/Makefile   1969-12-31 16:00:00.000000000 -0800
5429+++ glibc-2.19-riscv/sysdeps/riscv/Makefile     2014-12-09 16:55:03.152727766 -0800
5430@@ -0,0 +1,9 @@
5431+ifeq ($(subdir),misc)
5432+sysdep_headers += sys/asm.h sgidefs.h
5433+endif
5434+
5435+ifeq ($(subdir),rt)
5436+librt-sysdep_routines += rt-sysdep
5437+endif
5438+
5439+ASFLAGS-.os += $(pic-ccflag)
5440diff -ruN glibc-2.19/sysdeps/riscv/memcpy.c glibc-2.19-riscv/sysdeps/riscv/memcpy.c
5441--- glibc-2.19/sysdeps/riscv/memcpy.c   1969-12-31 16:00:00.000000000 -0800
5442+++ glibc-2.19-riscv/sysdeps/riscv/memcpy.c     2014-12-09 16:55:03.164727835 -0800
5443@@ -0,0 +1,52 @@
5444+#include <string.h>
5445+
5446+#undef memcpy
5447+#undef __memcpy_g
5448+
5449+void* __memcpy_g(void* dst, const void* src, size_t n)
5450+{
5451+  void* dst0 = dst;
5452+  void* end = dst + n;
5453+
5454+  /* are dst and src word-aligned? */
5455+  if ((((long)dst | (long)src) & (sizeof(long)-1)) == 0)
5456+  {
5457+    /* copy 10 words at a time */
5458+    for ( ; dst <= end - 10*sizeof(long); dst += 10*sizeof(long), src += 10*sizeof(long))
5459+    {
5460+      long t0 = *(const long*)(src+0*sizeof(long));
5461+      long t1 = *(const long*)(src+1*sizeof(long));
5462+      long t2 = *(const long*)(src+2*sizeof(long));
5463+      long t3 = *(const long*)(src+3*sizeof(long));
5464+      long t4 = *(const long*)(src+4*sizeof(long));
5465+      long t5 = *(const long*)(src+5*sizeof(long));
5466+      long t6 = *(const long*)(src+6*sizeof(long));
5467+      long t7 = *(const long*)(src+7*sizeof(long));
5468+      long t8 = *(const long*)(src+8*sizeof(long));
5469+      long t9 = *(const long*)(src+9*sizeof(long));
5470+      *(long*)(dst+0*sizeof(long)) = t0;
5471+      *(long*)(dst+1*sizeof(long)) = t1;
5472+      *(long*)(dst+2*sizeof(long)) = t2;
5473+      *(long*)(dst+3*sizeof(long)) = t3;
5474+      *(long*)(dst+4*sizeof(long)) = t4;
5475+      *(long*)(dst+5*sizeof(long)) = t5;
5476+      *(long*)(dst+6*sizeof(long)) = t6;
5477+      *(long*)(dst+7*sizeof(long)) = t7;
5478+      *(long*)(dst+8*sizeof(long)) = t8;
5479+      *(long*)(dst+9*sizeof(long)) = t9;
5480+    }
5481+
5482+    /* copy a word at a time */
5483+    for ( ; dst <= end - sizeof(long); dst += sizeof(long), src += sizeof(long))
5484+      *(long*)dst = *(const long*)src;
5485+  }
5486+
5487+  /* copy a byte at a time */
5488+  for ( ; dst < end; dst++, src++)
5489+    *(char*)dst = *(const char*)src;
5490+
5491+  return dst0;
5492+}
5493+libc_hidden_def (__memcpy_g)
5494+strong_alias (__memcpy_g, memcpy)
5495+libc_hidden_builtin_def (memcpy)
5496diff -ruN glibc-2.19/sysdeps/riscv/memset.c glibc-2.19-riscv/sysdeps/riscv/memset.c
5497--- glibc-2.19/sysdeps/riscv/memset.c   1969-12-31 16:00:00.000000000 -0800
5498+++ glibc-2.19-riscv/sysdeps/riscv/memset.c     2014-12-09 16:55:03.164727835 -0800
5499@@ -0,0 +1,49 @@
5500+typedef unsigned long size_t;
5501+//#include <string.h>
5502+
5503+void* memset(void* dst, int val, size_t n)
5504+{
5505+  void* dst0 = dst;
5506+  void* end = dst + n;
5507+  unsigned char v = val;
5508+
5509+  /* is dst word-aligned? */
5510+  if (((long)dst & (sizeof(long)-1)) == 0)
5511+  {
5512+    long lval = v;
5513+    lval |= lval << 8;
5514+    lval |= lval << 16;
5515+    #ifdef __riscv64
5516+    lval |= lval << 32;
5517+    #elif !defined(__riscv32)
5518+    # error
5519+    #endif
5520+
5521+    /* set 10 words at a time */
5522+    for ( ; dst <= end - 10*sizeof(long); dst += 10*sizeof(long))
5523+    {
5524+      *(long*)(dst+0*sizeof(long)) = lval;
5525+      *(long*)(dst+1*sizeof(long)) = lval;
5526+      *(long*)(dst+2*sizeof(long)) = lval;
5527+      *(long*)(dst+3*sizeof(long)) = lval;
5528+      *(long*)(dst+4*sizeof(long)) = lval;
5529+      *(long*)(dst+5*sizeof(long)) = lval;
5530+      *(long*)(dst+6*sizeof(long)) = lval;
5531+      *(long*)(dst+7*sizeof(long)) = lval;
5532+      *(long*)(dst+8*sizeof(long)) = lval;
5533+      *(long*)(dst+9*sizeof(long)) = lval;
5534+    }
5535+
5536+    /* set a word at a time */
5537+    for ( ; dst <= end - sizeof(long); dst += sizeof(long))
5538+      *(long*)dst = lval;
5539+  }
5540+
5541+  /* set a byte at a time */
5542+  for ( ; dst < end; dst++)
5543+    *(unsigned char*)dst = v;
5544+
5545+  return dst0;
5546+}
5547+
5548+weak_alias (memset, __GI_memset)
5549diff -ruN glibc-2.19/sysdeps/riscv/memusage.h glibc-2.19-riscv/sysdeps/riscv/memusage.h
5550--- glibc-2.19/sysdeps/riscv/memusage.h 1969-12-31 16:00:00.000000000 -0800
5551+++ glibc-2.19-riscv/sysdeps/riscv/memusage.h   2014-12-09 16:55:03.164727835 -0800
5552@@ -0,0 +1,21 @@
5553+/* Copyright (C) 2000 Free Software Foundation, Inc.
5554+   This file is part of the GNU C Library.
5555+
5556+   The GNU C Library is free software; you can redistribute it and/or
5557+   modify it under the terms of the GNU Lesser General Public
5558+   License as published by the Free Software Foundation; either
5559+   version 2.1 of the License, or (at your option) any later version.
5560+
5561+   The GNU C Library is distributed in the hope that it will be useful,
5562+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5563+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5564+   Lesser General Public License for more details.
5565+
5566+   You should have received a copy of the GNU Lesser General Public
5567+   License along with the GNU C Library; if not, write to the Free
5568+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5569+   02111-1307 USA.  */
5570+
5571+#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
5572+
5573+#include <sysdeps/generic/memusage.h>
5574diff -ruN glibc-2.19/sysdeps/riscv/nptl/Makefile glibc-2.19-riscv/sysdeps/riscv/nptl/Makefile
5575--- glibc-2.19/sysdeps/riscv/nptl/Makefile      1969-12-31 16:00:00.000000000 -0800
5576+++ glibc-2.19-riscv/sysdeps/riscv/nptl/Makefile        2014-12-09 16:55:03.164727835 -0800
5577@@ -0,0 +1,25 @@
5578+# Copyright (C) 2005 Free Software Foundation, Inc.
5579+# This file is part of the GNU C Library.
5580+#
5581+# The GNU C Library is free software; you can redistribute it and/or
5582+# modify it under the terms of the GNU Lesser General Public
5583+# License as published by the Free Software Foundation; either
5584+# version 2.1 of the License, or (at your option) any later version.
5585+#
5586+# The GNU C Library is distributed in the hope that it will be useful,
5587+# but WITHOUT ANY WARRANTY; without even the implied warranty of
5588+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5589+# Lesser General Public License for more details.
5590+#
5591+# You should have received a copy of the GNU Lesser General Public
5592+# License along with the GNU C Library; if not, write to the Free
5593+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5594+# 02111-1307 USA.
5595+
5596+ifeq ($(subdir),csu)
5597+gen-as-const-headers += tcb-offsets.sym
5598+endif
5599+
5600+ifeq ($(subdir),nptl)
5601+libpthread-sysdep_routines += nptl-sysdep
5602+endif
5603diff -ruN glibc-2.19/sysdeps/riscv/nptl/nptl-sysdep.c glibc-2.19-riscv/sysdeps/riscv/nptl/nptl-sysdep.c
5604--- glibc-2.19/sysdeps/riscv/nptl/nptl-sysdep.c 1969-12-31 16:00:00.000000000 -0800
5605+++ glibc-2.19-riscv/sysdeps/riscv/nptl/nptl-sysdep.c   2014-12-09 16:55:03.164727835 -0800
5606@@ -0,0 +1,2 @@
5607+/* Pull in __syscall_error.  */
5608+#include <sysdep.c>
5609diff -ruN glibc-2.19/sysdeps/riscv/nptl/pthreaddef.h glibc-2.19-riscv/sysdeps/riscv/nptl/pthreaddef.h
5610--- glibc-2.19/sysdeps/riscv/nptl/pthreaddef.h  1969-12-31 16:00:00.000000000 -0800
5611+++ glibc-2.19-riscv/sysdeps/riscv/nptl/pthreaddef.h    2014-12-09 16:55:03.168727857 -0800
5612@@ -0,0 +1,39 @@
5613+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
5614+   This file is part of the GNU C Library.
5615+
5616+   The GNU C Library is free software; you can redistribute it and/or
5617+   modify it under the terms of the GNU Lesser General Public
5618+   License as published by the Free Software Foundation; either
5619+   version 2.1 of the License, or (at your option) any later version.
5620+
5621+   The GNU C Library is distributed in the hope that it will be useful,
5622+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5623+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5624+   Lesser General Public License for more details.
5625+
5626+   You should have received a copy of the GNU Lesser General Public
5627+   License along with the GNU C Library; if not, write to the Free
5628+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5629+   02111-1307 USA.  */
5630+
5631+/* Default stack size.  */
5632+#define ARCH_STACK_DEFAULT_SIZE        (2 * 1024 * 1024)
5633+
5634+/* Required stack pointer alignment at beginning.  */
5635+#define STACK_ALIGN            16
5636+
5637+/* Minimal stack size after allocating thread descriptor and guard size.  */
5638+#define MINIMAL_REST_STACK     2048
5639+
5640+/* Alignment requirement for TCB.  */
5641+#define TCB_ALIGNMENT          16
5642+
5643+
5644+/* Location of current stack frame.  */
5645+#define CURRENT_STACK_FRAME    __builtin_frame_address (0)
5646+
5647+
5648+/* XXX Until we have a better place keep the definitions here.  */
5649+
5650+#define __exit_thread_inline(val) \
5651+  INLINE_SYSCALL (exit, 1, (val))
5652diff -ruN glibc-2.19/sysdeps/riscv/nptl/pthread_spin_lock.c glibc-2.19-riscv/sysdeps/riscv/nptl/pthread_spin_lock.c
5653--- glibc-2.19/sysdeps/riscv/nptl/pthread_spin_lock.c   1969-12-31 16:00:00.000000000 -0800
5654+++ glibc-2.19-riscv/sysdeps/riscv/nptl/pthread_spin_lock.c     2014-12-09 16:55:03.164727835 -0800
5655@@ -0,0 +1,32 @@
5656+/* Copyright (C) 2005 Free Software Foundation, Inc.
5657+   This file is part of the GNU C Library.
5658+
5659+   The GNU C Library is free software; you can redistribute it and/or
5660+   modify it under the terms of the GNU Lesser General Public
5661+   License as published by the Free Software Foundation; either
5662+   version 2.1 of the License, or (at your option) any later version.
5663+
5664+   The GNU C Library is distributed in the hope that it will be useful,
5665+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5666+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5667+   Lesser General Public License for more details.
5668+
5669+   You should have received a copy of the GNU Lesser General Public
5670+   License along with the GNU C Library; if not, write to the Free
5671+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5672+   02111-1307 USA.  */
5673+
5674+#include <errno.h>
5675+
5676+int pthread_spin_lock(pthread_spinlock_t* lock)
5677+{
5678+  while (__sync_fetch_and_or(lock, 1) != 0)
5679+  {
5680+    while (*lock)
5681+      ;
5682+  }
5683+
5684+  __sync_synchronize();
5685+
5686+  return 0;
5687+}
5688diff -ruN glibc-2.19/sysdeps/riscv/nptl/pthread_spin_trylock.c glibc-2.19-riscv/sysdeps/riscv/nptl/pthread_spin_trylock.c
5689--- glibc-2.19/sysdeps/riscv/nptl/pthread_spin_trylock.c        1969-12-31 16:00:00.000000000 -0800
5690+++ glibc-2.19-riscv/sysdeps/riscv/nptl/pthread_spin_trylock.c  2014-12-09 16:55:03.164727835 -0800
5691@@ -0,0 +1,33 @@
5692+/* Copyright (C) 2005 Free Software Foundation, Inc.
5693+   This file is part of the GNU C Library.
5694+
5695+   The GNU C Library is free software; you can redistribute it and/or
5696+   modify it under the terms of the GNU Lesser General Public
5697+   License as published by the Free Software Foundation; either
5698+   version 2.1 of the License, or (at your option) any later version.
5699+
5700+   The GNU C Library is distributed in the hope that it will be useful,
5701+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5702+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5703+   Lesser General Public License for more details.
5704+
5705+   You should have received a copy of the GNU Lesser General Public
5706+   License along with the GNU C Library; if not, write to the Free
5707+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5708+   02111-1307 USA.  */
5709+
5710+#include <errno.h>
5711+
5712+int pthread_spin_trylock(pthread_spinlock_t* lock)
5713+{
5714+  int ret;
5715+
5716+  if (__sync_fetch_and_or(lock, 1) == 0)
5717+    ret = 0;
5718+  else
5719+    ret = EBUSY;
5720+
5721+  __sync_synchronize();
5722+
5723+  return ret;
5724+}
5725diff -ruN glibc-2.19/sysdeps/riscv/nptl/tcb-offsets.sym glibc-2.19-riscv/sysdeps/riscv/nptl/tcb-offsets.sym
5726--- glibc-2.19/sysdeps/riscv/nptl/tcb-offsets.sym       1969-12-31 16:00:00.000000000 -0800
5727+++ glibc-2.19-riscv/sysdeps/riscv/nptl/tcb-offsets.sym 2014-12-09 16:55:03.168727857 -0800
5728@@ -0,0 +1,11 @@
5729+#include <sysdep.h>
5730+#include <tls.h>
5731+
5732+--
5733+
5734+-- Abuse tls.h macros to derive offsets relative to the thread register.
5735+#define thread_offsetof(mem)   (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
5736+
5737+MULTIPLE_THREADS_OFFSET                thread_offsetof (header.multiple_threads)
5738+PID_OFFSET                     thread_offsetof (pid)
5739+TID_OFFSET                     thread_offsetof (tid)
5740diff -ruN glibc-2.19/sysdeps/riscv/nptl/tls.h glibc-2.19-riscv/sysdeps/riscv/nptl/tls.h
5741--- glibc-2.19/sysdeps/riscv/nptl/tls.h 1969-12-31 16:00:00.000000000 -0800
5742+++ glibc-2.19-riscv/sysdeps/riscv/nptl/tls.h   2014-12-09 16:55:03.168727857 -0800
5743@@ -0,0 +1,165 @@
5744+/* Definition for thread-local data handling.  NPTL/MIPS version.
5745+   Copyright (C) 2005, 2007 Free Software Foundation, Inc.
5746+   This file is part of the GNU C Library.
5747+
5748+   The GNU C Library is free software; you can redistribute it and/or
5749+   modify it under the terms of the GNU Lesser General Public
5750+   License as published by the Free Software Foundation; either
5751+   version 2.1 of the License, or (at your option) any later version.
5752+
5753+   The GNU C Library is distributed in the hope that it will be useful,
5754+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5755+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5756+   Lesser General Public License for more details.
5757+
5758+   You should have received a copy of the GNU Lesser General Public
5759+   License along with the GNU C Library; if not, write to the Free
5760+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5761+   02111-1307 USA.  */
5762+
5763+#ifndef _TLS_H
5764+#define _TLS_H 1
5765+
5766+#include <dl-sysdep.h>
5767+
5768+#ifndef __ASSEMBLER__
5769+# include <stdbool.h>
5770+# include <stddef.h>
5771+# include <stdint.h>
5772+
5773+/* Type for the dtv.  */
5774+typedef union dtv
5775+{
5776+  size_t counter;
5777+  struct
5778+  {
5779+    void *val;
5780+    bool is_static;
5781+  } pointer;
5782+} dtv_t;
5783+
5784+register void* __thread_self asm("tp");
5785+# define READ_THREAD_POINTER() ({ __thread_self; })
5786+
5787+#endif /* __ASSEMBLER__ */
5788+
5789+
5790+/* We require TLS support in the tools.  */
5791+#ifndef HAVE_TLS_SUPPORT
5792+# error "TLS support is required."
5793+#endif
5794+
5795+/* Signal that TLS support is available.  */
5796+#define USE_TLS        1
5797+
5798+#ifndef __ASSEMBLER__
5799+
5800+/* Get system call information.  */
5801+# include <sysdep.h>
5802+
5803+/* The TP points to the start of the thread blocks.  */
5804+# define TLS_DTV_AT_TP 1
5805+
5806+/* Get the thread descriptor definition.  */
5807+# include <nptl/descr.h>
5808+
5809+typedef struct
5810+{
5811+  dtv_t *dtv;
5812+  void *private;
5813+} tcbhead_t;
5814+
5815+/* This is the size of the initial TCB.  Because our TCB is before the thread
5816+   pointer, we don't need this.  */
5817+# define TLS_INIT_TCB_SIZE     0
5818+
5819+/* Alignment requirements for the initial TCB.  */
5820+# define TLS_INIT_TCB_ALIGN    __alignof__ (struct pthread)
5821+
5822+/* This is the size of the TCB.  Because our TCB is before the thread
5823+   pointer, we don't need this.  */
5824+# define TLS_TCB_SIZE          0
5825+
5826+/* Alignment requirements for the TCB.  */
5827+# define TLS_TCB_ALIGN         __alignof__ (struct pthread)
5828+
5829+/* This is the size we need before TCB - actually, it includes the TCB.  */
5830+# define TLS_PRE_TCB_SIZE \
5831+  (sizeof (struct pthread)                                                   \
5832+   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
5833+
5834+/* The thread pointer (in hardware register $29) points to the end of
5835+   the TCB + 0x7000, as for PowerPC.  The pthread_descr structure is
5836+   immediately in front of the TCB.  */
5837+# define TLS_TCB_OFFSET        0x7000
5838+
5839+/* Install the dtv pointer.  The pointer passed is to the element with
5840+   index -1 which contain the length.  */
5841+# define INSTALL_DTV(tcbp, dtvp) \
5842+  (((tcbhead_t *) (tcbp))[-1].dtv = (dtvp) + 1)
5843+
5844+/* Install new dtv for current thread.  */
5845+# define INSTALL_NEW_DTV(dtv) \
5846+  (THREAD_DTV() = (dtv))
5847+
5848+/* Return dtv of given thread descriptor.  */
5849+# define GET_DTV(tcbp) \
5850+  (((tcbhead_t *) (tcbp))[-1].dtv)
5851+
5852+/* Code to initially initialize the thread pointer. */
5853+# define TLS_INIT_TP(tcbp, secondcall) \
5854+  ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; NULL; })
5855+
5856+/* Return the address of the dtv for the current thread.  */
5857+# define THREAD_DTV() \
5858+  (((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))[-1].dtv)
5859+
5860+/* Return the thread descriptor for the current thread.  */
5861+# define THREAD_SELF \
5862+ ((struct pthread *) (READ_THREAD_POINTER ()                        \
5863+                     - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
5864+
5865+/* Magic for libthread_db to know how to do THREAD_SELF.  */
5866+# define DB_THREAD_SELF \
5867+  CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
5868+
5869+/* Access to data in the thread descriptor is easy.  */
5870+# define THREAD_GETMEM(descr, member) \
5871+  descr->member
5872+# define THREAD_GETMEM_NC(descr, member, idx) \
5873+  descr->member[idx]
5874+# define THREAD_SETMEM(descr, member, value) \
5875+  descr->member = (value)
5876+# define THREAD_SETMEM_NC(descr, member, idx, value) \
5877+  descr->member[idx] = (value)
5878+
5879+/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
5880+   different value to mean unset l_tls_offset.  */
5881+# define NO_TLS_OFFSET         -1
5882+
5883+/* Get and set the global scope generation counter in struct pthread.  */
5884+#define THREAD_GSCOPE_FLAG_UNUSED 0
5885+#define THREAD_GSCOPE_FLAG_USED   1
5886+#define THREAD_GSCOPE_FLAG_WAIT   2
5887+#define THREAD_GSCOPE_RESET_FLAG() \
5888+  do                                                                        \
5889+    { int __res                                                                     \
5890+       = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,             \
5891+                              THREAD_GSCOPE_FLAG_UNUSED);                   \
5892+      if (__res == THREAD_GSCOPE_FLAG_WAIT)                                 \
5893+       lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);   \
5894+    }                                                                       \
5895+  while (0)
5896+#define THREAD_GSCOPE_SET_FLAG() \
5897+  do                                                                        \
5898+    {                                                                       \
5899+      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;            \
5900+      atomic_write_barrier ();                                              \
5901+    }                                                                       \
5902+  while (0)
5903+#define THREAD_GSCOPE_WAIT() \
5904+  GL(dl_wait_lookup_done) ()
5905+
5906+#endif /* __ASSEMBLER__ */
5907+
5908+#endif /* tls.h */
5909diff -ruN glibc-2.19/sysdeps/riscv/preconfigure glibc-2.19-riscv/sysdeps/riscv/preconfigure
5910--- glibc-2.19/sysdeps/riscv/preconfigure       1969-12-31 16:00:00.000000000 -0800
5911+++ glibc-2.19-riscv/sysdeps/riscv/preconfigure 2014-12-09 16:55:03.168727857 -0800
5912@@ -0,0 +1,21 @@
5913+ccccase "$CC $CFLAGS $CPPFLAGS " in
5914+*" -m32 "*) mips_cc_abi=32 ;;
5915+*" -m64 "*) mips_cc_abi=64 ;;
5916+*) mips_cc_abi=default ;;
5917+esac
5918+case $config_os in
5919+*abi64*) mips_config_abi=64 ;;
5920+*abi32*) mips_config_abi=32 ;;
5921+*) mips_config_abi=$mips_cc_abi ;;
5922+esac
5923+case $mips_config_abi in
5924+default) machine=riscv/rv64 ;;
5925+32) machine=riscv/rv32 ;;
5926+esac
5927+machine=$machine/$config_machine
5928+if test $mips_config_abi != $mips_cc_abi; then
5929+  # This won't make it to config.make, but we want to
5930+  # set this in case configure tests depend on it.
5931+  CPPFLAGS="$CPPFLAGS -m$mips_config_abi"
5932+fi
5933+;;
5934diff -ruN glibc-2.19/sysdeps/riscv/rv32/Implies glibc-2.19-riscv/sysdeps/riscv/rv32/Implies
5935--- glibc-2.19/sysdeps/riscv/rv32/Implies       1969-12-31 16:00:00.000000000 -0800
5936+++ glibc-2.19-riscv/sysdeps/riscv/rv32/Implies 2014-12-09 16:55:03.168727857 -0800
5937@@ -0,0 +1,2 @@
5938+riscv
5939+wordsize-32
5940diff -ruN glibc-2.19/sysdeps/riscv/rv32/Makefile glibc-2.19-riscv/sysdeps/riscv/rv32/Makefile
5941--- glibc-2.19/sysdeps/riscv/rv32/Makefile      1969-12-31 16:00:00.000000000 -0800
5942+++ glibc-2.19-riscv/sysdeps/riscv/rv32/Makefile        2014-12-09 16:55:03.168727857 -0800
5943@@ -0,0 +1,3 @@
5944+ifeq ($(filter -m32,$(CC)),)
5945+CC += -m32
5946+endif
5947diff -ruN glibc-2.19/sysdeps/riscv/rv64/gmp-mparam.h glibc-2.19-riscv/sysdeps/riscv/rv64/gmp-mparam.h
5948--- glibc-2.19/sysdeps/riscv/rv64/gmp-mparam.h  1969-12-31 16:00:00.000000000 -0800
5949+++ glibc-2.19-riscv/sysdeps/riscv/rv64/gmp-mparam.h    2014-12-09 16:55:03.168727857 -0800
5950@@ -0,0 +1,31 @@
5951+/* gmp-mparam.h -- Compiler/machine parameter header file.
5952+
5953+Copyright (C) 1991, 1993, 1994, 2002, 2003 Free Software Foundation, Inc.
5954+
5955+This file is part of the GNU MP Library.
5956+
5957+The GNU MP Library is free software; you can redistribute it and/or modify
5958+it under the terms of the GNU Lesser General Public License as published by
5959+the Free Software Foundation; either version 2.1 of the License, or (at your
5960+option) any later version.
5961+
5962+The GNU MP Library is distributed in the hope that it will be useful, but
5963+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
5964+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
5965+License for more details.
5966+
5967+You should have received a copy of the GNU Lesser General Public License
5968+along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
5969+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
5970+
5971+#if defined __GMP_H__ && ! defined _LONG_LONG_LIMB
5972+#error "Included too late for _LONG_LONG_LIMB to take effect"
5973+#endif
5974+
5975+#define _LONG_LONG_LIMB
5976+#define BITS_PER_MP_LIMB 64
5977+#define BYTES_PER_MP_LIMB 8
5978+#define BITS_PER_LONGINT __WORDSIZE
5979+#define BITS_PER_INT 32
5980+#define BITS_PER_SHORTINT 16
5981+#define BITS_PER_CHAR 8
5982diff -ruN glibc-2.19/sysdeps/riscv/rv64/Implies glibc-2.19-riscv/sysdeps/riscv/rv64/Implies
5983--- glibc-2.19/sysdeps/riscv/rv64/Implies       1969-12-31 16:00:00.000000000 -0800
5984+++ glibc-2.19-riscv/sysdeps/riscv/rv64/Implies 2014-12-09 16:55:03.168727857 -0800
5985@@ -0,0 +1,6 @@
5986+ieee754/flt-32
5987+ieee754/dbl-64
5988+riscv/rv64/soft-fp
5989+riscv/rv64
5990+riscv
5991+wordsize-64
5992diff -ruN glibc-2.19/sysdeps/riscv/rv64/libm-test-ulps glibc-2.19-riscv/sysdeps/riscv/rv64/libm-test-ulps
5993--- glibc-2.19/sysdeps/riscv/rv64/libm-test-ulps        1969-12-31 16:00:00.000000000 -0800
5994+++ glibc-2.19-riscv/sysdeps/riscv/rv64/libm-test-ulps  2014-12-09 16:55:03.168727857 -0800
5995@@ -0,0 +1,1245 @@
5996+# Begin of automatic generation
5997+
5998+# atan2
5999+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
6000+ildouble: 1
6001+ldouble: 1
6002+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
6003+float: 1
6004+ifloat: 1
6005+ildouble: 1
6006+ldouble: 1
6007+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
6008+float: 1
6009+ifloat: 1
6010+ildouble: 1
6011+ldouble: 1
6012+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
6013+float: 1
6014+ifloat: 1
6015+ildouble: 1
6016+ldouble: 1
6017+
6018+# atanh
6019+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
6020+float: 1
6021+ifloat: 1
6022+
6023+# cacos
6024+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
6025+ildouble: 1
6026+ldouble: 1
6027+
6028+# cacosh
6029+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
6030+float: 1
6031+ifloat: 1
6032+ildouble: 1
6033+ldouble: 1
6034+
6035+# casin
6036+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
6037+double: 1
6038+float: 1
6039+idouble: 1
6040+ifloat: 1
6041+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
6042+ildouble: 1
6043+ldouble: 1
6044+
6045+# casinh
6046+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
6047+double: 5
6048+float: 1
6049+idouble: 5
6050+ifloat: 1
6051+ildouble: 4
6052+ldouble: 4
6053+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
6054+double: 3
6055+float: 6
6056+idouble: 3
6057+ifloat: 6
6058+ildouble: 2
6059+ldouble: 2
6060+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
6061+float: 1
6062+ifloat: 1
6063+ildouble: 1
6064+ldouble: 1
6065+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
6066+double: 1
6067+float: 1
6068+idouble: 1
6069+ifloat: 1
6070+ildouble: 1
6071+ldouble: 1
6072+
6073+# catan
6074+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
6075+double: 1
6076+float: 1
6077+idouble: 1
6078+ifloat: 1
6079+Test "Imaginary part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
6080+ildouble: 1
6081+ldouble: 1
6082+
6083+# catanh
6084+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
6085+double: 4
6086+idouble: 4
6087+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
6088+double: 1
6089+idouble: 1
6090+ildouble: 1
6091+ldouble: 1
6092+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
6093+ildouble: 1
6094+ldouble: 1
6095+
6096+# cbrt
6097+Test "cbrt (-0.001) == -0.1":
6098+ildouble: 1
6099+ldouble: 1
6100+Test "cbrt (-27.0) == -3.0":
6101+double: 1
6102+idouble: 1
6103+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
6104+double: 1
6105+idouble: 1
6106+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
6107+double: 1
6108+idouble: 1
6109+
6110+# ccos
6111+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
6112+ildouble: 1
6113+ldouble: 1
6114+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
6115+float: 1
6116+ifloat: 1
6117+ildouble: 1
6118+ldouble: 1
6119+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
6120+double: 1
6121+float: 1
6122+idouble: 1
6123+ifloat: 1
6124+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
6125+float: 1
6126+ifloat: 1
6127+
6128+# ccosh
6129+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
6130+float: 1
6131+ifloat: 1
6132+ildouble: 1
6133+ldouble: 1
6134+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
6135+float: 1
6136+ifloat: 1
6137+ildouble: 1
6138+ldouble: 1
6139+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
6140+double: 1
6141+float: 1
6142+idouble: 1
6143+ifloat: 1
6144+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
6145+float: 1
6146+ifloat: 1
6147+
6148+# cexp
6149+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
6150+ildouble: 1
6151+ldouble: 1
6152+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
6153+float: 1
6154+ifloat: 1
6155+ildouble: 1
6156+ldouble: 1
6157+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
6158+float: 1
6159+ifloat: 1
6160+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
6161+ildouble: 1
6162+ldouble: 1
6163+
6164+# clog
6165+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
6166+float: 1
6167+ifloat: 1
6168+ildouble: 1
6169+ldouble: 1
6170+
6171+# clog10
6172+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
6173+double: 1
6174+float: 1
6175+idouble: 1
6176+ifloat: 1
6177+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
6178+double: 1
6179+float: 1
6180+idouble: 1
6181+ifloat: 1
6182+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
6183+ildouble: 1
6184+ldouble: 1
6185+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
6186+double: 1
6187+idouble: 1
6188+ildouble: 1
6189+ldouble: 1
6190+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
6191+double: 1
6192+float: 1
6193+idouble: 1
6194+ifloat: 1
6195+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
6196+double: 1
6197+float: 1
6198+idouble: 1
6199+ifloat: 1
6200+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
6201+double: 1
6202+float: 1
6203+idouble: 1
6204+ifloat: 1
6205+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
6206+double: 1
6207+float: 1
6208+idouble: 1
6209+ifloat: 1
6210+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
6211+double: 1
6212+idouble: 1
6213+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
6214+double: 1
6215+float: 1
6216+idouble: 1
6217+ifloat: 1
6218+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
6219+double: 1
6220+float: 1
6221+idouble: 1
6222+ifloat: 1
6223+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
6224+double: 1
6225+float: 1
6226+idouble: 1
6227+ifloat: 1
6228+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
6229+double: 1
6230+float: 1
6231+idouble: 1
6232+ifloat: 1
6233+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
6234+float: 1
6235+ifloat: 1
6236+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
6237+ildouble: 1
6238+ldouble: 1
6239+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
6240+double: 1
6241+float: 1
6242+idouble: 1
6243+ifloat: 1
6244+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
6245+double: 1
6246+float: 1
6247+idouble: 1
6248+ifloat: 1
6249+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
6250+double: 1
6251+float: 1
6252+idouble: 1
6253+ifloat: 1
6254+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
6255+double: 1
6256+float: 1
6257+idouble: 1
6258+ifloat: 1
6259+
6260+# cos
6261+Test "cos (M_PI_6l * 2.0) == 0.5":
6262+double: 1
6263+idouble: 1
6264+ildouble: 1
6265+ldouble: 1
6266+Test "cos (M_PI_6l * 4.0) == -0.5":
6267+double: 2
6268+float: 1
6269+idouble: 2
6270+ifloat: 1
6271+ildouble: 1
6272+ldouble: 1
6273+
6274+# cpow
6275+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
6276+float: 1
6277+ifloat: 1
6278+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
6279+float: 1
6280+ifloat: 1
6281+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
6282+double: 1
6283+float: 4
6284+idouble: 1
6285+ifloat: 4
6286+ildouble: 4
6287+ldouble: 4
6288+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
6289+ildouble: 2
6290+ldouble: 2
6291+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
6292+ildouble: 1
6293+ldouble: 1
6294+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
6295+double: 2
6296+float: 3
6297+idouble: 2
6298+ifloat: 3
6299+ildouble: 10
6300+ldouble: 10
6301+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
6302+ildouble: 2
6303+ldouble: 2
6304+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
6305+double: 1
6306+float: 4
6307+idouble: 1
6308+ifloat: 4
6309+ildouble: 3
6310+ldouble: 3
6311+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
6312+float: 2
6313+ifloat: 2
6314+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
6315+double: 2
6316+float: 2
6317+idouble: 2
6318+ifloat: 2
6319+ildouble: 1
6320+ldouble: 1
6321+
6322+# csin
6323+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
6324+ildouble: 1
6325+ldouble: 1
6326+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
6327+ildouble: 1
6328+ldouble: 1
6329+
6330+# csinh
6331+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
6332+ildouble: 1
6333+ldouble: 1
6334+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
6335+double: 1
6336+idouble: 1
6337+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
6338+float: 1
6339+ifloat: 1
6340+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
6341+float: 1
6342+ifloat: 1
6343+
6344+# csqrt
6345+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
6346+float: 1
6347+ifloat: 1
6348+ildouble: 1
6349+ldouble: 1
6350+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
6351+float: 1
6352+ifloat: 1
6353+ildouble: 1
6354+ldouble: 1
6355+Test "Imaginary part of: csqrt (0.75 + 1.25 i) == 1.05065169626078392338656675760808326 + 0.594868882070379067881984030639932657 i":
6356+ildouble: 1
6357+ldouble: 1
6358+
6359+# ctan
6360+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
6361+ildouble: 1
6362+ldouble: 1
6363+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
6364+ildouble: 1
6365+ldouble: 1
6366+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
6367+double: 1
6368+idouble: 1
6369+ildouble: 2
6370+ldouble: 2
6371+
6372+# ctanh
6373+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
6374+double: 1
6375+float: 2
6376+idouble: 1
6377+ifloat: 2
6378+ildouble: 1
6379+ldouble: 1
6380+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
6381+ildouble: 1
6382+ldouble: 1
6383+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
6384+float: 1
6385+ifloat: 1
6386+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
6387+double: 1
6388+idouble: 1
6389+
6390+# erf
6391+Test "erf (1.25) == 0.922900128256458230136523481197281140":
6392+double: 1
6393+idouble: 1
6394+
6395+# erfc
6396+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
6397+double: 1
6398+idouble: 1
6399+Test "erfc (27.0) == 0.523704892378925568501606768284954709e-318":
6400+ildouble: 1
6401+ldouble: 1
6402+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
6403+double: 1
6404+idouble: 1
6405+
6406+# exp10
6407+Test "exp10 (-1) == 0.1":
6408+double: 2
6409+float: 1
6410+idouble: 2
6411+ifloat: 1
6412+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
6413+double: 1
6414+float: 1
6415+idouble: 1
6416+ifloat: 1
6417+Test "exp10 (3) == 1000":
6418+double: 6
6419+float: 2
6420+idouble: 6
6421+ifloat: 2
6422+ildouble: 1
6423+ldouble: 1
6424+
6425+# exp2
6426+Test "exp2 (10) == 1024":
6427+ildouble: 2
6428+ldouble: 2
6429+
6430+# expm1
6431+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
6432+double: 1
6433+idouble: 1
6434+Test "expm1 (1) == M_El - 1.0":
6435+double: 1
6436+float: 1
6437+idouble: 1
6438+ifloat: 1
6439+ildouble: 1
6440+ldouble: 1
6441+
6442+# gamma
6443+Test "gamma (-0.5) == log(2*sqrt(pi))":
6444+ildouble: 1
6445+ldouble: 1
6446+
6447+# hypot
6448+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
6449+float: 1
6450+ifloat: 1
6451+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
6452+float: 1
6453+ifloat: 1
6454+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
6455+float: 1
6456+ifloat: 1
6457+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
6458+float: 1
6459+ifloat: 1
6460+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
6461+float: 1
6462+ifloat: 1
6463+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
6464+float: 1
6465+ifloat: 1
6466+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
6467+float: 1
6468+ifloat: 1
6469+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
6470+float: 1
6471+ifloat: 1
6472+
6473+# j0
6474+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
6475+double: 1
6476+float: 1
6477+idouble: 1
6478+ifloat: 1
6479+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
6480+float: 1
6481+ifloat: 1
6482+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
6483+double: 2
6484+float: 1
6485+idouble: 2
6486+ifloat: 1
6487+ildouble: 2
6488+ldouble: 2
6489+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
6490+float: 2
6491+ifloat: 2
6492+ildouble: 2
6493+ldouble: 2
6494+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
6495+double: 1
6496+float: 1
6497+idouble: 1
6498+ifloat: 1
6499+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
6500+float: 1
6501+ifloat: 1
6502+ildouble: 1
6503+ldouble: 1
6504+
6505+# j1
6506+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
6507+ildouble: 1
6508+ldouble: 1
6509+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
6510+ildouble: 1
6511+ldouble: 1
6512+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
6513+ildouble: 1
6514+ldouble: 1
6515+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
6516+float: 2
6517+ifloat: 2
6518+ildouble: 2
6519+ldouble: 2
6520+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
6521+double: 1
6522+idouble: 1
6523+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
6524+double: 1
6525+idouble: 1
6526+ildouble: 4
6527+ldouble: 4
6528+
6529+# jn
6530+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
6531+double: 1
6532+float: 1
6533+idouble: 1
6534+ifloat: 1
6535+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
6536+float: 1
6537+ifloat: 1
6538+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
6539+double: 2
6540+float: 1
6541+idouble: 2
6542+ifloat: 1
6543+ildouble: 2
6544+ldouble: 2
6545+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
6546+float: 2
6547+ifloat: 2
6548+ildouble: 2
6549+ldouble: 2
6550+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
6551+double: 1
6552+float: 1
6553+idouble: 1
6554+ifloat: 1
6555+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
6556+float: 1
6557+ifloat: 1
6558+ildouble: 1
6559+ldouble: 1
6560+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
6561+ildouble: 1
6562+ldouble: 1
6563+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
6564+ildouble: 1
6565+ldouble: 1
6566+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
6567+ildouble: 1
6568+ldouble: 1
6569+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
6570+float: 2
6571+ifloat: 2
6572+ildouble: 2
6573+ldouble: 2
6574+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
6575+double: 1
6576+idouble: 1
6577+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
6578+double: 1
6579+idouble: 1
6580+ildouble: 4
6581+ldouble: 4
6582+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
6583+ildouble: 1
6584+ldouble: 1
6585+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
6586+double: 1
6587+float: 1
6588+idouble: 1
6589+ifloat: 1
6590+ildouble: 1
6591+ldouble: 1
6592+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
6593+double: 1
6594+float: 1
6595+idouble: 1
6596+ifloat: 1
6597+ildouble: 1
6598+ldouble: 1
6599+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
6600+ildouble: 1
6601+ldouble: 1
6602+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
6603+double: 4
6604+float: 3
6605+idouble: 4
6606+ifloat: 3
6607+ildouble: 2
6608+ldouble: 2
6609+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
6610+float: 4
6611+ifloat: 4
6612+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
6613+double: 1
6614+float: 1
6615+idouble: 1
6616+ifloat: 1
6617+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
6618+double: 1
6619+float: 1
6620+idouble: 1
6621+ifloat: 1
6622+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
6623+double: 3
6624+float: 1
6625+idouble: 3
6626+ifloat: 1
6627+ildouble: 2
6628+ldouble: 2
6629+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
6630+double: 1
6631+float: 2
6632+idouble: 1
6633+ifloat: 2
6634+
6635+# lgamma
6636+Test "lgamma (-0.5) == log(2*sqrt(pi))":
6637+ildouble: 1
6638+ldouble: 1
6639+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
6640+double: 1
6641+float: 1
6642+idouble: 1
6643+ifloat: 1
6644+ildouble: 1
6645+ldouble: 1
6646+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
6647+double: 1
6648+float: 2
6649+idouble: 1
6650+ifloat: 2
6651+ildouble: 1
6652+ldouble: 1
6653+
6654+# log10
6655+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
6656+double: 1
6657+float: 2
6658+idouble: 1
6659+ifloat: 2
6660+Test "log10 (e) == log10(e)":
6661+float: 1
6662+ifloat: 1
6663+ildouble: 1
6664+ldouble: 1
6665+
6666+# log1p
6667+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
6668+float: 1
6669+ifloat: 1
6670+
6671+# log2
6672+Test "log2 (0.75) == -.415037499278843818546261056052183492":
6673+ildouble: 1
6674+ldouble: 1
6675+
6676+# sincos
6677+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
6678+double: 1
6679+idouble: 1
6680+ildouble: 1
6681+ldouble: 1
6682+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
6683+double: 1
6684+float: 1
6685+idouble: 1
6686+ifloat: 1
6687+ildouble: 1
6688+ldouble: 1
6689+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
6690+float: 1
6691+ifloat: 1
6692+
6693+# sqrt
6694+Test "sqrt (2) == M_SQRT2l":
6695+ildouble: 1
6696+ldouble: 1
6697+
6698+# tanh
6699+Test "tanh (-0.75) == -0.635148952387287319214434357312496495":
6700+ildouble: 1
6701+ldouble: 1
6702+Test "tanh (-1.0) == -0.7615941559557648881194582826047935904":
6703+ildouble: 1
6704+ldouble: 1
6705+Test "tanh (0.75) == 0.635148952387287319214434357312496495":
6706+ildouble: 1
6707+ldouble: 1
6708+Test "tanh (1.0) == 0.7615941559557648881194582826047935904":
6709+ildouble: 1
6710+ldouble: 1
6711+
6712+# tgamma
6713+Test "tgamma (-0.5) == -2 sqrt (pi)":
6714+double: 1
6715+float: 1
6716+idouble: 1
6717+ifloat: 1
6718+ildouble: 1
6719+ldouble: 1
6720+Test "tgamma (0.5) == sqrt (pi)":
6721+float: 1
6722+ifloat: 1
6723+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
6724+double: 1
6725+float: 1
6726+idouble: 1
6727+ifloat: 1
6728+Test "tgamma (4) == 6":
6729+ildouble: 1
6730+ldouble: 1
6731+
6732+# y0
6733+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
6734+double: 2
6735+float: 1
6736+idouble: 2
6737+ifloat: 1
6738+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
6739+double: 2
6740+float: 1
6741+idouble: 2
6742+ifloat: 1
6743+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
6744+float: 1
6745+ifloat: 1
6746+ildouble: 3
6747+ldouble: 3
6748+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
6749+double: 1
6750+float: 1
6751+idouble: 1
6752+ifloat: 1
6753+ildouble: 3
6754+ldouble: 3
6755+
6756+# y1
6757+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
6758+double: 1
6759+idouble: 1
6760+Test "y1 (0.75) == -1.03759455076928541973767132140642198":
6761+ildouble: 1
6762+ldouble: 1
6763+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
6764+float: 1
6765+ifloat: 1
6766+ildouble: 1
6767+ldouble: 1
6768+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
6769+double: 3
6770+float: 1
6771+idouble: 3
6772+ifloat: 1
6773+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
6774+double: 1
6775+float: 1
6776+idouble: 1
6777+ifloat: 1
6778+ildouble: 1
6779+ldouble: 1
6780+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
6781+double: 1
6782+float: 2
6783+idouble: 1
6784+ifloat: 2
6785+ildouble: 1
6786+ldouble: 1
6787+
6788+# yn
6789+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
6790+double: 2
6791+float: 1
6792+idouble: 2
6793+ifloat: 1
6794+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
6795+double: 2
6796+float: 1
6797+idouble: 2
6798+ifloat: 1
6799+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
6800+float: 1
6801+ifloat: 1
6802+ildouble: 3
6803+ldouble: 3
6804+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
6805+double: 1
6806+float: 1
6807+idouble: 1
6808+ifloat: 1
6809+ildouble: 3
6810+ldouble: 3
6811+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
6812+double: 1
6813+idouble: 1
6814+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
6815+ildouble: 1
6816+ldouble: 1
6817+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
6818+float: 1
6819+ifloat: 1
6820+ildouble: 1
6821+ldouble: 1
6822+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
6823+double: 3
6824+float: 1
6825+idouble: 3
6826+ifloat: 1
6827+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
6828+double: 1
6829+float: 1
6830+idouble: 1
6831+ifloat: 1
6832+ildouble: 1
6833+ldouble: 1
6834+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
6835+double: 1
6836+float: 2
6837+idouble: 1
6838+ifloat: 2
6839+ildouble: 1
6840+ldouble: 1
6841+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
6842+double: 1
6843+idouble: 1
6844+ildouble: 2
6845+ldouble: 2
6846+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
6847+double: 1
6848+float: 1
6849+idouble: 1
6850+ifloat: 1
6851+ildouble: 5
6852+ldouble: 5
6853+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
6854+double: 1
6855+idouble: 1
6856+ildouble: 1
6857+ldouble: 1
6858+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
6859+double: 1
6860+float: 1
6861+idouble: 1
6862+ifloat: 1
6863+ildouble: 2
6864+ldouble: 2
6865+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
6866+double: 2
6867+idouble: 2
6868+ildouble: 2
6869+ldouble: 2
6870+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
6871+double: 1
6872+idouble: 1
6873+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
6874+double: 1
6875+float: 1
6876+idouble: 1
6877+ifloat: 1
6878+ildouble: 2
6879+ldouble: 2
6880+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
6881+double: 1
6882+float: 1
6883+idouble: 1
6884+ifloat: 1
6885+ildouble: 1
6886+ldouble: 1
6887+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
6888+double: 1
6889+idouble: 1
6890+
6891+# Maximal error of functions:
6892+Function: "atan2":
6893+float: 1
6894+ifloat: 1
6895+ildouble: 1
6896+ldouble: 1
6897+
6898+Function: "atanh":
6899+float: 1
6900+ifloat: 1
6901+
6902+Function: Imaginary part of "cacos":
6903+ildouble: 1
6904+ldouble: 1
6905+
6906+Function: Imaginary part of "cacosh":
6907+float: 1
6908+ifloat: 1
6909+ildouble: 1
6910+ldouble: 1
6911+
6912+Function: Real part of "casin":
6913+double: 1
6914+float: 1
6915+idouble: 1
6916+ifloat: 1
6917+
6918+Function: Imaginary part of "casin":
6919+ildouble: 1
6920+ldouble: 1
6921+
6922+Function: Real part of "casinh":
6923+double: 5
6924+float: 1
6925+idouble: 5
6926+ifloat: 1
6927+ildouble: 4
6928+ldouble: 4
6929+
6930+Function: Imaginary part of "casinh":
6931+double: 3
6932+float: 6
6933+idouble: 3
6934+ifloat: 6
6935+ildouble: 2
6936+ldouble: 2
6937+
6938+Function: Imaginary part of "catan":
6939+double: 1
6940+float: 1
6941+idouble: 1
6942+ifloat: 1
6943+ildouble: 1
6944+ldouble: 1
6945+
6946+Function: Real part of "catanh":
6947+double: 4
6948+idouble: 4
6949+ildouble: 1
6950+ldouble: 1
6951+
6952+Function: Imaginary part of "catanh":
6953+ildouble: 1
6954+ldouble: 1
6955+
6956+Function: "cbrt":
6957+double: 1
6958+idouble: 1
6959+ildouble: 1
6960+ldouble: 1
6961+
6962+Function: Real part of "ccos":
6963+double: 1
6964+float: 1
6965+idouble: 1
6966+ifloat: 1
6967+ildouble: 1
6968+ldouble: 1
6969+
6970+Function: Imaginary part of "ccos":
6971+float: 1
6972+ifloat: 1
6973+ildouble: 1
6974+ldouble: 1
6975+
6976+Function: Real part of "ccosh":
6977+double: 1
6978+float: 1
6979+idouble: 1
6980+ifloat: 1
6981+ildouble: 1
6982+ldouble: 1
6983+
6984+Function: Imaginary part of "ccosh":
6985+float: 1
6986+ifloat: 1
6987+ildouble: 1
6988+ldouble: 1
6989+
6990+Function: Real part of "cexp":
6991+float: 1
6992+ifloat: 1
6993+ildouble: 1
6994+ldouble: 1
6995+
6996+Function: Imaginary part of "cexp":
6997+float: 1
6998+ifloat: 1
6999+ildouble: 1
7000+ldouble: 1
7001+
7002+Function: Real part of "clog":
7003+float: 1
7004+ifloat: 1
7005+ildouble: 1
7006+ldouble: 1
7007+
7008+Function: Real part of "clog10":
7009+float: 1
7010+ifloat: 1
7011+ildouble: 1
7012+ldouble: 1
7013+
7014+Function: Imaginary part of "clog10":
7015+double: 1
7016+float: 1
7017+idouble: 1
7018+ifloat: 1
7019+ildouble: 1
7020+ldouble: 1
7021+
7022+Function: "cos":
7023+double: 2
7024+float: 1
7025+idouble: 2
7026+ifloat: 1
7027+ildouble: 1
7028+ldouble: 1
7029+
7030+Function: Real part of "cpow":
7031+double: 2
7032+float: 4
7033+idouble: 2
7034+ifloat: 4
7035+ildouble: 10
7036+ldouble: 10
7037+
7038+Function: Imaginary part of "cpow":
7039+double: 2
7040+float: 2
7041+idouble: 2
7042+ifloat: 2
7043+ildouble: 1
7044+ldouble: 1
7045+
7046+Function: Real part of "csin":
7047+ildouble: 1
7048+ldouble: 1
7049+
7050+Function: Imaginary part of "csin":
7051+ildouble: 1
7052+ldouble: 1
7053+
7054+Function: Real part of "csinh":
7055+float: 1
7056+ifloat: 1
7057+ildouble: 1
7058+ldouble: 1
7059+
7060+Function: Imaginary part of "csinh":
7061+double: 1
7062+float: 1
7063+idouble: 1
7064+ifloat: 1
7065+
7066+Function: Real part of "csqrt":
7067+float: 1
7068+ifloat: 1
7069+ildouble: 1
7070+ldouble: 1
7071+
7072+Function: Imaginary part of "csqrt":
7073+ildouble: 1
7074+ldouble: 1
7075+
7076+Function: Real part of "ctan":
7077+ildouble: 1
7078+ldouble: 1
7079+
7080+Function: Imaginary part of "ctan":
7081+double: 1
7082+idouble: 1
7083+ildouble: 2
7084+ldouble: 2
7085+
7086+Function: Real part of "ctanh":
7087+double: 1
7088+float: 2
7089+idouble: 1
7090+ifloat: 2
7091+ildouble: 1
7092+ldouble: 1
7093+
7094+Function: Imaginary part of "ctanh":
7095+float: 1
7096+ifloat: 1
7097+ildouble: 1
7098+ldouble: 1
7099+
7100+Function: "erf":
7101+double: 1
7102+idouble: 1
7103+
7104+Function: "erfc":
7105+double: 1
7106+idouble: 1
7107+ildouble: 1
7108+ldouble: 1
7109+
7110+Function: "exp10":
7111+double: 6
7112+float: 2
7113+idouble: 6
7114+ifloat: 2
7115+ildouble: 1
7116+ldouble: 1
7117+
7118+Function: "exp2":
7119+ildouble: 2
7120+ldouble: 2
7121+
7122+Function: "expm1":
7123+double: 1
7124+float: 1
7125+idouble: 1
7126+ifloat: 1
7127+ildouble: 1
7128+ldouble: 1
7129+
7130+Function: "gamma":
7131+ildouble: 1
7132+ldouble: 1
7133+
7134+Function: "hypot":
7135+float: 1
7136+ifloat: 1
7137+
7138+Function: "j0":
7139+double: 2
7140+float: 2
7141+idouble: 2
7142+ifloat: 2
7143+ildouble: 2
7144+ldouble: 2
7145+
7146+Function: "j1":
7147+double: 1
7148+float: 2
7149+idouble: 1
7150+ifloat: 2
7151+ildouble: 4
7152+ldouble: 4
7153+
7154+Function: "jn":
7155+double: 4
7156+float: 4
7157+idouble: 4
7158+ifloat: 4
7159+ildouble: 4
7160+ldouble: 4
7161+
7162+Function: "lgamma":
7163+double: 1
7164+float: 2
7165+idouble: 1
7166+ifloat: 2
7167+ildouble: 1
7168+ldouble: 1
7169+
7170+Function: "log10":
7171+double: 1
7172+float: 2
7173+idouble: 1
7174+ifloat: 2
7175+ildouble: 1
7176+ldouble: 1
7177+