about summary refs log tree commit diff
path: root/stdio-common/printf_fp.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/printf_fp.c')
-rw-r--r--stdio-common/printf_fp.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 1b550abe4f..0a2efb7891 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -439,9 +439,28 @@ __printf_fp (FILE *fp,
 	    {
 	      if (scalesize == 0)
 		{
-		  tmpsize = powers->arraysize;
-		  memcpy (tmp, &__tens[powers->arrayoff],
-			  tmpsize * sizeof (mp_limb_t));
+#ifndef __NO_LONG_DOUBLE_MATH
+		  if (LDBL_MANT_DIG > _FPIO_CONST_OFFSET * BITS_PER_MP_LIMB
+		      && info->is_long_double)
+		    {
+#define _FPIO_CONST_SHIFT \
+  (((LDBL_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB) \
+   - _FPIO_CONST_OFFSET)
+		      /* 64bit const offset is not enough for
+			 IEEE quad long double.  */
+		      tmpsize = powers->arraysize + _FPIO_CONST_SHIFT;
+		      memcpy (tmp + _FPIO_CONST_SHIFT,
+			      &__tens[powers->arrayoff],
+			      tmpsize * sizeof (mp_limb_t));
+		      MPN_ZERO (tmp, _FPIO_CONST_SHIFT);
+		    }
+		  else
+#endif
+		    {
+		      tmpsize = powers->arraysize;
+		      memcpy (tmp, &__tens[powers->arrayoff],
+			      tmpsize * sizeof (mp_limb_t));
+		    }
 		}
 	      else
 		{