;;
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
;;
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 */