Parcourir la source

Implement hidden poll, switch user to hidden *printf/*scanf/poll

Peter S. Mazinger il y a 19 ans
Parent
commit
4f16d2e03a

+ 11 - 0
include/libc-internal.h

@@ -187,6 +187,11 @@ extern __pid_t __getpid (void) attribute_hidden;
 
 /* #include <stdio.h> */
 extern void __perror (__const char *__s) attribute_hidden;
+extern int __printf (__const char *__restrict __format, ...) attribute_hidden;
+extern int __sprintf (char *__restrict __s,
+		    __const char *__restrict __format, ...) attribute_hidden;
+/* hack */
+#define fprintf __fprintf
 
 /* #include <stdlib.h> */
 extern char *__getenv (__const char *__name) attribute_hidden;
@@ -207,6 +212,12 @@ typedef struct __dirstream DIR;
 extern DIR *__opendir (__const char *__name) attribute_hidden;
 extern int __closedir (DIR *__dirp) attribute_hidden;
 
+/* #include <stdio.h> */
+extern int __vfprintf (FILE *__restrict __s, __const char *__restrict __format,
+		     __gnuc_va_list __arg) attribute_hidden;
+extern int __fprintf (FILE *__restrict __stream,
+		    __const char *__restrict __format, ...) attribute_hidden;
+
 /* #include <sys/time.h> */
 #   define __need_timeval
 #   include <bits/time.h>

+ 1 - 1
libc/inet/ether_addr.c

@@ -79,7 +79,7 @@ struct ether_addr *ether_aton(const char *asc)
 
 char attribute_hidden *__ether_ntoa_r(const struct ether_addr *addr, char *buf)
 {
-	sprintf(buf, "%x:%x:%x:%x:%x:%x",
+	__sprintf(buf, "%x:%x:%x:%x:%x:%x",
 			addr->ether_addr_octet[0], addr->ether_addr_octet[1],
 			addr->ether_addr_octet[2], addr->ether_addr_octet[3],
 			addr->ether_addr_octet[4], addr->ether_addr_octet[5]);

+ 1 - 1
libc/inet/ntop.c

@@ -163,7 +163,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
 			tp += __strlen(tp);
 			break;
 		}
-		tp += sprintf(tp, "%x", words[i]);
+		tp += __sprintf(tp, "%x", words[i]);
 	}
 	/* Was it a trailing run of 0x00's? */
 	if (best.base != -1 && (best.base + best.len) == 8)

+ 4 - 3
libc/inet/resolv.c

@@ -148,6 +148,7 @@
 #define select __select
 #define recv __recv
 #define send __send
+#define snprintf __snprintf
 
 #define __FORCE_GLIBC
 #include <features.h>
@@ -1397,7 +1398,7 @@ int res_querydomain(name, domain, class, type, answer, anslen)
 
 #ifdef DEBUG
 	if (_res.options & RES_DEBUG)
-		printf(";; res_querydomain(%s, %s, %d, %d)\n",
+		__printf(";; res_querydomain(%s, %s, %d, %d)\n",
 			name, domain?domain:"<Nil>", class, type);
 #endif
 	if (domain == NULL) {
@@ -2335,7 +2336,7 @@ int attribute_hidden __gethostbyaddr_r (const void *addr, socklen_t len, int typ
 
 		addr_list[0] = in;
 
-		sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
+		__sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
 			tmp_addr[3], tmp_addr[2], tmp_addr[1], tmp_addr[0]);
 #ifdef __UCLIBC_HAS_IPV6__
 	} else {
@@ -2345,7 +2346,7 @@ int attribute_hidden __gethostbyaddr_r (const void *addr, socklen_t len, int typ
 		qp = buf;
 
 		for (i = len - 1; i >= 0; i--) {
-			qp += sprintf(qp, "%x.%x.", in6->s6_addr[i] & 0xf,
+			qp += __sprintf(qp, "%x.%x.", in6->s6_addr[i] & 0xf,
 				(in6->s6_addr[i] >> 4) & 0xf);
     	}
     	__strcpy(qp, "ip6.int");

+ 7 - 7
libc/inet/rpc/clnt_perror.c

@@ -220,7 +220,7 @@ __clnt_sperror (CLIENT * rpch, const char *msg)
     return NULL;
   CLNT_GETERR (rpch, &e);
 
-  len = sprintf (str, "%s: ", msg);
+  len = __sprintf (str, "%s: ", msg);
   str += len;
 
   (void) __strcpy(str, __clnt_sperrno(e.re_status));
@@ -246,12 +246,12 @@ __clnt_sperror (CLIENT * rpch, const char *msg)
     case RPC_CANTSEND:
     case RPC_CANTRECV:
       strerror_r (e.re_errno, chrbuf, sizeof chrbuf);
-      len = sprintf (str, "; errno = %s", chrbuf); 
+      len = __sprintf (str, "; errno = %s", chrbuf); 
       str += len;
       break;
 
     case RPC_VERSMISMATCH:
-      len= sprintf (str, _("; low version = %lu, high version = %lu"),
+      len= __sprintf (str, _("; low version = %lu, high version = %lu"),
 		    e.re_vers.low, e.re_vers.high);
       str += len;
       break;
@@ -268,20 +268,20 @@ __clnt_sperror (CLIENT * rpch, const char *msg)
 	}
       else
 	{
-	  len = sprintf (str, _("(unknown authentication error - %d)"),
+	  len = __sprintf (str, _("(unknown authentication error - %d)"),
 			 (int) e.re_why);
 	  str += len;
 	}
       break;
 
     case RPC_PROGVERSMISMATCH:
-      len = sprintf (str, _("; low version = %lu, high version = %lu"),
+      len = __sprintf (str, _("; low version = %lu, high version = %lu"),
 		     e.re_vers.low, e.re_vers.high);
       str += len;
       break;
 
     default:			/* unknown */
-      len = sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2);
+      len = __sprintf (str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2);
       str += len;
       break;
     }
@@ -315,7 +315,7 @@ __clnt_spcreateerror (const char *msg)
   if (str == NULL)
     return NULL;
   ce = &get_rpc_createerr ();
-  len = sprintf (str, "%s: ", msg);
+  len = __sprintf (str, "%s: ", msg);
   cp = str + len;
   (void) __strcpy(cp, __clnt_sperrno (ce->cf_stat));
   cp += __strlen(cp);

+ 1 - 0
libc/inet/rpc/clnt_tcp.c

@@ -62,6 +62,7 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
 #define _seterr_reply __seterr_reply
 #define connect __connect
 #define bindresvport __bindresvport
+#define poll __poll
 
 #define __FORCE_GLIBC
 #include <features.h>

+ 1 - 0
libc/inet/rpc/clnt_udp.c

@@ -52,6 +52,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
 #define recvfrom __recvfrom
 #define sendto __sendto
 #define recvmsg __recvmsg
+#define poll __poll
 
 #define __FORCE_GLIBC
 #include <features.h>

+ 1 - 0
libc/inet/rpc/clnt_unix.c

@@ -61,6 +61,7 @@
 #define connect __connect
 #define recvmsg __recvmsg
 #define sendmsg __sendmsg
+#define poll __poll
 
 #define __FORCE_GLIBC
 #include <features.h>

+ 1 - 0
libc/inet/rpc/pmap_rmt.c

@@ -51,6 +51,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
 #define setsockopt __setsockopt
 #define recvfrom __recvfrom
 #define sendto __sendto
+#define poll __poll
 
 #define __FORCE_GLIBC
 #include <features.h>

+ 2 - 0
libc/inet/rpc/rcmd.c

@@ -51,6 +51,8 @@ static char sccsid[] = "@(#)rcmd.c	8.3 (Berkeley) 3/26/94";
 #define bind __bind
 #define connect __connect
 #define sigblock __sigblock
+#define snprintf __snprintf
+#define poll __poll
 
 #define __FORCE_GLIBC
 #include <features.h>

+ 2 - 1
libc/inet/rpc/rexec.c

@@ -34,6 +34,7 @@
 #define sleep __sleep
 #define atoi __atoi
 #define connect __connect
+#define snprintf __snprintf
 
 #define __FORCE_GLIBC
 #include <features.h>
@@ -136,7 +137,7 @@ retry:
 				 NULL, 0, servbuff, sizeof(servbuff),
 				 NI_NUMERICSERV))
 			port = atoi(servbuff);
-		(void) sprintf(num, "%u", port);
+		(void) __sprintf(num, "%u", port);
 		(void) __write(s, num, __strlen(num)+1);
 		{ socklen_t len = sizeof (from);
 		  s3 = accept(s2, (struct sockaddr *)&from, &len);

+ 1 - 0
libc/inet/rpc/rtime.c

@@ -46,6 +46,7 @@ static char sccsid[] = "@(#)rtime.c	2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 S
 #define connect __connect
 #define recvfrom __recvfrom
 #define sendto __sendto
+#define poll __poll
 
 #define __FORCE_GLIBC
 #include <features.h>

+ 14 - 14
libc/inet/rpc/ruserpass.c

@@ -122,7 +122,7 @@ int attribute_hidden __ruserpass(const char *host, const char **aname, const cha
 	cfile = fopen(buf, "r");
 	if (cfile == NULL) {
 		if (errno != ENOENT)
-			printf("%s", buf);
+			__printf("%s", buf);
 		return (0);
 	}
 	/* No threads use this stream.  */
@@ -170,7 +170,7 @@ next:
 				  newp = malloc((unsigned) __strlen(tokval) + 1);
 				  if (newp == NULL)
 				    {
-				      printf(_("out of memory"));
+				      __printf(_("out of memory"));
 				      goto bad;
 				    }
 				  *aname = __strcpy(newp, tokval);
@@ -184,8 +184,8 @@ next:
 			if (__strcmp(*aname, "anonymous") &&
 			    fstat(fileno(cfile), &stb) >= 0 &&
 			    (stb.st_mode & 077) != 0) {
-	printf(_("Error: .netrc file is readable by others."));
-	printf(_("Remove password or make file unreadable by others."));
+	__printf(_("Error: .netrc file is readable by others."));
+	__printf(_("Remove password or make file unreadable by others."));
 				goto bad;
 			}
 			if (token() && *apass == 0) {
@@ -193,7 +193,7 @@ next:
 				newp = malloc((unsigned) __strlen(tokval) + 1);
 				if (newp == NULL)
 				  {
-				    printf(_("out of memory"));
+				    __printf(_("out of memory"));
 				    goto bad;
 				  }
 				*apass = __strcpy(newp, tokval);
@@ -203,8 +203,8 @@ next:
 #if 0
 			if (fstat(fileno(cfile), &stb) >= 0
 			    && (stb.st_mode & 077) != 0) {
-	printf("Error: .netrc file is readable by others.");
-	printf("Remove account or make file unreadable by others.");
+	__printf("Error: .netrc file is readable by others.");
+	__printf("Remove account or make file unreadable by others.");
 				goto bad;
 			}
 			if (token() && *aacct == 0) {
@@ -222,11 +222,11 @@ next:
 			while ((c=getc_unlocked(cfile)) != EOF && c == ' '
 			       || c == '\t');
 			if (c == EOF || c == '\n') {
-				printf("Missing macdef name argument.\n");
+				__printf("Missing macdef name argument.\n");
 				goto bad;
 			}
 			if (macnum == 16) {
-				printf("Limit of 16 macros have already been defined\n");
+				__printf("Limit of 16 macros have already been defined\n");
 				goto bad;
 			}
 			tmp = macros[macnum].mac_name;
@@ -236,7 +236,7 @@ next:
 				*tmp++ = c;
 			}
 			if (c == EOF) {
-				printf("Macro definition missing null line terminator.\n");
+				__printf("Macro definition missing null line terminator.\n");
 				goto bad;
 			}
 			*tmp = '\0';
@@ -245,7 +245,7 @@ next:
 				       && c != '\n');
 			}
 			if (c == EOF) {
-				printf("Macro definition missing null line terminator.\n");
+				__printf("Macro definition missing null line terminator.\n");
 				goto bad;
 			}
 			if (macnum == 0) {
@@ -257,7 +257,7 @@ next:
 			tmp = macros[macnum].mac_start;
 			while (tmp != macbuf + 4096) {
 				if ((c=getc_unlocked(cfile)) == EOF) {
-				printf("Macro definition missing null line terminator.\n");
+				__printf("Macro definition missing null line terminator.\n");
 					goto bad;
 				}
 				*tmp = c;
@@ -271,13 +271,13 @@ next:
 				tmp++;
 			}
 			if (tmp == macbuf + 4096) {
-				printf("4K macro buffer exceeded\n");
+				__printf("4K macro buffer exceeded\n");
 				goto bad;
 			}
 #endif
 			break;
 		default:
-			printf(_("Unknown .netrc keyword %s"), tokval);
+			__printf(_("Unknown .netrc keyword %s"), tokval);
 			break;
 		}
 		goto done;

+ 1 - 1
libc/inet/rpc/svc_auth_unix.c

@@ -110,7 +110,7 @@ _svcauth_unix (struct svc_req *rqst, struct rpc_msg *msg)
        */
       if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len)
 	{
-	  (void) printf ("bad auth_len gid %d str %d auth %d\n",
+	  (void) __printf ("bad auth_len gid %d str %d auth %d\n",
 			 gid_len, str_len, auth_len);
 	  stat = AUTH_BADCRED;
 	  goto done;

+ 1 - 0
libc/inet/rpc/svc_run.c

@@ -32,6 +32,7 @@
  */
 
 #define svc_getreq_poll __svc_getreq_poll
+#define poll __poll
 
 /* used by svc_[max_]pollfd */
 #define __rpc_thread_svc_pollfd __rpc_thread_svc_pollfd_internal

+ 1 - 0
libc/inet/rpc/svc_tcp.c

@@ -52,6 +52,7 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
 #define getsockname __getsockname
 #define bind __bind
 #define bindresvport __bindresvport
+#define poll __poll
 
 #define __FORCE_GLIBC
 #define _GNU_SOURCE

+ 1 - 0
libc/inet/rpc/svc_unix.c

@@ -52,6 +52,7 @@
 #define bind __bind
 #define recvmsg __recvmsg
 #define sendmsg __sendmsg
+#define poll __poll
 
 #define __FORCE_GLIBC
 #include <features.h>

+ 2 - 0
libc/misc/error/err.c

@@ -5,6 +5,8 @@
  * Dedicated to Toni.  See uClibc/DEDICATION.mjn3 for details.
  */
 
+#define vfprintf __vfprintf
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>

+ 1 - 0
libc/misc/error/error.c

@@ -23,6 +23,7 @@
 /* Adjusted slightly by Erik Andersen <andersen@uclibc.org> */
 
 #define strerror __strerror
+#define vfprintf __vfprintf
 
 #include <stdio.h>
 #include <stdarg.h>

+ 1 - 1
libc/misc/internals/tempname.c

@@ -118,7 +118,7 @@ int attribute_hidden __path_search (char *tmpl, size_t tmpl_len, const char *dir
 	return -1;
     }
 
-    sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
+    __sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
     return 0;
 }
 

+ 1 - 0
libc/misc/regex/regex_old.c

@@ -34,6 +34,7 @@
 #define wctype __wctype
 #define iswctype __iswctype
 #define iswalnum __iswalnum
+#define printf __printf
 
 /* To exclude some unwanted junk.... */
 #undef _LIBC

+ 5 - 4
libc/misc/syslog/syslog.c

@@ -34,6 +34,7 @@
 #define ctime __ctime
 #define sigaction __sigaction
 #define connect __connect
+#define vsnprintf __vsnprintf
 
 #define __FORCE_GLIBC
 #define _GNU_SOURCE
@@ -220,15 +221,15 @@ __vsyslog( int pri, const char *fmt, va_list ap )
 	 * safe to test only LogTag and use normal sprintf everywhere else.
 	 */
 	(void)__time(&now);
-	stdp = p = tbuf + sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4);
+	stdp = p = tbuf + __sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4);
 	if (LogTag) {
 		if (__strlen(LogTag) < sizeof(tbuf) - 64)
-			p += sprintf(p, "%s", LogTag);
+			p += __sprintf(p, "%s", LogTag);
 		else
-			p += sprintf(p, "<BUFFER OVERRUN ATTEMPT>");
+			p += __sprintf(p, "<BUFFER OVERRUN ATTEMPT>");
 	}
 	if (LogStat & LOG_PID)
-		p += sprintf(p, "[%d]", __getpid());
+		p += __sprintf(p, "[%d]", __getpid());
 	if (LogTag) {
 		*p++ = ':';
 		*p++ = ' ';

+ 1 - 1
libc/misc/time/time.c

@@ -274,7 +274,7 @@ strong_alias(__asctime,asctime)
  *       };
  *       static char result[26];
  *   
- *       sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
+ *       __sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
  *           wday_name[timeptr->tm_wday],                   
  *           mon_name[timeptr->tm_mon],
  *           timeptr->tm_mday, timeptr->tm_hour,

+ 2 - 0
libc/misc/wchar/wchar.c

@@ -98,6 +98,8 @@
  * Manuel
  */
 
+#define vfprintf __vfprintf
+
 #define _GNU_SOURCE
 #define _ISOC99_SOURCE
 #include <errno.h>

+ 1 - 1
libc/misc/wordexp/wordexp.c

@@ -509,7 +509,7 @@ static int eval_expr(char *expr, long int *result);
 
 static char *_itoa(unsigned long long int value, char *buflim)
 {
-	sprintf(buflim, "%llu", value);
+	__sprintf(buflim, "%llu", value);
 	return buflim;
 }
 

+ 1 - 1
libc/pwd_grp/pwd_grp.c

@@ -435,7 +435,7 @@ int getpw(uid_t uid, char *buf)
 	if (!buf) {
 		__set_errno(EINVAL);
 	} else if (!__getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result)) {
-		if (sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n",
+		if (__sprintf(buf, "%s:%s:%lu:%lu:%s:%s:%s\n",
 					resultbuf.pw_name, resultbuf.pw_passwd,
 					(unsigned long)(resultbuf.pw_uid),
 					(unsigned long)(resultbuf.pw_gid),

+ 1 - 1
libc/signal/siggetmask.c

@@ -19,7 +19,7 @@
 
 #include <signal.h>
 
-extern int __sigblock (int __mask) __THROW __attribute_deprecated__ attribute_hidden;
+extern int __sigblock (int __mask) __THROW /*__attribute_deprecated__*/ attribute_hidden;
 int
 siggetmask (void)
 {

+ 1 - 1
libc/stdlib/gcvt.c

@@ -5,7 +5,7 @@
 #define MAX_NDIGIT 17
 char *gcvt (double number, int ndigit, char *buf)
 {
-    sprintf(buf, "%.*g", (ndigit > MAX_NDIGIT)? MAX_NDIGIT : ndigit, number);
+    __sprintf(buf, "%.*g", (ndigit > MAX_NDIGIT)? MAX_NDIGIT : ndigit, number);
     return buf;
 }
 #endif

+ 2 - 0
libc/stdlib/malloc/heap_debug.c

@@ -11,6 +11,8 @@
  * Written by Miles Bader <miles@gnu.org>
  */
 
+#define vfprintf __vfprintf
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>

+ 1 - 0
libc/stdlib/malloc/malloc_debug.c

@@ -12,6 +12,7 @@
  */
 
 #define atoi __atoi
+#define vfprintf __vfprintf
 
 #include <stdlib.h>
 #include <stdio.h>

+ 1 - 1
libc/stdlib/system.c

@@ -45,7 +45,7 @@ int __libc_system(char *command)
 	signal(SIGINT, SIG_IGN);
 
 #if 0
-	printf("Waiting for child %d\n", pid);
+	__printf("Waiting for child %d\n", pid);
 #endif
 
 	if (wait4(pid, &wait_val, 0, 0) == -1)

+ 2 - 0
libc/sysdeps/linux/arm/ioperm.c

@@ -35,6 +35,8 @@
 
 #define readlink __readlink
 #define mmap __mmap
+#define sscanf __sscanf
+#define fscanf __fscanf
 
 #include <errno.h>
 #include <fcntl.h>

+ 4 - 4
libc/sysdeps/linux/common/poll.c

@@ -24,8 +24,8 @@
 #include <sys/poll.h>
 
 #ifdef __NR_poll
-
-_syscall3(int, poll, struct pollfd *, fds,
+#define __NR___poll __NR_poll
+attribute_hidden _syscall3(int, __poll, struct pollfd *, fds,
 	unsigned long int, nfds, int, timeout);
 #else
 
@@ -45,7 +45,7 @@ _syscall3(int, poll, struct pollfd *, fds,
    Returns the number of file descriptors with events, zero if timed out,
    or -1 for errors.  */
 
-int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
 {
     static int max_fd_size;
     struct timeval tv;
@@ -204,4 +204,4 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
 }
 
 #endif
-
+strong_alias(__poll,poll)