1) Moved tprintf and related functions to their own file in common/libc/printf/tprintf.c.

This file is included by both libc and hostcompat.

2) Changed printf -> tprintf in all testbin programs
This commit is contained in:
Scott Haseley
2016-01-15 13:33:11 -05:00
parent 98ff530afb
commit 0ab862abfa
49 changed files with 501 additions and 478 deletions

View File

@@ -22,6 +22,11 @@ TOP=../../..
LIB=hostcompat
SRCS=err.c ntohll.c time.c hostcompat.c
# printf
COMMON=$(TOP)/common/libc
SRCS+=\
$(COMMON)/printf/tprintf.c
HOST_CFLAGS+=$(COMPAT_CFLAGS)
MKDIRS=$(INSTALLTOP)/hostinclude

View File

@@ -35,6 +35,13 @@ void hostcompat_init(int argc, char **argv);
time_t __time(time_t *secs, unsigned long *nsecs);
/* Automated testing extensions. */
int tprintf(const char *fmt, ...);
int nprintf(const char *fmt, ...);
int printsf(const char *fmt, ...);
#ifdef DECLARE_NTOHLL
uint64_t ntohll(uint64_t);
#define htonll(x) (ntohll(x))

View File

@@ -10,7 +10,8 @@ COMMON=$(TOP)/common/libc
# printf
SRCS+=\
$(COMMON)/printf/__printf.c \
$(COMMON)/printf/snprintf.c
$(COMMON)/printf/snprintf.c \
$(COMMON)/printf/tprintf.c
# stdio
SRCS+=\

View File

@@ -78,56 +78,3 @@ vprintf(const char *fmt, va_list ap)
}
return chars;
}
/* printf variant that is quiet during automated testing */
int
tprintf(const char *fmt, ...)
{
int chars;
va_list ap;
if (strcmp(KERNEL_SECRET, "") != 0) {
return 0;
}
va_start(ap, fmt);
chars = vprintf(fmt, ap);
va_end(ap);
return chars;
}
/* printf variant that is loud during automated testing */
int
nprintf(const char *fmt, ...)
{
int chars;
va_list ap;
if (strcmp(KERNEL_SECRET, "") == 0) {
return 0;
}
va_start(ap, fmt);
chars = vprintf(fmt, ap);
va_end(ap);
return chars;
}
/* printf variant that prepends the kernel secret */
int
printsf(const char *fmt, ...)
{
int chars;
va_list ap;
if (strcmp(KERNEL_SECRET, "") != 0) {
printf("%s: ", KERNEL_SECRET);
}
va_start(ap, fmt);
chars = vprintf(fmt, ap);
va_end(ap);
return chars;
}