manual/stdio: Clarify putc and putwc

The manual entry for `putc' described what "most systems" do instead of
describing the glibc implementation and its guarantees.  This commit
fixes that by warning that putc may be implemented as a macro that
double-evaluates `stream', and removing the performance claim.

Even though the current `putc' implementation does not double-evaluate
`stream', offering this obscure guarantee as an extension to what
POSIX allows does not seem very useful.

The entry for `putwc' is also edited to bring it in line with `putc'.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
Arjun Shankar 2024-07-29 14:30:59 +02:00
parent 32328a5a14
commit 10de4a47ef
1 changed files with 6 additions and 6 deletions

View File

@ -903,21 +903,21 @@ This function is a GNU extension.
@deftypefun int putc (int @var{c}, FILE *@var{stream}) @deftypefun int putc (int @var{c}, FILE *@var{stream})
@standards{ISO, stdio.h} @standards{ISO, stdio.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{} @aculock{}}} @safety{@prelim{}@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{} @aculock{}}}
This is just like @code{fputc}, except that most systems implement it as This is just like @code{fputc}, except that it may be implemented as
a macro, making it faster. One consequence is that it may evaluate the a macro, making it faster. One consequence is that it may evaluate the
@var{stream} argument more than once, which is an exception to the @var{stream} argument more than once, which is an exception to the
general rule for macros. @code{putc} is usually the best function to general rule for macros. Therefore, @var{stream} should never be an
use for writing a single character. expression with side-effects.
@end deftypefun @end deftypefun
@deftypefun wint_t putwc (wchar_t @var{wc}, FILE *@var{stream}) @deftypefun wint_t putwc (wchar_t @var{wc}, FILE *@var{stream})
@standards{ISO, wchar.h} @standards{ISO, wchar.h}
@safety{@prelim{}@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{} @aculock{}}} @safety{@prelim{}@mtsafe{}@asunsafe{@asucorrupt{}}@acunsafe{@acucorrupt{} @aculock{}}}
This is just like @code{fputwc}, except that it can be implement as This is just like @code{fputwc}, except that it may be implemented as
a macro, making it faster. One consequence is that it may evaluate the a macro, making it faster. One consequence is that it may evaluate the
@var{stream} argument more than once, which is an exception to the @var{stream} argument more than once, which is an exception to the
general rule for macros. @code{putwc} is usually the best function to general rule for macros. Therefore, @var{stream} should never be an
use for writing a single wide character. expression with side-effects.
@end deftypefun @end deftypefun
@deftypefun int putc_unlocked (int @var{c}, FILE *@var{stream}) @deftypefun int putc_unlocked (int @var{c}, FILE *@var{stream})