2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
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 #if !HAVE_DECL_ENVIRON && HAVE_VAR_ENVIRON
12 /*****************************************************************************/
13 /* I dont like this system dependent part, but it would be quite a challenge
16 /* define if the following does not work:
18 connect() -> Connection refused
20 instead, it needs close() and socket() between the two connect() attmpts: */
21 #if __FreeBSD__ || __APPLE__ || _AIX || __hpux__ || __osf__
22 # undef SOCKET_CAN_RECOVER
24 # define SOCKET_CAN_RECOVER 1
27 /* define if stat() says that pipes are sockets */
29 # define PIPE_STATES_SOCKET 1
31 # undef PIPE_STATES_SOCKET
34 #if defined(__sun) || defined(__sun__) || defined(__SunOS)
35 # define XIO_ANCILLARY_TYPE_SOLARIS 1
38 /*****************************************************************************/
40 /* substitute some features that might be missing on some platforms */
42 #if !HAVE_TYPE_SIG_ATOMIC_T
43 typedef int sig_atomic_t;
57 # define MIN(x,y) ((x)<=(y)?(x):(y))
61 # define MAX(x,y) ((x)>=(y)?(x):(y))
64 /* O_ASYNC: Linux 2.2.10 */
65 #if !defined(O_ASYNC) && defined(FASYNC)
66 # define O_ASYNC FASYNC
69 /* NGROUPS not defined on Solaris */
70 #if !defined(NGROUPS) && defined(NGROUPS_MAX)
71 # define NGROUPS NGROUPS_MAX
74 /* UNIX_PATH_MAX: AIX 4.3.3 */
76 # define UNIX_PATH_MAX 104 /*! why 104? Linux: 108 ! */
80 /* SOL_IP: AIX 4.3.3 */
85 /* SOL_TCP: AIX 4.3.3 */
88 # define SOL_TCP IPPROTO_TCP
92 /* POSIX.1 doesn't seem to know sockets */
94 # define S_ISSOCK(fmode) 0
97 #if defined(IPPROTO_IPV6) && !defined(SOL_IPV6)
98 # define SOL_IPV6 IPPROTO_IPV6
101 #define F_uint8_t "%hu"
102 #define F_uint8_x "%02hx"
103 #define F_int8_t "%hd"
106 # if HAVE_BASIC_UINT16_T==0
107 # define F_uint16_t "%hu"
108 # define F_uint16_x "%04hx"
109 # elif HAVE_BASIC_UINT16_T==2
110 # define F_uint16_t "%hu"
111 # define F_uint16_x "%04hx"
112 # elif HAVE_BASIC_UINT16_T==4
113 # define F_uint16_t "%u"
114 # define F_uint16_x "%04x"
115 # elif HAVE_BASIC_UINT16_T==6
116 # define F_uint16_t "%lu"
117 # define F_uint16_x "%04lx"
119 # error "HAVE_BASIC_UINT16_T is out of range:" HAVE_BASIC_UINT16_T
124 # if HAVE_BASIC_UINT32_T==0
125 # define F_uint32_t "%hu"
126 # define F_uint32_x "%08hx"
127 # elif HAVE_BASIC_UINT32_T==2
128 # define F_uint32_t "%hu"
129 # define F_uint32_x "%08hx"
130 # elif HAVE_BASIC_UINT32_T==4
131 # define F_uint32_t "%u"
132 # define F_uint32_x "%08x"
133 # elif HAVE_BASIC_UINT32_T==6
134 # define F_uint32_t "%lu"
135 # define F_uint32_x "%08lx"
137 # error "HAVE_BASIC_UINT32_T is out of range:" HAVE_BASIC_UINT32_T
142 # if HAVE_BASIC_UINT64_T==0
143 # define F_uint64_t "%hu"
144 # define F_uint64_x "%016hx"
145 # elif HAVE_BASIC_UINT64_T==2
146 # define F_uint64_t "%hu"
147 # define F_uint64_x "%016hx"
148 # elif HAVE_BASIC_UINT64_T==4
149 # define F_uint64_t "%u"
150 # define F_uint64_x "%016x"
151 # elif HAVE_BASIC_UINT64_T==6
152 # define F_uint64_t "%lu"
153 # define F_uint64_x "%016lx"
154 # elif HAVE_BASIC_UINT64_T==8
155 # define F_uint64_t "%llu"
156 # define F_uint64_x "%016llx"
158 # error "HAVE_BASIC_UINT64_T is out of range:" HAVE_BASIC_UINT64_T
163 # if HAVE_BASIC_INT16_T==0
164 # define F_int16_t "%hd"
165 # elif HAVE_BASIC_INT16_T==1
166 # define F_int16_t "%hd"
167 # elif HAVE_BASIC_INT16_T==3
168 # define F_int16_t "%d"
169 # elif HAVE_BASIC_INT16_T==5
170 # define F_int16_t "%ld"
172 # error "HAVE_BASIC_INT16_T is out of range:" HAVE_BASIC_INT16_T
177 # if HAVE_BASIC_INT32_T==0
178 # define F_int32_t "%hd"
179 # elif HAVE_BASIC_INT32_T==1
180 # define F_int32_t "%hd"
181 # elif HAVE_BASIC_INT32_T==3
182 # define F_int32_t "%d"
183 # elif HAVE_BASIC_INT32_T==5
184 # define F_int32_t "%ld"
186 # error "HAVE_BASIC_INT32_T is out of range:" HAVE_BASIC_INT32_T
191 # if HAVE_BASIC_INT64_T==0
192 # define F_int64_t "%hd"
193 # elif HAVE_BASIC_INT64_T==1
194 # define F_int64_t "%hd"
195 # elif HAVE_BASIC_INT64_T==3
196 # define F_int64_t "%d"
197 # elif HAVE_BASIC_INT64_T==5
198 # define F_int64_t "%ld"
199 # elif HAVE_BASIC_INT64_T==7
200 # define F_int64_t "%lld"
202 # error "HAVE_BASIC_INT64_T is out of range:" HAVE_BASIC_INT64_T
207 #if !defined(HAVE_BASIC_SIZE_T) || !HAVE_BASIC_SIZE_T
208 # undef HAVE_BASIC_SIZE_T
209 # define HAVE_BASIC_SIZE_T 6
211 #if HAVE_BASIC_SIZE_T==2
212 # define SIZET_MAX USHRT_MAX
213 # define SSIZET_MIN SHRT_MIN
214 # define SSIZET_MAX SHRT_MAX
217 #elif HAVE_BASIC_SIZE_T==4
218 # define SIZET_MAX UINT_MAX
219 # define SSIZET_MIN INT_MIN
220 # define SSIZET_MAX INT_MAX
223 #elif HAVE_BASIC_SIZE_T==6
224 # define SIZET_MAX ULONG_MAX
225 # define SSIZET_MIN LONG_MIN
226 # define SSIZET_MAX LONG_MAX
229 #elif HAVE_BASIC_SIZE_T==8
230 # define SIZET_MAX ULLONG_MAX
231 # define SSIZET_MIN LLONG_MIN
232 # define SSIZET_MAX LLONG_MAX
236 # error "HAVE_BASIC_SIZE_T is out of range:" HAVE_BASIC_SIZE_T
246 /* mode_t is always unsigned; default: unsigned int */
247 #if !defined(HAVE_BASIC_MODE_T) || !HAVE_BASIC_MODE_T
248 # undef HAVE_BASIC_MODE_T
249 # define HAVE_BASIC_MODE_T 4
252 # if HAVE_BASIC_MODE_T==1 || HAVE_BASIC_MODE_T==2
253 #define F_mode "0%03ho"
254 # elif HAVE_BASIC_MODE_T==3 || HAVE_BASIC_MODE_T==4
255 #define F_mode "0%03o"
256 # elif HAVE_BASIC_MODE_T==5 || HAVE_BASIC_MODE_T==6
257 #define F_mode "0%03lo"
259 #error "HAVE_BASIC_MODE_T is out of range:" HAVE_BASIC_MODE_T
264 /* default: unsigned int */
265 #if !defined(HAVE_BASIC_PID_T) || !HAVE_BASIC_PID_T
266 # undef HAVE_BASIC_PID_T
267 # define HAVE_BASIC_PID_T 4
270 # if HAVE_BASIC_PID_T==1
272 # elif HAVE_BASIC_PID_T==2
274 # elif HAVE_BASIC_PID_T==3
276 # elif HAVE_BASIC_PID_T==4
278 # elif HAVE_BASIC_PID_T==5
280 # elif HAVE_BASIC_PID_T==6
283 #error "HAVE_BASIC_PID_T is out of range:" HAVE_BASIC_PID_T
288 /* default: unsigned int */
289 #if !defined(HAVE_BASIC_UID_T) || !HAVE_BASIC_UID_T
290 # undef HAVE_BASIC_UID_T
291 # define HAVE_BASIC_UID_T 4
294 # if HAVE_BASIC_UID_T==1
296 # elif HAVE_BASIC_UID_T==2
298 # elif HAVE_BASIC_UID_T==3
300 # elif HAVE_BASIC_UID_T==4
302 # elif HAVE_BASIC_UID_T==5
304 # elif HAVE_BASIC_UID_T==6
307 #error "HAVE_BASIC_UID_T is out of range:" HAVE_BASIC_UID_T
312 /* default: unsigned int */
313 #if !defined(HAVE_BASIC_GID_T) || !HAVE_BASIC_GID_T
314 # undef HAVE_BASIC_GID_T
315 # define HAVE_BASIC_GID_T 4
318 # if HAVE_BASIC_GID_T==1
320 # elif HAVE_BASIC_GID_T==2
322 # elif HAVE_BASIC_GID_T==3
324 # elif HAVE_BASIC_GID_T==4
326 # elif HAVE_BASIC_GID_T==5
328 # elif HAVE_BASIC_GID_T==6
331 #error "HAVE_BASIC_GID_T is out of range:" HAVE_BASIC_GID_T
336 /* all signed; default: long */
337 #if !defined(HAVE_BASIC_TIME_T) || !HAVE_BASIC_TIME_T
338 # undef HAVE_BASIC_TIME_T
339 # define HAVE_BASIC_TIME_T 5
342 # if HAVE_BASIC_TIME_T==1
344 # elif HAVE_BASIC_TIME_T==2
346 # elif HAVE_BASIC_TIME_T==3
347 #define F_time "%""d"
348 # elif HAVE_BASIC_TIME_T==4
350 # elif HAVE_BASIC_TIME_T==5
352 # elif HAVE_BASIC_TIME_T==6
354 # elif HAVE_BASIC_TIME_T==7
356 # elif HAVE_BASIC_TIME_T==8
359 #error "HAVE_BASIC_TIME_T is out of range:" HAVE_BASIC_TIME_T
365 #if !defined(HAVE_BASIC_SOCKLEN_T) || !HAVE_BASIC_SOCKLEN_T
366 # undef HAVE_BASIC_SOCKLEN_T
367 # define HAVE_BASIC_SOCKLEN_T 3
370 # if HAVE_BASIC_SOCKLEN_T==1
371 #define F_socklen "%hd"
372 # elif HAVE_BASIC_SOCKLEN_T==2
373 #define F_socklen "%hu"
374 # elif HAVE_BASIC_SOCKLEN_T==3
375 #define F_socklen "%""d"
376 # elif HAVE_BASIC_SOCKLEN_T==4
377 #define F_socklen "%u"
378 # elif HAVE_BASIC_SOCKLEN_T==5
379 #define F_socklen "%ld"
380 # elif HAVE_BASIC_SOCKLEN_T==6
381 #define F_socklen "%lu"
382 # elif HAVE_BASIC_SOCKLEN_T==7
383 #define F_socklen "%Ld"
384 # elif HAVE_BASIC_SOCKLEN_T==8
385 #define F_socklen "%Lu"
387 #error "HAVE_BASIC_SOCKLEN_T is out of range:" HAVE_BASIC_SOCKLEN_T
391 #if !defined(HAVE_BASIC_OFF_T) || !HAVE_BASIC_OFF_T
392 # undef HAVE_BASIC_OFF_T
393 # define HAVE_BASIC_OFF_T 5 /*long*/
396 # if HAVE_BASIC_OFF_T==3
397 # define F_off "%""d"
398 # elif HAVE_BASIC_OFF_T==5
400 # elif HAVE_BASIC_OFF_T==7
403 #error "HAVE_BASIC_OFF_T is out of range:" HAVE_BASIC_OFF_T
407 /* default: long long */
408 #if !defined(HAVE_BASIC_OFF64_T) || !HAVE_BASIC_OFF64_T
409 # undef HAVE_BASIC_OFF64_T
410 # define HAVE_BASIC_OFF64_T 7
413 # if HAVE_BASIC_OFF64_T==1
414 #define F_off64 "%hd"
415 # elif HAVE_BASIC_OFF64_T==2
416 #define F_off64 "%hu"
417 # elif HAVE_BASIC_OFF64_T==3
418 #define F_off64 "%""d"
419 # elif HAVE_BASIC_OFF64_T==4
421 # elif HAVE_BASIC_OFF64_T==5
422 #define F_off64 "%ld"
423 # elif HAVE_BASIC_OFF64_T==6
424 #define F_off64 "%lu"
425 # elif HAVE_BASIC_OFF64_T==7
426 #define F_off64 "%Ld"
427 # elif HAVE_BASIC_OFF64_T==8
428 #define F_off64 "%Lu"
430 #error "HAVE_BASIC_OFF64_T is out of range:" HAVE_BASIC_OFF64_T
435 /* all unsigned; default: unsigned long */
436 #if !defined(HAVE_BASIC_DEV_T) || !HAVE_BASIC_DEV_T
437 # undef HAVE_BASIC_DEV_T
438 # define HAVE_BASIC_DEV_T 6
441 # if HAVE_BASIC_DEV_T==1
443 # elif HAVE_BASIC_DEV_T==2
445 # elif HAVE_BASIC_DEV_T==3
447 # elif HAVE_BASIC_DEV_T==4
449 # elif HAVE_BASIC_DEV_T==5
451 # elif HAVE_BASIC_DEV_T==6
453 # elif HAVE_BASIC_DEV_T==7
455 # elif HAVE_BASIC_DEV_T==8
458 #error "HAVE_BASIC_DEV_T is out of range:" HAVE_BASIC_DEV_T
464 #if !defined(HAVE_BASIC_SPEED_T) || !HAVE_BASIC_SPEED_T
465 # undef HAVE_BASIC_SPEED_T
466 # define HAVE_BASIC_SPEED_T 4
469 # if HAVE_BASIC_SPEED_T==1
470 #define F_speed "%hd"
471 # elif HAVE_BASIC_SPEED_T==2
472 #define F_speed "%hu"
473 # elif HAVE_BASIC_SPEED_T==3
474 #define F_speed "%""d"
475 # elif HAVE_BASIC_SPEED_T==4
477 # elif HAVE_BASIC_SPEED_T==5
478 #define F_speed "%ld"
479 # elif HAVE_BASIC_SPEED_T==6
480 #define F_speed "%lu"
481 # elif HAVE_BASIC_SPEED_T==7
482 #define F_speed "%Ld"
483 # elif HAVE_BASIC_SPEED_T==8
484 #define F_speed "%Lu"
486 #error "HAVE_BASIC_SPEED_T is out of range:" HAVE_BASIC_SPEED_T
489 #endif /* _WITH_TERMIOS */
491 /* all unsigned; default; unsigned long */
492 #if !defined(HAVE_TYPEOF_ST_INO) || !HAVE_TYPEOF_ST_INO
493 # undef HAVE_TYPEOF_ST_INO
494 # define HAVE_TYPEOF_ST_INO 6
497 # if HAVE_TYPEOF_ST_INO==1
498 #define F_st_ino "%hd"
499 # elif HAVE_TYPEOF_ST_INO==2
500 #define F_st_ino "%hu"
501 # elif HAVE_TYPEOF_ST_INO==3
502 #define F_st_ino "%""d"
503 # elif HAVE_TYPEOF_ST_INO==4
504 #define F_st_ino "%u"
505 # elif HAVE_TYPEOF_ST_INO==5
506 #define F_st_ino "%ld"
507 # elif HAVE_TYPEOF_ST_INO==6
508 #define F_st_ino "%lu"
509 # elif HAVE_TYPEOF_ST_INO==7 /* Cygwin 1.5 */
510 #define F_st_ino "%Ld"
511 # elif HAVE_TYPEOF_ST_INO==8
512 #define F_st_ino "%Lu"
514 #error "HAVE_TYPEOF_ST_INO is out of range:" HAVE_TYPEOF_ST_INO
518 /* all unsigned; default; unsigned long long */
519 #if !defined(HAVE_TYPEOF_ST64_INO) || !HAVE_TYPEOF_ST64_INO
520 # undef HAVE_TYPEOF_ST64_INO
521 # define HAVE_TYPEOF_ST64_INO 8
524 # if HAVE_TYPEOF_ST64_INO==1
525 #define F_st64_ino "%hd"
526 # elif HAVE_TYPEOF_ST64_INO==2
527 #define F_st64_ino "%hu"
528 # elif HAVE_TYPEOF_ST64_INO==3
529 #define F_st64_ino "%""d"
530 # elif HAVE_TYPEOF_ST64_INO==4
531 #define F_st64_ino "%u"
532 # elif HAVE_TYPEOF_ST64_INO==5
533 #define F_st64_ino "%ld"
534 # elif HAVE_TYPEOF_ST64_INO==6
535 #define F_st64_ino "%lu"
536 # elif HAVE_TYPEOF_ST64_INO==7
537 #define F_st64_ino "%Ld"
538 # elif HAVE_TYPEOF_ST64_INO==8
539 #define F_st64_ino "%Lu"
541 #error "HAVE_TYPEOF_ST64_INO is out of range:" HAVE_TYPEOF_ST64_INO
545 /* default: unsigned short */
546 #if !defined(HAVE_TYPEOF_ST_NLINK) || !HAVE_TYPEOF_ST_NLINK
547 # undef HAVE_TYPEOF_ST_NLINK
548 # define HAVE_TYPEOF_ST_NLINK 2
551 # if HAVE_TYPEOF_ST_NLINK==1
552 #define F_st_nlink "%hd"
553 # elif HAVE_TYPEOF_ST_NLINK==2
554 #define F_st_nlink "%hu"
555 # elif HAVE_TYPEOF_ST_NLINK==3
556 #define F_st_nlink "%""d"
557 # elif HAVE_TYPEOF_ST_NLINK==4
558 #define F_st_nlink "%u"
559 # elif HAVE_TYPEOF_ST_NLINK==5
560 #define F_st_nlink "%ld"
561 # elif HAVE_TYPEOF_ST_NLINK==6
562 #define F_st_nlink "%lu"
563 # elif HAVE_TYPEOF_ST_NLINK==7
564 #define F_st_nlink "%Ld"
565 # elif HAVE_TYPEOF_ST_NLINK==8
566 #define F_st_nlink "%Lu"
568 #error "HAVE_TYPEOF_ST_NLINK is out of range:" HAVE_TYPEOF_ST_NLINK
572 /* all signed; default: long */
573 #if !defined(HAVE_TYPEOF_ST_SIZE) || !HAVE_TYPEOF_ST_SIZE
574 # undef HAVE_TYPEOF_ST_SIZE
575 # define HAVE_TYPEOF_ST_SIZE 5
578 # if HAVE_TYPEOF_ST_SIZE==1
579 #define F_st_size "%hd"
580 # elif HAVE_TYPEOF_ST_SIZE==2
581 #define F_st_size "%hu"
582 # elif HAVE_TYPEOF_ST_SIZE==3
583 #define F_st_size "%""d"
584 # elif HAVE_TYPEOF_ST_SIZE==4
585 #define F_st_size "%u"
586 # elif HAVE_TYPEOF_ST_SIZE==5
587 #define F_st_size "%ld"
588 # elif HAVE_TYPEOF_ST_SIZE==6
589 #define F_st_size "%lu"
590 # elif HAVE_TYPEOF_ST_SIZE==7
591 #define F_st_size "%Ld"
592 # elif HAVE_TYPEOF_ST_SIZE==8
593 #define F_st_size "%Lu"
595 #error "HAVE_TYPEOF_ST_SIZE is out of range:" HAVE_TYPEOF_ST_SIZE
599 /* all signed; default: long long */
600 #if !defined(HAVE_TYPEOF_ST64_SIZE) || !HAVE_TYPEOF_ST64_SIZE
601 # undef HAVE_TYPEOF_ST64_SIZE
602 # define HAVE_TYPEOF_ST64_SIZE 7
605 # if HAVE_TYPEOF_ST64_SIZE==1
606 #define F_st64_size "%hd"
607 # elif HAVE_TYPEOF_ST64_SIZE==2
608 #define F_st64_size "%hu"
609 # elif HAVE_TYPEOF_ST64_SIZE==3
610 #define F_st64_size "%""d"
611 # elif HAVE_TYPEOF_ST64_SIZE==4
612 #define F_st64_size "%u"
613 # elif HAVE_TYPEOF_ST64_SIZE==5
614 #define F_st64_size "%ld"
615 # elif HAVE_TYPEOF_ST64_SIZE==6
616 #define F_st64_size "%lu"
617 # elif HAVE_TYPEOF_ST64_SIZE==7
618 #define F_st64_size "%Ld"
619 # elif HAVE_TYPEOF_ST64_SIZE==8
620 #define F_st64_size "%Lu"
622 #error "HAVE_TYPEOF_ST64_SIZE is out of range:" HAVE_TYPEOF_ST64_SIZE
626 /* very different results; default: long */
627 #if !defined(HAVE_TYPEOF_ST_BLKSIZE) || !HAVE_TYPEOF_ST_BLKSIZE
628 # undef HAVE_TYPEOF_ST_BLKSIZE
629 # define HAVE_TYPEOF_ST_BLKSIZE 5
632 # if HAVE_TYPEOF_ST_BLKSIZE==1
633 #define F_st_blksize "%hd"
634 # elif HAVE_TYPEOF_ST_BLKSIZE==2
635 #define F_st_blksize "%hu"
636 # elif HAVE_TYPEOF_ST_BLKSIZE==3
637 #define F_st_blksize "%""d"
638 # elif HAVE_TYPEOF_ST_BLKSIZE==4
639 #define F_st_blksize "%u"
640 # elif HAVE_TYPEOF_ST_BLKSIZE==5
641 #define F_st_blksize "%ld"
642 # elif HAVE_TYPEOF_ST_BLKSIZE==6
643 #define F_st_blksize "%lu"
644 # elif HAVE_TYPEOF_ST_BLKSIZE==7
645 #define F_st_blksize "%Ld"
646 # elif HAVE_TYPEOF_ST_BLKSIZE==8
647 #define F_st_blksize "%Lu"
649 #error "HAVE_TYPEOF_ST_BLKSIZE is out of range:" HAVE_TYPEOF_ST_BLKSIZE
654 #if !defined(HAVE_TYPEOF_ST_BLOCKS) || !HAVE_TYPEOF_ST_BLOCKS
655 # undef HAVE_TYPEOF_ST_BLOCKS
656 # define HAVE_TYPEOF_ST_BLOCKS 5
659 # if HAVE_TYPEOF_ST_BLOCKS==1
660 #define F_st_blocks "%hd"
661 # elif HAVE_TYPEOF_ST_BLOCKS==2
662 #define F_st_blocks "%hu"
663 # elif HAVE_TYPEOF_ST_BLOCKS==3
664 #define F_st_blocks "%""d"
665 # elif HAVE_TYPEOF_ST_BLOCKS==4
666 #define F_st_blocks "%u"
667 # elif HAVE_TYPEOF_ST_BLOCKS==5
668 #define F_st_blocks "%ld"
669 # elif HAVE_TYPEOF_ST_BLOCKS==6
670 #define F_st_blocks "%lu"
671 # elif HAVE_TYPEOF_ST_BLOCKS==7
672 #define F_st_blocks "%Ld"
673 # elif HAVE_TYPEOF_ST_BLOCKS==8
674 #define F_st_blocks "%Lu"
676 #error "HAVE_TYPEOF_ST_BLOCKS is out of range:" HAVE_TYPEOF_ST_BLOCKS
680 /* default: long long */
681 #if !defined(HAVE_TYPEOF_ST64_BLOCKS) || !HAVE_TYPEOF_ST64_BLOCKS
682 # undef HAVE_TYPEOF_ST64_BLOCKS
683 # define HAVE_TYPEOF_ST64_BLOCKS 7
685 #ifndef F_st64_blocks
686 # if HAVE_TYPEOF_ST64_BLOCKS==1
687 #define F_st64_blocks "%hd"
688 # elif HAVE_TYPEOF_ST64_BLOCKS==2
689 #define F_st64_blocks "%hu"
690 # elif HAVE_TYPEOF_ST64_BLOCKS==3
691 #define F_st64_blocks "%""d"
692 # elif HAVE_TYPEOF_ST64_BLOCKS==4
693 #define F_st64_blocks "%u"
694 # elif HAVE_TYPEOF_ST64_BLOCKS==5
695 #define F_st64_blocks "%ld"
696 # elif HAVE_TYPEOF_ST64_BLOCKS==6
697 #define F_st64_blocks "%lu"
698 # elif HAVE_TYPEOF_ST64_BLOCKS==7
699 #define F_st64_blocks "%Ld"
700 # elif HAVE_TYPEOF_ST64_BLOCKS==8
701 #define F_st64_blocks "%Lu"
703 #error "HAVE_TYPEOF_ST64_BLOCKS is out of range:" HAVE_TYPEOF_ST64_BLOCKS
708 /* at least for Linux */
709 #define F_tv_sec "%ld"
712 #if !defined(HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC) || !HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
713 # undef HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
714 # define HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC 5
717 # if HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==1
718 #define F_tv_usec "%06hd"
719 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==2
720 #define F_tv_usec "%06hu"
721 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==3
722 #define F_tv_usec "%06d"
723 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==4
724 #define F_tv_usec "%06u"
725 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==5
726 #define F_tv_usec "%06ld"
727 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==6
728 #define F_tv_usec "%06lu"
729 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==7
730 #define F_tv_usec "%06Ld"
731 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==8
732 #define F_tv_usec "%06Lu"
734 #error "HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC is out of range:" HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
739 #if !defined(HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC) || !HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC
740 # undef HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC
741 # define HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC 5
744 # if HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==1
745 #define F_tv_nsec "%09hd"
746 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==2
747 #define F_tv_nsec "%09hu"
748 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==3
749 #define F_tv_nsec "%09d"
750 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==4
751 #define F_tv_nsec "%09u"
752 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==5
753 #define F_tv_nsec "%09ld"
754 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==6
755 #define F_tv_nsec "%09lu"
756 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==7
757 #define F_tv_nsec "%09Ld"
758 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==8
759 #define F_tv_nsec "%09Lu"
761 #error "HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC is out of range:" HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC
766 #if !defined(HAVE_TYPEOF_RLIM_MAX) || !HAVE_TYPEOF_RLIM_MAX
767 # undef HAVE_TYPEOF_RLIM_MAX
768 # define HAVE_TYPEOF_RLIM_MAX 5
771 # if HAVE_TYPEOF_RLIM_MAX==1
772 #define F_rlim_max "hd"
773 # elif HAVE_TYPEOF_RLIM_MAX==2
774 #define F_rlim_max "hu"
775 # elif HAVE_TYPEOF_RLIM_MAX==3
776 #define F_rlim_max "d"
777 # elif HAVE_TYPEOF_RLIM_MAX==4
778 #define F_rlim_max "u"
779 # elif HAVE_TYPEOF_RLIM_MAX==5
780 #define F_rlim_max "ld"
781 # elif HAVE_TYPEOF_RLIM_MAX==6
782 #define F_rlim_max "lu"
783 # elif HAVE_TYPEOF_RLIM_MAX==7
784 #define F_rlim_max "Ld"
785 # elif HAVE_TYPEOF_RLIM_MAX==8
786 #define F_rlim_max "Lu"
788 #error "HAVE_TYPEOF_RLIM_MAX is out of range:" HAVE_TYPEOF_RLIM_MAX
792 /* sigset_t printing - not an exact solution yet */
793 #define F_sigset "0x%06lx"
794 typedef unsigned long T_sigset
;
796 /* default: socklen_t */
797 #if !defined(HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN) || !HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
798 # undef HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
799 # define HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN HAVE_BASIC_SOCKLEN_T
802 # if HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==1
803 #define F_cmsg_len "%""hd"
804 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==2
805 #define F_cmsg_len "%""hu"
806 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==3
807 #define F_cmsg_len "%""d"
808 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==4
809 #define F_cmsg_len "%""u"
810 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==5
811 #define F_cmsg_len "%""ld"
812 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==6
813 #define F_cmsg_len "%""lu"
814 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==7
815 #define F_cmsg_len "%""Ld"
816 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==8
817 #define F_cmsg_len "%""Lu"
819 #error "HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN is out of range:" HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
823 /* basic type of struct timeval tv_usec */
825 # if TYPEOF_STRUCT_TIMEVAL_TV_USEC==1
826 # define F_tv_usec "%hu"
827 # elif TYPEOF_STRUCT_TIMEVAL_TV_USEC==3
828 # define F_tv_usec "%u"
829 # elif TYPEOF_STRUCT_TIMEVAL_TV_USEC==5
830 # define F_tv_usec "%lu"
834 /* OpenBSD (at least 7.2) does better with this special setting */
835 #if __FreeBSD__ || __OpenBSD__
836 # define UNIX_TIGHTSOCKLEN false
838 # define UNIX_TIGHTSOCKLEN true
841 /* Cygwin 1.3.22 has the prototypes, but not the type... */
842 #ifndef HAVE_TYPE_STAT64
847 #ifndef HAVE_TYPE_OFF64
849 # undef HAVE_FTRUNCATE64
852 #if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
853 # define NETDB_INTERNAL h_NETDB_INTERNAL
854 #elif !defined(NETDB_INTERNAL)
855 # define NETDB_INTERNAL (-1)
858 #ifndef INET_ADDRSTRLEN
859 # define INET_ADDRSTRLEN sizeof(struct sockaddr_in)
862 #if !HAVE_PROTOTYPE_HSTRERROR
863 /* with MacOSX this is char * */
864 extern const char *hstrerror(int);
867 #if !HAVE_PROTOTYPE_LIB_strndup
868 extern char *strndup (const char *s
, size_t n
);
871 #endif /* !defined(__compat_h_included) */