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