From 3060d4aa1d5586c085aaec108ac6ced094304322 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Jan 2000 02:16:51 +0000 Subject: [PATCH] handle systems that don't take a 2nd argument to gettimeofday() --- Makefile.in | 2 +- acconfig.h | 1 + authenticate.c | 2 +- configure.in | 11 +++++++++++ lib/compat.c | 10 ++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 353caa30..d401cd78 100644 --- a/Makefile.in +++ b/Makefile.in @@ -64,7 +64,7 @@ rsyncd.conf.5: rsyncd.conf.yo yodl2man -o rsyncd.conf.5 rsyncd.conf.yo proto: - cat *.c | awk -f mkproto.awk > proto.h + cat *.c lib/compat.c | awk -f mkproto.awk > proto.h clean: rm -f *~ $(OBJS) rsync diff --git a/acconfig.h b/acconfig.h index 57522923..d35ec3fb 100644 --- a/acconfig.h +++ b/acconfig.h @@ -10,3 +10,4 @@ #undef HAVE_SHORT_INO_T #undef HAVE_GETOPT_LONG #undef REPLACE_INET_NTOA +#undef HAVE_GETTIMEOFDAY_TZ diff --git a/authenticate.c b/authenticate.c index 50c10aae..f87fceef 100644 --- a/authenticate.c +++ b/authenticate.c @@ -56,7 +56,7 @@ static void gen_challenge(char *addr, char *challenge) memset(input, 0, sizeof(input)); strlcpy((char *)input, addr, 17); - gettimeofday(&tv, NULL); + sys_gettimeofday(&tv); SIVAL(input, 16, tv.tv_sec); SIVAL(input, 20, tv.tv_usec); SIVAL(input, 24, getpid()); diff --git a/configure.in b/configure.in index 80f46508..0257de9d 100644 --- a/configure.in +++ b/configure.in @@ -135,6 +135,17 @@ if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then AC_DEFINE(HAVE_UTIMBUF) fi +AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[ +AC_TRY_RUN([ +#include +#include +main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}], + rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no,rsync_cv_HAVE_GETTIMEOFDAY_TZ=cross)]) +if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then + AC_DEFINE(HAVE_GETTIMEOFDAY_TZ) +fi + + AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include diff --git a/lib/compat.c b/lib/compat.c index 8580fdb9..b1e386a0 100644 --- a/lib/compat.c +++ b/lib/compat.c @@ -161,3 +161,13 @@ return 1; } #endif + +/* some systems don't take the 2nd argument */ +int sys_gettimeofday(struct timeval *tv) +{ +#if HAVE_GETTIMEOFDAY_TZ + return gettimeofday(tv, NULL); +#else + return gettimeofday(tv); +#endif +} -- 2.34.1