Annotation of embedaddon/ntp/include/ntp_machine.h, revision 1.1
1.1 ! misho 1: /*
! 2: * Collect all machine dependent idiosyncrasies in one place.
! 3: */
! 4:
! 5: #ifndef NTP_MACHINE_H
! 6: #define NTP_MACHINE_H
! 7:
! 8: #ifdef HAVE_CONFIG_H
! 9: # include <config.h>
! 10: #endif
! 11:
! 12: #ifdef TIME_WITH_SYS_TIME
! 13: # include <sys/time.h>
! 14: # include <time.h>
! 15: #else
! 16: # ifdef HAVE_SYS_TIME_H
! 17: # include <sys/time.h>
! 18: # else
! 19: # include <time.h>
! 20: # endif
! 21: #endif
! 22:
! 23: #include "ntp_proto.h"
! 24:
! 25: /*
! 26:
! 27: HEY! CHECK THIS OUT!
! 28:
! 29: The first half of this file is obsolete, and is only there to help
! 30: reconcile "what went before" with "current behavior".
! 31:
! 32: The per-system SYS_* #defins ARE NO LONGER USED, with the temporary
! 33: exception of SYS_WINNT.
! 34:
! 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.
! 38:
! 39: */
! 40:
! 41: /*
! 42:
! 43: INFO ON NEW KERNEL PLL SYS CALLS
! 44:
! 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.
! 49:
! 50: HOW TO GET IP INTERFACE INFORMATION
! 51:
! 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.
! 56:
! 57: WHAT DOES IOCTL(SIOCGIFCONF) RETURN IN THE BUFFER
! 58:
! 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.
! 64:
! 65: SIZE_RETURNED_IN_BUFFER - size integer is in the buffer
! 66:
! 67: WILL IOCTL(SIOCGIFCONF) WORK ON A SOCKET
! 68:
! 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.
! 72:
! 73: USE_STREAMS_DEVICE_FOR_IF_CONFIG - use the /dev/ip device for configuration
! 74:
! 75: MISC
! 76:
! 77: DOSYNCTODR - Resync TODR clock every hour.
! 78: RETSIGTYPE - Define signal function type.
! 79: NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
! 80: LOCK_PROCESS - Have plock.
! 81: */
! 82:
! 83: #if !defined(HAVE_NTP_ADJTIME) && defined(HAVE___ADJTIMEX)
! 84: # define ntp_adjtime __adjtimex
! 85: #endif
! 86:
! 87: #if 0
! 88:
! 89: /*
! 90: * IRIX 4.X and IRIX 5.x
! 91: */
! 92: #if defined(SYS_IRIX4)||defined(SYS_IRIX5)
! 93: # define ADJTIME_IS_ACCURATE
! 94: # define LOCK_PROCESS
! 95: #endif
! 96:
! 97: /*
! 98: * Ultrix
! 99: * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
! 100: */
! 101: #if defined(SYS_ULTRIX)
! 102: # define S_CHAR_DEFINED
! 103: # define NTP_SYSCALLS_STD
! 104: # define HAVE_MODEM_CONTROL
! 105: #endif
! 106:
! 107: /*
! 108: * AUX
! 109: */
! 110: #if defined(SYS_AUX2) || defined(SYS_AUX3)
! 111: # define NO_SIGNED_CHAR_DECL
! 112: # define LOCK_PROCESS
! 113: # define NTP_POSIX_SOURCE
! 114: /*
! 115: * This requires that _POSIX_SOURCE be forced on the
! 116: * compiler command flag. We can't do it here since this
! 117: * file is included _after_ the system header files and we
! 118: * need to let _them_ know we're POSIX. We do this in
! 119: * compilers/aux3.gcc...
! 120: */
! 121: # define LOG_NTP LOG_LOCAL1
! 122: #endif
! 123:
! 124: /*
! 125: * HPUX
! 126: */
! 127: #if defined(SYS_HPUX)
! 128: # define getdtablesize() sysconf(_SC_OPEN_MAX)
! 129: # define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
! 130: # define NO_SIGNED_CHAR_DECL
! 131: # define LOCK_PROCESS
! 132: #endif
! 133:
! 134: /*
! 135: * BSD/OS 2.0 and above
! 136: */
! 137: #if defined(SYS_BSDI)
! 138: # define USE_FSETOWNCTTY /* this funny system demands a CTTY for FSETOWN */
! 139: #endif
! 140:
! 141: /*
! 142: * FreeBSD 2.0 and above
! 143: */
! 144: #ifdef SYS_FREEBSD
! 145: # define KERNEL_PLL
! 146: #endif
! 147:
! 148: /*
! 149: * Linux
! 150: */
! 151: #if defined(SYS_LINUX)
! 152: # define ntp_adjtime __adjtimex
! 153: #endif
! 154:
! 155: /*
! 156: * PTX
! 157: */
! 158: #if defined(SYS_PTX)
! 159: # define LOCK_PROCESS
! 160: struct timezone { int __0; }; /* unused placebo */
! 161: /*
! 162: * no comment !@!
! 163: */
! 164: typedef unsigned int u_int;
! 165: # ifndef _NETINET_IN_SYSTM_INCLUDED /* i am about to comment... */
! 166: typedef unsigned char u_char;
! 167: typedef unsigned short u_short;
! 168: typedef unsigned long u_long;
! 169: # endif
! 170: #endif
! 171:
! 172: /*
! 173: * UNIX V.4 on and NCR 3000
! 174: */
! 175: #if defined(SYS_SVR4)
! 176: # define STREAM
! 177: # define LOCK_PROCESS
! 178: # define SIZE_RETURNED_IN_BUFFER
! 179: #endif
! 180:
! 181: /*
! 182: * (Univel/Novell) Unixware1 SVR4 on intel x86 processor
! 183: */
! 184: #if defined(SYS_UNIXWARE1)
! 185: /* #define _POSIX_SOURCE */
! 186: # define STREAM
! 187: # define STREAMS
! 188: # undef STEP_SLEW /* TWO step */
! 189: # define LOCK_PROCESS
! 190: # define SIZE_RETURNED_IN_BUFFER
! 191: # include <sys/sockio.h>
! 192: # include <sys/types.h>
! 193: # include <netinet/in_systm.h>
! 194: #endif
! 195:
! 196: /*
! 197: * DomainOS
! 198: */
! 199: #if defined(SYS_DOMAINOS)
! 200: # define NTP_SYSCALLS_STD
! 201: /* older versions of domain/os don't have class D */
! 202: # ifndef IN_CLASSD
! 203: # define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
! 204: # define IN_CLASSD_NET 0xf0000000
! 205: # define IN_CLASSD_NSHIFT 28
! 206: # define IN_CLASSD_HOST 0xfffffff
! 207: # define IN_MULTICAST(i) IN_CLASSD(i)
! 208: # endif
! 209: #endif
! 210:
! 211: /*
! 212: * Fujitsu UXP/V
! 213: */
! 214: #if defined(SYS_UXPV)
! 215: # define LOCK_PROCESS
! 216: # define SIZE_RETURNED_IN_BUFFER
! 217: #endif
! 218:
! 219:
! 220: #endif /* 0 */
! 221:
! 222: /*
! 223: * Define these here for non-Windows NT systems
! 224: * SOCKET and INVALID_SOCKET are native macros
! 225: * on Windows NT and since they have different
! 226: * requirements we use them in the code and
! 227: * make them macros for everyone else
! 228: */
! 229: #ifndef SYS_WINNT
! 230: typedef int SOCKET;
! 231: # define INVALID_SOCKET -1
! 232: # define SOCKET_ERROR -1
! 233: # define socket_errno() (errno)
! 234: # define closesocket(fd) close(fd)
! 235: #else /* SYS_WINNT follows */
! 236: # define socket_errno() (errno = WSAGetLastError())
! 237: #endif
! 238:
! 239: int ntp_set_tod (struct timeval *tvp, void *tzp);
! 240:
! 241: #if defined (SYS_CYGWIN32)
! 242: #include <windows.h>
! 243: #define __int64 long long
! 244: #endif
! 245:
! 246: /*casey Tue May 27 15:45:25 SAT 1997*/
! 247: #ifdef SYS_VXWORKS
! 248:
! 249: /* casey's new defines */
! 250: #define NO_MAIN_ALLOWED 1
! 251: #define NO_NETDB 1
! 252: #define NO_RENAME 1
! 253:
! 254: /* in vxWorks we use FIONBIO, but the others are defined for old systems, so
! 255: * all hell breaks loose if we leave them defined we define USE_FIONBIO to
! 256: * undefine O_NONBLOCK FNDELAY O_NDELAY where necessary.
! 257: */
! 258: #define USE_FIONBIO 1
! 259: /* end my new defines */
! 260:
! 261: #define TIMEOFDAY 0x0 /* system wide realtime clock */
! 262: #define HAVE_GETCLOCK 1 /* configure does not set this ... */
! 263: #define HAVE_NO_NICE 1 /* configure does not set this ... */
! 264: #define HAVE_RANDOM 1 /* configure does not set this ... */
! 265: #define HAVE_SRANDOM 1 /* configure does not set this ... */
! 266:
! 267: #define NODETACH 1
! 268:
! 269: /* vxWorks specific additions to take care of its
! 270: * unix (non)complicance
! 271: */
! 272:
! 273: #include "vxWorks.h"
! 274: #include "ioLib.h"
! 275: #include "taskLib.h"
! 276: #include "time.h"
! 277:
! 278: extern int sysClkRateGet ();
! 279:
! 280: /* usrtime.h
! 281: * Bob Herlien's excellent time code find it at:
! 282: * ftp://ftp.atd.ucar.edu/pub/vxworks/vx/usrTime.shar
! 283: * I would recommend this instead of clock_[g|s]ettime() plus you get
! 284: * adjtime() too ... casey
! 285: */
! 286: /*
! 287: extern int gettimeofday ( struct timeval *tp, struct timezone *tzp );
! 288: extern int settimeofday (struct timeval *, struct timezone *);
! 289: extern int adjtime ( struct timeval *delta, struct timeval *olddelta );
! 290: */
! 291:
! 292: /* in machines.c */
! 293: extern void sleep (int seconds);
! 294: extern void alarm (int seconds);
! 295: /* machines.c */
! 296:
! 297:
! 298: /* this is really this */
! 299: #define getpid taskIdSelf
! 300: #define getclock clock_gettime
! 301: #define fcntl ioctl
! 302: #define _getch getchar
! 303:
! 304: /* define this away for vxWorks */
! 305: #define openlog(x,y)
! 306: /* use local defines for these */
! 307: #undef min
! 308: #undef max
! 309:
! 310: #endif /* SYS_VXWORKS */
! 311:
! 312: #ifdef NO_NETDB
! 313: /* These structures are needed for gethostbyname() etc... */
! 314: /* structures used by netdb.h */
! 315: struct hostent {
! 316: char *h_name; /* official name of host */
! 317: char **h_aliases; /* alias list */
! 318: int h_addrtype; /* host address type */
! 319: int h_length; /* length of address */
! 320: char **h_addr_list; /* list of addresses from name server */
! 321: #define h_addr h_addr_list[0] /* address, for backward compatibility */
! 322: };
! 323:
! 324: struct servent {
! 325: char *s_name; /* official service name */
! 326: char **s_aliases; /* alias list */
! 327: int s_port; /* port # */
! 328: char *s_proto; /* protocol to use */
! 329: };
! 330: extern int h_errno;
! 331:
! 332: #define TRY_AGAIN 2
! 333:
! 334: struct hostent *gethostbyname (char * netnum);
! 335: struct hostent *gethostbyaddr (char * netnum, int size, int addr_type);
! 336: /* type is the protocol */
! 337: struct servent *getservbyname (char *name, char *type);
! 338: #endif /* NO_NETDB */
! 339:
! 340: #ifdef NO_MAIN_ALLOWED
! 341: /* we have no main routines so lets make a plan */
! 342: #define CALL(callname, progname, callmain) \
! 343: extern int callmain (int,char**); \
! 344: void callname (a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
! 345: char *a0; \
! 346: char *a1; \
! 347: char *a2; \
! 348: char *a3; \
! 349: char *a4; \
! 350: char *a5; \
! 351: char *a6; \
! 352: char *a7; \
! 353: char *a8; \
! 354: char *a9; \
! 355: char *a10; \
! 356: { \
! 357: char *x[11]; \
! 358: int argc; \
! 359: char *argv[] = {progname,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; \
! 360: int i; \
! 361: for (i=0;i<11;i++) \
! 362: x[i] = NULL; \
! 363: x[0] = a0; \
! 364: x[1] = a1; \
! 365: x[2] = a2; \
! 366: x[3] = a3; \
! 367: x[4] = a4; \
! 368: x[5] = a5; \
! 369: x[6] = a6; \
! 370: x[7] = a7; \
! 371: x[8] = a8; \
! 372: x[9] = a9; \
! 373: x[10] = a10; \
! 374: argc=1; \
! 375: for (i=0; i<11;i++) \
! 376: if (x[i]) \
! 377: { \
! 378: argv[argc++] = x[i]; \
! 379: } \
! 380: callmain(argc,argv); \
! 381: }
! 382: #endif /* NO_MAIN_ALLOWED */
! 383: /*casey Tue May 27 15:45:25 SAT 1997*/
! 384:
! 385: /*
! 386: * Here's where autoconfig starts to take over
! 387: */
! 388: #ifdef HAVE_SYS_STROPTS_H
! 389: # ifdef HAVE_SYS_STREAM_H
! 390: # define STREAM
! 391: # endif
! 392: #endif
! 393:
! 394: #ifndef RETSIGTYPE
! 395: # if defined(NTP_POSIX_SOURCE)
! 396: # define RETSIGTYPE void
! 397: # else
! 398: # define RETSIGTYPE int
! 399: # endif
! 400: #endif
! 401:
! 402: #ifdef NTP_SYSCALLS_STD
! 403: # ifndef NTP_SYSCALL_GET
! 404: # define NTP_SYSCALL_GET 235
! 405: # endif
! 406: # ifndef NTP_SYSCALL_ADJ
! 407: # define NTP_SYSCALL_ADJ 236
! 408: # endif
! 409: #endif /* NTP_SYSCALLS_STD */
! 410:
! 411: #ifdef MPE
! 412: # include <sys/types.h>
! 413: # include <netinet/in.h>
! 414: # include <stdio.h>
! 415: # include <time.h>
! 416:
! 417: /* missing functions that are easily renamed */
! 418:
! 419: # define _getch getchar
! 420:
! 421: /* special functions that require MPE-specific wrappers */
! 422:
! 423: # define bind __ntp_mpe_bind
! 424: # define fcntl __ntp_mpe_fcntl
! 425:
! 426: /* standard macros missing from MPE include files */
! 427:
! 428: # define IN_CLASSD(i) ((((long)(i))&0xf0000000)==0xe0000000)
! 429: # define IN_MULTICAST IN_CLASSD
! 430: # define ITIMER_REAL 0
! 431: # define MAXHOSTNAMELEN 64
! 432:
! 433: /* standard structures missing from MPE include files */
! 434:
! 435: struct itimerval {
! 436: struct timeval it_interval; /* timer interval */
! 437: struct timeval it_value; /* current value */
! 438: };
! 439:
! 440: /* various declarations to make gcc stop complaining */
! 441:
! 442: extern int __filbuf(FILE *);
! 443: extern int __flsbuf(int, FILE *);
! 444: extern int gethostname(char *, int);
! 445: extern unsigned long inet_addr(char *);
! 446: extern char *strdup(const char *);
! 447:
! 448: /* miscellaneous NTP macros */
! 449:
! 450: # define HAVE_NO_NICE
! 451: #endif /* MPE */
! 452:
! 453: #ifdef HAVE_RTPRIO
! 454: # define HAVE_NO_NICE
! 455: #else
! 456: # ifdef HAVE_SETPRIORITY
! 457: # define HAVE_BSD_NICE
! 458: # else
! 459: # ifdef HAVE_NICE
! 460: # define HAVE_ATT_NICE
! 461: # endif
! 462: # endif
! 463: #endif
! 464:
! 465: #if !defined(HAVE_ATT_NICE) \
! 466: && !defined(HAVE_BSD_NICE) \
! 467: && !defined(HAVE_NO_NICE)
! 468: #include "ERROR: You must define one of the HAVE_xx_NICE defines!"
! 469: #endif
! 470:
! 471: /*
! 472: * use only one tty model - no use in initialising
! 473: * a tty in three ways
! 474: * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
! 475: */
! 476:
! 477: #ifdef HAVE_TERMIOS_H
! 478: # define HAVE_TERMIOS
! 479: #else
! 480: # ifdef HAVE_TERMIO_H
! 481: # define HAVE_SYSV_TTYS
! 482: # else
! 483: # ifdef HAVE_SGTTY_H
! 484: # define HAVE_BSD_TTYS
! 485: # endif
! 486: # endif
! 487: #endif
! 488:
! 489: #ifdef HAVE_TERMIOS
! 490: # undef HAVE_BSD_TTYS
! 491: # undef HAVE_SYSV_TTYS
! 492: #endif
! 493:
! 494: #ifndef HAVE_TIMEGM
! 495: extern time_t timegm (struct tm *);
! 496: #endif
! 497:
! 498: #ifdef HAVE_SYSV_TTYS
! 499: # undef HAVE_BSD_TTYS
! 500: #endif
! 501:
! 502: #if !defined(SYS_WINNT) && !defined(VMS) && !defined(SYS_VXWORKS)
! 503: # if !defined(HAVE_SYSV_TTYS) \
! 504: && !defined(HAVE_BSD_TTYS) \
! 505: && !defined(HAVE_TERMIOS)
! 506: #include "ERROR: no tty type defined!"
! 507: # endif
! 508: #endif /* SYS_WINNT || VMS || SYS_VXWORKS*/
! 509:
! 510: #ifdef WORDS_BIGENDIAN
! 511: # define XNTP_BIG_ENDIAN 1
! 512: #else
! 513: # define XNTP_LITTLE_ENDIAN 1
! 514: #endif
! 515:
! 516: /*
! 517: * Byte order woes.
! 518: * This used to be resolved by calling ntohl() and htonl() to swap things
! 519: * around, but this turned out to be quite costly on Vaxes where those
! 520: * things are actual functions. The code now straightens out byte
! 521: * order troubles on its own, with no performance penalty for little
! 522: * end first machines, but at great expense to cleanliness.
! 523: */
! 524: #if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
! 525: /*
! 526: * Pick one or the other.
! 527: */
! 528: BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
! 529: #endif
! 530:
! 531: #if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
! 532: /*
! 533: * Pick one or the other.
! 534: */
! 535: BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
! 536: #endif
! 537:
! 538: #endif /* NTP_MACHINE_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>