diff --git a/configure.in b/configure.in index 1203242..c6b5f1a 100755 --- a/configure.in +++ b/configure.in @@ -43,7 +43,7 @@ AC_FUNC_STRFTIME # Checks for header files. AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \ sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \ - ctype.h unistd.h time.h sys/stat.h) + ctype.h unistd.h time.h sys/stat.h sys/time.h unistd.h sys/mman.h) AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [ AC_TRY_COMPILE( diff --git a/jlog.c b/jlog.c index f108e0f..db44b4a 100644 --- a/jlog.c +++ b/jlog.c @@ -70,6 +70,12 @@ #include "jlog_config.h" #include "jlog_private.h" +#if HAVE_UNISTD_H +#include +#endif +#if HAVE_SYS_TIME_H +#include +#endif #if HAVE_DIRENT_H #include #endif @@ -82,6 +88,9 @@ #if HAVE_TIME_H #include #endif +#if HAVE_SYS_MMAN_H +#include +#endif #define BUFFERED_INDICES 1024 @@ -104,7 +113,7 @@ int jlog_snprint_logid(char *b, int n, const jlog_id *id) { int jlog_repair_datafile(jlog_ctx *ctx, u_int32_t log) { jlog_message_header hdr; - char *this, *next, *afternext, *mmap_end; + char *this, *next, *afternext = NULL, *mmap_end; int i, invalid_count = 0; struct { off_t start, end; @@ -247,12 +256,12 @@ int jlog_inspect_datafile(jlog_ctx *ctx, u_int32_t log) i++; if (hdr.reserved != 0) { fprintf(stderr, "Message %d at [%ld] has invalid reserved value %u\n", - i, this - (char *)ctx->mmap_base, hdr.reserved); + i, (long int)(this - (char *)ctx->mmap_base), hdr.reserved); return 1; } fprintf(stderr, "Message %d at [%ld] of (%lu+%u)", i, - this - (char *)ctx->mmap_base, sizeof(hdr), hdr.mlen); + (long int)(this - (char *)ctx->mmap_base), sizeof(hdr), hdr.mlen); next = this + sizeof(hdr) + hdr.mlen; if (next <= (char *)ctx->mmap_base) { @@ -271,7 +280,8 @@ int jlog_inspect_datafile(jlog_ctx *ctx, u_int32_t log) this = next; } if (this < mmap_end) { - fprintf(stderr, "%ld bytes of junk at the end\n", mmap_end - this); + fprintf(stderr, "%ld bytes of junk at the end\n", + (long int)(mmap_end - this)); return 1; } diff --git a/jlog_config.h.in b/jlog_config.h.in index 0f93e56..bf49654 100644 --- a/jlog_config.h.in +++ b/jlog_config.h.in @@ -42,8 +42,11 @@ #undef HAVE_ERRNO_H #undef HAVE_STRING_H #undef HAVE_STDLIB_H +#undef HAVE_UNISTD_H #undef HAVE_SYS_PARAM_H +#undef HAVE_SYS_MMAN_H #undef HAVE_TIME_H +#undef HAVE_SYS_TIME_H #undef HAVE_SYS_STAT_H #undef HAVE_INT64_T #undef HAVE_INTXX_T diff --git a/jlogctl.c b/jlogctl.c index 23fbca5..9d357a4 100644 --- a/jlogctl.c +++ b/jlogctl.c @@ -34,6 +34,9 @@ #include "jlog_private.h" #include "getopt_long.h" #include +#if HAVE_UNISTD_H +#include +#endif #if HAVE_ERRNO_H #include #endif diff --git a/jthreadtest.c b/jthreadtest.c index c1261f1..e663344 100644 --- a/jthreadtest.c +++ b/jthreadtest.c @@ -32,6 +32,7 @@ #include #include +#include #include "jlog_config.h" #include "jlog.h"