add listen-timeout to function as an accept timeout
[socat/sam.git] / compat.h
blob5f7c588a23bd04595776b46bbba4c6dc04458807
1 /* source: compat.h */
2 /* Copyright Gerhard Rieger 2001-2008 */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 #ifndef __compat_h_included
6 #define __compat_h_included 1
8 /*****************************************************************************/
9 /* I dont like this system dependent part, but it would be quite a challenge
10 for configure */
12 /* define if the following does not work:
13 socket()
14 connect() -> Connection refused
15 connect() -> ok
16 instead, it needs close() and socket() between the two connect() attmpts: */
17 #if __FreeBSD__ || __APPLE__ || _AIX || __hpux__ || __osf__
18 # undef SOCKET_CAN_RECOVER
19 #else
20 # define SOCKET_CAN_RECOVER 1
21 #endif
23 /* define if stat() says that pipes are sockets */
24 #if __APPLE__
25 # define PIPE_STATES_SOCKET 1
26 #else
27 # undef PIPE_STATES_SOCKET
28 #endif
30 /*****************************************************************************/
32 /* substitute some features that might be missing on some platforms */
34 #ifndef SHUT_RD
35 # define SHUT_RD 0
36 #endif
37 #ifndef SHUT_WR
38 # define SHUT_WR 1
39 #endif
40 #ifndef SHUT_RDWR
41 # define SHUT_RDWR 2
42 #endif
44 #ifndef MIN
45 # define MIN(x,y) ((x)<=(y)?(x):(y))
46 #endif
48 #ifndef MAX
49 # define MAX(x,y) ((x)>=(y)?(x):(y))
50 #endif
52 /* O_ASYNC: Linux 2.2.10 */
53 #if !defined(O_ASYNC) && defined(FASYNC)
54 # define O_ASYNC FASYNC
55 #endif
57 /* NGROUPS not defined on Solaris */
58 #if !defined(NGROUPS) && defined(NGROUPS_MAX)
59 # define NGROUPS NGROUPS_MAX
60 #endif
62 /* UNIX_PATH_MAX: AIX 4.3.3 */
63 #ifndef UNIX_PATH_MAX
64 # define UNIX_PATH_MAX 104 /*! why 104? Linux: 108 ! */
65 #endif
68 /* SOL_IP: AIX 4.3.3 */
69 #ifndef SOL_IP
70 # define SOL_IP 0
71 #endif
73 /* SOL_TCP: AIX 4.3.3 */
74 #ifndef SOL_TCP
75 # define SOL_TCP IPPROTO_TCP
76 #endif
78 /* POSIX.1 doesn't seem to know sockets */
79 #ifndef S_ISSOCK
80 # define S_ISSOCK(fmode) 0
81 #endif
83 #if defined(IPPROTO_IPV6) && !defined(SOL_IPV6)
84 # define SOL_IPV6 IPPROTO_IPV6
85 #endif
87 /* all unsigned */
88 #if !defined(HAVE_BASIC_SIZE_T) || !HAVE_BASIC_SIZE_T
89 # undef HAVE_BASIC_SIZE_T
90 # define HAVE_BASIC_SIZE_T 6
91 #endif
92 #if HAVE_BASIC_SIZE_T==2
93 # define SIZET_MAX USHRT_MAX
94 # define SSIZET_MIN SHRT_MIN
95 # define SSIZET_MAX SHRT_MAX
96 # define F_Zd "%hd"
97 # define F_Zu "%hu"
98 #elif HAVE_BASIC_SIZE_T==4
99 # define SIZET_MAX UINT_MAX
100 # define SSIZET_MIN INT_MIN
101 # define SSIZET_MAX INT_MAX
102 # define F_Zd "%d"
103 # define F_Zu "%u"
104 #elif HAVE_BASIC_SIZE_T==6
105 # define SIZET_MAX ULONG_MAX
106 # define SSIZET_MIN LONG_MIN
107 # define SSIZET_MAX LONG_MAX
108 # define F_Zd "%ld"
109 # define F_Zu "%lu"
110 #elif HAVE_BASIC_SIZE_T==8
111 # define SIZET_MAX ULLONG_MAX
112 # define SSIZET_MIN LLONG_MIN
113 # define SSIZET_MAX LLONG_MAX
114 # define F_Zd "%Ld"
115 # define F_Zu "%Lu"
116 #else
117 # error "HAVE_BASIC_SIZE_T is out of range:" HAVE_BASIC_SIZE_T
118 #endif
119 #if HAVE_FORMAT_Z
120 # undef F_Zd
121 # undef F_Zu
122 # define F_Zd "%Zd"
123 # define F_Zu "%Zu"
124 #endif
127 /* mode_t is always unsigned; default: unsigned int */
128 #if !defined(HAVE_BASIC_MODE_T) || !HAVE_BASIC_MODE_T
129 # undef HAVE_BASIC_MODE_T
130 # define HAVE_BASIC_MODE_T 4
131 #endif
132 #ifndef F_mode
133 # if HAVE_BASIC_MODE_T==1 || HAVE_BASIC_MODE_T==2
134 #define F_mode "0%03ho"
135 # elif HAVE_BASIC_MODE_T==3 || HAVE_BASIC_MODE_T==4
136 #define F_mode "0%03o"
137 # elif HAVE_BASIC_MODE_T==5 || HAVE_BASIC_MODE_T==6
138 #define F_mode "0%03lo"
139 # else
140 #error "HAVE_BASIC_MODE_T is out of range:" HAVE_BASIC_MODE_T
141 # endif
142 #endif
145 /* default: unsigned int */
146 #if !defined(HAVE_BASIC_PID_T) || !HAVE_BASIC_PID_T
147 # undef HAVE_BASIC_PID_T
148 # define HAVE_BASIC_PID_T 4
149 #endif
150 #ifndef F_pid
151 # if HAVE_BASIC_PID_T==1
152 #define F_pid "%hd"
153 # elif HAVE_BASIC_PID_T==2
154 #define F_pid "%hu"
155 # elif HAVE_BASIC_PID_T==3
156 #define F_pid "%d"
157 # elif HAVE_BASIC_PID_T==4
158 #define F_pid "%u"
159 # elif HAVE_BASIC_PID_T==5
160 #define F_pid "%ld"
161 # elif HAVE_BASIC_PID_T==6
162 #define F_pid "%lu"
163 # else
164 #error "HAVE_BASIC_PID_T is out of range:" HAVE_BASIC_PID_T
165 # endif
166 #endif
169 /* default: unsigned int */
170 #if !defined(HAVE_BASIC_UID_T) || !HAVE_BASIC_UID_T
171 # undef HAVE_BASIC_UID_T
172 # define HAVE_BASIC_UID_T 4
173 #endif
174 #ifndef F_uid
175 # if HAVE_BASIC_UID_T==1
176 #define F_uid "%hd"
177 # elif HAVE_BASIC_UID_T==2
178 #define F_uid "%hu"
179 # elif HAVE_BASIC_UID_T==3
180 #define F_uid "%d"
181 # elif HAVE_BASIC_UID_T==4
182 #define F_uid "%u"
183 # elif HAVE_BASIC_UID_T==5
184 #define F_uid "%ld"
185 # elif HAVE_BASIC_UID_T==6
186 #define F_uid "%lu"
187 # else
188 #error "HAVE_BASIC_UID_T is out of range:" HAVE_BASIC_UID_T
189 # endif
190 #endif
193 /* default: unsigned int */
194 #if !defined(HAVE_BASIC_GID_T) || !HAVE_BASIC_GID_T
195 # undef HAVE_BASIC_GID_T
196 # define HAVE_BASIC_GID_T 4
197 #endif
198 #ifndef F_gid
199 # if HAVE_BASIC_GID_T==1
200 #define F_gid "%hd"
201 # elif HAVE_BASIC_GID_T==2
202 #define F_gid "%hu"
203 # elif HAVE_BASIC_GID_T==3
204 #define F_gid "%d"
205 # elif HAVE_BASIC_GID_T==4
206 #define F_gid "%u"
207 # elif HAVE_BASIC_GID_T==5
208 #define F_gid "%ld"
209 # elif HAVE_BASIC_GID_T==6
210 #define F_gid "%lu"
211 # else
212 #error "HAVE_BASIC_GID_T is out of range:" HAVE_BASIC_GID_T
213 # endif
214 #endif
217 /* all signed; default: long */
218 #if !defined(HAVE_BASIC_TIME_T) || !HAVE_BASIC_TIME_T
219 # undef HAVE_BASIC_TIME_T
220 # define HAVE_BASIC_TIME_T 5
221 #endif
222 #ifndef F_time
223 # if HAVE_BASIC_TIME_T==1
224 #define F_time "%hd"
225 # elif HAVE_BASIC_TIME_T==2
226 #define F_time "%hu"
227 # elif HAVE_BASIC_TIME_T==3
228 #define F_time "%d"
229 # elif HAVE_BASIC_TIME_T==4
230 #define F_time "%u"
231 # elif HAVE_BASIC_TIME_T==5
232 #define F_time "%ld"
233 # elif HAVE_BASIC_TIME_T==6
234 #define F_time "%lu"
235 # else
236 #error "HAVE_BASIC_TIME_T is out of range:" HAVE_BASIC_TIME_T
237 # endif
238 #endif
241 /* default: int */
242 #if !defined(HAVE_BASIC_SOCKLEN_T) || !HAVE_BASIC_SOCKLEN_T
243 # undef HAVE_BASIC_SOCKLEN_T
244 # define HAVE_BASIC_SOCKLEN_T 3
245 #endif
246 #ifndef F_socklen
247 # if HAVE_BASIC_SOCKLEN_T==1
248 #define F_socklen "%hd"
249 # elif HAVE_BASIC_SOCKLEN_T==2
250 #define F_socklen "%hu"
251 # elif HAVE_BASIC_SOCKLEN_T==3
252 #define F_socklen "%d"
253 # elif HAVE_BASIC_SOCKLEN_T==4
254 #define F_socklen "%u"
255 # elif HAVE_BASIC_SOCKLEN_T==5
256 #define F_socklen "%ld"
257 # elif HAVE_BASIC_SOCKLEN_T==6
258 #define F_socklen "%lu"
259 # else
260 #error "HAVE_BASIC_SOCKLEN_T is out of range:" HAVE_BASIC_SOCKLEN_T
261 # endif
262 #endif
264 /* might be checked in later versions */
265 #ifndef F_off
266 #define F_off "%ld"
267 #endif
269 /* default: long long */
270 #if !defined(HAVE_BASIC_OFF64_T) || !HAVE_BASIC_OFF64_T
271 # undef HAVE_BASIC_OFF64_T
272 # define HAVE_BASIC_OFF64_T 7
273 #endif
274 #ifndef F_off64
275 # if HAVE_BASIC_OFF64_T==1
276 #define F_off64 "%hd"
277 # elif HAVE_BASIC_OFF64_T==2
278 #define F_off64 "%hu"
279 # elif HAVE_BASIC_OFF64_T==3
280 #define F_off64 "%d"
281 # elif HAVE_BASIC_OFF64_T==4
282 #define F_off64 "%u"
283 # elif HAVE_BASIC_OFF64_T==5
284 #define F_off64 "%ld"
285 # elif HAVE_BASIC_OFF64_T==6
286 #define F_off64 "%lu"
287 # elif HAVE_BASIC_OFF64_T==7
288 #define F_off64 "%Ld"
289 # elif HAVE_BASIC_OFF64_T==8
290 #define F_off64 "%Lu"
291 # else
292 #error "HAVE_BASIC_OFF64_T is out of range:" HAVE_BASIC_OFF64_T
293 # endif
294 #endif
297 /* all unsigned; default: unsigned long */
298 #if !defined(HAVE_TYPEOF_ST_DEV) || !HAVE_TYPEOF_ST_DEV
299 # undef HAVE_TYPEOF_ST_DEV
300 # define HAVE_TYPEOF_ST_DEV 6
301 #endif
302 #ifndef F_st_dev
303 # if HAVE_TYPEOF_ST_DEV==1
304 #define F_st_dev "%hd"
305 # elif HAVE_TYPEOF_ST_DEV==2
306 #define F_st_dev "%hu"
307 # elif HAVE_TYPEOF_ST_DEV==3
308 #define F_st_dev "%d"
309 # elif HAVE_TYPEOF_ST_DEV==4
310 #define F_st_dev "%u"
311 # elif HAVE_TYPEOF_ST_DEV==5
312 #define F_st_dev "%ld"
313 # elif HAVE_TYPEOF_ST_DEV==6
314 #define F_st_dev "%lu"
315 # elif HAVE_TYPEOF_ST_DEV==7
316 #define F_st_dev "%Ld"
317 # elif HAVE_TYPEOF_ST_DEV==8
318 #define F_st_dev "%Lu"
319 # else
320 #error "HAVE_TYPEOF_ST_DEV is out of range:" HAVE_TYPEOF_ST_DEV
321 # endif
322 #endif
324 /* all unsigned; default; unsigned long */
325 #if !defined(HAVE_TYPEOF_ST_INO) || !HAVE_TYPEOF_ST_INO
326 # undef HAVE_TYPEOF_ST_INO
327 # define HAVE_TYPEOF_ST_INO 6
328 #endif
329 #ifndef F_st_ino
330 # if HAVE_TYPEOF_ST_INO==1
331 #define F_st_ino "%hd"
332 # elif HAVE_TYPEOF_ST_INO==2
333 #define F_st_ino "%hu"
334 # elif HAVE_TYPEOF_ST_INO==3
335 #define F_st_ino "%d"
336 # elif HAVE_TYPEOF_ST_INO==4
337 #define F_st_ino "%u"
338 # elif HAVE_TYPEOF_ST_INO==5
339 #define F_st_ino "%ld"
340 # elif HAVE_TYPEOF_ST_INO==6
341 #define F_st_ino "%lu"
342 # elif HAVE_TYPEOF_ST_INO==7 /* Cygwin 1.5 */
343 #define F_st_ino "%Ld"
344 # elif HAVE_TYPEOF_ST_INO==8
345 #define F_st_ino "%Lu"
346 # else
347 #error "HAVE_TYPEOF_ST_INO is out of range:" HAVE_TYPEOF_ST_INO
348 # endif
349 #endif
351 /* all unsigned; default; unsigned long long */
352 #if !defined(HAVE_TYPEOF_ST64_INO) || !HAVE_TYPEOF_ST64_INO
353 # undef HAVE_TYPEOF_ST64_INO
354 # define HAVE_TYPEOF_ST64_INO 8
355 #endif
356 #ifndef F_st64_ino
357 # if HAVE_TYPEOF_ST64_INO==1
358 #define F_st64_ino "%hd"
359 # elif HAVE_TYPEOF_ST64_INO==2
360 #define F_st64_ino "%hu"
361 # elif HAVE_TYPEOF_ST64_INO==3
362 #define F_st64_ino "%d"
363 # elif HAVE_TYPEOF_ST64_INO==4
364 #define F_st64_ino "%u"
365 # elif HAVE_TYPEOF_ST64_INO==5
366 #define F_st64_ino "%ld"
367 # elif HAVE_TYPEOF_ST64_INO==6
368 #define F_st64_ino "%lu"
369 # elif HAVE_TYPEOF_ST64_INO==7
370 #define F_st64_ino "%Ld"
371 # elif HAVE_TYPEOF_ST64_INO==8
372 #define F_st64_ino "%Lu"
373 # else
374 #error "HAVE_TYPEOF_ST64_INO is out of range:" HAVE_TYPEOF_ST64_INO
375 # endif
376 #endif
378 /* default: unsigned short */
379 #if !defined(HAVE_TYPEOF_ST_NLINK) || !HAVE_TYPEOF_ST_NLINK
380 # undef HAVE_TYPEOF_ST_NLINK
381 # define HAVE_TYPEOF_ST_NLINK 2
382 #endif
383 #ifndef F_st_nlink
384 # if HAVE_TYPEOF_ST_NLINK==1
385 #define F_st_nlink "%hd"
386 # elif HAVE_TYPEOF_ST_NLINK==2
387 #define F_st_nlink "%hu"
388 # elif HAVE_TYPEOF_ST_NLINK==3
389 #define F_st_nlink "%d"
390 # elif HAVE_TYPEOF_ST_NLINK==4
391 #define F_st_nlink "%u"
392 # elif HAVE_TYPEOF_ST_NLINK==5
393 #define F_st_nlink "%ld"
394 # elif HAVE_TYPEOF_ST_NLINK==6
395 #define F_st_nlink "%lu"
396 # else
397 #error "HAVE_TYPEOF_ST_NLINK is out of range:" HAVE_TYPEOF_ST_NLINK
398 # endif
399 #endif
401 /* all signed; default: long */
402 #if !defined(HAVE_TYPEOF_ST_SIZE) || !HAVE_TYPEOF_ST_SIZE
403 # undef HAVE_TYPEOF_ST_SIZE
404 # define HAVE_TYPEOF_ST_SIZE 5
405 #endif
406 #ifndef F_st_size
407 # if HAVE_TYPEOF_ST_SIZE==1
408 #define F_st_size "%hd"
409 # elif HAVE_TYPEOF_ST_SIZE==2
410 #define F_st_size "%hu"
411 # elif HAVE_TYPEOF_ST_SIZE==3
412 #define F_st_size "%d"
413 # elif HAVE_TYPEOF_ST_SIZE==4
414 #define F_st_size "%u"
415 # elif HAVE_TYPEOF_ST_SIZE==5
416 #define F_st_size "%ld"
417 # elif HAVE_TYPEOF_ST_SIZE==6
418 #define F_st_size "%lu"
419 # elif HAVE_TYPEOF_ST_SIZE==7
420 #define F_st_size "%Ld"
421 # elif HAVE_TYPEOF_ST_SIZE==8
422 #define F_st_size "%Lu"
423 # else
424 #error "HAVE_TYPEOF_ST_SIZE is out of range:" HAVE_TYPEOF_ST_SIZE
425 # endif
426 #endif
428 /* all signed; default: long long */
429 #if !defined(HAVE_TYPEOF_ST64_SIZE) || !HAVE_TYPEOF_ST64_SIZE
430 # undef HAVE_TYPEOF_ST64_SIZE
431 # define HAVE_TYPEOF_ST64_SIZE 7
432 #endif
433 #ifndef F_st64_size
434 # if HAVE_TYPEOF_ST64_SIZE==1
435 #define F_st64_size "%hd"
436 # elif HAVE_TYPEOF_ST64_SIZE==2
437 #define F_st64_size "%hu"
438 # elif HAVE_TYPEOF_ST64_SIZE==3
439 #define F_st64_size "%d"
440 # elif HAVE_TYPEOF_ST64_SIZE==4
441 #define F_st64_size "%u"
442 # elif HAVE_TYPEOF_ST64_SIZE==5
443 #define F_st64_size "%ld"
444 # elif HAVE_TYPEOF_ST64_SIZE==6
445 #define F_st64_size "%lu"
446 # elif HAVE_TYPEOF_ST64_SIZE==7
447 #define F_st64_size "%Ld"
448 # elif HAVE_TYPEOF_ST64_SIZE==8
449 #define F_st64_size "%Lu"
450 # else
451 #error "HAVE_TYPEOF_ST64_SIZE is out of range:" HAVE_TYPEOF_ST64_SIZE
452 # endif
453 #endif
455 /* very different results; default: long */
456 #if !defined(HAVE_TYPEOF_ST_BLKSIZE) || !HAVE_TYPEOF_ST_BLKSIZE
457 # undef HAVE_TYPEOF_ST_BLKSIZE
458 # define HAVE_TYPEOF_ST_BLKSIZE 5
459 #endif
460 #ifndef F_st_blksize
461 # if HAVE_TYPEOF_ST_BLKSIZE==1
462 #define F_st_blksize "%hd"
463 # elif HAVE_TYPEOF_ST_BLKSIZE==2
464 #define F_st_blksize "%hu"
465 # elif HAVE_TYPEOF_ST_BLKSIZE==3
466 #define F_st_blksize "%d"
467 # elif HAVE_TYPEOF_ST_BLKSIZE==4
468 #define F_st_blksize "%u"
469 # elif HAVE_TYPEOF_ST_BLKSIZE==5
470 #define F_st_blksize "%ld"
471 # elif HAVE_TYPEOF_ST_BLKSIZE==6
472 #define F_st_blksize "%lu"
473 # else
474 #error "HAVE_TYPEOF_ST_BLKSIZE is out of range:" HAVE_TYPEOF_ST_BLKSIZE
475 # endif
476 #endif
478 /* default: long */
479 #if !defined(HAVE_TYPEOF_ST_BLOCKS) || !HAVE_TYPEOF_ST_BLOCKS
480 # undef HAVE_TYPEOF_ST_BLOCKS
481 # define HAVE_TYPEOF_ST_BLOCKS 5
482 #endif
483 #ifndef F_st_blocks
484 # if HAVE_TYPEOF_ST_BLOCKS==1
485 #define F_st_blocks "%hd"
486 # elif HAVE_TYPEOF_ST_BLOCKS==2
487 #define F_st_blocks "%hu"
488 # elif HAVE_TYPEOF_ST_BLOCKS==3
489 #define F_st_blocks "%d"
490 # elif HAVE_TYPEOF_ST_BLOCKS==4
491 #define F_st_blocks "%u"
492 # elif HAVE_TYPEOF_ST_BLOCKS==5
493 #define F_st_blocks "%ld"
494 # elif HAVE_TYPEOF_ST_BLOCKS==6
495 #define F_st_blocks "%lu"
496 # elif HAVE_TYPEOF_ST_BLOCKS==7
497 #define F_st_blocks "%Ld"
498 # elif HAVE_TYPEOF_ST_BLOCKS==8
499 #define F_st_blocks "%Lu"
500 # else
501 #error "HAVE_TYPEOF_ST_BLOCKS is out of range:" HAVE_TYPEOF_ST_BLOCKS
502 # endif
503 #endif
505 /* default: long long */
506 #if !defined(HAVE_TYPEOF_ST64_BLOCKS) || !HAVE_TYPEOF_ST64_BLOCKS
507 # undef HAVE_TYPEOF_ST64_BLOCKS
508 # define HAVE_TYPEOF_ST64_BLOCKS 7
509 #endif
510 #ifndef F_st64_blocks
511 # if HAVE_TYPEOF_ST64_BLOCKS==1
512 #define F_st64_blocks "%hd"
513 # elif HAVE_TYPEOF_ST64_BLOCKS==2
514 #define F_st64_blocks "%hu"
515 # elif HAVE_TYPEOF_ST64_BLOCKS==3
516 #define F_st64_blocks "%d"
517 # elif HAVE_TYPEOF_ST64_BLOCKS==4
518 #define F_st64_blocks "%u"
519 # elif HAVE_TYPEOF_ST64_BLOCKS==5
520 #define F_st64_blocks "%ld"
521 # elif HAVE_TYPEOF_ST64_BLOCKS==6
522 #define F_st64_blocks "%lu"
523 # elif HAVE_TYPEOF_ST64_BLOCKS==7
524 #define F_st64_blocks "%Ld"
525 # elif HAVE_TYPEOF_ST64_BLOCKS==8
526 #define F_st64_blocks "%Lu"
527 # else
528 #error "HAVE_TYPEOF_ST64_BLOCKS is out of range:" HAVE_TYPEOF_ST64_BLOCKS
529 # endif
530 #endif
533 /* at least for Linux */
534 #define F_tv_sec "%ld"
536 /* default: long */
537 #if !defined(HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC) || !HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
538 # undef HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
539 # define HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC 5
540 #endif
541 #ifndef F_tv_usec
542 # if HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==1
543 #define F_tv_usec "%06hd"
544 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==2
545 #define F_tv_usec "%06hu"
546 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==3
547 #define F_tv_usec "%06d"
548 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==4
549 #define F_tv_usec "%06u"
550 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==5
551 #define F_tv_usec "%06ld"
552 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==6
553 #define F_tv_usec "%06lu"
554 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==7
555 #define F_tv_usec "%06Ld"
556 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==8
557 #define F_tv_usec "%06Lu"
558 # else
559 #error "HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC is out of range:" HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
560 # endif
561 #endif
563 /* default: long */
564 #if !defined(HAVE_TYPEOF_RLIM_MAX) || !HAVE_TYPEOF_RLIM_MAX
565 # undef HAVE_TYPEOF_RLIM_MAX
566 # define HAVE_TYPEOF_RLIM_MAX 5
567 #endif
568 #ifndef F_rlim_max
569 # if HAVE_TYPEOF_RLIM_MAX==1
570 #define F_rlim_max "hd"
571 # elif HAVE_TYPEOF_RLIM_MAX==2
572 #define F_rlim_max "hu"
573 # elif HAVE_TYPEOF_RLIM_MAX==3
574 #define F_rlim_max "d"
575 # elif HAVE_TYPEOF_RLIM_MAX==4
576 #define F_rlim_max "u"
577 # elif HAVE_TYPEOF_RLIM_MAX==5
578 #define F_rlim_max "ld"
579 # elif HAVE_TYPEOF_RLIM_MAX==6
580 #define F_rlim_max "lu"
581 # elif HAVE_TYPEOF_RLIM_MAX==7
582 #define F_rlim_max "Ld"
583 # elif HAVE_TYPEOF_RLIM_MAX==8
584 #define F_rlim_max "Lu"
585 # else
586 #error "HAVE_TYPEOF_RLIM_MAX is out of range:" HAVE_TYPEOF_RLIM_MAX
587 # endif
588 #endif
590 /* Cygwin 1.3.22 has the prototypes, but not the type... */
591 #ifndef HAVE_TYPE_STAT64
592 # undef HAVE_STAT64
593 # undef HAVE_FSTAT64
594 # undef HAVE_LSTAT64
595 #endif
596 #ifndef HAVE_TYPE_OFF64
597 # undef HAVE_LSEEK64
598 # undef HAVE_FTRUNCATE64
599 #endif
601 #if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
602 # define NETDB_INTERNAL h_NETDB_INTERNAL
603 #endif
605 #ifndef INET_ADDRSTRLEN
606 # define INET_ADDRSTRLEN sizeof(struct sockaddr_in)
607 #endif
609 #if !HAVE_PROTOTYPE_HSTRERROR
610 /* with MacOSX this is char * */
611 extern const char *hstrerror(int);
612 #endif
614 /*****************************************************************************/
615 /* here are the declarations of compat.c */
617 #if !HAVE_SIGACTION
618 struct sigaction {
619 void (*sa_handler)(int);
620 void (*sa_sigaction)(int, siginfo_t *, void *);
621 sigset_t sa_mask;
622 int sa_flags;
624 struct siginfo {
625 int si_signo;
626 int si_errno;
627 int si_code;
628 pid_t si_pid;
629 uid_t si_uid;
630 int si_status;
631 /*clock_t si_utime;*/
632 /*clock_t si_stime;*/
633 sigval_t si_value;
634 int si_int;
635 void *si_ptr;
636 void *si_addr;
637 /*int si_band;*/
638 /*int si_fd;*/
640 extern int sigaction(int signum, const struct sigaction *act,
641 struct sigaction *oldact);
642 #endif /* !HAVE_SIGACTION */
644 #endif /* !defined(__compat_h_included) */