Added doc of OpenSSL options min-proto-version etc.
[socat.git] / compat.h
blobaa5d098d5d2612ef8f9f3758722069703e197fec
1 /* source: compat.h */
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
9 extern char **environ;
10 #endif
12 /*****************************************************************************/
13 /* I dont like this system dependent part, but it would be quite a challenge
14 for configure */
16 /* define if the following does not work:
17 socket()
18 connect() -> Connection refused
19 connect() -> ok
20 instead, it needs close() and socket() between the two connect() attmpts: */
21 #if __FreeBSD__ || __APPLE__ || _AIX || __hpux__ || __osf__
22 # undef SOCKET_CAN_RECOVER
23 #else
24 # define SOCKET_CAN_RECOVER 1
25 #endif
27 /* define if stat() says that pipes are sockets */
28 #if __APPLE__
29 # define PIPE_STATES_SOCKET 1
30 #else
31 # undef PIPE_STATES_SOCKET
32 #endif
34 /*****************************************************************************/
36 /* substitute some features that might be missing on some platforms */
38 #if !HAVE_TYPE_SIG_ATOMIC_T
39 typedef int sig_atomic_t;
40 #endif
42 #ifndef SHUT_RD
43 # define SHUT_RD 0
44 #endif
45 #ifndef SHUT_WR
46 # define SHUT_WR 1
47 #endif
48 #ifndef SHUT_RDWR
49 # define SHUT_RDWR 2
50 #endif
52 #ifndef MIN
53 # define MIN(x,y) ((x)<=(y)?(x):(y))
54 #endif
56 #ifndef MAX
57 # define MAX(x,y) ((x)>=(y)?(x):(y))
58 #endif
60 /* O_ASYNC: Linux 2.2.10 */
61 #if !defined(O_ASYNC) && defined(FASYNC)
62 # define O_ASYNC FASYNC
63 #endif
65 /* NGROUPS not defined on Solaris */
66 #if !defined(NGROUPS) && defined(NGROUPS_MAX)
67 # define NGROUPS NGROUPS_MAX
68 #endif
70 /* UNIX_PATH_MAX: AIX 4.3.3 */
71 #ifndef UNIX_PATH_MAX
72 # define UNIX_PATH_MAX 104 /*! why 104? Linux: 108 ! */
73 #endif
76 /* SOL_IP: AIX 4.3.3 */
77 #ifndef SOL_IP
78 # define SOL_IP 0
79 #endif
81 /* SOL_TCP: AIX 4.3.3 */
82 #ifndef SOL_TCP
83 # ifdef IPPROTO_TCP
84 # define SOL_TCP IPPROTO_TCP
85 # endif
86 #endif
88 /* POSIX.1 doesn't seem to know sockets */
89 #ifndef S_ISSOCK
90 # define S_ISSOCK(fmode) 0
91 #endif
93 #if defined(IPPROTO_IPV6) && !defined(SOL_IPV6)
94 # define SOL_IPV6 IPPROTO_IPV6
95 #endif
97 #define F_uint8_t "%hu"
98 #define F_int8_t "%hd"
100 #ifndef F_uint16_t
101 # if HAVE_BASIC_UINT16_T==0
102 # define F_uint16_t "%hu"
103 # elif HAVE_BASIC_UINT16_T==2
104 # define F_uint16_t "%hu"
105 # elif HAVE_BASIC_UINT16_T==4
106 # define F_uint16_t "%u"
107 # elif HAVE_BASIC_UINT16_T==6
108 # define F_uint16_t "%lu"
109 # else
110 # error "HAVE_BASIC_UINT16_T is out of range:" HAVE_BASIC_UINT16_T
111 # endif
112 #endif
114 #ifndef F_uint32_t
115 # if HAVE_BASIC_UINT32_T==0
116 # define F_uint32_t "%hu"
117 # elif HAVE_BASIC_UINT32_T==2
118 # define F_uint32_t "%hu"
119 # elif HAVE_BASIC_UINT32_T==4
120 # define F_uint32_t "%u"
121 # elif HAVE_BASIC_UINT32_T==6
122 # define F_uint32_t "%lu"
123 # else
124 # error "HAVE_BASIC_UINT32_T is out of range:" HAVE_BASIC_UINT32_T
125 # endif
126 #endif
128 #ifndef F_uint64_t
129 # if HAVE_BASIC_UINT64_T==0
130 # define F_uint64_t "%hu"
131 # elif HAVE_BASIC_UINT64_T==2
132 # define F_uint64_t "%hu"
133 # elif HAVE_BASIC_UINT64_T==4
134 # define F_uint64_t "%u"
135 # elif HAVE_BASIC_UINT64_T==6
136 # define F_uint64_t "%lu"
137 # elif HAVE_BASIC_UINT64_T==8
138 # define F_uint64_t "%llu"
139 # else
140 # error "HAVE_BASIC_UINT64_T is out of range:" HAVE_BASIC_UINT64_T
141 # endif
142 #endif
144 #ifndef F_int16_t
145 # if HAVE_BASIC_INT16_T==0
146 # define F_int16_t "%hd"
147 # elif HAVE_BASIC_INT16_T==1
148 # define F_int16_t "%hd"
149 # elif HAVE_BASIC_INT16_T==3
150 # define F_int16_t "%d"
151 # elif HAVE_BASIC_INT16_T==5
152 # define F_int16_t "%ld"
153 # else
154 # error "HAVE_BASIC_INT16_T is out of range:" HAVE_BASIC_INT16_T
155 # endif
156 #endif
158 #ifndef F_int32_t
159 # if HAVE_BASIC_INT32_T==0
160 # define F_int32_t "%hd"
161 # elif HAVE_BASIC_INT32_T==1
162 # define F_int32_t "%hd"
163 # elif HAVE_BASIC_INT32_T==3
164 # define F_int32_t "%d"
165 # elif HAVE_BASIC_INT32_T==5
166 # define F_int32_t "%ld"
167 # else
168 # error "HAVE_BASIC_INT32_T is out of range:" HAVE_BASIC_INT32_T
169 # endif
170 #endif
172 #ifndef F_int64_t
173 # if HAVE_BASIC_INT64_T==0
174 # define F_int64_t "%hd"
175 # elif HAVE_BASIC_INT64_T==1
176 # define F_int64_t "%hd"
177 # elif HAVE_BASIC_INT64_T==3
178 # define F_int64_t "%d"
179 # elif HAVE_BASIC_INT64_T==5
180 # define F_int64_t "%ld"
181 # elif HAVE_BASIC_INT64_T==7
182 # define F_int64_t "%lld"
183 # else
184 # error "HAVE_BASIC_INT64_T is out of range:" HAVE_BASIC_INT64_T
185 # endif
186 #endif
188 /* all unsigned */
189 #if !defined(HAVE_BASIC_SIZE_T) || !HAVE_BASIC_SIZE_T
190 # undef HAVE_BASIC_SIZE_T
191 # define HAVE_BASIC_SIZE_T 6
192 #endif
193 #if HAVE_BASIC_SIZE_T==2
194 # define SIZET_MAX USHRT_MAX
195 # define SSIZET_MIN SHRT_MIN
196 # define SSIZET_MAX SHRT_MAX
197 # define F_Zd "%hd"
198 # define F_Zu "%hu"
199 #elif HAVE_BASIC_SIZE_T==4
200 # define SIZET_MAX UINT_MAX
201 # define SSIZET_MIN INT_MIN
202 # define SSIZET_MAX INT_MAX
203 # define F_Zd "%""d"
204 # define F_Zu "%u"
205 #elif HAVE_BASIC_SIZE_T==6
206 # define SIZET_MAX ULONG_MAX
207 # define SSIZET_MIN LONG_MIN
208 # define SSIZET_MAX LONG_MAX
209 # define F_Zd "%ld"
210 # define F_Zu "%lu"
211 #elif HAVE_BASIC_SIZE_T==8
212 # define SIZET_MAX ULLONG_MAX
213 # define SSIZET_MIN LLONG_MIN
214 # define SSIZET_MAX LLONG_MAX
215 # define F_Zd "%Ld"
216 # define F_Zu "%Lu"
217 #else
218 # error "HAVE_BASIC_SIZE_T is out of range:" HAVE_BASIC_SIZE_T
219 #endif
220 #if HAVE_FORMAT_Z
221 # undef F_Zd
222 # undef F_Zu
223 # define F_Zd "%Zd"
224 # define F_Zu "%Zu"
225 #endif
228 /* mode_t is always unsigned; default: unsigned int */
229 #if !defined(HAVE_BASIC_MODE_T) || !HAVE_BASIC_MODE_T
230 # undef HAVE_BASIC_MODE_T
231 # define HAVE_BASIC_MODE_T 4
232 #endif
233 #ifndef F_mode
234 # if HAVE_BASIC_MODE_T==1 || HAVE_BASIC_MODE_T==2
235 #define F_mode "0%03ho"
236 # elif HAVE_BASIC_MODE_T==3 || HAVE_BASIC_MODE_T==4
237 #define F_mode "0%03o"
238 # elif HAVE_BASIC_MODE_T==5 || HAVE_BASIC_MODE_T==6
239 #define F_mode "0%03lo"
240 # else
241 #error "HAVE_BASIC_MODE_T is out of range:" HAVE_BASIC_MODE_T
242 # endif
243 #endif
246 /* default: unsigned int */
247 #if !defined(HAVE_BASIC_PID_T) || !HAVE_BASIC_PID_T
248 # undef HAVE_BASIC_PID_T
249 # define HAVE_BASIC_PID_T 4
250 #endif
251 #ifndef F_pid
252 # if HAVE_BASIC_PID_T==1
253 #define F_pid "%hd"
254 # elif HAVE_BASIC_PID_T==2
255 #define F_pid "%hu"
256 # elif HAVE_BASIC_PID_T==3
257 #define F_pid "%""d"
258 # elif HAVE_BASIC_PID_T==4
259 #define F_pid "%u"
260 # elif HAVE_BASIC_PID_T==5
261 #define F_pid "%ld"
262 # elif HAVE_BASIC_PID_T==6
263 #define F_pid "%lu"
264 # else
265 #error "HAVE_BASIC_PID_T is out of range:" HAVE_BASIC_PID_T
266 # endif
267 #endif
270 /* default: unsigned int */
271 #if !defined(HAVE_BASIC_UID_T) || !HAVE_BASIC_UID_T
272 # undef HAVE_BASIC_UID_T
273 # define HAVE_BASIC_UID_T 4
274 #endif
275 #ifndef F_uid
276 # if HAVE_BASIC_UID_T==1
277 #define F_uid "%hd"
278 # elif HAVE_BASIC_UID_T==2
279 #define F_uid "%hu"
280 # elif HAVE_BASIC_UID_T==3
281 #define F_uid "%""d"
282 # elif HAVE_BASIC_UID_T==4
283 #define F_uid "%u"
284 # elif HAVE_BASIC_UID_T==5
285 #define F_uid "%ld"
286 # elif HAVE_BASIC_UID_T==6
287 #define F_uid "%lu"
288 # else
289 #error "HAVE_BASIC_UID_T is out of range:" HAVE_BASIC_UID_T
290 # endif
291 #endif
294 /* default: unsigned int */
295 #if !defined(HAVE_BASIC_GID_T) || !HAVE_BASIC_GID_T
296 # undef HAVE_BASIC_GID_T
297 # define HAVE_BASIC_GID_T 4
298 #endif
299 #ifndef F_gid
300 # if HAVE_BASIC_GID_T==1
301 #define F_gid "%hd"
302 # elif HAVE_BASIC_GID_T==2
303 #define F_gid "%hu"
304 # elif HAVE_BASIC_GID_T==3
305 #define F_gid "%""d"
306 # elif HAVE_BASIC_GID_T==4
307 #define F_gid "%u"
308 # elif HAVE_BASIC_GID_T==5
309 #define F_gid "%ld"
310 # elif HAVE_BASIC_GID_T==6
311 #define F_gid "%lu"
312 # else
313 #error "HAVE_BASIC_GID_T is out of range:" HAVE_BASIC_GID_T
314 # endif
315 #endif
318 /* all signed; default: long */
319 #if !defined(HAVE_BASIC_TIME_T) || !HAVE_BASIC_TIME_T
320 # undef HAVE_BASIC_TIME_T
321 # define HAVE_BASIC_TIME_T 5
322 #endif
323 #ifndef F_time
324 # if HAVE_BASIC_TIME_T==1
325 #define F_time "%hd"
326 # elif HAVE_BASIC_TIME_T==2
327 #define F_time "%hu"
328 # elif HAVE_BASIC_TIME_T==3
329 #define F_time "%""d"
330 # elif HAVE_BASIC_TIME_T==4
331 #define F_time "%u"
332 # elif HAVE_BASIC_TIME_T==5
333 #define F_time "%ld"
334 # elif HAVE_BASIC_TIME_T==6
335 #define F_time "%lu"
336 # elif HAVE_BASIC_TIME_T==7
337 #define F_time "%Ld"
338 # elif HAVE_BASIC_TIME_T==8
339 #define F_time "%Lu"
340 # else
341 #error "HAVE_BASIC_TIME_T is out of range:" HAVE_BASIC_TIME_T
342 # endif
343 #endif
346 /* default: int */
347 #if !defined(HAVE_BASIC_SOCKLEN_T) || !HAVE_BASIC_SOCKLEN_T
348 # undef HAVE_BASIC_SOCKLEN_T
349 # define HAVE_BASIC_SOCKLEN_T 3
350 #endif
351 #ifndef F_socklen
352 # if HAVE_BASIC_SOCKLEN_T==1
353 #define F_socklen "%hd"
354 # elif HAVE_BASIC_SOCKLEN_T==2
355 #define F_socklen "%hu"
356 # elif HAVE_BASIC_SOCKLEN_T==3
357 #define F_socklen "%""d"
358 # elif HAVE_BASIC_SOCKLEN_T==4
359 #define F_socklen "%u"
360 # elif HAVE_BASIC_SOCKLEN_T==5
361 #define F_socklen "%ld"
362 # elif HAVE_BASIC_SOCKLEN_T==6
363 #define F_socklen "%lu"
364 # elif HAVE_BASIC_SOCKLEN_T==7
365 #define F_socklen "%Ld"
366 # elif HAVE_BASIC_SOCKLEN_T==8
367 #define F_socklen "%Lu"
368 # else
369 #error "HAVE_BASIC_SOCKLEN_T is out of range:" HAVE_BASIC_SOCKLEN_T
370 # endif
371 #endif
373 #if !defined(HAVE_BASIC_OFF_T) || !HAVE_BASIC_OFF_T
374 # undef HAVE_BASIC_OFF_T
375 # define HAVE_BASIC_OFF_T 5 /*long*/
376 #endif
377 #ifndef F_off
378 # if HAVE_BASIC_OFF_T==3
379 # define F_off "%""d"
380 # elif HAVE_BASIC_OFF_T==5
381 # define F_off "%ld"
382 # elif HAVE_BASIC_OFF_T==7
383 # define F_off "%Ld"
384 # else
385 #error "HAVE_BASIC_OFF_T is out of range:" HAVE_BASIC_OFF_T
386 # endif
387 #endif
389 /* default: long long */
390 #if !defined(HAVE_BASIC_OFF64_T) || !HAVE_BASIC_OFF64_T
391 # undef HAVE_BASIC_OFF64_T
392 # define HAVE_BASIC_OFF64_T 7
393 #endif
394 #ifndef F_off64
395 # if HAVE_BASIC_OFF64_T==1
396 #define F_off64 "%hd"
397 # elif HAVE_BASIC_OFF64_T==2
398 #define F_off64 "%hu"
399 # elif HAVE_BASIC_OFF64_T==3
400 #define F_off64 "%""d"
401 # elif HAVE_BASIC_OFF64_T==4
402 #define F_off64 "%u"
403 # elif HAVE_BASIC_OFF64_T==5
404 #define F_off64 "%ld"
405 # elif HAVE_BASIC_OFF64_T==6
406 #define F_off64 "%lu"
407 # elif HAVE_BASIC_OFF64_T==7
408 #define F_off64 "%Ld"
409 # elif HAVE_BASIC_OFF64_T==8
410 #define F_off64 "%Lu"
411 # else
412 #error "HAVE_BASIC_OFF64_T is out of range:" HAVE_BASIC_OFF64_T
413 # endif
414 #endif
417 /* all unsigned; default: unsigned long */
418 #if !defined(HAVE_BASIC_DEV_T) || !HAVE_BASIC_DEV_T
419 # undef HAVE_BASIC_DEV_T
420 # define HAVE_BASIC_DEV_T 6
421 #endif
422 #ifndef F_dev
423 # if HAVE_BASIC_DEV_T==1
424 #define F_dev "%hd"
425 # elif HAVE_BASIC_DEV_T==2
426 #define F_dev "%hu"
427 # elif HAVE_BASIC_DEV_T==3
428 #define F_dev "%""d"
429 # elif HAVE_BASIC_DEV_T==4
430 #define F_dev "%u"
431 # elif HAVE_BASIC_DEV_T==5
432 #define F_dev "%ld"
433 # elif HAVE_BASIC_DEV_T==6
434 #define F_dev "%lu"
435 # elif HAVE_BASIC_DEV_T==7
436 #define F_dev "%Ld"
437 # elif HAVE_BASIC_DEV_T==8
438 #define F_dev "%Lu"
439 # else
440 #error "HAVE_BASIC_DEV_T is out of range:" HAVE_BASIC_DEV_T
441 # endif
442 #endif
445 #if _WITH_TERMIOS
446 #if !defined(HAVE_BASIC_SPEED_T) || !HAVE_BASIC_SPEED_T
447 # undef HAVE_BASIC_SPEED_T
448 # define HAVE_BASIC_SPEED_T 4
449 #endif
450 #ifndef F_speed
451 # if HAVE_BASIC_SPEED_T==1
452 #define F_speed "%hd"
453 # elif HAVE_BASIC_SPEED_T==2
454 #define F_speed "%hu"
455 # elif HAVE_BASIC_SPEED_T==3
456 #define F_speed "%""d"
457 # elif HAVE_BASIC_SPEED_T==4
458 #define F_speed "%u"
459 # elif HAVE_BASIC_SPEED_T==5
460 #define F_speed "%ld"
461 # elif HAVE_BASIC_SPEED_T==6
462 #define F_speed "%lu"
463 # elif HAVE_BASIC_SPEED_T==7
464 #define F_speed "%Ld"
465 # elif HAVE_BASIC_SPEED_T==8
466 #define F_speed "%Lu"
467 # else
468 #error "HAVE_BASIC_SPEED_T is out of range:" HAVE_BASIC_SPEED_T
469 # endif
470 #endif
471 #endif /* _WITH_TERMIOS */
473 /* all unsigned; default; unsigned long */
474 #if !defined(HAVE_TYPEOF_ST_INO) || !HAVE_TYPEOF_ST_INO
475 # undef HAVE_TYPEOF_ST_INO
476 # define HAVE_TYPEOF_ST_INO 6
477 #endif
478 #ifndef F_st_ino
479 # if HAVE_TYPEOF_ST_INO==1
480 #define F_st_ino "%hd"
481 # elif HAVE_TYPEOF_ST_INO==2
482 #define F_st_ino "%hu"
483 # elif HAVE_TYPEOF_ST_INO==3
484 #define F_st_ino "%""d"
485 # elif HAVE_TYPEOF_ST_INO==4
486 #define F_st_ino "%u"
487 # elif HAVE_TYPEOF_ST_INO==5
488 #define F_st_ino "%ld"
489 # elif HAVE_TYPEOF_ST_INO==6
490 #define F_st_ino "%lu"
491 # elif HAVE_TYPEOF_ST_INO==7 /* Cygwin 1.5 */
492 #define F_st_ino "%Ld"
493 # elif HAVE_TYPEOF_ST_INO==8
494 #define F_st_ino "%Lu"
495 # else
496 #error "HAVE_TYPEOF_ST_INO is out of range:" HAVE_TYPEOF_ST_INO
497 # endif
498 #endif
500 /* all unsigned; default; unsigned long long */
501 #if !defined(HAVE_TYPEOF_ST64_INO) || !HAVE_TYPEOF_ST64_INO
502 # undef HAVE_TYPEOF_ST64_INO
503 # define HAVE_TYPEOF_ST64_INO 8
504 #endif
505 #ifndef F_st64_ino
506 # if HAVE_TYPEOF_ST64_INO==1
507 #define F_st64_ino "%hd"
508 # elif HAVE_TYPEOF_ST64_INO==2
509 #define F_st64_ino "%hu"
510 # elif HAVE_TYPEOF_ST64_INO==3
511 #define F_st64_ino "%""d"
512 # elif HAVE_TYPEOF_ST64_INO==4
513 #define F_st64_ino "%u"
514 # elif HAVE_TYPEOF_ST64_INO==5
515 #define F_st64_ino "%ld"
516 # elif HAVE_TYPEOF_ST64_INO==6
517 #define F_st64_ino "%lu"
518 # elif HAVE_TYPEOF_ST64_INO==7
519 #define F_st64_ino "%Ld"
520 # elif HAVE_TYPEOF_ST64_INO==8
521 #define F_st64_ino "%Lu"
522 # else
523 #error "HAVE_TYPEOF_ST64_INO is out of range:" HAVE_TYPEOF_ST64_INO
524 # endif
525 #endif
527 /* default: unsigned short */
528 #if !defined(HAVE_TYPEOF_ST_NLINK) || !HAVE_TYPEOF_ST_NLINK
529 # undef HAVE_TYPEOF_ST_NLINK
530 # define HAVE_TYPEOF_ST_NLINK 2
531 #endif
532 #ifndef F_st_nlink
533 # if HAVE_TYPEOF_ST_NLINK==1
534 #define F_st_nlink "%hd"
535 # elif HAVE_TYPEOF_ST_NLINK==2
536 #define F_st_nlink "%hu"
537 # elif HAVE_TYPEOF_ST_NLINK==3
538 #define F_st_nlink "%""d"
539 # elif HAVE_TYPEOF_ST_NLINK==4
540 #define F_st_nlink "%u"
541 # elif HAVE_TYPEOF_ST_NLINK==5
542 #define F_st_nlink "%ld"
543 # elif HAVE_TYPEOF_ST_NLINK==6
544 #define F_st_nlink "%lu"
545 # elif HAVE_TYPEOF_ST_NLINK==7
546 #define F_st_nlink "%Ld"
547 # elif HAVE_TYPEOF_ST_NLINK==8
548 #define F_st_nlink "%Lu"
549 # else
550 #error "HAVE_TYPEOF_ST_NLINK is out of range:" HAVE_TYPEOF_ST_NLINK
551 # endif
552 #endif
554 /* all signed; default: long */
555 #if !defined(HAVE_TYPEOF_ST_SIZE) || !HAVE_TYPEOF_ST_SIZE
556 # undef HAVE_TYPEOF_ST_SIZE
557 # define HAVE_TYPEOF_ST_SIZE 5
558 #endif
559 #ifndef F_st_size
560 # if HAVE_TYPEOF_ST_SIZE==1
561 #define F_st_size "%hd"
562 # elif HAVE_TYPEOF_ST_SIZE==2
563 #define F_st_size "%hu"
564 # elif HAVE_TYPEOF_ST_SIZE==3
565 #define F_st_size "%""d"
566 # elif HAVE_TYPEOF_ST_SIZE==4
567 #define F_st_size "%u"
568 # elif HAVE_TYPEOF_ST_SIZE==5
569 #define F_st_size "%ld"
570 # elif HAVE_TYPEOF_ST_SIZE==6
571 #define F_st_size "%lu"
572 # elif HAVE_TYPEOF_ST_SIZE==7
573 #define F_st_size "%Ld"
574 # elif HAVE_TYPEOF_ST_SIZE==8
575 #define F_st_size "%Lu"
576 # else
577 #error "HAVE_TYPEOF_ST_SIZE is out of range:" HAVE_TYPEOF_ST_SIZE
578 # endif
579 #endif
581 /* all signed; default: long long */
582 #if !defined(HAVE_TYPEOF_ST64_SIZE) || !HAVE_TYPEOF_ST64_SIZE
583 # undef HAVE_TYPEOF_ST64_SIZE
584 # define HAVE_TYPEOF_ST64_SIZE 7
585 #endif
586 #ifndef F_st64_size
587 # if HAVE_TYPEOF_ST64_SIZE==1
588 #define F_st64_size "%hd"
589 # elif HAVE_TYPEOF_ST64_SIZE==2
590 #define F_st64_size "%hu"
591 # elif HAVE_TYPEOF_ST64_SIZE==3
592 #define F_st64_size "%""d"
593 # elif HAVE_TYPEOF_ST64_SIZE==4
594 #define F_st64_size "%u"
595 # elif HAVE_TYPEOF_ST64_SIZE==5
596 #define F_st64_size "%ld"
597 # elif HAVE_TYPEOF_ST64_SIZE==6
598 #define F_st64_size "%lu"
599 # elif HAVE_TYPEOF_ST64_SIZE==7
600 #define F_st64_size "%Ld"
601 # elif HAVE_TYPEOF_ST64_SIZE==8
602 #define F_st64_size "%Lu"
603 # else
604 #error "HAVE_TYPEOF_ST64_SIZE is out of range:" HAVE_TYPEOF_ST64_SIZE
605 # endif
606 #endif
608 /* very different results; default: long */
609 #if !defined(HAVE_TYPEOF_ST_BLKSIZE) || !HAVE_TYPEOF_ST_BLKSIZE
610 # undef HAVE_TYPEOF_ST_BLKSIZE
611 # define HAVE_TYPEOF_ST_BLKSIZE 5
612 #endif
613 #ifndef F_st_blksize
614 # if HAVE_TYPEOF_ST_BLKSIZE==1
615 #define F_st_blksize "%hd"
616 # elif HAVE_TYPEOF_ST_BLKSIZE==2
617 #define F_st_blksize "%hu"
618 # elif HAVE_TYPEOF_ST_BLKSIZE==3
619 #define F_st_blksize "%""d"
620 # elif HAVE_TYPEOF_ST_BLKSIZE==4
621 #define F_st_blksize "%u"
622 # elif HAVE_TYPEOF_ST_BLKSIZE==5
623 #define F_st_blksize "%ld"
624 # elif HAVE_TYPEOF_ST_BLKSIZE==6
625 #define F_st_blksize "%lu"
626 # elif HAVE_TYPEOF_ST_BLKSIZE==7
627 #define F_st_blksize "%Ld"
628 # elif HAVE_TYPEOF_ST_BLKSIZE==8
629 #define F_st_blksize "%Lu"
630 # else
631 #error "HAVE_TYPEOF_ST_BLKSIZE is out of range:" HAVE_TYPEOF_ST_BLKSIZE
632 # endif
633 #endif
635 /* default: long */
636 #if !defined(HAVE_TYPEOF_ST_BLOCKS) || !HAVE_TYPEOF_ST_BLOCKS
637 # undef HAVE_TYPEOF_ST_BLOCKS
638 # define HAVE_TYPEOF_ST_BLOCKS 5
639 #endif
640 #ifndef F_st_blocks
641 # if HAVE_TYPEOF_ST_BLOCKS==1
642 #define F_st_blocks "%hd"
643 # elif HAVE_TYPEOF_ST_BLOCKS==2
644 #define F_st_blocks "%hu"
645 # elif HAVE_TYPEOF_ST_BLOCKS==3
646 #define F_st_blocks "%""d"
647 # elif HAVE_TYPEOF_ST_BLOCKS==4
648 #define F_st_blocks "%u"
649 # elif HAVE_TYPEOF_ST_BLOCKS==5
650 #define F_st_blocks "%ld"
651 # elif HAVE_TYPEOF_ST_BLOCKS==6
652 #define F_st_blocks "%lu"
653 # elif HAVE_TYPEOF_ST_BLOCKS==7
654 #define F_st_blocks "%Ld"
655 # elif HAVE_TYPEOF_ST_BLOCKS==8
656 #define F_st_blocks "%Lu"
657 # else
658 #error "HAVE_TYPEOF_ST_BLOCKS is out of range:" HAVE_TYPEOF_ST_BLOCKS
659 # endif
660 #endif
662 /* default: long long */
663 #if !defined(HAVE_TYPEOF_ST64_BLOCKS) || !HAVE_TYPEOF_ST64_BLOCKS
664 # undef HAVE_TYPEOF_ST64_BLOCKS
665 # define HAVE_TYPEOF_ST64_BLOCKS 7
666 #endif
667 #ifndef F_st64_blocks
668 # if HAVE_TYPEOF_ST64_BLOCKS==1
669 #define F_st64_blocks "%hd"
670 # elif HAVE_TYPEOF_ST64_BLOCKS==2
671 #define F_st64_blocks "%hu"
672 # elif HAVE_TYPEOF_ST64_BLOCKS==3
673 #define F_st64_blocks "%""d"
674 # elif HAVE_TYPEOF_ST64_BLOCKS==4
675 #define F_st64_blocks "%u"
676 # elif HAVE_TYPEOF_ST64_BLOCKS==5
677 #define F_st64_blocks "%ld"
678 # elif HAVE_TYPEOF_ST64_BLOCKS==6
679 #define F_st64_blocks "%lu"
680 # elif HAVE_TYPEOF_ST64_BLOCKS==7
681 #define F_st64_blocks "%Ld"
682 # elif HAVE_TYPEOF_ST64_BLOCKS==8
683 #define F_st64_blocks "%Lu"
684 # else
685 #error "HAVE_TYPEOF_ST64_BLOCKS is out of range:" HAVE_TYPEOF_ST64_BLOCKS
686 # endif
687 #endif
690 /* at least for Linux */
691 #define F_tv_sec "%ld"
693 /* default: long */
694 #if !defined(HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC) || !HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
695 # undef HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
696 # define HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC 5
697 #endif
698 #ifndef F_tv_usec
699 # if HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==1
700 #define F_tv_usec "%06hd"
701 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==2
702 #define F_tv_usec "%06hu"
703 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==3
704 #define F_tv_usec "%06d"
705 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==4
706 #define F_tv_usec "%06u"
707 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==5
708 #define F_tv_usec "%06ld"
709 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==6
710 #define F_tv_usec "%06lu"
711 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==7
712 #define F_tv_usec "%06Ld"
713 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==8
714 #define F_tv_usec "%06Lu"
715 # else
716 #error "HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC is out of range:" HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
717 # endif
718 #endif
720 /* default: long */
721 #if !defined(HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC) || !HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC
722 # undef HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC
723 # define HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC 5
724 #endif
725 #ifndef F_tv_nsec
726 # if HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==1
727 #define F_tv_nsec "%09hd"
728 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==2
729 #define F_tv_nsec "%09hu"
730 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==3
731 #define F_tv_nsec "%09d"
732 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==4
733 #define F_tv_nsec "%09u"
734 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==5
735 #define F_tv_nsec "%09ld"
736 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==6
737 #define F_tv_nsec "%09lu"
738 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==7
739 #define F_tv_nsec "%09Ld"
740 # elif HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC==8
741 #define F_tv_nsec "%09Lu"
742 # else
743 #error "HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC is out of range:" HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC
744 # endif
745 #endif
747 /* default: long */
748 #if !defined(HAVE_TYPEOF_RLIM_MAX) || !HAVE_TYPEOF_RLIM_MAX
749 # undef HAVE_TYPEOF_RLIM_MAX
750 # define HAVE_TYPEOF_RLIM_MAX 5
751 #endif
752 #ifndef F_rlim_max
753 # if HAVE_TYPEOF_RLIM_MAX==1
754 #define F_rlim_max "hd"
755 # elif HAVE_TYPEOF_RLIM_MAX==2
756 #define F_rlim_max "hu"
757 # elif HAVE_TYPEOF_RLIM_MAX==3
758 #define F_rlim_max "d"
759 # elif HAVE_TYPEOF_RLIM_MAX==4
760 #define F_rlim_max "u"
761 # elif HAVE_TYPEOF_RLIM_MAX==5
762 #define F_rlim_max "ld"
763 # elif HAVE_TYPEOF_RLIM_MAX==6
764 #define F_rlim_max "lu"
765 # elif HAVE_TYPEOF_RLIM_MAX==7
766 #define F_rlim_max "Ld"
767 # elif HAVE_TYPEOF_RLIM_MAX==8
768 #define F_rlim_max "Lu"
769 # else
770 #error "HAVE_TYPEOF_RLIM_MAX is out of range:" HAVE_TYPEOF_RLIM_MAX
771 # endif
772 #endif
774 /* sigset_t printing - not an exact solution yet */
775 #define F_sigset "0x%06lx"
776 typedef unsigned long T_sigset;
778 /* default: socklen_t */
779 #if !defined(HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN) || !HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
780 # undef HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
781 # define HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN HAVE_BASIC_SOCKLEN_T
782 #endif
783 #ifndef F_cmsg_len
784 # if HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==1
785 #define F_cmsg_len "%""hd"
786 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==2
787 #define F_cmsg_len "%""hu"
788 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==3
789 #define F_cmsg_len "%""d"
790 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==4
791 #define F_cmsg_len "%""u"
792 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==5
793 #define F_cmsg_len "%""ld"
794 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==6
795 #define F_cmsg_len "%""lu"
796 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==7
797 #define F_cmsg_len "%""Ld"
798 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==8
799 #define F_cmsg_len "%""Lu"
800 # else
801 #error "HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN is out of range:" HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
802 # endif
803 #endif
805 /* basic type of struct timeval tv_usec */
806 #ifndef F_tv_usec
807 # if TYPEOF_STRUCT_TIMEVAL_TV_USEC==1
808 # define F_tv_usec "%hu"
809 # elif TYPEOF_STRUCT_TIMEVAL_TV_USEC==3
810 # define F_tv_usec "%u"
811 # elif TYPEOF_STRUCT_TIMEVAL_TV_USEC==5
812 # define F_tv_usec "%lu"
813 # endif
814 #endif
816 /* Cygwin 1.3.22 has the prototypes, but not the type... */
817 #ifndef HAVE_TYPE_STAT64
818 # undef HAVE_STAT64
819 # undef HAVE_FSTAT64
820 # undef HAVE_LSTAT64
821 #endif
822 #ifndef HAVE_TYPE_OFF64
823 # undef HAVE_LSEEK64
824 # undef HAVE_FTRUNCATE64
825 #endif
827 #if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
828 # define NETDB_INTERNAL h_NETDB_INTERNAL
829 #endif
831 #ifndef INET_ADDRSTRLEN
832 # define INET_ADDRSTRLEN sizeof(struct sockaddr_in)
833 #endif
835 #if !HAVE_PROTOTYPE_HSTRERROR
836 /* with MacOSX this is char * */
837 extern const char *hstrerror(int);
838 #endif
840 #if !HAVE_PROTOTYPE_LIB_strndup
841 extern char *strndup (const char *s, size_t n);
842 #endif
844 #endif /* !defined(__compat_h_included) */