Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / include / ntp_machine.h
blob0cc6acc11e18082e2b1689dddf72121844c6d81f
1 /* $NetBSD: ntp_machine.h,v 1.3 2006/06/11 19:34:09 kardel Exp $ */
3 /*
4 * Collect all machine dependent idiosyncrasies in one place.
5 */
7 #ifndef __ntp_machine
8 #define __ntp_machine
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
14 #ifdef TIME_WITH_SYS_TIME
15 # include <sys/time.h>
16 # include <time.h>
17 #else
18 # ifdef HAVE_SYS_TIME_H
19 # include <sys/time.h>
20 # else
21 # include <time.h>
22 # endif
23 #endif
25 #include "ntp_proto.h"
29 HEY! CHECK THIS OUT!
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
77 MISC
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.
87 * Set up for prototyping (duplicated from ntp_types.h)
89 #ifndef P
90 #if defined(__STDC__) || defined(HAVE_PROTOTYPES)
91 #define P(x) x
92 #else /* not __STDC__ and not HAVE_PROTOTYPES */
93 #define P(x) ()
94 #endif /* not __STDC__ and not HAVE_PROTOTYPES */
95 #endif /* P */
97 #if !defined(HAVE_NTP_ADJTIME) && defined(HAVE___ADJTIMEX)
98 # define ntp_adjtime __adjtimex
99 #endif
101 #if 0
104 * IRIX 4.X and IRIX 5.x
106 #if defined(SYS_IRIX4)||defined(SYS_IRIX5)
107 # define ADJTIME_IS_ACCURATE
108 # define LOCK_PROCESS
109 #endif
112 * Ultrix
113 * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
115 #if defined(SYS_ULTRIX)
116 # define S_CHAR_DEFINED
117 # define NTP_SYSCALLS_STD
118 # define HAVE_MODEM_CONTROL
119 #endif
122 * AUX
124 #if defined(SYS_AUX2) || defined(SYS_AUX3)
125 # define NO_SIGNED_CHAR_DECL
126 # define LOCK_PROCESS
127 # define NTP_POSIX_SOURCE
129 * This requires that _POSIX_SOURCE be forced on the
130 * compiler command flag. We can't do it here since this
131 * file is included _after_ the system header files and we
132 * need to let _them_ know we're POSIX. We do this in
133 * compilers/aux3.gcc...
135 # define LOG_NTP LOG_LOCAL1
136 #endif
139 * HPUX
141 #if defined(SYS_HPUX)
142 # define getdtablesize() sysconf(_SC_OPEN_MAX)
143 # define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
144 # define NO_SIGNED_CHAR_DECL
145 # define LOCK_PROCESS
146 #endif
149 * BSD/OS 2.0 and above
151 #if defined(SYS_BSDI)
152 # define USE_FSETOWNCTTY /* this funny system demands a CTTY for FSETOWN */
153 #endif
156 * FreeBSD 2.0 and above
158 #ifdef SYS_FREEBSD
159 # define KERNEL_PLL
160 #endif
163 * Linux
165 #if defined(SYS_LINUX)
166 # define ntp_adjtime __adjtimex
167 #endif
170 * PTX
172 #if defined(SYS_PTX)
173 # define LOCK_PROCESS
174 struct timezone { int __0; }; /* unused placebo */
176 * no comment !@!
178 typedef unsigned int u_int;
179 # ifndef _NETINET_IN_SYSTM_INCLUDED /* i am about to comment... */
180 typedef unsigned char u_char;
181 typedef unsigned short u_short;
182 typedef unsigned long u_long;
183 # endif
184 #endif
187 * UNIX V.4 on and NCR 3000
189 #if defined(SYS_SVR4)
190 # define STREAM
191 # define LOCK_PROCESS
192 # define SIZE_RETURNED_IN_BUFFER
193 #endif
196 * (Univel/Novell) Unixware1 SVR4 on intel x86 processor
198 #if defined(SYS_UNIXWARE1)
199 /* #define _POSIX_SOURCE */
200 # define STREAM
201 # define STREAMS
202 # undef STEP_SLEW /* TWO step */
203 # define LOCK_PROCESS
204 # define SIZE_RETURNED_IN_BUFFER
205 # include <sys/sockio.h>
206 # include <sys/types.h>
207 # include <netinet/in_systm.h>
208 #endif
211 * DomainOS
213 #if defined(SYS_DOMAINOS)
214 # define NTP_SYSCALLS_STD
215 /* older versions of domain/os don't have class D */
216 # ifndef IN_CLASSD
217 # define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
218 # define IN_CLASSD_NET 0xf0000000
219 # define IN_CLASSD_NSHIFT 28
220 # define IN_CLASSD_HOST 0xfffffff
221 # define IN_MULTICAST(i) IN_CLASSD(i)
222 # endif
223 #endif
226 * Fujitsu UXP/V
228 #if defined(SYS_UXPV)
229 # define LOCK_PROCESS
230 # define SIZE_RETURNED_IN_BUFFER
231 #endif
234 #endif /* 0 */
237 * Define these here for non-Windows NT systems
238 * SOCKET and INVALID_SOCKET are native macros
239 * on Windows NT and since they have different
240 * requirements we use them in the code and
241 * make them macros for everyone else
243 #ifndef SYS_WINNT
244 # define SOCKET int
245 # define INVALID_SOCKET -1
246 # define SOCKET_ERROR -1
247 # define closesocket close
248 #endif
250 * Windows NT
252 #if defined(SYS_WINNT)
253 # if !defined(HAVE_CONFIG_H) || !defined(__config)
254 # include <config.h>
255 # endif /* HAVE_CONFIG_H) */
256 # include <windows.h>
257 # include <ws2tcpip.h>
258 # include <winsock2.h>
260 # define ifreq _INTERFACE_INFO
261 # define ifr_flags iiFlags
262 # define ifr_addr iiAddress.AddressIn
263 # define ifr_broadaddr iiBroadcastAddress.AddressIn
264 # define ifr_mask iiNetmask.AddressIn
265 # define zz_family sin_family
267 # define S_IFREG _S_IFREG
268 # define stat _stat
269 # define isascii __isascii
270 # define isatty _isatty
271 # define mktemp _mktemp
272 # define unlink _unlink
273 # define fileno _fileno
274 # define write _write
275 #ifndef close
276 # define close _close
277 #endif
278 # undef interface
279 # include <process.h>
280 #define getpid _getpid
282 * Defining registers are not a good idea on Windows
283 * This gets rid of the usage
285 #ifndef register
286 # define register
287 #endif
288 typedef char *caddr_t;
289 # define vsnprintf _vsnprintf
290 #endif /* SYS_WINNT */
292 int ntp_set_tod P((struct timeval *tvp, void *tzp));
294 #if defined (SYS_CYGWIN32)
295 #include <windows.h>
296 #define __int64 long long
297 #endif
299 /*casey Tue May 27 15:45:25 SAT 1997*/
300 #ifdef SYS_VXWORKS
302 /* casey's new defines */
303 #define NO_MAIN_ALLOWED 1
304 #define NO_NETDB 1
305 #define NO_RENAME 1
307 /* in vxWorks we use FIONBIO, but the others are defined for old systems, so
308 * all hell breaks loose if we leave them defined we define USE_FIONBIO to
309 * undefine O_NONBLOCK FNDELAY O_NDELAY where necessary.
311 #define USE_FIONBIO 1
312 /* end my new defines */
314 #define TIMEOFDAY 0x0 /* system wide realtime clock */
315 #define HAVE_GETCLOCK 1 /* configure does not set this ... */
316 #define HAVE_NO_NICE 1 /* configure does not set this ... */
317 #define HAVE_RANDOM 1 /* configure does not set this ... */
318 #define HAVE_SRANDOM 1 /* configure does not set this ... */
320 #define NODETACH 1
322 /* vxWorks specific additions to take care of its
323 * unix (non)complicance
326 #include "vxWorks.h"
327 #include "ioLib.h"
328 #include "taskLib.h"
329 #include "time.h"
331 extern int sysClkRateGet P(());
333 /* usrtime.h
334 * Bob Herlien's excellent time code find it at:
335 * ftp://ftp.atd.ucar.edu/pub/vxworks/vx/usrTime.shar
336 * I would recommend this instead of clock_[g|s]ettime() plus you get
337 * adjtime() too ... casey
340 extern int gettimeofday P(( struct timeval *tp, struct timezone *tzp ));
341 extern int settimeofday P((struct timeval *, struct timezone *));
342 extern int adjtime P(( struct timeval *delta, struct timeval *olddelta ));
345 /* in machines.c */
346 extern void sleep P((int seconds));
347 extern void alarm P((int seconds));
348 /* machines.c */
351 /* this is really this */
352 #define getpid taskIdSelf
353 #define getclock clock_gettime
354 #define fcntl ioctl
355 #define _getch getchar
357 /* define this away for vxWorks */
358 #define openlog(x,y)
359 /* use local defines for these */
360 #undef min
361 #undef max
363 #endif /* SYS_VXWORKS */
365 #ifdef NO_NETDB
366 /* These structures are needed for gethostbyname() etc... */
367 /* structures used by netdb.h */
368 struct hostent {
369 char *h_name; /* official name of host */
370 char **h_aliases; /* alias list */
371 int h_addrtype; /* host address type */
372 int h_length; /* length of address */
373 char **h_addr_list; /* list of addresses from name server */
374 #define h_addr h_addr_list[0] /* address, for backward compatibility */
377 struct servent {
378 char *s_name; /* official service name */
379 char **s_aliases; /* alias list */
380 int s_port; /* port # */
381 char *s_proto; /* protocol to use */
383 extern int h_errno;
385 #define TRY_AGAIN 2
387 struct hostent *gethostbyname P((char * netnum));
388 struct hostent *gethostbyaddr P((char * netnum, int size, int addr_type));
389 /* type is the protocol */
390 struct servent *getservbyname P((char *name, char *type));
391 #endif /* NO_NETDB */
393 #ifdef NO_MAIN_ALLOWED
394 /* we have no main routines so lets make a plan */
395 #define CALL(callname, progname, callmain) \
396 extern int callmain (int,char**); \
397 void callname (a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
398 char *a0; \
399 char *a1; \
400 char *a2; \
401 char *a3; \
402 char *a4; \
403 char *a5; \
404 char *a6; \
405 char *a7; \
406 char *a8; \
407 char *a9; \
408 char *a10; \
410 char *x[11]; \
411 int argc; \
412 char *argv[] = {progname,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; \
413 int i; \
414 for (i=0;i<11;i++) \
415 x[i] = NULL; \
416 x[0] = a0; \
417 x[1] = a1; \
418 x[2] = a2; \
419 x[3] = a3; \
420 x[4] = a4; \
421 x[5] = a5; \
422 x[6] = a6; \
423 x[7] = a7; \
424 x[8] = a8; \
425 x[9] = a9; \
426 x[10] = a10; \
427 argc=1; \
428 for (i=0; i<11;i++) \
429 if (x[i]) \
431 argv[argc++] = x[i]; \
433 callmain(argc,argv); \
435 #endif /* NO_MAIN_ALLOWED */
436 /*casey Tue May 27 15:45:25 SAT 1997*/
439 * Here's where autoconfig starts to take over
441 #ifdef HAVE_SYS_STROPTS_H
442 # ifdef HAVE_SYS_STREAM_H
443 # define STREAM
444 # endif
445 #endif
447 #ifndef RETSIGTYPE
448 # if defined(NTP_POSIX_SOURCE)
449 # define RETSIGTYPE void
450 # else
451 # define RETSIGTYPE int
452 # endif
453 #endif
455 #ifdef NTP_SYSCALLS_STD
456 # ifndef NTP_SYSCALL_GET
457 # define NTP_SYSCALL_GET 235
458 # endif
459 # ifndef NTP_SYSCALL_ADJ
460 # define NTP_SYSCALL_ADJ 236
461 # endif
462 #endif /* NTP_SYSCALLS_STD */
464 #ifdef MPE
465 # include <sys/types.h>
466 # include <netinet/in.h>
467 # include <stdio.h>
468 # include <time.h>
470 /* missing functions that are easily renamed */
472 # define _getch getchar
474 /* special functions that require MPE-specific wrappers */
476 # define bind __ntp_mpe_bind
477 # define fcntl __ntp_mpe_fcntl
479 /* standard macros missing from MPE include files */
481 # define IN_CLASSD(i) ((((long)(i))&0xf0000000)==0xe0000000)
482 # define IN_MULTICAST IN_CLASSD
483 # define ITIMER_REAL 0
484 # define MAXHOSTNAMELEN 64
486 /* standard structures missing from MPE include files */
488 struct itimerval {
489 struct timeval it_interval; /* timer interval */
490 struct timeval it_value; /* current value */
493 /* various declarations to make gcc stop complaining */
495 extern int __filbuf(FILE *);
496 extern int __flsbuf(int, FILE *);
497 extern int gethostname(char *, int);
498 extern unsigned long inet_addr(char *);
499 extern char *strdup(const char *);
501 /* miscellaneous NTP macros */
503 # define HAVE_NO_NICE
504 #endif /* MPE */
506 #ifdef HAVE_RTPRIO
507 # define HAVE_NO_NICE
508 #else
509 # ifdef HAVE_SETPRIORITY
510 # define HAVE_BSD_NICE
511 # else
512 # ifdef HAVE_NICE
513 # define HAVE_ATT_NICE
514 # endif
515 # endif
516 #endif
518 #if !defined(HAVE_ATT_NICE) \
519 && !defined(HAVE_BSD_NICE) \
520 && !defined(HAVE_NO_NICE) \
521 && !defined(SYS_WINNT)
522 #include "ERROR: You must define one of the HAVE_xx_NICE defines!"
523 #endif
526 * use only one tty model - no use in initialising
527 * a tty in three ways
528 * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
531 #ifdef HAVE_TERMIOS_H
532 # define HAVE_TERMIOS
533 #else
534 # ifdef HAVE_TERMIO_H
535 # define HAVE_SYSV_TTYS
536 # else
537 # ifdef HAVE_SGTTY_H
538 # define HAVE_BSD_TTYS
539 # endif
540 # endif
541 #endif
543 #ifdef HAVE_TERMIOS
544 # undef HAVE_BSD_TTYS
545 # undef HAVE_SYSV_TTYS
546 #endif
548 #ifndef HAVE_TIMEGM
549 extern time_t timegm P((struct tm *));
550 #endif
552 #ifdef HAVE_SYSV_TTYS
553 # undef HAVE_BSD_TTYS
554 #endif
556 #if !defined(SYS_WINNT) && !defined(VMS) && !defined(SYS_VXWORKS)
557 # if !defined(HAVE_SYSV_TTYS) \
558 && !defined(HAVE_BSD_TTYS) \
559 && !defined(HAVE_TERMIOS)
560 #include "ERROR: no tty type defined!"
561 # endif
562 #endif /* SYS_WINNT || VMS || SYS_VXWORKS*/
564 #ifdef WORDS_BIGENDIAN
565 # define XNTP_BIG_ENDIAN 1
566 #else
567 # define XNTP_LITTLE_ENDIAN 1
568 #endif
571 * Byte order woes.
572 * This used to be resolved by calling ntohl() and htonl() to swap things
573 * around, but this turned out to be quite costly on Vaxes where those
574 * things are actual functions. The code now straightens out byte
575 * order troubles on its own, with no performance penalty for little
576 * end first machines, but at great expense to cleanliness.
578 #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
580 * Pick one or the other.
582 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
583 #endif
585 #if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
587 * Pick one or the other.
589 BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
590 #endif
592 #endif /* __ntp_machine */