@@ -687,8 +687,9 @@ extern int __vswprintf_internal (wchar_t *string, size_t maxlen,
unsigned int mode_flags);
/* Flags for __v*printf_internal. */
-#define PRINTF_LDBL_IS_DBL 0x0001
-#define PRINTF_FORTIFY 0x0002
+#define PRINTF_LDBL_IS_DBL 0x0001
+#define PRINTF_FORTIFY 0x0002
+#define PRINTF_LDBL_USES_FLOAT128 0x0004
extern size_t _IO_getline (FILE *,char *, size_t, int, int);
libc_hidden_proto (_IO_getline)
@@ -57,6 +57,9 @@ union printf_arg
unsigned long long int pa_u_long_long_int;
double pa_double;
long double pa_long_double;
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ __float128 pa_float128;
+#endif
const char *pa_string;
const wchar_t *pa_wstring;
void *pa_pointer;
@@ -68,8 +68,43 @@
} while (0)
#define UNBUFFERED_P(S) ((S)->_flags & _IO_UNBUFFERED)
#define LDBL_IS_DBL (__glibc_unlikely ((mode_flags & PRINTF_LDBL_IS_DBL) != 0))
+#define LDBL_USES_FLOAT128 ((mode_flags && PRINTF_LDBL_USES_FLOAT128) == 1)
#define DO_FORTIFY ((mode_flags & PRINTF_FORTIFY) != 0)
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ if (LDBL_USES_FLOAT128) \
+ { \
+ INFO.is_binary128 = 1; \
+ the_arg.pa_float128 = va_arg (ap, __float128); \
+ } \
+ else \
+ { \
+ PARSE_FLOAT_VA_ARG (INFO) \
+ }
+#else
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ PARSE_FLOAT_VA_ARG (INFO)
+#endif
+
+#define PARSE_FLOAT_VA_ARG(INFO) \
+ INFO.is_binary128 = 0; \
+ if (is_long_double) \
+ the_arg.pa_long_double = va_arg (ap, long double); \
+ else \
+ the_arg.pa_double = va_arg (ap, double);
+
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define SETUP_FLOAT128_INFO(INFO) \
+ if (LDBL_USES_FLOAT128) \
+ INFO.is_binary128 = 1; \
+ else \
+ INFO.is_binary128 = 0;
+#else
+# define SETUP_FLOAT128_INFO(INFO) \
+ INFO.is_binary128 = 0;
+#endif
+
#define done_add(val) \
do { \
unsigned int _val = val; \
@@ -773,10 +808,7 @@ static const uint8_t jump_table[] =
.wide = sizeof (CHAR_T) != 1, \
.is_binary128 = 0}; \
\
- if (is_long_double) \
- the_arg.pa_long_double = va_arg (ap, long double); \
- else \
- the_arg.pa_double = va_arg (ap, double); \
+ PARSE_FLOAT_VA_ARG_EXTENDED (info) \
ptr = (const void *) &the_arg; \
\
function_done = __printf_fp (s, &info, &ptr); \
@@ -789,8 +821,7 @@ static const uint8_t jump_table[] =
fspec->data_arg_type = PA_DOUBLE; \
fspec->info.is_long_double = 0; \
} \
- /* Not supported by *printf functions. */ \
- fspec->info.is_binary128 = 0; \
+ SETUP_FLOAT128_INFO (fspec->info) \
\
function_done = __printf_fp (s, &fspec->info, &ptr); \
} \
@@ -833,10 +864,7 @@ static const uint8_t jump_table[] =
.wide = sizeof (CHAR_T) != 1, \
.is_binary128 = 0}; \
\
- if (is_long_double) \
- the_arg.pa_long_double = va_arg (ap, long double); \
- else \
- the_arg.pa_double = va_arg (ap, double); \
+ PARSE_FLOAT_VA_ARG_EXTENDED (info) \
ptr = (const void *) &the_arg; \
\
function_done = __printf_fphex (s, &info, &ptr); \
@@ -846,8 +874,7 @@ static const uint8_t jump_table[] =
ptr = (const void *) &args_value[fspec->data_arg]; \
if (LDBL_IS_DBL) \
fspec->info.is_long_double = 0; \
- /* Not supported by *printf functions. */ \
- fspec->info.is_binary128 = 0; \
+ SETUP_FLOAT128_INFO (fspec->info) \
\
function_done = __printf_fphex (s, &fspec->info, &ptr); \
} \
@@ -1871,6 +1898,10 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
args_value[cnt].pa_double = va_arg (*ap_savep, double);
args_type[cnt] &= ~PA_FLAG_LONG_DOUBLE;
}
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ else if (LDBL_USES_FLOAT128)
+ args_value[cnt].pa_float128 = va_arg (*ap_savep, __float128);
+#endif
else
args_value[cnt].pa_long_double = va_arg (*ap_savep, long double);
break;
@@ -1889,7 +1920,12 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
(args_value[cnt].pa_user, ap_savep);
}
else
- args_value[cnt].pa_long_double = 0.0;
+ {
+ args_value[cnt].pa_long_double = 0.0;
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ args_value[cnt].pa_float128 = 0;
+#endif
+ }
break;
case -1:
/* Error case. Not all parameters appear in N$ format