Home | History | Annotate | Line # | Download | only in include
      1 /*	$NetBSD: ntp_machine.h,v 1.5 2020/05/25 20:47:19 christos Exp $	*/
      2 
      3 /*
      4  * ntp_machine.h
      5  *
      6  * Collect all machine dependent idiosyncrasies in one place.
      7  *
      8  * The functionality formerly in this file is mostly handled by
      9  * Autoconf these days.
     10  */
     11 
     12 #ifndef NTP_MACHINE_H
     13 #define NTP_MACHINE_H
     14 
     15 #ifdef HAVE_SYS_TIME_H
     16 # include <sys/time.h>
     17 #endif
     18 #include <time.h>
     19 
     20 #include "ntp_proto.h"
     21 
     22 /*
     23 
     24 			 HEY!  CHECK THIS OUT!
     25 
     26   The per-system SYS_* #defins ARE NO LONGER USED, with the temporary
     27   exception of SYS_WINNT.
     28 
     29   If you find a hunk of code that is bracketed by a SYS_* macro and you
     30   *know* that it is still needed, please let us know.  In many cases the
     31   code fragment is now handled somewhere else by autoconf choices.
     32 
     33 */
     34 
     35 /*
     36 
     37 HOW TO GET IP INTERFACE INFORMATION
     38 
     39   Some UNIX V.4 machines implement a sockets library on top of
     40   streams. For these systems, you must use send the SIOCGIFCONF down
     41   the stream in an I_STR ioctl. This ususally also implies
     42   USE_STREAMS_DEVICE FOR IF_CONFIG. Dell UNIX is a notable exception.
     43 
     44 WHAT DOES IOCTL(SIOCGIFCONF) RETURN IN THE BUFFER
     45 
     46   UNIX V.4 machines implement a sockets library on top of streams.
     47   When requesting the IP interface configuration with an ioctl(2) calll,
     48   an array of ifreq structures are placed in the provided buffer.  Some
     49   implementations also place the length of the buffer information in
     50   the first integer position of the buffer.
     51 
     52   SIZE_RETURNED_IN_BUFFER - size integer is in the buffer
     53 
     54 WILL IOCTL(SIOCGIFCONF) WORK ON A SOCKET
     55 
     56   Some UNIX V.4 machines do not appear to support ioctl() requests for the
     57   IP interface configuration on a socket.  They appear to require the use
     58   of the streams device instead.
     59 
     60   USE_STREAMS_DEVICE_FOR_IF_CONFIG - use the /dev/ip device for configuration
     61 
     62 MISC
     63 
     64   DOSYNCTODR		- Resync TODR clock  every hour.
     65   RETSIGTYPE		- Define signal function type.
     66   NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
     67   LOCK_PROCESS		- Have plock.
     68 */
     69 
     70 int ntp_set_tod (struct timeval *tvp, void *tzp);
     71 
     72 /*casey Tue May 27 15:45:25 SAT 1997*/
     73 #ifdef SYS_VXWORKS
     74 
     75 /* casey's new defines */
     76 #define NO_MAIN_ALLOWED 	1
     77 #define NO_NETDB			1
     78 #define NO_RENAME			1
     79 
     80 /* in vxWorks we use FIONBIO, but the others are defined for old systems, so
     81  * all hell breaks loose if we leave them defined we define USE_FIONBIO to
     82  * undefine O_NONBLOCK FNDELAY O_NDELAY where necessary.
     83  */
     84 #define USE_FIONBIO 		1
     85 /* end my new defines */
     86 
     87 #define TIMEOFDAY		0x0 	/* system wide realtime clock */
     88 #define HAVE_GETCLOCK		1	/* configure does not set this ... */
     89 #define HAVE_NO_NICE		1	/* configure does not set this ... */
     90 #define HAVE_RANDOM		1	/* configure does not set this ...  */
     91 #define HAVE_SRANDOM		1	/* configure does not set this ... */
     92 
     93 /* vxWorks specific additions to take care of its
     94  * unix (non)complicance
     95  */
     96 
     97 #include "vxWorks.h"
     98 #include "ioLib.h"
     99 #include "taskLib.h"
    100 #include "time.h"
    101 
    102 extern int sysClkRateGet ();
    103 
    104 /* usrtime.h
    105  * Bob Herlien's excellent time code find it at:
    106  * ftp://ftp.atd.ucar.edu/pub/vxworks/vx/usrTime.shar
    107  * I would recommend this instead of clock_[g|s]ettime() plus you get
    108  * adjtime() too ... casey
    109  */
    110 /*
    111 extern int	  gettimeofday ( struct timeval *tp, struct timezone *tzp );
    112 extern int	  settimeofday (struct timeval *, struct timezone *);
    113 extern int	  adjtime ( struct timeval *delta, struct timeval *olddelta );
    114  */
    115 
    116 /* in  machines.c */
    117 extern void sleep (int seconds);
    118 extern void alarm (int seconds);
    119 /* machines.c */
    120 
    121 
    122 /*		this is really this 	*/
    123 #define getpid		taskIdSelf
    124 #define getclock	clock_gettime
    125 #define fcntl		ioctl
    126 #define _getch		getchar
    127 
    128 /* define this away for vxWorks */
    129 #define openlog(x,y)
    130 /* use local defines for these */
    131 #undef min
    132 #undef max
    133 
    134 #endif /* SYS_VXWORKS */
    135 
    136 #ifdef NO_NETDB
    137 /* These structures are needed for gethostbyname() etc... */
    138 /* structures used by netdb.h */
    139 struct	hostent {
    140 	char	*h_name;				/* official name of host */
    141 	char	**h_aliases;			/* alias list */
    142 	int h_addrtype; 				/* host address type */
    143 	int h_length;					/* length of address */
    144 	char	**h_addr_list;			/* list of addresses from name server */
    145 #define 	h_addr h_addr_list[0]	/* address, for backward compatibility */
    146 };
    147 
    148 struct	servent {
    149 	char	*s_name;				/* official service name */
    150 	char	**s_aliases;			/* alias list */
    151 	int s_port; 					/* port # */
    152 	char	*s_proto;				/* protocol to use */
    153 };
    154 extern int h_errno;
    155 
    156 #define TRY_AGAIN	2
    157 
    158 struct hostent *gethostbyname (char * netnum);
    159 struct hostent *gethostbyaddr (char * netnum, int size, int addr_type);
    160 /* type is the protocol */
    161 struct servent *getservbyname (char *name, char *type);
    162 #endif	/* NO_NETDB */
    163 
    164 #ifdef NO_MAIN_ALLOWED
    165 /* we have no main routines so lets make a plan */
    166 #define CALL(callname, progname, callmain) \
    167 	extern int callmain (int,char**); \
    168 	void callname (a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
    169 		char *a0;  \
    170 		char *a1;  \
    171 		char *a2;  \
    172 		char *a3;  \
    173 		char *a4;  \
    174 		char *a5;  \
    175 		char *a6;  \
    176 		char *a7;  \
    177 		char *a8;  \
    178 		char *a9;  \
    179 		char *a10; \
    180 	{ \
    181 	  char *x[11]; \
    182 	  int argc; \
    183 	  char *argv[] = {progname,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; \
    184 	  int i; \
    185 	  for (i=0;i<11;i++) \
    186 	   x[i] = NULL; \
    187 	  x[0] = a0; \
    188 	  x[1] = a1; \
    189 	  x[2] = a2; \
    190 	  x[3] = a3; \
    191 	  x[4] = a4; \
    192 	  x[5] = a5; \
    193 	  x[6] = a6; \
    194 	  x[7] = a7; \
    195 	  x[8] = a8; \
    196 	  x[9] = a9; \
    197 	  x[10] = a10; \
    198 	  argc=1; \
    199 	  for (i=0; i<11;i++) \
    200 		if (x[i]) \
    201 		{ \
    202 		  argv[argc++] = x[i];	\
    203 		} \
    204 	 callmain(argc,argv);  \
    205 	}
    206 #endif /* NO_MAIN_ALLOWED */
    207 /*casey Tue May 27 15:45:25 SAT 1997*/
    208 
    209 /*
    210  * Here's where autoconfig starts to take over
    211  */
    212 #ifdef HAVE_SYS_STROPTS_H
    213 # ifdef HAVE_SYS_STREAM_H
    214 #  define STREAM
    215 # endif
    216 #endif
    217 
    218 #ifndef RETSIGTYPE
    219 # if defined(NTP_POSIX_SOURCE)
    220 #  define	RETSIGTYPE	void
    221 # else
    222 #  define	RETSIGTYPE	int
    223 # endif
    224 #endif
    225 
    226 #ifdef	NTP_SYSCALLS_STD
    227 # ifndef	NTP_SYSCALL_GET
    228 #  define	NTP_SYSCALL_GET 235
    229 # endif
    230 # ifndef	NTP_SYSCALL_ADJ
    231 #  define	NTP_SYSCALL_ADJ 236
    232 # endif
    233 #endif	/* NTP_SYSCALLS_STD */
    234 
    235 #ifdef MPE
    236 # include <sys/types.h>
    237 # include <netinet/in.h>
    238 # include <stdio.h>
    239 # include <time.h>
    240 
    241 /* missing functions that are easily renamed */
    242 
    243 # define _getch getchar
    244 
    245 /* special functions that require MPE-specific wrappers */
    246 
    247 # define bind	__ntp_mpe_bind
    248 # define fcntl	__ntp_mpe_fcntl
    249 
    250 /* standard macros missing from MPE include files */
    251 
    252 # define IN_CLASSD(i)	((((long)(i))&0xf0000000)==0xe0000000)
    253 # define IN_MULTICAST IN_CLASSD
    254 # define ITIMER_REAL 0
    255 
    256 /* standard structures missing from MPE include files */
    257 
    258 struct itimerval {
    259         struct timeval it_interval;    /* timer interval */
    260         struct timeval it_value;       /* current value */
    261 };
    262 
    263 /* various declarations to make gcc stop complaining */
    264 
    265 extern int __filbuf(FILE *);
    266 extern int __flsbuf(int, FILE *);
    267 extern int gethostname(char *, int);
    268 extern unsigned long inet_addr(char *);
    269 extern char *strdup(const char *);
    270 
    271 /* miscellaneous NTP macros */
    272 
    273 # define HAVE_NO_NICE
    274 #endif /* MPE */
    275 
    276 #ifdef HAVE_RTPRIO
    277 # define HAVE_NO_NICE
    278 #else
    279 # ifdef HAVE_SETPRIORITY
    280 #  define HAVE_BSD_NICE
    281 # else
    282 #  ifdef HAVE_NICE
    283 #	define HAVE_ATT_NICE
    284 #  endif
    285 # endif
    286 #endif
    287 
    288 #if !defined(HAVE_ATT_NICE) \
    289 	&& !defined(HAVE_BSD_NICE) \
    290 	&& !defined(HAVE_NO_NICE)
    291 #include "ERROR: You must define one of the HAVE_xx_NICE defines!"
    292 #endif
    293 
    294 #ifndef HAVE_TIMEGM
    295 extern time_t	timegm		(struct tm *);
    296 #endif
    297 
    298 
    299 #endif	/* NTP_MACHINE_H */
    300