public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Use more flags parameters instead of global bits in stdio
@ 2018-03-07 19:32 Zack Weinberg
  2018-03-07 19:32 ` [PATCH 6/9] Add __vsyslog_internal, with same flags as __v*printf_internal Zack Weinberg
                   ` (11 more replies)
  0 siblings, 12 replies; 37+ messages in thread
From: Zack Weinberg @ 2018-03-07 19:32 UTC (permalink / raw)
  To: libc-alpha

I got stuck on the patch to use C99-compliant scanf in _GNU_SOURCE
mode because the interaction with ldbl-is-dbl was too confusing.  The
reason it's too confusing is that C99 compliance in scanf, ldbl-is-dbl
mode in scanf, printf, and strfmon, and fortify mode in printf are
handled with mode bits on the FILE and thread-global flags that must
be set and reset at just the right times.  Correct behavior is
invariably to set and then reset around just one call to a lower-level
function, and there's a better way to do that: flags parameters.

This patch series implements _internal variants of scanf, printf,
strfmon, and syslog that take flag parameters that control C99
compliance, ldbl-is-dbl mode, and fortification.  I regret the length
and the messiness, and it might make sense to squash it on landing.
I have manually hacked the patches that introduce vfprintf-internal.c
and vfscanf-internal.c so the diffs are actually readable -- git doesn't
handle "rename this file and then create a new file in its place" very
well.

(N.B. It does not make sense to do the same thing to _IO_FLAGS2_NOTCANCEL,
even though we do occasionally want to turn that mode on temporarily.
It is also used for extended fopen mode "c", and the places where we
turn it on temporarily often want to do a whole string of printfs.
What would make sense is _IO_acquire_lock_disable_cancellation, but
this patch series is already quite long enough, and if we were going
to do that we should probably also make it easier to write to a stream
whose narrow/wide orientation is unknown.)

zw

-- 
Zack Weinberg (9):
  Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl.
  Add __vfscanf_internal and __vfwscanf_internal with flags arguments.
  Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD.
  Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl.
  Add __v*printf_internal with flags arguments.
  Add __vsyslog_internal, with same flags as __v*printf_internal.
  Use PRINTF_FORTIFY instead of _IO_FLAGS2_FORTIFY.
  Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl.
  Post-cleanup: don't include math.h/math_private.h in math_ldbl_opt.h.

 argp/argp-fmtstream.c                              |    1 -
 argp/argp-help.c                                   |    4 +-
 argp/argp-namefrob.h                               |    2 +
 debug/Makefile                                     |    2 +-
 debug/asprintf_chk.c                               |   20 +-
 debug/dprintf_chk.c                                |   20 +-
 debug/fprintf_chk.c                                |   20 +-
 debug/fwprintf_chk.c                               |   20 +-
 debug/obprintf_chk.c                               |   96 +-
 debug/printf_chk.c                                 |   20 +-
 debug/snprintf_chk.c                               |   24 +-
 debug/sprintf_chk.c                                |   25 +-
 debug/swprintf_chk.c                               |   27 +-
 debug/vasprintf_chk.c                              |   68 +-
 debug/vdprintf_chk.c                               |   37 +-
 debug/vfprintf_chk.c                               |   21 +-
 debug/vfwprintf_chk.c                              |   21 +-
 debug/vobprintf_chk.c                              |   32 +
 debug/vprintf_chk.c                                |   20 +-
 debug/vsnprintf_chk.c                              |   46 +-
 debug/vsprintf_chk.c                               |   69 +-
 debug/vswprintf_chk.c                              |   51 +-
 debug/vwprintf_chk.c                               |   21 +-
 debug/wprintf_chk.c                                |   21 +-
 hurd/vpprintf.c                                    |    2 +-
 include/monetary.h                                 |   10 +-
 include/stdio.h                                    |    9 +-
 include/sys/syslog.h                               |   15 +-
 include/wchar.h                                    |    2 -
 libio/fwprintf.c                                   |    2 +-
 libio/iolibio.h                                    |    7 -
 libio/iovdprintf.c                                 |   13 +-
 libio/iovsprintf.c                                 |   66 +-
 libio/iovsscanf.c                                  |   12 +-
 libio/iovswscanf.c                                 |   14 +-
 libio/libio.h                                      |    6 -
 libio/libioP.h                                     |   65 +-
 libio/obprintf.c                                   |   19 +-
 libio/strfile.h                                    |   33 +-
 libio/swprintf.c                                   |    2 +-
 libio/swscanf.c                                    |   10 +-
 libio/vasprintf.c                                  |   20 +-
 libio/vscanf.c                                     |    2 +-
 libio/vsnprintf.c                                  |   17 +-
 libio/vswprintf.c                                  |   16 +-
 libio/vwprintf.c                                   |    2 +-
 libio/vwscanf.c                                    |    2 +-
 libio/wprintf.c                                    |    2 +-
 libio/wscanf.c                                     |    2 +-
 manual/locale.texi                                 |    9 +-
 misc/syslog.c                                      |   35 +-
 stdio-common/Makefile                              |    4 +-
 stdio-common/Versions                              |    3 +
 stdio-common/asprintf.c                            |    7 +-
 stdio-common/dprintf.c                             |    5 +-
 stdio-common/fprintf.c                             |    2 +-
 stdio-common/fxprintf.c                            |    4 +-
 stdio-common/iovfscanf.c                           |   34 +
 stdio-common/iovfwscanf.c                          |   34 +
 stdio-common/isoc99_fscanf.c                       |    6 +-
 stdio-common/isoc99_scanf.c                        |   13 +-
 stdio-common/isoc99_sscanf.c                       |    7 +-
 stdio-common/isoc99_vfscanf.c                      |    8 +-
 stdio-common/isoc99_vscanf.c                       |    8 +-
 stdio-common/isoc99_vsscanf.c                      |   16 +-
 stdio-common/printf.c                              |    3 +-
 stdio-common/scanf.c                               |    2 +-
 stdio-common/snprintf.c                            |    4 +-
 stdio-common/sprintf.c                             |    4 +-
 stdio-common/sscanf.c                              |   12 +-
 stdio-common/vfprintf-internal.c                   | 2360 +++++++++++++++
 stdio-common/vfprintf.c                            | 2351 +--------------
 stdio-common/vfscanf-internal.c                    | 3043 ++++++++++++++++++++
 stdio-common/vfscanf.c                             | 3041 +------------------
 stdio-common/vfwprintf-internal.c                  |    2 +
 stdio-common/vfwprintf.c                           |   28 +-
 stdio-common/vfwscanf-internal.c                   |    2 +
 stdio-common/vfwscanf.c                            |   27 +-
 stdio-common/vprintf.c                             |    4 +-
 stdlib/strfmon.c                                   |    3 +-
 stdlib/strfmon_l.c                                 |    8 +-
 stdlib/strfrom-skeleton.c                          |    2 +-
 sysdeps/generic/math_ldbl_opt.h                    |    5 +-
 sysdeps/generic/stdio-lock.h                       |    7 -
 sysdeps/ieee754/ldbl-128ibm/s_ceill.c              |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_floorl.c             |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_llrintl.c            |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_llroundl.c           |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_lrintl.c             |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_lroundl.c            |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_rintl.c              |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_roundl.c             |    1 +
 sysdeps/ieee754/ldbl-128ibm/s_truncl.c             |    1 +
 sysdeps/ieee754/ldbl-opt/Makefile                  |    2 +-
 sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h           |   14 +-
 sysdeps/ieee754/ldbl-opt/nldbl-compat.c            |  764 ++---
 sysdeps/ieee754/ldbl-opt/nldbl-compat.h            |    8 +-
 sysdeps/nptl/stdio-lock.h                          |    7 -
 sysdeps/powerpc/power7/fpu/s_logb.c                |    2 +
 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c   |    1 +
 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c  |    1 +
 sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c |    1 +
 wcsmbs/isoc99_fwscanf.c                            |    6 +-
 wcsmbs/isoc99_swscanf.c                            |   11 +-
 wcsmbs/isoc99_vfwscanf.c                           |    8 +-
 wcsmbs/isoc99_vswscanf.c                           |   15 +-
 wcsmbs/isoc99_vwscanf.c                            |    8 +-
 wcsmbs/isoc99_wscanf.c                             |    6 +-
 108 files changed, 6445 insertions(+), 6559 deletions(-)
 create mode 100644 debug/vobprintf_chk.c
 create mode 100644 stdio-common/iovfscanf.c
 create mode 100644 stdio-common/iovfwscanf.c
 create mode 100644 stdio-common/vfprintf-internal.c
 create mode 100644 stdio-common/vfscanf-internal.c
 create mode 100644 stdio-common/vfwprintf-internal.c
 create mode 100644 stdio-common/vfwscanf-internal.c

-- 
2.16.2

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2018-06-29 14:29 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 19:32 [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-07 19:32 ` [PATCH 6/9] Add __vsyslog_internal, with same flags as __v*printf_internal Zack Weinberg
2018-03-13 11:59   ` Florian Weimer
2018-03-13 12:39     ` Zack Weinberg
2018-03-13 12:43       ` Florian Weimer
2018-03-13 13:37         ` Zack Weinberg
2018-03-13 13:50           ` Florian Weimer
2018-03-13 14:11             ` Zack Weinberg
2018-03-13 14:13               ` Florian Weimer
2018-03-07 19:32 ` [PATCH 5/9] Add __v*printf_internal with flags arguments Zack Weinberg
2018-03-26 15:41   ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 1/9] Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-12 20:36   ` Adhemerval Zanella
2018-03-12 21:11     ` Zack Weinberg
2018-03-13 11:45       ` Adhemerval Zanella
2018-03-26 15:17   ` Gabriel F. T. Gomes
2018-03-26 15:40     ` Zack Weinberg
2018-03-26 15:52       ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 2/9] Add __vfscanf_internal and __vfwscanf_internal with flags arguments Zack Weinberg
2018-03-13 12:35   ` Adhemerval Zanella
2018-06-29 14:04     ` Florian Weimer
2018-03-26 15:28   ` Gabriel F. T. Gomes
2018-06-29 14:12     ` Florian Weimer
2018-06-29 14:24   ` Florian Weimer
2018-06-29 14:29   ` Florian Weimer
2018-03-07 19:32 ` [PATCH 4/9] Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-14 12:22   ` Florian Weimer
2018-03-26 15:36   ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 8/9] Use PRINTF_LDBL_IS_DBL " Zack Weinberg
2018-03-07 19:32 ` [PATCH 3/9] Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD Zack Weinberg
2018-03-26 15:35   ` Gabriel F. T. Gomes
2018-03-07 19:51 ` [PATCH 7/9] Use PRINTF_FORTIFY instead of _IO_FLAGS2_FORTIFY Zack Weinberg
2018-03-07 19:51 ` [PATCH 9/9] Post-cleanup: don't include math.h/math_private.h in math_ldbl_opt.h Zack Weinberg
2018-03-12 15:29 ` [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-26 15:16 ` Gabriel F. T. Gomes
2018-03-26 15:47   ` Zack Weinberg
2018-06-27 15:50 ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).