4 * Collect all machine dependent idiosyncrasies in one place.
14 #ifdef TIME_WITH_SYS_TIME
15 # include <sys/time.h>
18 # ifdef HAVE_SYS_TIME_H
19 # include <sys/time.h>
25 #include "ntp_proto.h"
31 The first half of this file is obsolete, and is only there to help
32 reconcile "what went before" with "current behavior".
34 The per-system SYS_* #defins ARE NO LONGER USED, with the temporary
35 exception of SYS_WINNT.
37 If you find a hunk of code that is bracketed by a SYS_* macro and you
38 *know* that it is still needed, please let us know. In many cases the
39 code fragment is now handled somewhere else by autoconf choices.
45 INFO ON NEW KERNEL PLL SYS CALLS
47 NTP_SYSCALLS_STD - use the "normal" ones
48 NTP_SYSCALL_GET - SYS_ntp_gettime id
49 NTP_SYSCALL_ADJ - SYS_ntp_adjtime id
50 NTP_SYSCALLS_LIBC - ntp_adjtime() and ntp_gettime() are in libc.
52 HOW TO GET IP INTERFACE INFORMATION
54 Some UNIX V.4 machines implement a sockets library on top of
55 streams. For these systems, you must use send the SIOCGIFCONF down
56 the stream in an I_STR ioctl. This ususally also implies
57 USE_STREAMS_DEVICE FOR IF_CONFIG. Dell UNIX is a notable exception.
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 DOSYNCTODR - Resync TODR clock every hour.
80 RETSIGTYPE - Define signal function type.
81 NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
82 LOCK_PROCESS - Have plock.
85 #if !defined(HAVE_NTP_ADJTIME) && defined(HAVE___ADJTIMEX)
86 # define ntp_adjtime __adjtimex
92 * IRIX 4.X and IRIX 5.x
94 #if defined(SYS_IRIX4)||defined(SYS_IRIX5)
95 # define ADJTIME_IS_ACCURATE
101 * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
103 #if defined(SYS_ULTRIX)
104 # define S_CHAR_DEFINED
105 # define NTP_SYSCALLS_STD
106 # define HAVE_MODEM_CONTROL
112 #if defined(SYS_AUX2) || defined(SYS_AUX3)
113 # define NO_SIGNED_CHAR_DECL
114 # define LOCK_PROCESS
115 # define NTP_POSIX_SOURCE
117 * This requires that _POSIX_SOURCE be forced on the
118 * compiler command flag. We can't do it here since this
119 * file is included _after_ the system header files and we
120 * need to let _them_ know we're POSIX. We do this in
121 * compilers/aux3.gcc...
123 # define LOG_NTP LOG_LOCAL1
129 #if defined(SYS_HPUX)
130 # define getdtablesize() sysconf(_SC_OPEN_MAX)
131 # define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
132 # define NO_SIGNED_CHAR_DECL
133 # define LOCK_PROCESS
137 * BSD/OS 2.0 and above
139 #if defined(SYS_BSDI)
140 # define USE_FSETOWNCTTY /* this funny system demands a CTTY for FSETOWN */
144 * FreeBSD 2.0 and above
153 #if defined(SYS_LINUX)
154 # define ntp_adjtime __adjtimex
161 # define LOCK_PROCESS
162 struct timezone
{ int __0
; }; /* unused placebo */
166 typedef unsigned int u_int
;
167 # ifndef _NETINET_IN_SYSTM_INCLUDED /* i am about to comment... */
168 typedef unsigned char u_char
;
169 typedef unsigned short u_short
;
170 typedef unsigned long u_long
;
175 * UNIX V.4 on and NCR 3000
177 #if defined(SYS_SVR4)
179 # define LOCK_PROCESS
180 # define SIZE_RETURNED_IN_BUFFER
184 * (Univel/Novell) Unixware1 SVR4 on intel x86 processor
186 #if defined(SYS_UNIXWARE1)
187 /* #define _POSIX_SOURCE */
190 # undef STEP_SLEW /* TWO step */
191 # define LOCK_PROCESS
192 # define SIZE_RETURNED_IN_BUFFER
193 # include <sys/sockio.h>
194 # include <sys/types.h>
195 # include <netinet/in_systm.h>
201 #if defined(SYS_DOMAINOS)
202 # define NTP_SYSCALLS_STD
203 /* older versions of domain/os don't have class D */
205 # define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
206 # define IN_CLASSD_NET 0xf0000000
207 # define IN_CLASSD_NSHIFT 28
208 # define IN_CLASSD_HOST 0xfffffff
209 # define IN_MULTICAST(i) IN_CLASSD(i)
216 #if defined(SYS_UXPV)
217 # define LOCK_PROCESS
218 # define SIZE_RETURNED_IN_BUFFER
225 * Define these here for non-Windows NT systems
226 * SOCKET and INVALID_SOCKET are native macros
227 * on Windows NT and since they have different
228 * requirements we use them in the code and
229 * make them macros for everyone else
233 # define INVALID_SOCKET -1
234 # define SOCKET_ERROR -1
235 # define closesocket(fd) close(fd)
238 int ntp_set_tod (struct timeval
*tvp
, void *tzp
);
240 #if defined (SYS_CYGWIN32)
242 #define __int64 long long
245 /*casey Tue May 27 15:45:25 SAT 1997*/
248 /* casey's new defines */
249 #define NO_MAIN_ALLOWED 1
253 /* in vxWorks we use FIONBIO, but the others are defined for old systems, so
254 * all hell breaks loose if we leave them defined we define USE_FIONBIO to
255 * undefine O_NONBLOCK FNDELAY O_NDELAY where necessary.
257 #define USE_FIONBIO 1
258 /* end my new defines */
260 #define TIMEOFDAY 0x0 /* system wide realtime clock */
261 #define HAVE_GETCLOCK 1 /* configure does not set this ... */
262 #define HAVE_NO_NICE 1 /* configure does not set this ... */
263 #define HAVE_RANDOM 1 /* configure does not set this ... */
264 #define HAVE_SRANDOM 1 /* configure does not set this ... */
268 /* vxWorks specific additions to take care of its
269 * unix (non)complicance
277 extern int sysClkRateGet ();
280 * Bob Herlien's excellent time code find it at:
281 * ftp://ftp.atd.ucar.edu/pub/vxworks/vx/usrTime.shar
282 * I would recommend this instead of clock_[g|s]ettime() plus you get
283 * adjtime() too ... casey
286 extern int gettimeofday ( struct timeval *tp, struct timezone *tzp );
287 extern int settimeofday (struct timeval *, struct timezone *);
288 extern int adjtime ( struct timeval *delta, struct timeval *olddelta );
292 extern void sleep (int seconds
);
293 extern void alarm (int seconds
);
297 /* this is really this */
298 #define getpid taskIdSelf
299 #define getclock clock_gettime
301 #define _getch getchar
303 /* define this away for vxWorks */
305 /* use local defines for these */
309 #endif /* SYS_VXWORKS */
312 /* These structures are needed for gethostbyname() etc... */
313 /* structures used by netdb.h */
315 char *h_name
; /* official name of host */
316 char **h_aliases
; /* alias list */
317 int h_addrtype
; /* host address type */
318 int h_length
; /* length of address */
319 char **h_addr_list
; /* list of addresses from name server */
320 #define h_addr h_addr_list[0] /* address, for backward compatibility */
324 char *s_name
; /* official service name */
325 char **s_aliases
; /* alias list */
326 int s_port
; /* port # */
327 char *s_proto
; /* protocol to use */
333 struct hostent
*gethostbyname (char * netnum
);
334 struct hostent
*gethostbyaddr (char * netnum
, int size
, int addr_type
);
335 /* type is the protocol */
336 struct servent
*getservbyname (char *name
, char *type
);
337 #endif /* NO_NETDB */
339 #ifdef NO_MAIN_ALLOWED
340 /* we have no main routines so lets make a plan */
341 #define CALL(callname, progname, callmain) \
342 extern int callmain (int,char**); \
343 void callname (a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
358 char *argv[] = {progname,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; \
374 for (i=0; i<11;i++) \
377 argv[argc++] = x[i]; \
379 callmain(argc,argv); \
381 #endif /* NO_MAIN_ALLOWED */
382 /*casey Tue May 27 15:45:25 SAT 1997*/
385 * Here's where autoconfig starts to take over
387 #ifdef HAVE_SYS_STROPTS_H
388 # ifdef HAVE_SYS_STREAM_H
394 # if defined(NTP_POSIX_SOURCE)
395 # define RETSIGTYPE void
397 # define RETSIGTYPE int
401 #ifdef NTP_SYSCALLS_STD
402 # ifndef NTP_SYSCALL_GET
403 # define NTP_SYSCALL_GET 235
405 # ifndef NTP_SYSCALL_ADJ
406 # define NTP_SYSCALL_ADJ 236
408 #endif /* NTP_SYSCALLS_STD */
411 # include <sys/types.h>
412 # include <netinet/in.h>
416 /* missing functions that are easily renamed */
418 # define _getch getchar
420 /* special functions that require MPE-specific wrappers */
422 # define bind __ntp_mpe_bind
423 # define fcntl __ntp_mpe_fcntl
425 /* standard macros missing from MPE include files */
427 # define IN_CLASSD(i) ((((long)(i))&0xf0000000)==0xe0000000)
428 # define IN_MULTICAST IN_CLASSD
429 # define ITIMER_REAL 0
430 # define MAXHOSTNAMELEN 64
432 /* standard structures missing from MPE include files */
435 struct timeval it_interval
; /* timer interval */
436 struct timeval it_value
; /* current value */
439 /* various declarations to make gcc stop complaining */
441 extern int __filbuf(FILE *);
442 extern int __flsbuf(int, FILE *);
443 extern int gethostname(char *, int);
444 extern unsigned long inet_addr(char *);
445 extern char *strdup(const char *);
447 /* miscellaneous NTP macros */
449 # define HAVE_NO_NICE
453 # define HAVE_NO_NICE
455 # ifdef HAVE_SETPRIORITY
456 # define HAVE_BSD_NICE
459 # define HAVE_ATT_NICE
464 #if !defined(HAVE_ATT_NICE) \
465 && !defined(HAVE_BSD_NICE) \
466 && !defined(HAVE_NO_NICE)
467 #include "ERROR: You must define one of the HAVE_xx_NICE defines!"
471 * use only one tty model - no use in initialising
472 * a tty in three ways
473 * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
476 #ifdef HAVE_TERMIOS_H
477 # define HAVE_TERMIOS
479 # ifdef HAVE_TERMIO_H
480 # define HAVE_SYSV_TTYS
483 # define HAVE_BSD_TTYS
489 # undef HAVE_BSD_TTYS
490 # undef HAVE_SYSV_TTYS
494 extern time_t timegm (struct tm
*);
497 #ifdef HAVE_SYSV_TTYS
498 # undef HAVE_BSD_TTYS
501 #if !defined(SYS_WINNT) && !defined(VMS) && !defined(SYS_VXWORKS)
502 # if !defined(HAVE_SYSV_TTYS) \
503 && !defined(HAVE_BSD_TTYS) \
504 && !defined(HAVE_TERMIOS)
505 #include "ERROR: no tty type defined!"
507 #endif /* SYS_WINNT || VMS || SYS_VXWORKS*/
509 #ifdef WORDS_BIGENDIAN
510 # define XNTP_BIG_ENDIAN 1
512 # define XNTP_LITTLE_ENDIAN 1
517 * This used to be resolved by calling ntohl() and htonl() to swap things
518 * around, but this turned out to be quite costly on Vaxes where those
519 * things are actual functions. The code now straightens out byte
520 * order troubles on its own, with no performance penalty for little
521 * end first machines, but at great expense to cleanliness.
523 #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
525 * Pick one or the other.
527 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
530 #if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
532 * Pick one or the other.
534 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
537 #endif /* NTP_MACHINE_H */