[ntp:hackers] Re: refclock_atom.c

Harlan Stenn stenn at www.ntp.org
Mon Dec 13 17:55:52 PST 2004


Dave,

I've added hackers@ to this thread.

Here's the history:

At one time, we noted we could find timepps.h in either /usr/include or
/usr/include/sys .

Therefore we support both locations.  The code to do that is:

 #ifdef HAVE_PPSAPI
 # ifdef HAVE_TIMEPPS_H
 #  include <timepps.h>
 # else
 #  ifdef HAVE_SYS_TIMEPPS_H
 #   include <sys/timepps.h>
 #  endif /* HAVE_SYS_TIMEPPS_H */
 # endif /* HAVE_TIMEPPS_H */
 #endif /* HAVE_PPSAPI */

Then, somebody noticed that we provide timepps.h files for SunOS, Solaris,
and SCO.

On the appropriate OS, the particular file is, as I understand it, designed
to be installed as-is into /usr/include/sys/timepps.h .  IS THIS TRUE?

Therefore, this person (I don't know who had this idea) decided that:

- if we HAVE_TIMEPPS_H or HAVE_SYS_TIMEPPS_H then use them and all is well.
- else if we are on SunOS we can use timepps-SunOS.h and then we HAVE_PPSAPI.
- else if we are on Solaris we can use timepps-Solaris.h and we HAVE_PPSAPI.
- else if we are on SCO we can use timepps-SCO.h and we HAVE_PPSAPI.

and therefore, on those OSes there is no functional difference between:

- installing include/timepps-OS.h as /usr/include/sys/timepps.h and
  getting /usr/include/sys/timepps.h, and
- getting include/timepps-OS.h

and therefore we can change the above header inclusion mess to be:

 #ifdef HAVE_PPSAPI
 # ifdef HAVE_TIMEPPS_H
 #  include <timepps.h>
 # else
 #  ifdef HAVE_SYS_TIMEPPS_H
 #   include <sys/timepps.h>
 #  else /* not HAVE_SYS_TIMEPPS_H */
 #   ifdef TheSunOsThingWeNeed
 #    include "timepps-SunOS.h"
 #    define HAVE_PPSAPI 1
 #   else /* not SunOs */
 #    ifdef TheSolarisThingWeNeed
 #     include "timepps-Solaris.h"
 #     define HAVE_PPSAPI 1
 #    else /* not Solaris */
 #     ifdef TheSCOThingWeNeed
 #      include "timepps-SCO.h"
 #      define HAVE_PPSAPI 1
 #     endif /* SCO */
 #    endif /* not Solaris */
 #   endif /* not Sunos */
 #  endif /* not HAVE_SYS_TIMEPPS_H */
 # endif /* HAVE_TIMEPPS_H */
 #endif /* HAVE_PPSAPI */

and this started to appear in a number of driver files.

I decided that I would *much* rather see:

 #ifdef HAVE_PPSAPI
 # include "ppsapi-timepps.h"
 #endif

in the 5 (or so) source files, and only put the #ifdef "nest" (either the
old one or the new one) in one place, namely ppsapi-timepps.h .

That's what I did, and the result seems to be much cleaner.

>From what I can see, the only potential problem with this is the case
where the different timepps-OS.h files are not really usable as-is, and
must be tweaked somehow.

Am I missing something?

H



More information about the hackers mailing list