Message ID | 48dd1f0e9d32e9a96f6c712e828efc3d5b1bb189.1517872307.git.zackw@panix.com |
---|---|
State | New |
Headers | show |
Series | Don't install libio.h or _G_config.h. | expand |
On Mon, 5 Feb 2018, Zack Weinberg wrote: > diff --git a/NEWS b/NEWS > index 3ac57eca4ee..eceab2b2be2 100644 > --- a/NEWS > +++ b/NEWS > @@ -15,6 +15,13 @@ Deprecated and removed features, and other changes affecting compatibility: > > [Add deprecations, removals and changes affecting compatibility here] > > + * The stdio.h functions 'getc' and 'putc' are no longer defined as macros. > + This was never required by the C standard, and the macros just expanded > + to call alternative names for the same functions. If you hoped getc and > + putc would provide performance improvements over fgetc and fputc, instead > + investigate using (f)getc_unlocked and (f)putc_unlocked, and, if > + necessary, flockfile and funlockfile. The "[Add deprecations, removals and changes affecting compatibility here]" placeholder should be removed by this patch, as the first one to put something in this section for 2.28. The patch is OK with that change. There is a theoretical use for implementation-namespace aliases of even C90 standard functions such as getc and putc - properly, if a function is used in a *macro* defined in a standard header, it should be used via such an alias to avoid possible shadowing of the standard function name by a block-scope variable in a scope where the macro is used (standard function names aren't generally reserved with block scope). But that doesn't affect this patch at all, since there are no such macros making use of either getc or putc (and in any case, the _IO_getc and _IO_putc function exports still exist should they prove to be of use in future, and any aliases for this issue could be defined in headers with asm redirection without needing library exports at all).
On Mon, Feb 5, 2018 at 7:01 PM, Joseph Myers <joseph@codesourcery.com> wrote: > On Mon, 5 Feb 2018, Zack Weinberg wrote: >> diff --git a/NEWS b/NEWS >> index 3ac57eca4ee..eceab2b2be2 100644 >> --- a/NEWS >> +++ b/NEWS >> @@ -15,6 +15,13 @@ Deprecated and removed features, and other changes affecting compatibility: >> >> [Add deprecations, removals and changes affecting compatibility here] >> >> + * The stdio.h functions 'getc' and 'putc' are no longer defined as macros. >> + This was never required by the C standard, and the macros just expanded >> + to call alternative names for the same functions. If you hoped getc and >> + putc would provide performance improvements over fgetc and fputc, instead >> + investigate using (f)getc_unlocked and (f)putc_unlocked, and, if >> + necessary, flockfile and funlockfile. > > The "[Add deprecations, removals and changes affecting compatibility > here]" placeholder should be removed by this patch, as the first one to > put something in this section for 2.28. Doh! That was a merge botch on my end. > The patch is OK with that change. I have made that change and pushed patches 1 and 2 of this series. Also, the full patchset is now available as git branch 'zack/no-libio-h' if anyone wants to experiment with it. zw
diff --git a/NEWS b/NEWS index 3ac57eca4ee..eceab2b2be2 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,13 @@ Deprecated and removed features, and other changes affecting compatibility: [Add deprecations, removals and changes affecting compatibility here] + * The stdio.h functions 'getc' and 'putc' are no longer defined as macros. + This was never required by the C standard, and the macros just expanded + to call alternative names for the same functions. If you hoped getc and + putc would provide performance improvements over fgetc and fputc, instead + investigate using (f)getc_unlocked and (f)putc_unlocked, and, if + necessary, flockfile and funlockfile. + Changes to build and runtime requirements: [Add changes to build and runtime requirements here] diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h index d287083de16..eb42b22153c 100644 --- a/libio/bits/stdio.h +++ b/libio/bits/stdio.h @@ -43,7 +43,7 @@ vprintf (const char *__restrict __fmt, _G_va_list __arg) __STDIO_INLINE int getchar (void) { - return _IO_getc (stdin); + return getc (stdin); } @@ -78,7 +78,7 @@ getchar_unlocked (void) __STDIO_INLINE int putchar (int __c) { - return _IO_putc (__c, stdout); + return putc (__c, stdout); } diff --git a/libio/stdio.h b/libio/stdio.h index 95bc902a82c..33de3813bbd 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -483,10 +483,6 @@ extern int getc (FILE *__stream); marked with __THROW. */ extern int getchar (void); -/* The C standard explicitly says this is a macro, so we always do the - optimization for it. */ -#define getc(_fp) _IO_getc (_fp) - #ifdef __USE_POSIX199506 /* These are defined in POSIX.1:1996. @@ -523,10 +519,6 @@ extern int putc (int __c, FILE *__stream); marked with __THROW. */ extern int putchar (int __c); -/* The C standard explicitly says this can be a macro, - so we always do the optimization for it. */ -#define putc(_ch, _fp) _IO_putc (_ch, _fp) - #ifdef __USE_MISC /* Faster version when locking is not necessary.