[committed] Fix bootstrap on pre-2.10 glibc (PR bootstrap/47736)

Submitted by Jakub Jelinek on Feb. 14, 2011, 6:52 p.m.

Details

Message ID 20110214185248.GP30899@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 14, 2011, 6:52 p.m.
Hi!

User field has been added into struct printf_info only for glibc 2.10+.
We actually never use it unless HAVE_PRINTF_HOOKS, so we don't need to
initialize it either.  The patch below just initializes everything to 0
so that individual fields don't have to be initialized one by one, then
we don't have to touch info.user and check whether it is present or not.
The configure snippet just double checks that the field exists.

Tested on glibc 2.12.2 and with hand edited printf.h to simulate older
glibcs.

2011-02-14  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/47736
	* configure.ac (HAVE_PRINTF_HOOKS): Test if printf_info struct has
	user field.
	* printf/quadmath-printf.c (quadmath_snprintf): Clear whole info
	field instead of setting individual fields to 0.  Don't set info.user
	to -1.
	* configure: Regenerated.


	Jakub

Patch hide | download patch | download mbox

--- libquadmath/configure.ac.jj	2011-02-14 17:28:39.000000000 +0100
+++ libquadmath/configure.ac	2011-02-14 19:14:25.281464520 +0100
@@ -241,6 +241,7 @@  extern int flt128_printf_fp (FILE *, con
 int pa_flt128 = register_printf_type (flt128_va);
 int mod_Q = register_printf_modifier (L"Q");
 int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais);
+struct printf_info info = { .user = -1 };
 ],
 [quadmath_printf_hooks=yes],[quadmath_printf_hooks=no])
 AC_MSG_RESULT($quadmath_printf_hooks)
--- libquadmath/printf/quadmath-printf.c.jj	2011-02-14 16:13:33.000000000 +0100
+++ libquadmath/printf/quadmath-printf.c	2011-02-14 19:12:59.678433319 +0100
@@ -121,15 +121,16 @@  quadmath_snprintf (char *str, size_t siz
     return -1;
 
   /* Clear information structure.  */
-  info.alt = 0;
+  memset (&info, '\0', sizeof info);
+  /* info.alt = 0;
   info.space = 0;
   info.left = 0;
   info.showsign = 0;
   info.group = 0;
   info.i18n = 0;
-  info.extra = 0;
+  info.extra = 0; */
   info.pad = ' ';
-  info.wide = 0;
+  /* info.wide = 0; */
 
   /* Check for spec modifiers.  */
   do
@@ -180,7 +181,7 @@  quadmath_snprintf (char *str, size_t siz
   va_start (ap, format);
 
   /* Get the field width.  */
-  info.width = 0;
+  /* info.width = 0; */
   if (*format == '*')
     {
       /* The field width is given in an argument.
@@ -213,11 +214,11 @@  quadmath_snprintf (char *str, size_t siz
     }
 
   /* Check for type modifiers.  */
-  info.is_long_double = 0;
+  /* info.is_long_double = 0;
   info.is_short = 0;
   info.is_long = 0;
   info.is_char = 0;
-  info.user = -1;
+  info.user = 0; */
 
   /* We require Q modifier.  */
   if (*format++ != 'Q')
--- libquadmath/configure.jj	2011-02-14 17:28:55.000000000 +0100
+++ libquadmath/configure	2011-02-14 19:14:45.609429566 +0100
@@ -12555,6 +12555,7 @@  main ()
 int pa_flt128 = register_printf_type (flt128_va);
 int mod_Q = register_printf_modifier (L"Q");
 int res = register_printf_specifier ('f', flt128_printf_fp, flt128_ais);
+struct printf_info info = { .user = -1 };
 
   ;
   return 0;