2 * Collect all machine dependent idiosyncrasies in one place.
12 #ifdef TIME_WITH_SYS_TIME
13 # include <sys/time.h>
16 # ifdef HAVE_SYS_TIME_H
17 # include <sys/time.h>
23 #include "ntp_proto.h"
29 The first half of this file is obsolete, and is only there to help
30 reconcile "what went before" with "current behavior".
32 The per-system SYS_* #defins ARE NO LONGER USED, with the temporary
33 exception of SYS_WINNT.
35 If you find a hunk of code that is bracketed by a SYS_* macro and you
36 *know* that it is still needed, please let us know. In many cases the
37 code fragment is now handled somewhere else by autoconf choices.
43 INFO ON NEW KERNEL PLL SYS CALLS
45 NTP_SYSCALLS_STD - use the "normal" ones
46 NTP_SYSCALL_GET - SYS_ntp_gettime id
47 NTP_SYSCALL_ADJ - SYS_ntp_adjtime id
48 NTP_SYSCALLS_LIBC - ntp_adjtime() and ntp_gettime() are in libc.
50 HOW TO GET IP INTERFACE INFORMATION
52 Some UNIX V.4 machines implement a sockets library on top of
53 streams. For these systems, you must use send the SIOCGIFCONF down
54 the stream in an I_STR ioctl. This ususally also implies
55 USE_STREAMS_DEVICE FOR IF_CONFIG. Dell UNIX is a notable exception.
57 WHAT DOES IOCTL(SIOCGIFCONF) RETURN IN THE BUFFER
59 UNIX V.4 machines implement a sockets library on top of streams.
60 When requesting the IP interface configuration with an ioctl(2) calll,
61 an array of ifreq structures are placed in the provided buffer. Some
62 implementations also place the length of the buffer information in
63 the first integer position of the buffer.
65 SIZE_RETURNED_IN_BUFFER - size integer is in the buffer
67 WILL IOCTL(SIOCGIFCONF) WORK ON A SOCKET
69 Some UNIX V.4 machines do not appear to support ioctl() requests for the
70 IP interface configuration on a socket. They appear to require the use
71 of the streams device instead.
73 USE_STREAMS_DEVICE_FOR_IF_CONFIG - use the /dev/ip device for configuration
77 HAVE_PROTOTYPES - Prototype functions
78 DOSYNCTODR - Resync TODR clock every hour.
79 RETSIGTYPE - Define signal function type.
80 NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
81 LOCK_PROCESS - Have plock.
85 * Set up for prototyping (duplicated from ntp_types.h)
88 #if defined(__STDC__) || defined(HAVE_PROTOTYPES)
90 #else /* not __STDC__ and not HAVE_PROTOTYPES */
92 #endif /* not __STDC__ and not HAVE_PROTOTYPES */
95 #if !defined(HAVE_NTP_ADJTIME) && defined(HAVE___ADJTIMEX)
96 # define ntp_adjtime __adjtimex
102 * IRIX 4.X and IRIX 5.x
104 #if defined(SYS_IRIX4)||defined(SYS_IRIX5)
105 # define ADJTIME_IS_ACCURATE
106 # define LOCK_PROCESS
111 * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
113 #if defined(SYS_ULTRIX)
114 # define S_CHAR_DEFINED
115 # define NTP_SYSCALLS_STD
116 # define HAVE_MODEM_CONTROL
122 #if defined(SYS_AUX2) || defined(SYS_AUX3)
123 # define NO_SIGNED_CHAR_DECL
124 # define LOCK_PROCESS
125 # define NTP_POSIX_SOURCE
127 * This requires that _POSIX_SOURCE be forced on the
128 * compiler command flag. We can't do it here since this
129 * file is included _after_ the system header files and we
130 * need to let _them_ know we're POSIX. We do this in
131 * compilers/aux3.gcc...
133 # define LOG_NTP LOG_LOCAL1
139 #if defined(SYS_HPUX)
140 # define getdtablesize() sysconf(_SC_OPEN_MAX)
141 # define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
142 # define NO_SIGNED_CHAR_DECL
143 # define LOCK_PROCESS
147 * BSD/OS 2.0 and above
149 #if defined(SYS_BSDI)
150 # define USE_FSETOWNCTTY /* this funny system demands a CTTY for FSETOWN */
154 * FreeBSD 2.0 and above
163 #if defined(SYS_LINUX)
164 # define ntp_adjtime __adjtimex
171 # define LOCK_PROCESS
172 struct timezone { int __0; }; /* unused placebo */
176 typedef unsigned int u_int;
177 # ifndef _NETINET_IN_SYSTM_INCLUDED /* i am about to comment... */
178 typedef unsigned char u_char;
179 typedef unsigned short u_short;
180 typedef unsigned long u_long;
185 * UNIX V.4 on and NCR 3000
187 #if defined(SYS_SVR4)
189 # define LOCK_PROCESS
190 # define SIZE_RETURNED_IN_BUFFER
194 * (Univel/Novell) Unixware1 SVR4 on intel x86 processor
196 #if defined(SYS_UNIXWARE1)
197 /* #define _POSIX_SOURCE */
200 # undef STEP_SLEW /* TWO step */
201 # define LOCK_PROCESS
202 # define SIZE_RETURNED_IN_BUFFER
203 # include <sys/sockio.h>
204 # include <sys/types.h>
205 # include <netinet/in_systm.h>
211 #if defined(SYS_DOMAINOS)
212 # define NTP_SYSCALLS_STD
213 /* older versions of domain/os don't have class D */
215 # define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
216 # define IN_CLASSD_NET 0xf0000000
217 # define IN_CLASSD_NSHIFT 28
218 # define IN_CLASSD_HOST 0xfffffff
219 # define IN_MULTICAST(i) IN_CLASSD(i)
226 #if defined(SYS_UXPV)
227 # define LOCK_PROCESS
228 # define SIZE_RETURNED_IN_BUFFER
235 * Define these here for non-Windows NT systems
236 * SOCKET and INVALID_SOCKET are native macros
237 * on Windows NT and since they have different
238 * requirements we use them in the code and
239 * make them macros for everyone else
243 # define INVALID_SOCKET -1
244 # define SOCKET_ERROR -1
245 # define closesocket close
250 #if defined(SYS_WINNT)
251 # if !defined(HAVE_CONFIG_H) || !defined(__config)
253 # endif /* HAVE_CONFIG_H) */
254 # include <windows.h>
255 # include <ws2tcpip.h>
256 # include <winsock2.h>
258 # define ifreq _INTERFACE_INFO
259 # define ifr_flags iiFlags
260 # define ifr_addr iiAddress.AddressIn
261 # define ifr_broadaddr iiBroadcastAddress.AddressIn
262 # define ifr_mask iiNetmask.AddressIn
263 # define zz_family sin_family
265 # define S_IFREG _S_IFREG
267 # define isascii __isascii
268 # define isatty _isatty
269 # define mktemp _mktemp
270 # define unlink _unlink
271 # define fileno _fileno
272 # define write _write
274 # define close _close
277 # include <process.h>
278 #define getpid _getpid
280 * Defining registers are not a good idea on Windows
281 * This gets rid of the usage
286 typedef char *caddr_t;
287 # define vsnprintf _vsnprintf
288 #endif /* SYS_WINNT */
290 int ntp_set_tod P((struct timeval *tvp, void *tzp));
292 #if defined (SYS_CYGWIN32)
294 #define __int64 long long
297 /*casey Tue May 27 15:45:25 SAT 1997*/
300 /* casey's new defines */
301 #define NO_MAIN_ALLOWED 1
305 /* in vxWorks we use FIONBIO, but the others are defined for old systems, so
306 * all hell breaks loose if we leave them defined we define USE_FIONBIO to
307 * undefine O_NONBLOCK FNDELAY O_NDELAY where necessary.
309 #define USE_FIONBIO 1
310 /* end my new defines */
312 #define TIMEOFDAY 0x0 /* system wide realtime clock */
313 #define HAVE_GETCLOCK 1 /* configure does not set this ... */
314 #define HAVE_NO_NICE 1 /* configure does not set this ... */
315 #define HAVE_RANDOM 1 /* configure does not set this ... */
316 #define HAVE_SRANDOM 1 /* configure does not set this ... */
320 /* vxWorks specific additions to take care of its
321 * unix (non)complicance
329 extern int sysClkRateGet P(());
332 * Bob Herlien's excellent time code find it at:
333 * ftp://ftp.atd.ucar.edu/pub/vxworks/vx/usrTime.shar
334 * I would recommend this instead of clock_[g|s]ettime() plus you get
335 * adjtime() too ... casey
338 extern int gettimeofday P(( struct timeval *tp, struct timezone *tzp ));
339 extern int settimeofday P((struct timeval *, struct timezone *));
340 extern int adjtime P(( struct timeval *delta, struct timeval *olddelta ));
344 extern void sleep P((int seconds));
345 extern void alarm P((int seconds));
349 /* this is really this */
350 #define getpid taskIdSelf
351 #define getclock clock_gettime
353 #define _getch getchar
355 /* define this away for vxWorks */
357 /* use local defines for these */
361 #endif /* SYS_VXWORKS */
364 /* These structures are needed for gethostbyname() etc... */
365 /* structures used by netdb.h */
367 char *h_name; /* official name of host */
368 char **h_aliases; /* alias list */
369 int h_addrtype; /* host address type */
370 int h_length; /* length of address */
371 char **h_addr_list; /* list of addresses from name server */
372 #define h_addr h_addr_list[0] /* address, for backward compatibility */
376 char *s_name; /* official service name */
377 char **s_aliases; /* alias list */
378 int s_port; /* port # */
379 char *s_proto; /* protocol to use */
385 struct hostent *gethostbyname P((char * netnum));
386 struct hostent *gethostbyaddr P((char * netnum, int size, int addr_type));
387 /* type is the protocol */
388 struct servent *getservbyname P((char *name, char *type));
389 #endif /* NO_NETDB */
391 #ifdef NO_MAIN_ALLOWED
392 /* we have no main routines so lets make a plan */
393 #define CALL(callname, progname, callmain) \
394 extern int callmain (int,char**); \
395 void callname (a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
410 char *argv[] = {progname,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; \
426 for (i=0; i<11;i++) \
429 argv[argc++] = x[i]; \
431 callmain(argc,argv); \
433 #endif /* NO_MAIN_ALLOWED */
434 /*casey Tue May 27 15:45:25 SAT 1997*/
437 * Here's where autoconfig starts to take over
439 #ifdef HAVE_SYS_STROPTS_H
440 # ifdef HAVE_SYS_STREAM_H
446 # if defined(NTP_POSIX_SOURCE)
447 # define RETSIGTYPE void
449 # define RETSIGTYPE int
453 #ifdef NTP_SYSCALLS_STD
454 # ifndef NTP_SYSCALL_GET
455 # define NTP_SYSCALL_GET 235
457 # ifndef NTP_SYSCALL_ADJ
458 # define NTP_SYSCALL_ADJ 236
460 #endif /* NTP_SYSCALLS_STD */
463 # include <sys/types.h>
464 # include <netinet/in.h>
468 /* missing functions that are easily renamed */
470 # define _getch getchar
472 /* special functions that require MPE-specific wrappers */
474 # define bind __ntp_mpe_bind
475 # define fcntl __ntp_mpe_fcntl
477 /* standard macros missing from MPE include files */
479 # define IN_CLASSD(i) ((((long)(i))&0xf0000000)==0xe0000000)
480 # define IN_MULTICAST IN_CLASSD
481 # define ITIMER_REAL 0
482 # define MAXHOSTNAMELEN 64
484 /* standard structures missing from MPE include files */
487 struct timeval it_interval; /* timer interval */
488 struct timeval it_value; /* current value */
491 /* various declarations to make gcc stop complaining */
493 extern int __filbuf(FILE *);
494 extern int __flsbuf(int, FILE *);
495 extern int gethostname(char *, int);
496 extern unsigned long inet_addr(char *);
497 extern char *strdup(const char *);
499 /* miscellaneous NTP macros */
501 # define HAVE_NO_NICE
505 # define HAVE_NO_NICE
507 # ifdef HAVE_SETPRIORITY
508 # define HAVE_BSD_NICE
511 # define HAVE_ATT_NICE
516 #if !defined(HAVE_ATT_NICE) \
517 && !defined(HAVE_BSD_NICE) \
518 && !defined(HAVE_NO_NICE) \
519 && !defined(SYS_WINNT)
520 #include "ERROR: You must define one of the HAVE_xx_NICE defines!"
524 * use only one tty model - no use in initialising
525 * a tty in three ways
526 * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
529 #ifdef HAVE_TERMIOS_H
530 # define HAVE_TERMIOS
532 # ifdef HAVE_TERMIO_H
533 # define HAVE_SYSV_TTYS
536 # define HAVE_BSD_TTYS
542 # undef HAVE_BSD_TTYS
543 # undef HAVE_SYSV_TTYS
547 extern time_t timegm P((struct tm *));
550 #ifdef HAVE_SYSV_TTYS
551 # undef HAVE_BSD_TTYS
554 #if !defined(SYS_WINNT) && !defined(VMS) && !defined(SYS_VXWORKS)
555 # if !defined(HAVE_SYSV_TTYS) \
556 && !defined(HAVE_BSD_TTYS) \
557 && !defined(HAVE_TERMIOS)
558 #include "ERROR: no tty type defined!"
560 #endif /* SYS_WINNT || VMS || SYS_VXWORKS*/
562 #ifdef WORDS_BIGENDIAN
563 # define XNTP_BIG_ENDIAN 1
565 # define XNTP_LITTLE_ENDIAN 1
570 * This used to be resolved by calling ntohl() and htonl() to swap things
571 * around, but this turned out to be quite costly on Vaxes where those
572 * things are actual functions. The code now straightens out byte
573 * order troubles on its own, with no performance penalty for little
574 * end first machines, but at great expense to cleanliness.
576 #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
578 * Pick one or the other.
580 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
583 #if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
585 * Pick one or the other.
587 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
590 #endif /* __ntp_machine */