1/* *printf* family compatibility routines for IEEE double as long double
2 Copyright (C) 2006-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* This file may define some of the deprecated scanf variants. */
20#include <features.h>
21#undef __GLIBC_USE_DEPRECATED_SCANF
22#define __GLIBC_USE_DEPRECATED_SCANF 1
23
24#include <argp.h>
25#include <err.h>
26#include <error.h>
27#include <stdarg.h>
28#include <stdio.h>
29#include <libio/strfile.h>
30#include <math.h>
31#include <wchar.h>
32#include <printf.h>
33#include <monetary.h>
34#include <locale/localeinfo.h>
35#include <sys/syslog.h>
36#include <libc-lock.h>
37
38#include "nldbl-compat.h"
39
40libc_hidden_proto (__nldbl_vsscanf)
41libc_hidden_proto (__nldbl_vfscanf)
42libc_hidden_proto (__nldbl_vfwscanf)
43libc_hidden_proto (__nldbl_vswscanf)
44libc_hidden_proto (__nldbl___isoc99_vsscanf)
45libc_hidden_proto (__nldbl___isoc99_vfscanf)
46libc_hidden_proto (__nldbl___isoc99_vswscanf)
47libc_hidden_proto (__nldbl___isoc99_vfwscanf)
48
49/* Compatibility with IEEE double as long double.
50 IEEE quad long double is used by default for most programs, so
51 we don't need to split this into one file per function for the
52 sake of statically linked programs. */
53
54int
55attribute_compat_text_section
56__nldbl___asprintf (char **string_ptr, const char *fmt, ...)
57{
58 va_list ap;
59 int ret;
60
61 va_start (ap, fmt);
62 ret = __vasprintf_internal (result_ptr: string_ptr, format: fmt, ap, PRINTF_LDBL_IS_DBL);
63 va_end (ap);
64
65 return ret;
66}
67weak_alias (__nldbl___asprintf, __nldbl_asprintf)
68
69int
70attribute_compat_text_section
71__nldbl_dprintf (int d, const char *fmt, ...)
72{
73 va_list ap;
74 int ret;
75
76 va_start (ap, fmt);
77 ret = __vdprintf_internal (d, format: fmt, ap, PRINTF_LDBL_IS_DBL);
78 va_end (ap);
79
80 return ret;
81}
82
83int
84attribute_compat_text_section
85__nldbl_fprintf (FILE *stream, const char *fmt, ...)
86{
87 va_list ap;
88 int ret;
89
90 va_start (ap, fmt);
91 ret = __vfprintf_internal (fp: stream, format: fmt, ap, PRINTF_LDBL_IS_DBL);
92 va_end (ap);
93
94 return ret;
95}
96weak_alias (__nldbl_fprintf, __nldbl__IO_fprintf)
97
98int
99attribute_compat_text_section weak_function
100__nldbl_fwprintf (FILE *stream, const wchar_t *fmt, ...)
101{
102 va_list ap;
103 int ret;
104
105 va_start (ap, fmt);
106 ret = __vfwprintf_internal (fp: stream, format: fmt, ap, PRINTF_LDBL_IS_DBL);
107 va_end (ap);
108
109 return ret;
110}
111
112int
113attribute_compat_text_section
114__nldbl_printf (const char *fmt, ...)
115{
116 va_list ap;
117 int ret;
118
119 va_start (ap, fmt);
120 ret = __vfprintf_internal (stdout, format: fmt, ap, PRINTF_LDBL_IS_DBL);
121 va_end (ap);
122
123 return ret;
124}
125strong_alias (__nldbl_printf, __nldbl__IO_printf)
126
127int
128attribute_compat_text_section
129__nldbl_sprintf (char *s, const char *fmt, ...)
130{
131 va_list ap;
132 int ret;
133
134 va_start (ap, fmt);
135 ret = __vsprintf_internal (string: s, maxlen: -1, format: fmt, ap, PRINTF_LDBL_IS_DBL);
136 va_end (ap);
137
138 return ret;
139}
140strong_alias (__nldbl_sprintf, __nldbl__IO_sprintf)
141
142int
143attribute_compat_text_section
144__nldbl_vfprintf (FILE *s, const char *fmt, va_list ap)
145{
146 return __vfprintf_internal (fp: s, format: fmt, ap, PRINTF_LDBL_IS_DBL);
147}
148strong_alias (__nldbl_vfprintf, __nldbl__IO_vfprintf)
149
150int
151attribute_compat_text_section
152__nldbl___vsprintf (char *string, const char *fmt, va_list ap)
153{
154 return __vsprintf_internal (string, maxlen: -1, format: fmt, ap, PRINTF_LDBL_IS_DBL);
155}
156strong_alias (__nldbl___vsprintf, __nldbl__IO_vsprintf)
157weak_alias (__nldbl___vsprintf, __nldbl_vsprintf)
158
159int
160attribute_compat_text_section
161__nldbl_obstack_vprintf (struct obstack *obstack, const char *fmt,
162 va_list ap)
163{
164 return __obstack_vprintf_internal (ob: obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
165}
166
167int
168attribute_compat_text_section
169__nldbl_obstack_printf (struct obstack *obstack, const char *fmt, ...)
170{
171 int ret;
172 va_list ap;
173 va_start (ap, fmt);
174 ret = __obstack_vprintf_internal (ob: obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
175 va_end (ap);
176 return ret;
177}
178
179int
180attribute_compat_text_section weak_function
181__nldbl_snprintf (char *s, size_t maxlen, const char *fmt, ...)
182{
183 va_list ap;
184 int ret;
185
186 va_start (ap, fmt);
187 ret = __vsnprintf_internal (string: s, maxlen, format: fmt, ap, PRINTF_LDBL_IS_DBL);
188 va_end (ap);
189
190 return ret;
191}
192
193int
194attribute_compat_text_section
195__nldbl_swprintf (wchar_t *s, size_t n, const wchar_t *fmt, ...)
196{
197 va_list ap;
198 int ret;
199
200 va_start (ap, fmt);
201 ret = __vswprintf_internal (string: s, maxlen: n, format: fmt, ap, PRINTF_LDBL_IS_DBL);
202 va_end (ap);
203
204 return ret;
205}
206
207int
208attribute_compat_text_section weak_function
209__nldbl_vasprintf (char **result_ptr, const char *fmt, va_list ap)
210{
211 return __vasprintf_internal (result_ptr, format: fmt, ap, PRINTF_LDBL_IS_DBL);
212}
213
214int
215attribute_compat_text_section
216__nldbl_vdprintf (int d, const char *fmt, va_list ap)
217{
218 return __vdprintf_internal (d, format: fmt, ap, PRINTF_LDBL_IS_DBL);
219}
220
221int
222attribute_compat_text_section weak_function
223__nldbl_vfwprintf (FILE *s, const wchar_t *fmt, va_list ap)
224{
225 return __vfwprintf_internal (fp: s, format: fmt, ap, PRINTF_LDBL_IS_DBL);
226}
227
228int
229attribute_compat_text_section
230__nldbl_vprintf (const char *fmt, va_list ap)
231{
232 return __vfprintf_internal (stdout, format: fmt, ap, PRINTF_LDBL_IS_DBL);
233}
234
235int
236attribute_compat_text_section
237__nldbl_vsnprintf (char *string, size_t maxlen, const char *fmt,
238 va_list ap)
239{
240 return __vsnprintf_internal (string, maxlen, format: fmt, ap, PRINTF_LDBL_IS_DBL);
241}
242weak_alias (__nldbl_vsnprintf, __nldbl___vsnprintf)
243
244int
245attribute_compat_text_section weak_function
246__nldbl_vswprintf (wchar_t *string, size_t maxlen, const wchar_t *fmt,
247 va_list ap)
248{
249 return __vswprintf_internal (string, maxlen, format: fmt, ap, PRINTF_LDBL_IS_DBL);
250}
251
252int
253attribute_compat_text_section
254__nldbl_vwprintf (const wchar_t *fmt, va_list ap)
255{
256 return __vfwprintf_internal (stdout, format: fmt, ap, PRINTF_LDBL_IS_DBL);
257}
258
259int
260attribute_compat_text_section
261__nldbl_wprintf (const wchar_t *fmt, ...)
262{
263 va_list ap;
264 int ret;
265
266 va_start (ap, fmt);
267 ret = __vfwprintf_internal (stdout, format: fmt, ap, PRINTF_LDBL_IS_DBL);
268 va_end (ap);
269
270 return ret;
271}
272
273#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
274int
275attribute_compat_text_section
276__nldbl__IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp)
277{
278 int ret = __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL);
279 if (__glibc_unlikely (errp != 0))
280 *errp = (ret == -1);
281 return ret;
282}
283#endif
284
285int
286attribute_compat_text_section
287__nldbl___vfscanf (FILE *s, const char *fmt, va_list ap)
288{
289 return __vfscanf_internal (fp: s, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
290}
291weak_alias (__nldbl___vfscanf, __nldbl_vfscanf)
292libc_hidden_def (__nldbl_vfscanf)
293
294int
295attribute_compat_text_section
296__nldbl_sscanf (const char *s, const char *fmt, ...)
297{
298 _IO_strfile sf;
299 FILE *f = _IO_strfile_read (sf: &sf, string: s);
300 va_list ap;
301 int ret;
302
303 va_start (ap, fmt);
304 ret = __vfscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
305 va_end (ap);
306
307 return ret;
308}
309strong_alias (__nldbl_sscanf, __nldbl__IO_sscanf)
310
311int
312attribute_compat_text_section
313__nldbl___vsscanf (const char *s, const char *fmt, va_list ap)
314{
315 _IO_strfile sf;
316 FILE *f = _IO_strfile_read (sf: &sf, string: s);
317 return __vfscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
318}
319weak_alias (__nldbl___vsscanf, __nldbl_vsscanf)
320libc_hidden_def (__nldbl_vsscanf)
321
322int
323attribute_compat_text_section weak_function
324__nldbl_vscanf (const char *fmt, va_list ap)
325{
326 return __vfscanf_internal (stdin, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
327}
328
329int
330attribute_compat_text_section
331__nldbl_fscanf (FILE *stream, const char *fmt, ...)
332{
333 va_list ap;
334 int ret;
335
336 va_start (ap, fmt);
337 ret = __vfscanf_internal (fp: stream, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
338 va_end (ap);
339
340 return ret;
341}
342
343int
344attribute_compat_text_section
345__nldbl_scanf (const char *fmt, ...)
346{
347 va_list ap;
348 int ret;
349
350 va_start (ap, fmt);
351 ret = __vfscanf_internal (stdin, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
352 va_end (ap);
353
354 return ret;
355}
356
357int
358attribute_compat_text_section
359__nldbl_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap)
360{
361 return __vfwscanf_internal (fp: s, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
362}
363libc_hidden_def (__nldbl_vfwscanf)
364
365int
366attribute_compat_text_section
367__nldbl_swscanf (const wchar_t *s, const wchar_t *fmt, ...)
368{
369 _IO_strfile sf;
370 struct _IO_wide_data wd;
371 FILE *f = _IO_strfile_readw (sf: &sf, wd: &wd, string: s);
372 va_list ap;
373 int ret;
374
375 va_start (ap, fmt);
376 ret = __vfwscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
377 va_end (ap);
378
379 return ret;
380}
381
382int
383attribute_compat_text_section
384__nldbl_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap)
385{
386 _IO_strfile sf;
387 struct _IO_wide_data wd;
388 FILE *f = _IO_strfile_readw (sf: &sf, wd: &wd, string: s);
389
390 return __vfwscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
391}
392libc_hidden_def (__nldbl_vswscanf)
393
394int
395attribute_compat_text_section weak_function
396__nldbl_vwscanf (const wchar_t *fmt, va_list ap)
397{
398 return __vfwscanf_internal (stdin, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
399}
400
401int
402attribute_compat_text_section
403__nldbl_fwscanf (FILE *stream, const wchar_t *fmt, ...)
404{
405 va_list ap;
406 int ret;
407
408 va_start (ap, fmt);
409 ret = __vfwscanf_internal (fp: stream, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
410 va_end (ap);
411
412 return ret;
413}
414
415int
416attribute_compat_text_section
417__nldbl_wscanf (const wchar_t *fmt, ...)
418{
419 va_list ap;
420 int ret;
421
422 va_start (ap, fmt);
423 ret = __vfwscanf_internal (stdin, format: fmt, argp: ap, SCANF_LDBL_IS_DBL);
424 va_end (ap);
425
426 return ret;
427}
428
429int
430attribute_compat_text_section
431__nldbl___fprintf_chk (FILE *stream, int flag, const char *fmt, ...)
432{
433 va_list ap;
434 int ret;
435 unsigned int mode = PRINTF_LDBL_IS_DBL;
436 if (flag > 0)
437 mode |= PRINTF_FORTIFY;
438
439 va_start (ap, fmt);
440 ret = __vfprintf_internal (fp: stream, format: fmt, ap, mode_flags: mode);
441 va_end (ap);
442
443 return ret;
444}
445
446int
447attribute_compat_text_section
448__nldbl___fwprintf_chk (FILE *stream, int flag, const wchar_t *fmt, ...)
449{
450 va_list ap;
451 int ret;
452 unsigned int mode = PRINTF_LDBL_IS_DBL;
453 if (flag > 0)
454 mode |= PRINTF_FORTIFY;
455
456 va_start (ap, fmt);
457 ret = __vfwprintf_internal (fp: stream, format: fmt, ap, mode_flags: mode);
458 va_end (ap);
459
460 return ret;
461}
462
463int
464attribute_compat_text_section
465__nldbl___printf_chk (int flag, const char *fmt, ...)
466{
467 va_list ap;
468 int ret;
469 unsigned int mode = PRINTF_LDBL_IS_DBL;
470 if (flag > 0)
471 mode |= PRINTF_FORTIFY;
472
473 va_start (ap, fmt);
474 ret = __vfprintf_internal (stdout, format: fmt, ap, mode_flags: mode);
475 va_end (ap);
476
477 return ret;
478}
479
480int
481attribute_compat_text_section
482__nldbl___snprintf_chk (char *s, size_t maxlen, int flag, size_t slen,
483 const char *fmt, ...)
484{
485 if (__glibc_unlikely (slen < maxlen))
486 __chk_fail ();
487
488 va_list ap;
489 int ret;
490 unsigned int mode = PRINTF_LDBL_IS_DBL;
491 if (flag > 0)
492 mode |= PRINTF_FORTIFY;
493
494 va_start (ap, fmt);
495 ret = __vsnprintf_internal (string: s, maxlen, format: fmt, ap, mode_flags: mode);
496 va_end (ap);
497
498 return ret;
499}
500
501int
502attribute_compat_text_section
503__nldbl___sprintf_chk (char *s, int flag, size_t slen, const char *fmt, ...)
504{
505 if (slen == 0)
506 __chk_fail ();
507
508 va_list ap;
509 int ret;
510 unsigned int mode = PRINTF_LDBL_IS_DBL;
511 if (flag > 0)
512 mode |= PRINTF_FORTIFY;
513
514 va_start (ap, fmt);
515 ret = __vsprintf_internal (string: s, maxlen: slen, format: fmt, ap, mode_flags: mode);
516 va_end (ap);
517
518 return ret;
519}
520
521int
522attribute_compat_text_section
523__nldbl___swprintf_chk (wchar_t *s, size_t maxlen, int flag, size_t slen,
524 const wchar_t *fmt, ...)
525{
526 if (__glibc_unlikely (slen < maxlen))
527 __chk_fail ();
528
529 va_list ap;
530 int ret;
531 unsigned int mode = PRINTF_LDBL_IS_DBL;
532 if (flag > 0)
533 mode |= PRINTF_FORTIFY;
534
535 va_start (ap, fmt);
536 ret = __vswprintf_internal (string: s, maxlen, format: fmt, ap, mode_flags: mode);
537 va_end (ap);
538
539 return ret;
540}
541
542int
543attribute_compat_text_section
544__nldbl___vfprintf_chk (FILE *s, int flag, const char *fmt, va_list ap)
545{
546 unsigned int mode = PRINTF_LDBL_IS_DBL;
547 if (flag > 0)
548 mode |= PRINTF_FORTIFY;
549
550 return __vfprintf_internal (fp: s, format: fmt, ap, mode_flags: mode);
551}
552
553int
554attribute_compat_text_section
555__nldbl___vfwprintf_chk (FILE *s, int flag, const wchar_t *fmt, va_list ap)
556{
557 unsigned int mode = PRINTF_LDBL_IS_DBL;
558 if (flag > 0)
559 mode |= PRINTF_FORTIFY;
560
561 return __vfwprintf_internal (fp: s, format: fmt, ap, mode_flags: mode);
562}
563
564int
565attribute_compat_text_section
566__nldbl___vprintf_chk (int flag, const char *fmt, va_list ap)
567{
568 unsigned int mode = PRINTF_LDBL_IS_DBL;
569 if (flag > 0)
570 mode |= PRINTF_FORTIFY;
571
572 return __vfprintf_internal (stdout, format: fmt, ap, mode_flags: mode);
573}
574
575int
576attribute_compat_text_section
577__nldbl___vsnprintf_chk (char *string, size_t maxlen, int flag, size_t slen,
578 const char *fmt, va_list ap)
579{
580 if (__glibc_unlikely (slen < maxlen))
581 __chk_fail ();
582
583 unsigned int mode = PRINTF_LDBL_IS_DBL;
584 if (flag > 0)
585 mode |= PRINTF_FORTIFY;
586
587 return __vsnprintf_internal (string, maxlen, format: fmt, ap, mode_flags: mode);
588}
589
590int
591attribute_compat_text_section
592__nldbl___vsprintf_chk (char *string, int flag, size_t slen, const char *fmt,
593 va_list ap)
594{
595 if (slen == 0)
596 __chk_fail ();
597
598 unsigned int mode = PRINTF_LDBL_IS_DBL;
599 if (flag > 0)
600 mode |= PRINTF_FORTIFY;
601
602 return __vsprintf_internal (string, maxlen: slen, format: fmt, ap, mode_flags: mode);
603}
604
605int
606attribute_compat_text_section
607__nldbl___vswprintf_chk (wchar_t *string, size_t maxlen, int flag, size_t slen,
608 const wchar_t *fmt, va_list ap)
609{
610 if (__glibc_unlikely (slen < maxlen))
611 __chk_fail ();
612
613 unsigned int mode = PRINTF_LDBL_IS_DBL;
614 if (flag > 0)
615 mode |= PRINTF_FORTIFY;
616
617 return __vswprintf_internal (string, maxlen, format: fmt, ap, mode_flags: mode);
618}
619
620int
621attribute_compat_text_section
622__nldbl___vwprintf_chk (int flag, const wchar_t *fmt, va_list ap)
623{
624 unsigned int mode = PRINTF_LDBL_IS_DBL;
625 if (flag > 0)
626 mode |= PRINTF_FORTIFY;
627
628 return __vfwprintf_internal (stdout, format: fmt, ap, mode_flags: mode);
629}
630
631int
632attribute_compat_text_section
633__nldbl___wprintf_chk (int flag, const wchar_t *fmt, ...)
634{
635 va_list ap;
636 int ret;
637 unsigned int mode = PRINTF_LDBL_IS_DBL;
638 if (flag > 0)
639 mode |= PRINTF_FORTIFY;
640
641 va_start (ap, fmt);
642 ret = __vfwprintf_internal (stdout, format: fmt, ap, mode_flags: mode);
643 va_end (ap);
644
645 return ret;
646}
647
648int
649attribute_compat_text_section
650__nldbl___vasprintf_chk (char **ptr, int flag, const char *fmt, va_list ap)
651{
652 unsigned int mode = PRINTF_LDBL_IS_DBL;
653 if (flag > 0)
654 mode |= PRINTF_FORTIFY;
655
656 return __vasprintf_internal (result_ptr: ptr, format: fmt, ap, mode_flags: mode);
657}
658
659int
660attribute_compat_text_section
661__nldbl___asprintf_chk (char **ptr, int flag, const char *fmt, ...)
662{
663 va_list ap;
664 int ret;
665 unsigned int mode = PRINTF_LDBL_IS_DBL;
666 if (flag > 0)
667 mode |= PRINTF_FORTIFY;
668
669 va_start (ap, fmt);
670 ret = __vasprintf_internal (result_ptr: ptr, format: fmt, ap, mode_flags: mode);
671 va_end (ap);
672
673 return ret;
674}
675
676int
677attribute_compat_text_section
678__nldbl___vdprintf_chk (int d, int flag, const char *fmt, va_list ap)
679{
680 unsigned int mode = PRINTF_LDBL_IS_DBL;
681 if (flag > 0)
682 mode |= PRINTF_FORTIFY;
683
684 return __vdprintf_internal (d, format: fmt, ap, mode_flags: mode);
685}
686
687int
688attribute_compat_text_section
689__nldbl___dprintf_chk (int d, int flag, const char *fmt, ...)
690{
691 va_list ap;
692 int ret;
693 unsigned int mode = PRINTF_LDBL_IS_DBL;
694 if (flag > 0)
695 mode |= PRINTF_FORTIFY;
696
697 va_start (ap, fmt);
698 ret = __vdprintf_internal (d, format: fmt, ap, mode_flags: mode);
699 va_end (ap);
700
701 return ret;
702}
703
704int
705attribute_compat_text_section
706__nldbl___obstack_vprintf_chk (struct obstack *obstack, int flag,
707 const char *fmt, va_list ap)
708{
709 unsigned int mode = PRINTF_LDBL_IS_DBL;
710 if (flag > 0)
711 mode |= PRINTF_FORTIFY;
712
713 return __obstack_vprintf_internal (ob: obstack, fmt, ap, mode_flags: mode);
714}
715
716int
717attribute_compat_text_section
718__nldbl___obstack_printf_chk (struct obstack *obstack, int flag,
719 const char *fmt, ...)
720{
721 va_list ap;
722 int ret;
723 unsigned int mode = PRINTF_LDBL_IS_DBL;
724 if (flag > 0)
725 mode |= PRINTF_FORTIFY;
726
727 va_start (ap, fmt);
728 ret = __obstack_vprintf_internal (ob: obstack, fmt, ap, mode_flags: mode);
729 va_end (ap);
730
731 return ret;
732}
733
734extern __typeof (printf_size) __printf_size;
735
736int
737attribute_compat_text_section
738__nldbl_printf_size (FILE *fp, const struct printf_info *info,
739 const void *const *args)
740{
741 struct printf_info info_no_ldbl = *info;
742
743 info_no_ldbl.is_long_double = 0;
744 return __printf_size (fp, &info_no_ldbl, args);
745}
746
747extern __typeof (__printf_fp) ___printf_fp;
748
749int
750attribute_compat_text_section
751__nldbl___printf_fp (FILE *fp, const struct printf_info *info,
752 const void *const *args)
753{
754 struct printf_info info_no_ldbl = *info;
755
756 info_no_ldbl.is_long_double = 0;
757 return ___printf_fp (fp, &info_no_ldbl, args);
758}
759
760ssize_t
761attribute_compat_text_section
762__nldbl_strfmon (char *s, size_t maxsize, const char *format, ...)
763{
764 va_list ap;
765 ssize_t ret;
766
767 va_start (ap, format);
768 ret = __vstrfmon_l_internal (s, maxsize, _NL_CURRENT_LOCALE, format, ap,
769 STRFMON_LDBL_IS_DBL);
770 va_end (ap);
771 return ret;
772}
773
774ssize_t
775attribute_compat_text_section
776__nldbl___strfmon_l (char *s, size_t maxsize, locale_t loc,
777 const char *format, ...)
778{
779 va_list ap;
780 ssize_t ret;
781
782 va_start (ap, format);
783 ret = __vstrfmon_l_internal (s, maxsize, loc, format, ap,
784 STRFMON_LDBL_IS_DBL);
785 va_end (ap);
786 return ret;
787}
788weak_alias (__nldbl___strfmon_l, __nldbl_strfmon_l)
789
790ssize_t
791attribute_compat_text_section
792__nldbl___vstrfmon (char *s, size_t maxsize, const char *format, va_list ap)
793{
794 return __vstrfmon_l_internal (s, maxsize, _NL_CURRENT_LOCALE, format, ap,
795 STRFMON_LDBL_IS_DBL);
796}
797
798ssize_t
799attribute_compat_text_section
800__nldbl___vstrfmon_l (char *s, size_t maxsize, locale_t loc,
801 const char *format, va_list ap)
802{
803 return __vstrfmon_l_internal (s, maxsize, loc, format, ap,
804 STRFMON_LDBL_IS_DBL);
805}
806
807void
808attribute_compat_text_section
809__nldbl_syslog (int pri, const char *fmt, ...)
810{
811 va_list ap;
812 va_start (ap, fmt);
813 __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
814 va_end (ap);
815}
816
817void
818attribute_compat_text_section
819__nldbl_vsyslog (int pri, const char *fmt, va_list ap)
820{
821 __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
822}
823
824void
825attribute_compat_text_section
826__nldbl___syslog_chk (int pri, int flag, const char *fmt, ...)
827{
828 va_list ap;
829 unsigned int mode = PRINTF_LDBL_IS_DBL;
830 if (flag > 0)
831 mode |= PRINTF_FORTIFY;
832
833 va_start (ap, fmt);
834 __vsyslog_internal (pri, fmt, ap, mode_flags: mode);
835 va_end(ap);
836}
837
838void
839attribute_compat_text_section
840__nldbl___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
841{
842 unsigned int mode = PRINTF_LDBL_IS_DBL;
843 if (flag > 0)
844 mode |= PRINTF_FORTIFY;
845
846 __vsyslog_internal (pri, fmt, ap, mode_flags: mode);
847}
848
849int
850attribute_compat_text_section
851__nldbl___isoc99_vfscanf (FILE *s, const char *fmt, va_list ap)
852{
853 return __vfscanf_internal (fp: s, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
854}
855libc_hidden_def (__nldbl___isoc99_vfscanf)
856
857int
858attribute_compat_text_section
859__nldbl___isoc99_sscanf (const char *s, const char *fmt, ...)
860{
861 _IO_strfile sf;
862 FILE *f = _IO_strfile_read (sf: &sf, string: s);
863 va_list ap;
864 int ret;
865
866 va_start (ap, fmt);
867 ret = __vfscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
868 va_end (ap);
869
870 return ret;
871}
872
873int
874attribute_compat_text_section
875__nldbl___isoc99_vsscanf (const char *s, const char *fmt, va_list ap)
876{
877 _IO_strfile sf;
878 FILE *f = _IO_strfile_read (sf: &sf, string: s);
879
880 return __vfscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
881}
882libc_hidden_def (__nldbl___isoc99_vsscanf)
883
884int
885attribute_compat_text_section
886__nldbl___isoc99_vscanf (const char *fmt, va_list ap)
887{
888 return __vfscanf_internal (stdin, format: fmt, argp: ap,
889 SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
890}
891
892int
893attribute_compat_text_section
894__nldbl___isoc99_fscanf (FILE *s, const char *fmt, ...)
895{
896 va_list ap;
897 int ret;
898
899 va_start (ap, fmt);
900 ret = __vfscanf_internal (fp: s, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
901 va_end (ap);
902
903 return ret;
904}
905
906int
907attribute_compat_text_section
908__nldbl___isoc99_scanf (const char *fmt, ...)
909{
910 va_list ap;
911 int ret;
912
913 va_start (ap, fmt);
914 ret = __vfscanf_internal (stdin, format: fmt, argp: ap,
915 SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
916 va_end (ap);
917
918 return ret;
919}
920
921int
922attribute_compat_text_section
923__nldbl___isoc99_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap)
924{
925 return __vfwscanf_internal (fp: s, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
926}
927libc_hidden_def (__nldbl___isoc99_vfwscanf)
928
929int
930attribute_compat_text_section
931__nldbl___isoc99_swscanf (const wchar_t *s, const wchar_t *fmt, ...)
932{
933 _IO_strfile sf;
934 struct _IO_wide_data wd;
935 FILE *f = _IO_strfile_readw (sf: &sf, wd: &wd, string: s);
936 va_list ap;
937 int ret;
938
939 va_start (ap, fmt);
940 ret = __vfwscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
941 va_end (ap);
942
943 return ret;
944}
945
946int
947attribute_compat_text_section
948__nldbl___isoc99_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap)
949{
950 _IO_strfile sf;
951 struct _IO_wide_data wd;
952 FILE *f = _IO_strfile_readw (sf: &sf, wd: &wd, string: s);
953
954 return __vfwscanf_internal (fp: f, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
955}
956libc_hidden_def (__nldbl___isoc99_vswscanf)
957
958int
959attribute_compat_text_section
960__nldbl___isoc99_vwscanf (const wchar_t *fmt, va_list ap)
961{
962 return __vfwscanf_internal (stdin, format: fmt, argp: ap,
963 SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
964}
965
966int
967attribute_compat_text_section
968__nldbl___isoc99_fwscanf (FILE *s, const wchar_t *fmt, ...)
969{
970 va_list ap;
971 int ret;
972
973 va_start (ap, fmt);
974 ret = __vfwscanf_internal (fp: s, format: fmt, argp: ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
975 va_end (ap);
976
977 return ret;
978}
979
980int
981attribute_compat_text_section
982__nldbl___isoc99_wscanf (const wchar_t *fmt, ...)
983{
984 va_list ap;
985 int ret;
986
987 va_start (ap, fmt);
988 ret = __vfwscanf_internal (stdin, format: fmt, argp: ap,
989 SCANF_LDBL_IS_DBL | SCANF_ISOC99_A);
990 va_end (ap);
991
992 return ret;
993}
994
995void
996__nldbl_argp_error (const struct argp_state *state, const char *fmt, ...)
997{
998 va_list ap;
999 va_start (ap, fmt);
1000 __argp_error_internal (state, fmt, ap, PRINTF_LDBL_IS_DBL);
1001 va_end (ap);
1002}
1003
1004void
1005__nldbl_argp_failure (const struct argp_state *state, int status,
1006 int errnum, const char *fmt, ...)
1007{
1008 va_list ap;
1009 va_start (ap, fmt);
1010 __argp_failure_internal (state, status, errnum, fmt, ap,
1011 PRINTF_LDBL_IS_DBL);
1012 va_end (ap);
1013}
1014
1015#define VA_CALL(call) \
1016{ \
1017 va_list ap; \
1018 va_start (ap, format); \
1019 call (format, ap, PRINTF_LDBL_IS_DBL); \
1020 va_end (ap); \
1021}
1022
1023void
1024__nldbl_err (int status, const char *format, ...)
1025{
1026 VA_CALL (__vwarn_internal)
1027 exit (status: status);
1028}
1029
1030void
1031__nldbl_errx (int status, const char *format, ...)
1032{
1033 VA_CALL (__vwarnx_internal)
1034 exit (status: status);
1035}
1036
1037void
1038__nldbl_verr (int status, const char *format, __gnuc_va_list ap)
1039{
1040 __vwarn_internal (format, ap, PRINTF_LDBL_IS_DBL);
1041 exit (status: status);
1042}
1043
1044void
1045__nldbl_verrx (int status, const char *format, __gnuc_va_list ap)
1046{
1047 __vwarnx_internal (format, ap, PRINTF_LDBL_IS_DBL);
1048 exit (status: status);
1049}
1050
1051void
1052__nldbl_warn (const char *format, ...)
1053{
1054 VA_CALL (__vwarn_internal)
1055}
1056
1057void
1058__nldbl_warnx (const char *format, ...)
1059{
1060 VA_CALL (__vwarnx_internal)
1061}
1062
1063void
1064__nldbl_vwarn (const char *format, __gnuc_va_list ap)
1065{
1066 __vwarn_internal (format, ap, PRINTF_LDBL_IS_DBL);
1067}
1068
1069void
1070__nldbl_vwarnx (const char *format, __gnuc_va_list ap)
1071{
1072 __vwarnx_internal (format, ap, PRINTF_LDBL_IS_DBL);
1073}
1074
1075void
1076__nldbl_error (int status, int errnum, const char *message, ...)
1077{
1078 va_list ap;
1079 va_start (ap, message);
1080 __error_internal (status, errnum, message, args: ap, PRINTF_LDBL_IS_DBL);
1081 va_end (ap);
1082}
1083
1084void
1085__nldbl_error_at_line (int status, int errnum, const char *file_name,
1086 unsigned int line_number, const char *message,
1087 ...)
1088{
1089 va_list ap;
1090 va_start (ap, message);
1091 __error_at_line_internal (status, errnum, file_name, line_number,
1092 message, args: ap, PRINTF_LDBL_IS_DBL);
1093 va_end (ap);
1094}
1095
1096#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
1097compat_symbol (libc, __nldbl__IO_printf, _IO_printf, GLIBC_2_0);
1098compat_symbol (libc, __nldbl__IO_sprintf, _IO_sprintf, GLIBC_2_0);
1099compat_symbol (libc, __nldbl__IO_vfprintf, _IO_vfprintf, GLIBC_2_0);
1100compat_symbol (libc, __nldbl__IO_vsprintf, _IO_vsprintf, GLIBC_2_0);
1101compat_symbol (libc, __nldbl_dprintf, dprintf, GLIBC_2_0);
1102compat_symbol (libc, __nldbl_fprintf, fprintf, GLIBC_2_0);
1103compat_symbol (libc, __nldbl_printf, printf, GLIBC_2_0);
1104compat_symbol (libc, __nldbl_sprintf, sprintf, GLIBC_2_0);
1105compat_symbol (libc, __nldbl_vfprintf, vfprintf, GLIBC_2_0);
1106compat_symbol (libc, __nldbl_vprintf, vprintf, GLIBC_2_0);
1107compat_symbol (libc, __nldbl__IO_fprintf, _IO_fprintf, GLIBC_2_0);
1108compat_symbol (libc, __nldbl___vsnprintf, __vsnprintf, GLIBC_2_0);
1109compat_symbol (libc, __nldbl_asprintf, asprintf, GLIBC_2_0);
1110compat_symbol (libc, __nldbl_obstack_printf, obstack_printf, GLIBC_2_0);
1111compat_symbol (libc, __nldbl_obstack_vprintf, obstack_vprintf, GLIBC_2_0);
1112compat_symbol (libc, __nldbl_snprintf, snprintf, GLIBC_2_0);
1113compat_symbol (libc, __nldbl_vasprintf, vasprintf, GLIBC_2_0);
1114compat_symbol (libc, __nldbl_vdprintf, vdprintf, GLIBC_2_0);
1115compat_symbol (libc, __nldbl_vsnprintf, vsnprintf, GLIBC_2_0);
1116compat_symbol (libc, __nldbl_vsprintf, vsprintf, GLIBC_2_0);
1117compat_symbol (libc, __nldbl__IO_sscanf, _IO_sscanf, GLIBC_2_0);
1118compat_symbol (libc, __nldbl___vfscanf, __vfscanf, GLIBC_2_0);
1119compat_symbol (libc, __nldbl___vsscanf, __vsscanf, GLIBC_2_0);
1120compat_symbol (libc, __nldbl_fscanf, fscanf, GLIBC_2_0);
1121compat_symbol (libc, __nldbl_scanf, scanf, GLIBC_2_0);
1122compat_symbol (libc, __nldbl_sscanf, sscanf, GLIBC_2_0);
1123compat_symbol (libc, __nldbl_vfscanf, vfscanf, GLIBC_2_0);
1124compat_symbol (libc, __nldbl_vscanf, vscanf, GLIBC_2_0);
1125compat_symbol (libc, __nldbl_vsscanf, vsscanf, GLIBC_2_0);
1126compat_symbol (libc, __nldbl___printf_fp, __printf_fp, GLIBC_2_0);
1127compat_symbol (libc, __nldbl_strfmon, strfmon, GLIBC_2_0);
1128compat_symbol (libc, __nldbl_syslog, syslog, GLIBC_2_0);
1129compat_symbol (libc, __nldbl_vsyslog, vsyslog, GLIBC_2_0);
1130/* This function is not in public headers, but was exported until
1131 version 2.29. For platforms that are newer than that, there's no
1132 need to expose the symbol. */
1133# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
1134compat_symbol (libc, __nldbl__IO_vfscanf, _IO_vfscanf, GLIBC_2_0);
1135# endif
1136#endif
1137#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_1)
1138compat_symbol (libc, __nldbl___asprintf, __asprintf, GLIBC_2_1);
1139compat_symbol (libc, __nldbl_printf_size, printf_size, GLIBC_2_1);
1140compat_symbol (libc, __nldbl___strfmon_l, __strfmon_l, GLIBC_2_1);
1141#endif
1142#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_2)
1143compat_symbol (libc, __nldbl_swprintf, swprintf, GLIBC_2_2);
1144compat_symbol (libc, __nldbl_vwprintf, vwprintf, GLIBC_2_2);
1145compat_symbol (libc, __nldbl_wprintf, wprintf, GLIBC_2_2);
1146compat_symbol (libc, __nldbl_fwprintf, fwprintf, GLIBC_2_2);
1147compat_symbol (libc, __nldbl_vfwprintf, vfwprintf, GLIBC_2_2);
1148compat_symbol (libc, __nldbl_vswprintf, vswprintf, GLIBC_2_2);
1149compat_symbol (libc, __nldbl_fwscanf, fwscanf, GLIBC_2_2);
1150compat_symbol (libc, __nldbl_swscanf, swscanf, GLIBC_2_2);
1151compat_symbol (libc, __nldbl_vfwscanf, vfwscanf, GLIBC_2_2);
1152compat_symbol (libc, __nldbl_vswscanf, vswscanf, GLIBC_2_2);
1153compat_symbol (libc, __nldbl_vwscanf, vwscanf, GLIBC_2_2);
1154compat_symbol (libc, __nldbl_wscanf, wscanf, GLIBC_2_2);
1155#endif
1156#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_3)
1157compat_symbol (libc, __nldbl_strfmon_l, strfmon_l, GLIBC_2_3);
1158#endif
1159#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_3_4)
1160compat_symbol (libc, __nldbl___sprintf_chk, __sprintf_chk, GLIBC_2_3_4);
1161compat_symbol (libc, __nldbl___vsprintf_chk, __vsprintf_chk, GLIBC_2_3_4);
1162compat_symbol (libc, __nldbl___snprintf_chk, __snprintf_chk, GLIBC_2_3_4);
1163compat_symbol (libc, __nldbl___vsnprintf_chk, __vsnprintf_chk, GLIBC_2_3_4);
1164compat_symbol (libc, __nldbl___printf_chk, __printf_chk, GLIBC_2_3_4);
1165compat_symbol (libc, __nldbl___fprintf_chk, __fprintf_chk, GLIBC_2_3_4);
1166compat_symbol (libc, __nldbl___vprintf_chk, __vprintf_chk, GLIBC_2_3_4);
1167compat_symbol (libc, __nldbl___vfprintf_chk, __vfprintf_chk, GLIBC_2_3_4);
1168#endif
1169

source code of glibc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c