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