Browse Source

Implement all needed hidden *printf and correct vasprintf, thx blindvt

Peter S. Mazinger 18 years ago
parent
commit
60acdef205

+ 11 - 0
libc/stdio/_stdio.h

@@ -19,6 +19,17 @@
 #include <string.h>
 #include <unistd.h>
 
+extern int __vfprintf (FILE *__restrict __s, __const char *__restrict __format,
+		     __gnuc_va_list __arg) attribute_hidden;
+
+extern int __vsnprintf (char *__restrict __s, size_t __maxlen,
+		      __const char *__restrict __format, __gnuc_va_list __arg)
+     __THROW __attribute__ ((__format__ (__printf__, 3, 0))) attribute_hidden;
+
+extern int __vfwprintf (__FILE *__restrict __s,
+		      __const wchar_t *__restrict __format,
+		      __gnuc_va_list __arg) attribute_hidden;
+
 #ifdef __UCLIBC_HAS_WCHAR__
 #include <wchar.h>
 #endif

+ 3 - 2
libc/stdio/fprintf.c

@@ -8,14 +8,15 @@
 #include "_stdio.h"
 #include <stdarg.h>
 
-int fprintf(FILE * __restrict stream, const char * __restrict format, ...)
+int attribute_hidden __fprintf(FILE * __restrict stream, const char * __restrict format, ...)
 {
 	va_list arg;
 	int rv;
 
 	va_start(arg, format);
-	rv = vfprintf(stream, format, arg);
+	rv = __vfprintf(stream, format, arg);
 	va_end(arg);
 
 	return rv;
 }
+strong_alias(__fprintf,fprintf)

+ 2 - 1
libc/stdio/old_vfprintf.c

@@ -341,7 +341,7 @@ static const char u_spec[] = "%nbopxXudics";
 /* u_radix[i] <-> u_spec[i+2] for unsigned entries only */
 static const char u_radix[] = "\x02\x08\x10\x10\x10\x0a";
 
-int vfprintf(FILE * __restrict op, register const char * __restrict fmt,
+int attribute_hidden __vfprintf(FILE * __restrict op, register const char * __restrict fmt,
 			 va_list ap)
 {
 	union {
@@ -711,3 +711,4 @@ int vfprintf(FILE * __restrict op, register const char * __restrict fmt,
 
 	return i;
 }
+strong_alias(__vfprintf,vfprintf)

+ 3 - 2
libc/stdio/printf.c

@@ -8,14 +8,15 @@
 #include "_stdio.h"
 #include <stdarg.h>
 
-int printf(const char * __restrict format, ...)
+int attribute_hidden __printf(const char * __restrict format, ...)
 {
 	va_list arg;
 	int rv;
 
 	va_start(arg, format);
-	rv = vfprintf(stdout, format, arg);
+	rv = __vfprintf(stdout, format, arg);
 	va_end(arg);
 
 	return rv;
 }
+strong_alias(__printf,printf)

+ 3 - 2
libc/stdio/snprintf.c

@@ -12,16 +12,17 @@
 #warning Skipping snprintf since no vsnprintf!
 #else
 
-int snprintf(char *__restrict buf, size_t size,
+int attribute_hidden __snprintf(char *__restrict buf, size_t size,
 			 const char * __restrict format, ...)
 {
 	va_list arg;
 	int rv;
 
 	va_start(arg, format);
-	rv = vsnprintf(buf, size, format, arg);
+	rv = __vsnprintf(buf, size, format, arg);
 	va_end(arg);
 	return rv;
 }
+strong_alias(__snprintf,snprintf)
 
 #endif

+ 3 - 2
libc/stdio/sprintf.c

@@ -12,16 +12,17 @@
 #warning Skipping sprintf since no vsnprintf!
 #else
 
-int sprintf(char *__restrict buf, const char * __restrict format, ...)
+int attribute_hidden __sprintf(char *__restrict buf, const char * __restrict format, ...)
 {
 	va_list arg;
 	int rv;
 
 	va_start(arg, format);
-	rv = vsnprintf(buf, SIZE_MAX, format, arg);
+	rv = __vsnprintf(buf, SIZE_MAX, format, arg);
 	va_end(arg);
 
 	return rv;
 }
+strong_alias(__sprintf,sprintf)
 
 #endif

+ 4 - 4
libc/stdio/vasprintf.c

@@ -32,7 +32,7 @@ int attribute_hidden __vasprintf(char **__restrict buf, const char * __restrict
 	*buf = NULL;
 
 	if ((f = open_memstream(buf, &size)) != NULL) {
-		rv = vfprintf(f, format, arg);
+		rv = __vfprintf(f, format, arg);
 		fclose(f);
 		if (rv < 0) {
 			free(*buf);
@@ -54,14 +54,14 @@ int attribute_hidden __vasprintf(char **__restrict buf, const char * __restrict
 	int rv;
 
 	va_copy(arg2, arg);
- 	rv = vsnprintf(NULL, 0, format, arg2);
+ 	rv = __vsnprintf(NULL, 0, format, arg2);
 	va_end(arg2);
 
 	*buf = NULL;
 
 	if (rv >= 0) {
 		if ((*buf = malloc(++rv)) != NULL) {
-			if ((rv = vsnprintf(*buf, rv, format, arg)) < 0) {
+			if ((rv = __vsnprintf(*buf, rv, format, arg)) < 0) {
 				free(*buf);
 				*buf = NULL;
 			}
@@ -73,7 +73,7 @@ int attribute_hidden __vasprintf(char **__restrict buf, const char * __restrict
 	return rv;
 
 #endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
-strong_alias(__vasprintf,vasprintf)
 }
+strong_alias(__vasprintf,vasprintf)
 
 #endif

+ 1 - 1
libc/stdio/vdprintf.c

@@ -47,7 +47,7 @@ int attribute_hidden __vdprintf(int filedes, const char * __restrict format, va_
 #endif
 	f.__nextopen = NULL;
 
-	rv = vfprintf(&f, format, arg);
+	rv = __vfprintf(&f, format, arg);
 
 #ifdef __STDIO_BUFFERS
 	/* If not buffering, then fflush is unnecessary. */

+ 4 - 1
libc/stdio/vfprintf.c

@@ -1195,6 +1195,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad);
 
 #ifdef L_vfprintf
 
+#define HIDDEN_VFPRINTF __vfprintf
 #define VFPRINTF vfprintf
 #define FMT_TYPE char
 #define OUTNSTR _outnstr
@@ -1227,6 +1228,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
 
 #else  /* L_vfprintf */
 
+#define HIDDEN_VFPRINTF __vfwprintf
 #define VFPRINTF vfwprintf
 #define FMT_TYPE wchar_t
 #define OUTNSTR _outnwcs
@@ -1844,7 +1846,7 @@ static int _do_one_spec(FILE * __restrict stream,
 	return 0;
 }
 
-int VFPRINTF (FILE * __restrict stream,
+int attribute_hidden HIDDEN_VFPRINTF (FILE * __restrict stream,
 			  register const FMT_TYPE * __restrict format,
 			  va_list arg)
 {
@@ -1921,5 +1923,6 @@ int VFPRINTF (FILE * __restrict stream,
 
 	return count;
 }
+strong_alias(HIDDEN_VFPRINTF,VFPRINTF)
 #endif
 /**********************************************************************/

+ 1 - 1
libc/stdio/vprintf.c

@@ -10,5 +10,5 @@
 
 int vprintf(const char * __restrict format, va_list arg)
 {
-	return vfprintf(stdout, format, arg);
+	return __vfprintf(stdout, format, arg);
 }

+ 9 - 6
libc/stdio/vsnprintf.c

@@ -14,7 +14,7 @@
 
 #ifdef __STDIO_BUFFERS
 
-int vsnprintf(char *__restrict buf, size_t size,
+int attribute_hidden __vsnprintf(char *__restrict buf, size_t size,
 			  const char * __restrict format, va_list arg)
 {
 	FILE f;
@@ -57,7 +57,7 @@ int vsnprintf(char *__restrict buf, size_t size,
 	__STDIO_STREAM_DISABLE_GETC(&f);
 	__STDIO_STREAM_ENABLE_PUTC(&f);
 
-	rv = vfprintf(&f, format, arg);
+	rv = __vfprintf(&f, format, arg);
 	if (size) {
 		if (f.__bufpos == f.__bufend) {
 			--f.__bufpos;
@@ -66,6 +66,7 @@ int vsnprintf(char *__restrict buf, size_t size,
 	}
 	return rv;
 }
+strong_alias(__vsnprintf,vsnprintf)
 
 #elif defined(__USE_OLD_VFPRINTF__)
 
@@ -75,7 +76,7 @@ typedef struct {
 	unsigned char *bufpos;
 } __FILE_vsnprintf;
 
-int vsnprintf(char *__restrict buf, size_t size,
+int attribute_hidden __vsnprintf(char *__restrict buf, size_t size,
 			  const char * __restrict format, va_list arg)
 {
 	__FILE_vsnprintf f;
@@ -113,7 +114,7 @@ int vsnprintf(char *__restrict buf, size_t size,
 #endif
 	f.f.__nextopen = NULL;
 
-	rv = vfprintf((FILE *) &f, format, arg);
+	rv = __vfprintf((FILE *) &f, format, arg);
 	if (size) {
 		if (f.bufpos == f.bufend) {
 			--f.bufpos;
@@ -122,6 +123,7 @@ int vsnprintf(char *__restrict buf, size_t size,
 	}
 	return rv;
 }
+strong_alias(__vsnprintf,vsnprintf)
 
 #elif defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
 
@@ -163,7 +165,7 @@ static ssize_t snpf_write(register void *cookie, const char *buf,
 
 #undef COOKIE
 
-int vsnprintf(char *__restrict buf, size_t size,
+int attribute_hidden __vsnprintf(char *__restrict buf, size_t size,
 			  const char * __restrict format, va_list arg)
 {
 	FILE f;
@@ -197,10 +199,11 @@ int vsnprintf(char *__restrict buf, size_t size,
 #endif
 	f.__nextopen = NULL;
 
-	rv = vfprintf(&f, format, arg);
+	rv = __vfprintf(&f, format, arg);
 
 	return rv;
 }
+strong_alias(__vsnprintf,vsnprintf)
 
 #else
 #warning Skipping vsnprintf since no buffering, no custom streams, and not old vfprintf!

+ 1 - 1
libc/stdio/vsprintf.c

@@ -15,7 +15,7 @@
 int vsprintf(char *__restrict buf, const char * __restrict format,
 			 va_list arg)
 {
-	return vsnprintf(buf, SIZE_MAX, format, arg);
+	return __vsnprintf(buf, SIZE_MAX, format, arg);
 }
 
 #endif

+ 1 - 1
libc/stdio/vswprintf.c

@@ -52,7 +52,7 @@ int attribute_hidden __vswprintf(wchar_t *__restrict buf, size_t size,
 	__STDIO_STREAM_DISABLE_GETC(&f);
 	__STDIO_STREAM_DISABLE_PUTC(&f);
 
-	rv = vfwprintf(&f, format, arg);
+	rv = __vfwprintf(&f, format, arg);
 
 	/* NOTE: Return behaviour differs from snprintf... */
 	if (f.__bufpos == f.__bufend) {

+ 1 - 1
libc/stdio/vwprintf.c

@@ -11,5 +11,5 @@
 
 int vwprintf(const wchar_t * __restrict format, va_list arg)
 {
-	return vfwprintf(stdout, format, arg);
+	return __vfwprintf(stdout, format, arg);
 }

+ 1 - 1
libc/stdio/wprintf.c

@@ -15,7 +15,7 @@ int wprintf(const wchar_t * __restrict format, ...)
 	int rv;
 
 	va_start(arg, format);
-	rv = vfwprintf(stdout, format, arg);
+	rv = __vfwprintf(stdout, format, arg);
 	va_end(arg);
 
 	return rv;