From: Harlan Stenn Date: Sun, 2 Dec 2001 09:12:13 +0000 (-0500) Subject: settimeofday() fix in configure, do a better job tracking and X-Git-Tag: NTP_4_1_0B_RC2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c40d1d330179d7108da3f2d5d6d4a3c5dbc817a;p=thirdparty%2Fntp.git settimeofday() fix in configure, do a better job tracking and reporting progress in ntp_set_tod(). bk: 3c09f06dYV7tKVCw_-2Rg2L7zqfOZw --- diff --git a/configure.in b/configure.in index 5711ebe0db..12d4366cb5 100644 --- a/configure.in +++ b/configure.in @@ -650,7 +650,7 @@ case "$target" in ;; esac AC_CHECK_FUNCS(setlinebuf setpgid setpriority setsid) -AC_CHECK_FUNC(settimeofday, ,[ +AC_CHECK_FUNCS(settimeofday, ,[ case "$target" in *-*-mpeix*) ac_cv_func_settimeofday=yes ;; diff --git a/libntp/machines.c b/libntp/machines.c index ebb3fb4e4b..8a62e24405 100644 --- a/libntp/machines.c +++ b/libntp/machines.c @@ -417,48 +417,67 @@ ntp_set_tod( void *tzp ) { - int rc; + int rc = -1; + +#ifdef DEBUG + if (debug) + printf("In ntp_set_tod\n"); +#endif #ifdef HAVE_CLOCK_SETTIME - { + if (rc) { struct timespec ts; + set_tod_using = "clock_settime"; /* Convert timeval to timespec */ ts.tv_sec = tvp->tv_sec; ts.tv_nsec = 1000 * tvp->tv_usec; + errno = 0; rc = clock_settime(CLOCK_REALTIME, &ts); - if (!rc) - { - set_tod_using = "clock_settime"; - return rc; - } } +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif #endif /* HAVE_CLOCK_SETTIME */ #ifdef HAVE_SETTIMEOFDAY - { + if (rc) { + set_tod_using = "settimeofday"; rc = SETTIMEOFDAY(tvp, tzp); - if (!rc) - { - set_tod_using = "settimeofday"; - return rc; - } } +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif #endif /* HAVE_SETTIMEOFDAY */ #ifdef HAVE_STIME - { + if (rc) { long tp = tvp->tv_sec; + set_tod_using = "stime"; rc = stime(&tp); /* lie as bad as SysVR4 */ - if (!rc) - { - set_tod_using = "stime"; - return rc; - } } +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif #endif /* HAVE_STIME */ - set_tod_using = "Failed!"; - return -1; + if (rc) + set_tod_using = "Failed!"; +#ifdef DEBUG + if (debug) { + printf("ntp_set_tod: Final: %s: %d: %s\n", + set_tod_using, rc, strerror(errno)); + } +#endif + return rc; } #endif /* not SYS_WINNT */