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 STREAMS_TLI - use ioctl(I_STR) to implement ioctl(SIOCGIFCONF)
59 WHAT DOES IOCTL(SIOCGIFCONF) RETURN IN THE BUFFER
61 UNIX V.4 machines implement a sockets library on top of streams.
62 When requesting the IP interface configuration with an ioctl(2) calll,
63 an array of ifreq structures are placed in the provided buffer. Some
64 implementations also place the length of the buffer information in
65 the first integer position of the buffer.
67 SIZE_RETURNED_IN_BUFFER - size integer is in the buffer
69 WILL IOCTL(SIOCGIFCONF) WORK ON A SOCKET
71 Some UNIX V.4 machines do not appear to support ioctl() requests for the
72 IP interface configuration on a socket. They appear to require the use
73 of the streams device instead.
75 USE_STREAMS_DEVICE_FOR_IF_CONFIG - use the /dev/ip device for configuration
79 HAVE_PROTOTYPES - Prototype functions
80 DOSYNCTODR - Resync TODR clock every hour.
81 RETSIGTYPE - Define signal function type.
82 NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
83 LOCK_PROCESS - Have plock.
85 - these systems deliver broadcast packets to the wildcard
86 port instead to a port bound to the interface bound
87 to the correct broadcast address - are these
88 implementations broken or did the spec change ?
92 * Set up for prototyping (duplicated from ntp_types.h)
95 #if defined(__STDC__) || defined(HAVE_PROTOTYPES)
97 #else /* not __STDC__ and not HAVE_PROTOTYPES */
99 #endif /* not __STDC__ and not HAVE_PROTOTYPES */
105 * IRIX 4.X and IRIX 5.x
107 #if defined(SYS_IRIX4)||defined(SYS_IRIX5)
108 # define ADJTIME_IS_ACCURATE
109 # define LOCK_PROCESS
114 * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
116 #if defined(SYS_ULTRIX)
117 # define S_CHAR_DEFINED
118 # define NTP_SYSCALLS_STD
119 # define HAVE_MODEM_CONTROL
125 #if defined(SYS_AUX2) || defined(SYS_AUX3)
126 # define NO_SIGNED_CHAR_DECL
127 # define LOCK_PROCESS
128 # define NTP_POSIX_SOURCE
130 * This requires that _POSIX_SOURCE be forced on the
131 * compiler command flag. We can't do it here since this
132 * file is included _after_ the system header files and we
133 * need to let _them_ know we're POSIX. We do this in
134 * compilers/aux3.gcc...
136 # define LOG_NTP LOG_LOCAL1
142 #if defined(SYS_HPUX)
143 # define getdtablesize() sysconf(_SC_OPEN_MAX)
144 # define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
145 # define NO_SIGNED_CHAR_DECL
146 # define LOCK_PROCESS
150 * BSD/OS 2.0 and above
152 #if defined(SYS_BSDI)
153 # define USE_FSETOWNCTTY /* this funny system demands a CTTY for FSETOWN */
157 * FreeBSD 2.0 and above
166 #if defined(SYS_LINUX)
167 # define ntp_adjtime __adjtimex
174 # define LOCK_PROCESS
175 struct timezone { int __0; }; /* unused placebo */
179 typedef unsigned int u_int;
180 # ifndef _NETINET_IN_SYSTM_INCLUDED /* i am about to comment... */
181 typedef unsigned char u_char;
182 typedef unsigned short u_short;
183 typedef unsigned long u_long;
188 * UNIX V.4 on and NCR 3000
190 #if defined(SYS_SVR4)
192 # define LOCK_PROCESS
193 # define SIZE_RETURNED_IN_BUFFER
197 * (Univel/Novell) Unixware1 SVR4 on intel x86 processor
199 #if defined(SYS_UNIXWARE1)
200 /* #define _POSIX_SOURCE */
203 # undef STEP_SLEW /* TWO step */
204 # define LOCK_PROCESS
205 # define SIZE_RETURNED_IN_BUFFER
206 # include <sys/sockio.h>
207 # include <sys/types.h>
208 # include <netinet/in_systm.h>
214 #if defined(SYS_DOMAINOS)
215 # define NTP_SYSCALLS_STD
216 /* older versions of domain/os don't have class D */
218 # define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
219 # define IN_CLASSD_NET 0xf0000000
220 # define IN_CLASSD_NSHIFT 28
221 # define IN_CLASSD_HOST 0xfffffff
222 # define IN_MULTICAST(i) IN_CLASSD(i)
229 #if defined(SYS_UXPV)
230 # define LOCK_PROCESS
231 # define SIZE_RETURNED_IN_BUFFER
240 #if defined(SYS_WINNT)
241 # if !defined(HAVE_CONFIG_H) || !defined(__config)
242 error "NT requires config.h to be included"
243 # endif /* HAVE_CONFIG_H) */
245 # define ifreq _INTERFACE_INFO
246 # define ifr_flags iiFlags
247 # define ifr_addr iiAddress.AddressIn
248 # define ifr_broadaddr iiBroadcastAddress.AddressIn
249 # define ifr_mask iiNetmask.AddressIn
251 # define isascii __isascii
252 # define isatty _isatty
253 # define mktemp _mktemp
255 # define getpid GetCurrentProcessId
257 # include <windows.h>
258 # include <ws2tcpip.h>
260 typedef char *caddr_t;
261 #endif /* SYS_WINNT */
263 int ntp_set_tod P((struct timeval *tvp, void *tzp));
265 #if defined (SYS_CYGWIN32)
267 #define __int64 long long
270 /*casey Tue May 27 15:45:25 SAT 1997*/
273 /* casey's new defines */
274 #define NO_MAIN_ALLOWED 1
278 /* in vxWorks we use FIONBIO, but the others are defined for old systems, so
279 * all hell breaks loose if we leave them defined we define USE_FIONBIO to
280 * undefine O_NONBLOCK FNDELAY O_NDELAY where necessary.
282 #define USE_FIONBIO 1
283 /* end my new defines */
285 #define TIMEOFDAY 0x0 /* system wide realtime clock */
286 #define HAVE_GETCLOCK 1 /* configure does not set this ... */
287 #define HAVE_NO_NICE 1 /* configure does not set this ... */
288 #define HAVE_RANDOM 1 /* configure does not set this ... */
289 #define HAVE_SRANDOM 1 /* configure does not set this ... */
293 /* vxWorks specific additions to take care of its
294 * unix (non)complicance
302 extern int sysClkRateGet P(());
305 * Bob Herlien's excellent time code find it at:
306 * ftp://ftp.atd.ucar.edu/pub/vxworks/vx/usrTime.shar
307 * I would recommend this instead of clock_[g|s]ettime() plus you get
308 * adjtime() too ... casey
311 extern int gettimeofday P(( struct timeval *tp, struct timezone *tzp ));
312 extern int settimeofday P((struct timeval *, struct timezone *));
313 extern int adjtime P(( struct timeval *delta, struct timeval *olddelta ));
317 extern void sleep P((int seconds));
318 extern void alarm P((int seconds));
322 /* this is really this */
323 #define getpid taskIdSelf
324 #define getclock clock_gettime
326 #define _getch getchar
328 #define srandom srand
330 /* define this away for vxWorks */
332 /* use local defines for these */
336 #endif /* SYS_VXWORKS */
339 /* These structures are needed for gethostbyname() etc... */
340 /* structures used by netdb.h */
342 char *h_name; /* official name of host */
343 char **h_aliases; /* alias list */
344 int h_addrtype; /* host address type */
345 int h_length; /* length of address */
346 char **h_addr_list; /* list of addresses from name server */
347 #define h_addr h_addr_list[0] /* address, for backward compatibility */
351 char *s_name; /* official service name */
352 char **s_aliases; /* alias list */
353 int s_port; /* port # */
354 char *s_proto; /* protocol to use */
360 struct hostent *gethostbyname P((char * netnum));
361 struct hostent *gethostbyaddr P((char * netnum, int size, int addr_type));
362 /* type is the protocol */
363 struct servent *getservbyname P((char *name, char *type));
364 #endif /* NO_NETDB */
366 #ifdef NO_MAIN_ALLOWED
367 /* we have no main routines so lets make a plan */
368 #define CALL(callname, progname, callmain) \
369 extern int callmain (int,char**); \
370 void callname (a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
385 char *argv[] = {progname,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; \
401 for (i=0; i<11;i++) \
404 argv[argc++] = x[i]; \
406 callmain(argc,argv); \
408 #endif /* NO_MAIN_ALLOWED */
409 /*casey Tue May 27 15:45:25 SAT 1997*/
412 * Here's where autoconfig starts to take over
414 #ifdef HAVE_SYS_STROPTS_H
415 # ifdef HAVE_SYS_STREAM_H
421 # if defined(NTP_POSIX_SOURCE)
422 # define RETSIGTYPE void
424 # define RETSIGTYPE int
428 #ifdef NTP_SYSCALLS_STD
429 # ifndef NTP_SYSCALL_GET
430 # define NTP_SYSCALL_GET 235
432 # ifndef NTP_SYSCALL_ADJ
433 # define NTP_SYSCALL_ADJ 236
435 #endif /* NTP_SYSCALLS_STD */
438 # define HAVE_NO_NICE
440 # ifdef HAVE_SETPRIORITY
441 # define HAVE_BSD_NICE
444 # define HAVE_ATT_NICE
449 #if !defined(HAVE_ATT_NICE) \
450 && !defined(HAVE_BSD_NICE) \
451 && !defined(HAVE_NO_NICE) \
452 && !defined(SYS_WINNT)
453 #include "ERROR: You must define one of the HAVE_xx_NICE defines!"
457 * use only one tty model - no use in initialising
458 * a tty in three ways
459 * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
462 #ifdef HAVE_TERMIOS_H
463 # define HAVE_TERMIOS
465 # ifdef HAVE_TERMIO_H
466 # define HAVE_SYSV_TTYS
469 # define HAVE_BSD_TTYS
475 # undef HAVE_BSD_TTYS
476 # undef HAVE_SYSV_TTYS
479 #ifdef HAVE_SYSV_TTYS
480 # undef HAVE_BSD_TTYS
483 #if !defined(SYS_WINNT) && !defined(VMS) && !defined(SYS_VXWORKS)
484 # if !defined(HAVE_SYSV_TTYS) \
485 && !defined(HAVE_BSD_TTYS) \
486 && !defined(HAVE_TERMIOS)
487 #include "ERROR: no tty type defined!"
489 #endif /* SYS_WINNT || VMS || SYS_VXWORKS*/
491 #ifdef WORDS_BIGENDIAN
492 # define XNTP_BIG_ENDIAN 1
494 # define XNTP_LITTLE_ENDIAN 1
498 * Byte order woes. The DES code is sensitive to byte order. This
499 * used to be resolved by calling ntohl() and htonl() to swap things
500 * around, but this turned out to be quite costly on Vaxes where those
501 * things are actual functions. The code now straightens out byte
502 * order troubles on its own, with no performance penalty for little
503 * end first machines, but at great expense to cleanliness.
505 #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
507 * Pick one or the other.
509 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
512 #if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
514 * Pick one or the other.
516 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
519 #endif /* __ntp_machine */