Jan Friesse wrote: ... > Typo fixed + Jim added to CC. > > Jim, > I don't think logic is so complex, but maybe there is really some better > solution, I'm not autotools expert.
Hi Jan, My first reaction was to use clock_gettime unconditionally. Remove autoconf test, #ifdefs, and alternate gettimeofday implementation. I suggest this because clock_gettime is so widely available these days. Here's a list of systems that lack the function: http://git.sv.gnu.org/cgit/gnulib.git/plain/doc/posix-functions/clock_gettime.texi Do you care about Mac OS X 10.3? I think that's the only possibly-viable corosync build system there. Otherwise, if we were using gnulib, I'd say just add "gethrxtime" to the list of modules, and then use that function. Done. http://git.sv.gnu.org/cgit/gnulib.git/plain/lib/gethrxtime.c > clock_gettime where is available (this is why configure.ac is modified), > and when using this functions make sense. > > diff --git a/trunk/configure.ac b/trunk/configure.ac > index bff779a..a30b41c 100644 > --- a/trunk/configure.ac > +++ b/trunk/configure.ac > @@ -107,6 +107,26 @@ AC_CHECK_FUNCS([alarm alphasort atexit bzero dup2 > endgrent endpwent fcntl \ > pthread_spin_unlock pthread_setschedparam \ > sched_get_priority_max sched_setscheduler]) > > +# Check for time source to use (monotonic in function clock_gettime, or > gettimeofday) > +if test "x$USE_GETTIMEOFDAY" = "x" > +then > + AC_CHECK_FUNCS([clock_gettime], > + dnl clock_gettime() found > + > [AC_CHECK_DECLS([CLOCK_MONOTONIC],AC_DEFINE([USE_CLOCK_MONOTONIC],,[Clock > type to use]), > + dnl no CLOCK_MONOTONIC > + [AC_CHECK_FUNCS([gettimeofday],AC_DEFINE([USE_GETTIMEOFDAY],,[Clock > type to use]),AC_MSG_ERROR([No suitable clock found]))], > + dnl for CLOCK_MONOTONIC > + [#include <time.h>])], > + dnl clock_gettime() not found > + [AC_CHECK_FUNCS([gettimeofday],AC_DEFINE([USE_GETTIMEOFDAY],,[Clock > type to use]),AC_MSG_ERROR([No suitable clock found]))] > + ) > +else > + AC_MSG_NOTICE([Forced to use gettimeofday()]) > + AC_CHECK_FUNCS([gettimeofday],AC_DEFINE([USE_GETTIMEOFDAY],,[Clock type > to use]),AC_MSG_ERROR([No suitable clock found])) This check+define pair is duplicated 3 times, and that nested implicit if/else (action-if-found, action-if-not-found) logic is hard to read. Longer-than-80 lines don't help. If you keep these configure-time tests, it'd be nice not to do that. Something like this would be more readable: AC_CHECK_FUNCS([clock_gettime]) AC_CHECK_DECLS([CLOCK_MONOTONIC], [have_decl=1], [have_decl=0], ...) if test $ac_cv_func_clock_gettime:$have_decl = yes,1; then # have the function and CLOCK_MONOTONIC ... else ... fi > + AC_CHECK_FUNCS([clock_gettime]) > + AC_CHECK_TYPES([clockid_t]) This check appears unused, since the code doesn't use HAVE_CLOCKID_T. _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
