public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-03-16 18:04 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-03-16 18:04 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=588fe628c0f67a18bb57c244cc630b39191607f1

commit 588fe628c0f67a18bb57c244cc630b39191607f1
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 421eb1f2af..1128c10121 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -274,13 +274,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 737863e2d1..010bbed68b 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-06-09 21:20 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 21:20 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2d3de9516241e8bd101a2e0f29ca0322c19e83c0

commit 2d3de9516241e8bd101a2e0f29ca0322c19e83c0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 561c9b14bb..8ae96b99c4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -275,13 +275,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index e3fc513de1..4b3eae8284 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-06-09 13:17 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 13:17 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2d3de9516241e8bd101a2e0f29ca0322c19e83c0

commit 2d3de9516241e8bd101a2e0f29ca0322c19e83c0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 561c9b14bb..8ae96b99c4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -275,13 +275,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index e3fc513de1..4b3eae8284 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-06-03 14:06 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-06-03 14:06 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8da4d2aa0e3837a6aca7d0faf04e2e838e547b6a

commit 8da4d2aa0e3837a6aca7d0faf04e2e838e547b6a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 561c9b14bb..8ae96b99c4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -275,13 +275,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index e3fc513de1..4b3eae8284 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-05-13 14:20 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-05-13 14:20 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=633f4264168a362bcbdb03b550b17f2ff35022a2

commit 633f4264168a362bcbdb03b550b17f2ff35022a2
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 561c9b14bb..8ae96b99c4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -275,13 +275,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-05-12 19:34 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 19:34 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2a482fea1e3b1977605ba06f864889ae2ef04276

commit 2a482fea1e3b1977605ba06f864889ae2ef04276
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 561c9b14bb..8ae96b99c4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -275,13 +275,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-05-10 18:24 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-05-10 18:24 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=79c6384970f1d8cbecae254edc807cebf568477a

commit 79c6384970f1d8cbecae254edc807cebf568477a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 561c9b14bb..8ae96b99c4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -275,13 +275,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-04-29 14:04 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-04-29 14:04 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a1b26d4aba5bb419f921028c467d80c9ecc23bc9

commit a1b26d4aba5bb419f921028c467d80c9ecc23bc9
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 561c9b14bb..8ae96b99c4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -275,13 +275,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-04-04 12:54 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-04-04 12:54 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8d2ef196efac6f2e7e12d6a5a1b1aa1a3c9bf321

commit 8d2ef196efac6f2e7e12d6a5a1b1aa1a3c9bf321
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 421eb1f2af..1128c10121 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -274,13 +274,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-03-31 19:07 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-03-31 19:07 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b5468a3c2f3944b09fdf71b55d7307c3c002b99f

commit b5468a3c2f3944b09fdf71b55d7307c3c002b99f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 421eb1f2af..1128c10121 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -274,13 +274,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-03-29 20:30 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-03-29 20:30 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=de0ebfdda62473d7a46afc0e40346840ef17b322

commit de0ebfdda62473d7a46afc0e40346840ef17b322
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 421eb1f2af..1128c10121 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -274,13 +274,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 41c18be789..289a5511b6 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

* [glibc/azanella/clang] libio: Refactor internal aliases
@ 2022-03-15 18:42 Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2022-03-15 18:42 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6a3aeba71a577182b23773b613fc2ba8f9f3ef3d

commit 6a3aeba71a577182b23773b613fc2ba8f9f3ef3d
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Mon Mar 14 18:15:36 2022 -0300

    libio: Refactor internal aliases

Diff:
---
 argp/argp-fmtstream.c |  1 +
 argp/argp-help.c      |  1 +
 grp/putgrent.c        |  2 +-
 gshadow/putsgent.c    |  4 ++--
 include/stdio.h       | 10 ++++++++--
 inet/ruserpass.c      | 10 +++++-----
 libio/__fpurge.c      |  2 +-
 libio/fileops.c       |  4 ++--
 libio/genops.c        | 17 ++++++++++-------
 libio/iogetdelim.c    |  4 ++--
 libio/iogetline.c     |  2 +-
 libio/ioseekoff.c     |  2 +-
 libio/ioseekpos.c     |  2 +-
 libio/libio.h         | 41 ++++++++++++++++++++---------------------
 libio/oldfileops.c    |  2 +-
 libio/putc.c          |  1 -
 libio/wfileops.c      |  4 ++--
 libio/wgenops.c       | 11 ++++++-----
 shadow/putspent.c     | 14 +++++++-------
 19 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 2f74bde2ab..c220adfd41 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -42,6 +42,7 @@
 #ifdef _LIBC
 # include <wchar.h>
 # include <libio/libioP.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index f128313e06..bfaffa215a 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -51,6 +51,7 @@ char *alloca ();
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# define putc_unlocked(__c, __f) __putc_unlocked (__c, __f)
 #endif
 
 #ifndef _
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 305ff44359..c16c08f97a 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -68,7 +68,7 @@ putgrent (const struct group *gr, FILE *stream)
 	  }
     }
 
-  retval = fputc_unlocked ('\n', stream);
+  retval = __fputc_unlocked ('\n', stream);
 
   funlockfile (stream);
 
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 870438de6d..e0ae418114 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -57,7 +57,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked (':', stream) == EOF)
+  if (__putc_unlocked (':', stream) == EOF)
     ++errors;
 
   first = true;
@@ -72,7 +72,7 @@ putsgent (const struct sgrp *g, FILE *stream)
 	  }
 	first = false;
       }
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   _IO_funlockfile (stream);
diff --git a/include/stdio.h b/include/stdio.h
index 421eb1f2af..1128c10121 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -274,13 +274,19 @@ __ferror_unlocked (FILE *__stream)
 static inline int
 __getc_unlocked (FILE *__fp)
 {
-  return __getc_unlocked_body (__fp);
+  return _IO_getc_unlocked (__fp);
 }
 
 static inline int
 __putc_unlocked (int __c, FILE *__stream)
 {
-  return __putc_unlocked_body (__c, __stream);
+  return _IO_putc_unlocked (__c, __stream);
+}
+
+static inline int
+__fputc_unlocked (int __c, FILE *__stream)
+{
+  return _IO_putc_unlocked (__c, __stream);
 }
 
 extern __typeof (renameat) __renameat;
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 742aa0cfa0..def63acac0 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -219,24 +219,24 @@ token (void)
 
 	if (feof_unlocked(cfile) || ferror_unlocked(cfile))
 		return (0);
-	while ((c = getc_unlocked(cfile)) != EOF &&
+	while ((c = __getc_unlocked(cfile)) != EOF &&
 	    (c == '\n' || c == '\t' || c == ' ' || c == ','))
 		continue;
 	if (c == EOF)
 		return (0);
 	cp = tokval;
 	if (c == '"') {
-		while ((c = getc_unlocked(cfile)) != EOF && c != '"') {
+		while ((c = __getc_unlocked(cfile)) != EOF && c != '"') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	} else {
 		*cp++ = c;
-		while ((c = getc_unlocked(cfile)) != EOF
+		while ((c = __getc_unlocked(cfile)) != EOF
 		    && c != '\n' && c != '\t' && c != ' ' && c != ',') {
 			if (c == '\\')
-				c = getc_unlocked(cfile);
+				c = __getc_unlocked(cfile);
 			*cp++ = c;
 		}
 	}
diff --git a/libio/__fpurge.c b/libio/__fpurge.c
index aa73ef2f7f..d012feeb43 100644
--- a/libio/__fpurge.c
+++ b/libio/__fpurge.c
@@ -25,7 +25,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
diff --git a/libio/fileops.c b/libio/fileops.c
index 737863e2d1..010bbed68b 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -145,7 +145,7 @@ _IO_new_file_close_it (FILE *fp)
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
       _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
@@ -1318,7 +1318,7 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
 	  if (fp->_IO_buf_base
 	      && want < (size_t) (fp->_IO_buf_end - fp->_IO_buf_base))
 	    {
-	      if (__underflow (fp) == EOF)
+	      if (__libc_underflow (fp) == EOF)
 		break;
 
 	      continue;
diff --git a/libio/genops.c b/libio/genops.c
index 1b629eb695..48c202d010 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -195,14 +195,15 @@ _IO_free_backup_area (FILE *fp)
 libc_hidden_def (_IO_free_backup_area)
 
 int
-__overflow (FILE *f, int ch)
+__libc_overflow (FILE *f, int ch)
 {
   /* This is a single-byte stream.  */
   if (f->_mode == 0)
     _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def (__overflow)
+libc_hidden_def (__libc_overflow)
+strong_alias (__libc_overflow, __overflow)
 
 static int
 save_for_backup (FILE *fp, char *end_p)
@@ -265,7 +266,7 @@ save_for_backup (FILE *fp, char *end_p)
 }
 
 int
-__underflow (FILE *fp)
+__libc_underflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -292,10 +293,11 @@ __underflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def (__underflow)
+libc_hidden_def (__libc_underflow)
+strong_alias (__libc_underflow, __underflow)
 
 int
-__uflow (FILE *fp)
+__libc_uflow (FILE *fp)
 {
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
@@ -322,7 +324,8 @@ __uflow (FILE *fp)
     _IO_free_backup_area (fp);
   return _IO_UFLOW (fp);
 }
-libc_hidden_def (__uflow)
+libc_hidden_def (__libc_uflow)
+strong_alias (__libc_uflow, __uflow)
 
 void
 _IO_setb (FILE *f, char *b, char *eb, int a)
@@ -440,7 +443,7 @@ _IO_default_xsgetn (FILE *fp, void *data, size_t n)
 	    }
 	    more -= count;
 	}
-      if (more == 0 || __underflow (fp) == EOF)
+      if (more == 0 || __libc_underflow (fp) == EOF)
 	break;
     }
   return n - more;
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index d24cb07e50..44a0b7538d 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -70,7 +70,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
   len = fp->_IO_read_end - fp->_IO_read_ptr;
   if (len <= 0)
     {
-      if (__underflow (fp) == EOF)
+      if (__libc_underflow (fp) == EOF)
 	{
 	  result = -1;
 	  goto unlock_return;
@@ -111,7 +111,7 @@ __libc_getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
       memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
       fp->_IO_read_ptr += len;
       cur_len += len;
-      if (t != NULL || __underflow (fp) == EOF)
+      if (t != NULL || __libc_underflow (fp) == EOF)
 	break;
       len = fp->_IO_read_end - fp->_IO_read_ptr;
     }
diff --git a/libio/iogetline.c b/libio/iogetline.c
index f5c3ec38f7..f937773e08 100644
--- a/libio/iogetline.c
+++ b/libio/iogetline.c
@@ -57,7 +57,7 @@ _IO_getline_info (FILE *fp, char *buf, size_t n, int delim,
       ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
       if (len <= 0)
 	{
-	  int c = __uflow (fp);
+	  int c = __libc_uflow (fp);
 	  if (c == EOF)
 	    {
 	      if (eof)
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 6c077cdfd8..946732295b 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -53,7 +53,7 @@ _IO_seekoff_unlocked (FILE *fp, off64_t offset, int dir, int mode)
       if (_IO_fwide (fp, 0) < 0)
 	_IO_free_backup_area (fp);
       else
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 31d70fc255..5e241157af 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -40,7 +40,7 @@ _IO_seekpos_unlocked (FILE *fp, off64_t pos, int mode)
   else
     {
       if (_IO_have_wbackup (fp))
-	_IO_free_wbackup_area (fp);
+	__libc_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, pos, 0, mode);
diff --git a/libio/libio.h b/libio/libio.h
index b0c1c8c3a8..cb3754fab3 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -156,17 +156,27 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 			     void *__cookie, cookie_io_functions_t __fns);
 
 extern int __underflow (FILE *);
-extern wint_t __wunderflow (FILE *);
-extern wint_t __wuflow (FILE *);
-extern wint_t __woverflow (FILE *, wint_t);
+hidden_proto2 (__underflow, __libc_underflow)
+extern wint_t hidden_proto3 (__wunderflow, (FILE *));
+extern wint_t hidden_proto3 (__wuflow, (FILE *));
+extern wint_t hidden_proto3 (__woverflow, (FILE *, wint_t));
+
+hidden_proto2 (__overflow, __libc_overflow)
+hidden_proto2 (__uflow, __libc_uflow)
+
+#define _IO_getc_unlocked(_fp)						\
+  (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)        \
+   ? __libc_uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 
-#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
 #define _IO_peekc_unlocked(_fp)						\
   (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end)	\
-   && __underflow (_fp) == EOF						\
+   && __libc_underflow (_fp) == EOF						\
    ? EOF								\
    : *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
+#define _IO_putc_unlocked(_ch, _fp)					\
+  (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end)	\
+      ? __libc_overflow (_fp, (unsigned char) (_ch))			\
+         : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
 # define _IO_getwc_unlocked(_fp)					\
   (__glibc_unlikely ((_fp)->_wide_data == NULL				\
@@ -214,13 +224,13 @@ extern int _IO_ftrylockfile (FILE *) __THROW;
 
 extern int _IO_vfscanf (FILE * __restrict, const char * __restrict,
 			__gnuc_va_list, int *__restrict);
-extern __ssize_t _IO_padn (FILE *, int, __ssize_t);
-extern size_t _IO_sgetn (FILE *, void *, size_t);
+extern __ssize_t hidden_proto3 (_IO_padn, (FILE *, int, __ssize_t));
+extern size_t hidden_proto3 (_IO_sgetn, (FILE *, void *, size_t));
 
 extern off64_t _IO_seekoff (FILE *, off64_t, int, int);
 extern off64_t _IO_seekpos (FILE *, off64_t, int);
 
-extern void _IO_free_backup_area (FILE *) __THROW;
+extern void hidden_proto3 (_IO_free_backup_area, (FILE *)) __THROW;
 
 
 extern wint_t _IO_getwc (FILE *__fp);
@@ -255,6 +265,7 @@ weak_extern (_IO_stdin_used);
 
 extern __ssize_t _IO_wpadn (FILE *, wint_t, __ssize_t);
 extern void _IO_free_wbackup_area (FILE *) __THROW;
+hidden_proto2 (_IO_free_wbackup_area, __libc_IO_free_wbackup_area)
 
 #ifdef __LDBL_COMPAT
 extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
@@ -262,18 +273,6 @@ extern int __REDIRECT_LDBL_COMPAT (_IO_vfscanf, (FILE * __restrict,
 						 __gnuc_va_list, int *__restrict));
 #endif
 
-libc_hidden_proto (__overflow)
-libc_hidden_proto (__underflow)
-libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-
 #ifdef _IO_MTSAFE_IO
 # undef _IO_peekc
 # undef _IO_flockfile
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ea3b864447..ceb5ea3125 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -691,7 +691,7 @@ _IO_old_file_xsputn (FILE *f, const void *data, size_t n)
     {
       size_t block_size, do_write;
       /* Next flush the (full) buffer. */
-      if (__overflow (f, EOF) == EOF)
+      if (__libc_overflow (f, EOF) == EOF)
 	return to_do == 0 ? EOF : n - to_do;
 
       /* Try to maintain alignment: write a whole number of blocks.
diff --git a/libio/putc.c b/libio/putc.c
index 7036c5b6bb..075e9d054d 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -32,7 +32,6 @@ _IO_putc (int c, FILE *fp)
   _IO_release_lock (fp);
   return result;
 }
-libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/libio/wfileops.c b/libio/wfileops.c
index b59a98881f..b73b00ba3a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -419,7 +419,7 @@ _IO_wfile_overflow (FILE *f, wint_t wch)
       if (f->_wide_data->_IO_write_base == 0)
 	{
 	  _IO_wdoallocbuf (f);
-	  _IO_free_wbackup_area (f);
+	  __libc_IO_free_wbackup_area (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
@@ -850,7 +850,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
       }
     }
 
-  _IO_free_wbackup_area (fp);
+  __libc_IO_free_wbackup_area (fp);
 
   /* At this point, dir==_IO_seek_set. */
 
diff --git a/libio/wgenops.c b/libio/wgenops.c
index e7ea75aed2..f4b80d1c8e 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -242,7 +242,7 @@ __wuflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -272,7 +272,7 @@ __wunderflow (FILE *fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -412,7 +412,7 @@ _IO_switch_to_wget_mode (FILE *fp)
 libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
-_IO_free_wbackup_area (FILE *fp)
+__libc_IO_free_wbackup_area (FILE *fp)
 {
   if (_IO_in_backup (fp))
     _IO_switch_to_main_wget_area (fp);  /* Just in case. */
@@ -421,7 +421,8 @@ _IO_free_wbackup_area (FILE *fp)
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-libc_hidden_def (_IO_free_wbackup_area)
+libc_hidden_def (__libc_IO_free_wbackup_area)
+strong_alias (__libc_IO_free_wbackup_area, _IO_free_wbackup_area)
 
 static int
 save_for_wbackup (FILE *fp, wchar_t *end_p)
@@ -605,5 +606,5 @@ _IO_unsave_wmarkers (FILE *fp)
     }
 
   if (_IO_have_backup (fp))
-    _IO_free_wbackup_area (fp);
+    __libc_IO_free_wbackup_area (fp);
 }
diff --git a/shadow/putspent.c b/shadow/putspent.c
index d675e28210..f58b958965 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -48,44 +48,44 @@ putspent (const struct spwd *p, FILE *stream)
   if ((p->sp_lstchg != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_lstchg) < 0)
       || (p->sp_lstchg == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_min != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_min) < 0)
       || (p->sp_min == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_max != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_max) < 0)
       || (p->sp_max == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_warn != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_warn) < 0)
       || (p->sp_warn == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_inact != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_inact) < 0)
       || (p->sp_inact == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if ((p->sp_expire != (long int) -1
        && __fprintf (stream, "%ld:", p->sp_expire) < 0)
       || (p->sp_expire == (long int) -1
-	  && putc_unlocked (':', stream) == EOF))
+	  && __putc_unlocked (':', stream) == EOF))
     ++errors;
 
   if (p->sp_flag != ~0ul
       && __fprintf (stream, "%ld", p->sp_flag) < 0)
     ++errors;
 
-  if (putc_unlocked ('\n', stream) == EOF)
+  if (__putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
   funlockfile (stream);


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

end of thread, other threads:[~2022-06-09 21:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 18:04 [glibc/azanella/clang] libio: Refactor internal aliases Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2022-06-09 21:20 Adhemerval Zanella
2022-06-09 13:17 Adhemerval Zanella
2022-06-03 14:06 Adhemerval Zanella
2022-05-13 14:20 Adhemerval Zanella
2022-05-12 19:34 Adhemerval Zanella
2022-05-10 18:24 Adhemerval Zanella
2022-04-29 14:04 Adhemerval Zanella
2022-04-04 12:54 Adhemerval Zanella
2022-03-31 19:07 Adhemerval Zanella
2022-03-29 20:30 Adhemerval Zanella
2022-03-15 18:42 Adhemerval Zanella

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).