mirror of
				https://sourceware.org/git/glibc.git
				synced 2025-10-30 10:45:40 +03:00 
			
		
		
		
	This patch mechanically removes all remaining uses, and the definitions, of the following libio name aliases: name replaced with ---- ------------- _IO_FILE FILE _IO_fpos_t __fpos_t _IO_fpos64_t __fpos64_t _IO_size_t size_t _IO_ssize_t ssize_t or __ssize_t _IO_off_t off_t _IO_off64_t off64_t _IO_pid_t pid_t _IO_uid_t uid_t _IO_wint_t wint_t _IO_va_list va_list or __gnuc_va_list _IO_BUFSIZ BUFSIZ _IO_cookie_io_functions_t cookie_io_functions_t __io_read_fn cookie_read_function_t __io_write_fn cookie_write_function_t __io_seek_fn cookie_seek_function_t __io_close_fn cookie_close_function_t I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because the definitions of fpos_t and fpos64_t depend on the largefile mode. I used __ssize_t and __gnuc_va_list in a handful of headers where namespace cleanliness might be relevant even though they're internal-use-only. In all other cases, I used the public-namespace name. There are a tiny handful of places where I left a use of 'struct _IO_FILE' alone, because it was being used together with 'struct _IO_FILE_plus' or 'struct _IO_FILE_complete' in the same arithmetic expression. Because this patch was almost entirely done with search and replace, I may have introduced indentation botches. I did proofread the diff, but I may have missed something. The ChangeLog below calls out all of the places where this was not a pure search-and-replace change. Installed stripped libraries and executables are unchanged by this patch, except that some assertions in vfscanf.c change line numbers. * libio/libio.h (_IO_FILE): Delete; all uses changed to FILE. (_IO_fpos_t): Delete; all uses changed to __fpos_t. (_IO_fpos64_t): Delete; all uses changed to __fpos64_t. (_IO_size_t): Delete; all uses changed to size_t. (_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t. (_IO_off_t): Delete; all uses changed to off_t. (_IO_off64_t): Delete; all uses changed to off64_t. (_IO_pid_t): Delete; all uses changed to pid_t. (_IO_uid_t): Delete; all uses changed to uid_t. (_IO_wint_t): Delete; all uses changed to wint_t. (_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list. (_IO_BUFSIZ): Delete; all uses changed to BUFSIZ. (_IO_cookie_io_functions_t): Delete; all uses changed to cookie_io_functions_t. (__io_read_fn): Delete; all uses changed to cookie_read_function_t. (__io_write_fn): Delete; all uses changed to cookie_write_function_t. (__io_seek_fn): Delete; all uses changed to cookie_seek_function_t. (__io_close_fn): Delete: all uses changed to cookie_close_function_t. * libio/iofopncook.c: Remove unnecessary forward declarations. * libio/iolibio.h: Correct outdated commentary. * malloc/malloc.c (__malloc_stats): Remove unnecessary casts. * stdio-common/fxprintf.c (__fxprintf_nocancel): Remove unnecessary casts. * stdio-common/getline.c: Use _IO_getdelim directly. Don't redefine ssize_t. * stdio-common/printf_fp.c, stdio_common/printf_fphex.c * stdio-common/printf_size.c: Don't redefine size_t or FILE. Remove outdated comments. * stdio-common/vfscanf.c: Don't redefine va_list.
		
			
				
	
	
		
			231 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			231 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* Print size value using units for orders of magnitude.
 | ||
|    Copyright (C) 1997-2018 Free Software Foundation, Inc.
 | ||
|    This file is part of the GNU C Library.
 | ||
|    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 | ||
|    Based on a proposal by Larry McVoy <lm@sgi.com>.
 | ||
| 
 | ||
|    The GNU C Library is free software; you can redistribute it and/or
 | ||
|    modify it under the terms of the GNU Lesser General Public
 | ||
|    License as published by the Free Software Foundation; either
 | ||
|    version 2.1 of the License, or (at your option) any later version.
 | ||
| 
 | ||
|    The GNU C Library is distributed in the hope that it will be useful,
 | ||
|    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | ||
|    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | ||
|    Lesser General Public License for more details.
 | ||
| 
 | ||
|    You should have received a copy of the GNU Lesser General Public
 | ||
|    License along with the GNU C Library; if not, see
 | ||
|    <http://www.gnu.org/licenses/>.  */
 | ||
| 
 | ||
| #include <ctype.h>
 | ||
| #include <ieee754.h>
 | ||
| #include <math.h>
 | ||
| #include <printf.h>
 | ||
| #include <libioP.h>
 | ||
| 
 | ||
| #define PUT(f, s, n) _IO_sputn (f, s, n)
 | ||
| #define PAD(f, c, n) (wide ? _IO_wpadn (f, c, n) : _IO_padn (f, c, n))
 | ||
| #undef putc
 | ||
| #define putc(c, f) (wide \
 | ||
| 		    ? (int)_IO_putwc_unlocked (c, f) : _IO_putc_unlocked (c, f))
 | ||
| 
 | ||
| 
 | ||
| /* Macros for doing the actual output.  */
 | ||
| 
 | ||
| #define outchar(ch)							      \
 | ||
|   do									      \
 | ||
|     {									      \
 | ||
|       const int outc = (ch);						      \
 | ||
|       if (putc (outc, fp) == EOF)					      \
 | ||
| 	return -1;							      \
 | ||
|       ++done;								      \
 | ||
|     } while (0)
 | ||
| 
 | ||
| #define PRINT(ptr, wptr, len)						      \
 | ||
|   do									      \
 | ||
|     {									      \
 | ||
|       size_t outlen = (len);						      \
 | ||
|       if (len > 20)							      \
 | ||
| 	{								      \
 | ||
| 	  if (PUT (fp, wide ? (const char *) wptr : ptr, outlen) != outlen)   \
 | ||
| 	    return -1;							      \
 | ||
| 	  ptr += outlen;						      \
 | ||
| 	  done += outlen;						      \
 | ||
| 	}								      \
 | ||
|       else								      \
 | ||
| 	{								      \
 | ||
| 	  if (wide)							      \
 | ||
| 	    while (outlen-- > 0)					      \
 | ||
| 	      outchar (*wptr++);					      \
 | ||
| 	  else								      \
 | ||
| 	    while (outlen-- > 0)					      \
 | ||
| 	      outchar (*ptr++);						      \
 | ||
| 	}								      \
 | ||
|     } while (0)
 | ||
| 
 | ||
| #define PADN(ch, len)							      \
 | ||
|   do									      \
 | ||
|     {									      \
 | ||
|       if (PAD (fp, ch, len) != len)					      \
 | ||
| 	return -1;							      \
 | ||
|       done += len;							      \
 | ||
|     }									      \
 | ||
|   while (0)
 | ||
| 
 | ||
| /* Prototype for helper functions.  */
 | ||
| extern int __printf_fp (FILE *fp, const struct printf_info *info,
 | ||
| 			const void *const *args);
 | ||
| 
 | ||
| 
 | ||
| int
 | ||
| __printf_size (FILE *fp, const struct printf_info *info,
 | ||
| 	       const void *const *args)
 | ||
| {
 | ||
|   /* Units for the both formats.  */
 | ||
| #define BINARY_UNITS	" kmgtpezy"
 | ||
| #define DECIMAL_UNITS	" KMGTPEZY"
 | ||
|   static const char units[2][sizeof (BINARY_UNITS)] =
 | ||
|   {
 | ||
|     BINARY_UNITS,	/* For binary format.  */
 | ||
|     DECIMAL_UNITS	/* For decimal format.  */
 | ||
|   };
 | ||
|   const char *tag = units[isupper (info->spec) != 0];
 | ||
|   int divisor = isupper (info->spec) ? 1000 : 1024;
 | ||
| 
 | ||
|   /* The floating-point value to output.  */
 | ||
|   union
 | ||
|     {
 | ||
|       union ieee754_double dbl;
 | ||
|       long double ldbl;
 | ||
| #if __HAVE_DISTINCT_FLOAT128
 | ||
|       _Float128 f128;
 | ||
| #endif
 | ||
|     }
 | ||
|   fpnum;
 | ||
|   const void *ptr = &fpnum;
 | ||
| 
 | ||
|   int is_neg = 0;
 | ||
| 
 | ||
|   /* "NaN" or "Inf" for the special cases.  */
 | ||
|   const char *special = NULL;
 | ||
|   const wchar_t *wspecial = NULL;
 | ||
| 
 | ||
|   struct printf_info fp_info;
 | ||
|   int done = 0;
 | ||
|   int wide = info->wide;
 | ||
| 
 | ||
| #define PRINTF_SIZE_FETCH(FLOAT, VAR)					\
 | ||
|   {									\
 | ||
|     (VAR) = *(const FLOAT *) args[0];					\
 | ||
| 									\
 | ||
|     /* Check for special values: not a number or infinity.  */		\
 | ||
|     if (isnan (VAR))							\
 | ||
|       {									\
 | ||
| 	special = "nan";						\
 | ||
| 	wspecial = L"nan";						\
 | ||
| 	/* is_neg = 0; Already zero */					\
 | ||
|       }									\
 | ||
|     else if (isinf (VAR))						\
 | ||
|       {									\
 | ||
| 	is_neg = signbit (VAR);						\
 | ||
| 	special = "inf";						\
 | ||
| 	wspecial = L"inf";						\
 | ||
|       }									\
 | ||
|     else								\
 | ||
|       while ((VAR) >= divisor && tag[1] != '\0')			\
 | ||
| 	{								\
 | ||
| 	  (VAR) /= divisor;						\
 | ||
| 	  ++tag;							\
 | ||
| 	}								\
 | ||
|   }
 | ||
| 
 | ||
|   /* Fetch the argument value.	*/
 | ||
| #if __HAVE_DISTINCT_FLOAT128
 | ||
|   if (info->is_binary128)
 | ||
|     PRINTF_SIZE_FETCH (_Float128, fpnum.f128)
 | ||
|   else
 | ||
| #endif
 | ||
| #ifndef __NO_LONG_DOUBLE_MATH
 | ||
|   if (info->is_long_double && sizeof (long double) > sizeof (double))
 | ||
|     PRINTF_SIZE_FETCH (long double, fpnum.ldbl)
 | ||
|   else
 | ||
| #endif
 | ||
|     PRINTF_SIZE_FETCH (double, fpnum.dbl.d)
 | ||
| 
 | ||
| #undef PRINTF_SIZE_FETCH
 | ||
| 
 | ||
|   if (special)
 | ||
|     {
 | ||
|       int width = info->prec > info->width ? info->prec : info->width;
 | ||
| 
 | ||
|       if (is_neg || info->showsign || info->space)
 | ||
| 	--width;
 | ||
|       width -= 3;
 | ||
| 
 | ||
|       if (!info->left && width > 0)
 | ||
| 	PADN (' ', width);
 | ||
| 
 | ||
|       if (is_neg)
 | ||
| 	outchar ('-');
 | ||
|       else if (info->showsign)
 | ||
| 	outchar ('+');
 | ||
|       else if (info->space)
 | ||
| 	outchar (' ');
 | ||
| 
 | ||
|       PRINT (special, wspecial, 3);
 | ||
| 
 | ||
|       if (info->left && width > 0)
 | ||
| 	PADN (' ', width);
 | ||
| 
 | ||
|       return done;
 | ||
|     }
 | ||
| 
 | ||
|   /* Prepare to print the number.  We want to use `__printf_fp' so we
 | ||
|      have to prepare a `printf_info' structure.  */
 | ||
|   fp_info = *info;
 | ||
|   fp_info.spec = 'f';
 | ||
|   fp_info.prec = info->prec < 0 ? 3 : info->prec;
 | ||
|   fp_info.wide = wide;
 | ||
| 
 | ||
|   if (fp_info.left && fp_info.pad == L' ')
 | ||
|     {
 | ||
|       /* We must do the padding ourself since the unit character must
 | ||
| 	 be placed before the padding spaces.  */
 | ||
|       fp_info.width = 0;
 | ||
| 
 | ||
|       done = __printf_fp (fp, &fp_info, &ptr);
 | ||
|       if (done > 0)
 | ||
| 	{
 | ||
| 	  outchar (*tag);
 | ||
| 	  if (info->width > done)
 | ||
| 	    PADN (' ', info->width - done);
 | ||
| 	}
 | ||
|     }
 | ||
|   else
 | ||
|     {
 | ||
|       /* We can let __printf_fp do all the printing and just add our
 | ||
| 	 unit character afterwards.  */
 | ||
|       fp_info.width = info->width - 1;
 | ||
| 
 | ||
|       done = __printf_fp (fp, &fp_info, &ptr);
 | ||
|       if (done > 0)
 | ||
| 	outchar (*tag);
 | ||
|     }
 | ||
| 
 | ||
|   return done;
 | ||
| }
 | ||
| ldbl_strong_alias (__printf_size, printf_size);
 | ||
| 
 | ||
| /* This is the function used by `vfprintf' to determine number and
 | ||
|    type of the arguments.  */
 | ||
| int
 | ||
| printf_size_info (const struct printf_info *info, size_t n, int *argtypes)
 | ||
| {
 | ||
|   /* We need only one double or long double argument.  */
 | ||
|   if (n >= 1)
 | ||
|     argtypes[0] = PA_DOUBLE | (info->is_long_double ? PA_FLAG_LONG_DOUBLE : 0);
 | ||
| 
 | ||
|   return 1;
 | ||
| }
 |