Skip to content

Commit

Permalink
use vprintf() when available
Browse files Browse the repository at this point in the history
  • Loading branch information
obgm committed Jun 7, 2012
1 parent f275f28 commit 1274eb2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.h.contiki
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#ifdef CONTIKI_TARGET_MINIMAL_NET
#undef HAVE_ASSERT_H
#define assert(x)
#define HAVE_VPRINTF
#endif /* CONTIKI_TARGET_MINIMAL_NET */

#if defined(TMOTE_SKY)
Expand Down
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

Expand Down
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dnl AC_TYPE_UINT64_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset select socket strdup strerror])
AC_CHECK_FUNCS([memset select socket strdup strerror vprintf])

AC_CONFIG_HEADERS([config.h])

Expand Down
6 changes: 6 additions & 0 deletions debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ dsrv_log(log_t level, char *format, ...) {
printf("%s ", loglevels[level]);

va_start(ap, format);
#ifdef HAVE_VPRINTF
vprintf(format, ap);
#endif
va_end(ap);
fflush(stdout);
}
Expand All @@ -244,7 +246,11 @@ dsrv_log(log_t level, char *format, ...) {
PRINTF("%s ", loglevels[level]);

va_start(ap, format);
#ifdef HAVE_VPRINTF
vprintf(format, ap);
#else /* HAVE_VPRINTF */
PRINTF(format, ap);
#endif /* HAVE_VPRINTF */
va_end(ap);
}
#endif /* WITH_CONTIKI */

0 comments on commit 1274eb2

Please sign in to comment.