From: Dave Hart Date: Sat, 26 Mar 2011 02:03:35 +0000 (+0000) Subject: [Bug 1861] tickadj build failure using uClibc. X-Git-Tag: NTP_4_2_7P143~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08b7b068e3b0b5b742a4e33c0d6387b3081e16a1;p=thirdparty%2Fntp.git [Bug 1861] tickadj build failure using uClibc. bk: 4d8d4977Ql1OY7MYiwW7D-X4TbqnOQ --- diff --git a/ChangeLog b/ChangeLog index c4c67c65b..d6deca172 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ * [Bug 1732] ntpd ties up CPU on disconnected USB refclock. +* [Bug 1861] tickadj build failure using uClibc. * Remove kernel line discipline driver code for clk and chu, deprecate related LDISC_ flags, and remove associated ntpd code to decode the timestamps, remove clktest line discipline test program. diff --git a/configure.ac b/configure.ac index 7d5fa4127..397b62e38 100644 --- a/configure.ac +++ b/configure.ac @@ -320,14 +320,48 @@ case "$host" in esac case "$host" in - *-*-*linux*) - AC_CHECK_FUNCS([__adjtimex __ntp_gettime]) - ;; -esac -case "$ac_cv_func___adjtimex" in - yes) + *-*-solaris2.6) + # Broken... ;; *) + AC_CHECK_FUNCS([ntp_adjtime ntp_gettime]) + ;; +esac + +case "$host" in + *-*-*linux*) + case "$ac_cv_func_ntp_gettime" in + yes) + ;; + *) + AC_CHECK_FUNCS([__ntp_gettime]) + case "$ac_cv_func___ntp_gettime" in + yes) + AC_DEFINE([ntp_gettime], [__ntp_gettime], [deviant]) + AC_DEFINE([HAVE_NTP_GETTIME], [1], [via __ntp_gettime]) + esac + ;; + esac + AC_CHECK_FUNCS([adjtimex]) + case "$ac_cv_func_adjtimex" in + yes) + AC_DEFINE([ntp_adjtime], [adjtimex], [deviant]) + AC_DEFINE([HAVE_NTP_ADJTIME], [1], [via adjtimex]) + ;; + *) + AC_CHECK_FUNCS([__adjtimex]) + case "$ac_cv_func___adjtimex" in + yes) + AC_DEFINE([ntp_adjtime], [__adjtimex], [deviant]) + AC_DEFINE([HAVE_NTP_ADJTIME], [1], [via __adjtimex]) + AC_DEFINE([adjtimex], [__adjtimex], [deviant]) + AC_DEFINE([HAVE_ADJTIMEX], [1], [via __adjtimex]) + esac + ;; + esac +esac +case "$HAVE_ADJTIMEX" in + '') AC_CHECK_LIB([elf], [nlist]) dnl Only needed for tickadj... dnl AC_CHECK_LIB(kvm, main, , , -lelf) AC_CHECK_LIB([kvm], [main]) dnl We already know about -lelf here... @@ -337,30 +371,29 @@ case "$ac_cv_func___adjtimex" in case "$ac_cv_header_nlist_h" in yes) AC_DEFINE([NLIST_STRUCT], [1], [nlist stuff]) - esac - AC_CACHE_CHECK( - [for n_un in struct nlist], - [ntp_cv_struct_nlist_n_un], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ - #include - ]], - [[ - struct nlist n; - n.n_un.n_name = 0; - ]] + AC_CACHE_CHECK( + [for n_un in struct nlist], + [ntp_cv_struct_nlist_n_un], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include + ]], + [[ + struct nlist n; + n.n_un.n_name = 0; + ]] + )] + [ntp_cv_struct_nlist_n_un=yes], + [ntp_cv_struct_nlist_n_un=no] )] - [ntp_cv_struct_nlist_n_un=yes], - [ntp_cv_struct_nlist_n_un=no] - )] - ) - case "$ntp_cv_struct_nlist_n_un" in - yes) - AC_DEFINE([NLIST_NAME_UNION], [1], - [does struct nlist use a name union?]) + ) + case "$ntp_cv_struct_nlist_n_un" in + yes) + AC_DEFINE([NLIST_NAME_UNION], [1], + [does struct nlist use a name union?]) + esac esac - ;; esac AC_CHECK_HEADERS([sys/proc.h], [], [], [ @@ -756,15 +789,7 @@ case "$host" in *) AC_CHECK_FUNCS([mlockall]) ;; esac -AC_CHECK_FUNCS([nice nlist]) -case "$host" in - *-*-solaris2.6) - # Broken... - ;; - *) AC_CHECK_FUNCS([ntp_adjtime ntp_gettime]) - ;; -esac -AC_CHECK_FUNCS([plock pututline pututxline readlink recvmsg rtprio]) +AC_CHECK_FUNCS([nice nlist plock pututline pututxline readlink recvmsg rtprio]) case "$host" in *-*-aix[[456]]*) # Just a stub in AIX 4. Idiots. diff --git a/include/ntp_machine.h b/include/ntp_machine.h index 3845e3e57..72b0a71f2 100644 --- a/include/ntp_machine.h +++ b/include/ntp_machine.h @@ -32,13 +32,6 @@ /* -INFO ON NEW KERNEL PLL SYS CALLS - - NTP_SYSCALLS_STD - use the "normal" ones - NTP_SYSCALL_GET - SYS_ntp_gettime id - NTP_SYSCALL_ADJ - SYS_ntp_adjtime id - NTP_SYSCALLS_LIBC - ntp_adjtime() and ntp_gettime() are in libc. - HOW TO GET IP INTERFACE INFORMATION Some UNIX V.4 machines implement a sockets library on top of @@ -72,10 +65,6 @@ MISC LOCK_PROCESS - Have plock. */ -#if !defined(HAVE_NTP_ADJTIME) && defined(HAVE___ADJTIMEX) -# define ntp_adjtime __adjtimex -#endif - int ntp_set_tod (struct timeval *tvp, void *tzp); #if defined (SYS_CYGWIN32) diff --git a/include/ntp_syscall.h b/include/ntp_syscall.h index df2452caa..d1ce03ea9 100644 --- a/include/ntp_syscall.h +++ b/include/ntp_syscall.h @@ -11,24 +11,23 @@ #endif #ifndef NTP_SYSCALLS_LIBC -#ifdef NTP_SYSCALLS_STD -# define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t)) -# define ntp_gettime(t) syscall(SYS_ntp_gettime, (t)) -#else /* !NTP_SYSCALLS_STD */ -# ifdef HAVE___ADJTIMEX -extern int __adjtimex (struct timex *); - -# define ntp_adjtime(t) __adjtimex((t)) - -#ifndef HAVE_STRUCT_NTPTIMEVAL +# ifdef NTP_SYSCALLS_STD +# define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t)) +# define ntp_gettime(t) syscall(SYS_ntp_gettime, (t)) +# else /* !NTP_SYSCALLS_STD */ +# ifdef HAVE_NTP_ADJTIME +extern int ntp_adjtime (struct timex *); + +# ifndef HAVE_STRUCT_NTPTIMEVAL struct ntptimeval { - struct timeval time; /* current time (ro) */ - long int maxerror; /* maximum error (us) (ro) */ - long int esterror; /* estimated error (us) (ro) */ + struct timeval time; /* current time (ro) */ + long int maxerror; /* maximum error (us) (ro) */ + long int esterror; /* estimated error (us) (ro) */ }; -#endif +# endif +# ifndef HAVE_NTP_GETTIME static inline int ntp_gettime( struct ntptimeval *ntv @@ -37,24 +36,21 @@ ntp_gettime( struct timex tntx; int result; - tntx.modes = 0; - result = __adjtimex (&tntx); + ZERO(tntx); + result = ntp_adjtime(&tntx); ntv->time = tntx.time; ntv->maxerror = tntx.maxerror; ntv->esterror = tntx.esterror; -#ifdef NTP_API -# if NTP_API > 3 +# ifdef NTP_API +# if NTP_API > 3 ntv->tai = tntx.tai; -# endif -#endif - return(result); +# endif +# endif + return result; } -# else /* !HAVE__ADJTIMEX */ -# ifdef HAVE___NTP_GETTIME -# define ntp_gettime(t) __ntp_gettime((t)) -# endif -# endif /* !HAVE_ADJTIMEX */ -#endif /* !NTP_SYSCALLS_STD */ -#endif /* !NTP_SYSCALLS_LIBC */ +# endif /* !HAVE_NTP_GETTIME */ +# endif /* !HAVE_NTP_ADJTIME */ +# endif /* !NTP_SYSCALLS_STD */ +#endif /* !NTP_SYSCALLS_LIBC */ -#endif /* NTP_SYSCALL_H */ +#endif /* NTP_SYSCALL_H */ diff --git a/util/tickadj.c b/util/tickadj.c index 80fc535a0..d54e9e684 100644 --- a/util/tickadj.c +++ b/util/tickadj.c @@ -21,9 +21,12 @@ # include #endif /* HAVE_UNISTD_H */ -#ifdef HAVE___ADJTIMEX /* Linux */ +#ifdef HAVE_SYS_TIMEX_H +# include +#endif + +#ifdef HAVE_ADJTIMEX /* Linux */ -#include struct timex txc; #if 0 @@ -57,9 +60,9 @@ main( txc.tickadj = i; txc.modes |= ADJ_TICKADJ; } else { - (void) fprintf(stderr, - "%s: unlikely value for tickadj: %s\n", - progname, ntp_optarg); + fprintf(stderr, + "%s: unlikely value for tickadj: %s\n", + progname, ntp_optarg); errflg++; } break; @@ -91,7 +94,7 @@ main( } if (!errflg) { - if (__adjtimex(&txc) < 0) + if (adjtimex(&txc) < 0) perror("adjtimex"); else if (!quiet) printf("tick = %ld\ntick_adj = %d\n", @@ -145,8 +148,8 @@ main( #endif #endif } - - if (__adjtimex(&txc) < 0) + + if (adjtimex(&txc) < 0) { perror("adjtimex"); } @@ -163,7 +166,7 @@ main( } #endif -#else /* not Linux... kmem tweaking: */ +#else /* not Linux... kmem tweaking: */ #ifdef HAVE_SYS_FILE_H # include