Permit -dd; print a useful error message when single character options appear to...
[socat.git] / compat.h
blobd40ccc545ae429b35660c0438f6e3ba1dbb3c897
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 /* all unsigned */
98 #if !defined(HAVE_BASIC_SIZE_T) || !HAVE_BASIC_SIZE_T
99 # undef HAVE_BASIC_SIZE_T
100 # define HAVE_BASIC_SIZE_T 6
101 #endif
102 #if HAVE_BASIC_SIZE_T==2
103 # define SIZET_MAX USHRT_MAX
104 # define SSIZET_MIN SHRT_MIN
105 # define SSIZET_MAX SHRT_MAX
106 # define F_Zd "%hd"
107 # define F_Zu "%hu"
108 #elif HAVE_BASIC_SIZE_T==4
109 # define SIZET_MAX UINT_MAX
110 # define SSIZET_MIN INT_MIN
111 # define SSIZET_MAX INT_MAX
112 # define F_Zd "%""d"
113 # define F_Zu "%u"
114 #elif HAVE_BASIC_SIZE_T==6
115 # define SIZET_MAX ULONG_MAX
116 # define SSIZET_MIN LONG_MIN
117 # define SSIZET_MAX LONG_MAX
118 # define F_Zd "%ld"
119 # define F_Zu "%lu"
120 #elif HAVE_BASIC_SIZE_T==8
121 # define SIZET_MAX ULLONG_MAX
122 # define SSIZET_MIN LLONG_MIN
123 # define SSIZET_MAX LLONG_MAX
124 # define F_Zd "%Ld"
125 # define F_Zu "%Lu"
126 #else
127 # error "HAVE_BASIC_SIZE_T is out of range:" HAVE_BASIC_SIZE_T
128 #endif
129 #if HAVE_FORMAT_Z
130 # undef F_Zd
131 # undef F_Zu
132 # define F_Zd "%Zd"
133 # define F_Zu "%Zu"
134 #endif
137 /* mode_t is always unsigned; default: unsigned int */
138 #if !defined(HAVE_BASIC_MODE_T) || !HAVE_BASIC_MODE_T
139 # undef HAVE_BASIC_MODE_T
140 # define HAVE_BASIC_MODE_T 4
141 #endif
142 #ifndef F_mode
143 # if HAVE_BASIC_MODE_T==1 || HAVE_BASIC_MODE_T==2
144 #define F_mode "0%03ho"
145 # elif HAVE_BASIC_MODE_T==3 || HAVE_BASIC_MODE_T==4
146 #define F_mode "0%03o"
147 # elif HAVE_BASIC_MODE_T==5 || HAVE_BASIC_MODE_T==6
148 #define F_mode "0%03lo"
149 # else
150 #error "HAVE_BASIC_MODE_T is out of range:" HAVE_BASIC_MODE_T
151 # endif
152 #endif
155 /* default: unsigned int */
156 #if !defined(HAVE_BASIC_PID_T) || !HAVE_BASIC_PID_T
157 # undef HAVE_BASIC_PID_T
158 # define HAVE_BASIC_PID_T 4
159 #endif
160 #ifndef F_pid
161 # if HAVE_BASIC_PID_T==1
162 #define F_pid "%hd"
163 # elif HAVE_BASIC_PID_T==2
164 #define F_pid "%hu"
165 # elif HAVE_BASIC_PID_T==3
166 #define F_pid "%""d"
167 # elif HAVE_BASIC_PID_T==4
168 #define F_pid "%u"
169 # elif HAVE_BASIC_PID_T==5
170 #define F_pid "%ld"
171 # elif HAVE_BASIC_PID_T==6
172 #define F_pid "%lu"
173 # else
174 #error "HAVE_BASIC_PID_T is out of range:" HAVE_BASIC_PID_T
175 # endif
176 #endif
179 /* default: unsigned int */
180 #if !defined(HAVE_BASIC_UID_T) || !HAVE_BASIC_UID_T
181 # undef HAVE_BASIC_UID_T
182 # define HAVE_BASIC_UID_T 4
183 #endif
184 #ifndef F_uid
185 # if HAVE_BASIC_UID_T==1
186 #define F_uid "%hd"
187 # elif HAVE_BASIC_UID_T==2
188 #define F_uid "%hu"
189 # elif HAVE_BASIC_UID_T==3
190 #define F_uid "%""d"
191 # elif HAVE_BASIC_UID_T==4
192 #define F_uid "%u"
193 # elif HAVE_BASIC_UID_T==5
194 #define F_uid "%ld"
195 # elif HAVE_BASIC_UID_T==6
196 #define F_uid "%lu"
197 # else
198 #error "HAVE_BASIC_UID_T is out of range:" HAVE_BASIC_UID_T
199 # endif
200 #endif
203 /* default: unsigned int */
204 #if !defined(HAVE_BASIC_GID_T) || !HAVE_BASIC_GID_T
205 # undef HAVE_BASIC_GID_T
206 # define HAVE_BASIC_GID_T 4
207 #endif
208 #ifndef F_gid
209 # if HAVE_BASIC_GID_T==1
210 #define F_gid "%hd"
211 # elif HAVE_BASIC_GID_T==2
212 #define F_gid "%hu"
213 # elif HAVE_BASIC_GID_T==3
214 #define F_gid "%""d"
215 # elif HAVE_BASIC_GID_T==4
216 #define F_gid "%u"
217 # elif HAVE_BASIC_GID_T==5
218 #define F_gid "%ld"
219 # elif HAVE_BASIC_GID_T==6
220 #define F_gid "%lu"
221 # else
222 #error "HAVE_BASIC_GID_T is out of range:" HAVE_BASIC_GID_T
223 # endif
224 #endif
227 /* all signed; default: long */
228 #if !defined(HAVE_BASIC_TIME_T) || !HAVE_BASIC_TIME_T
229 # undef HAVE_BASIC_TIME_T
230 # define HAVE_BASIC_TIME_T 5
231 #endif
232 #ifndef F_time
233 # if HAVE_BASIC_TIME_T==1
234 #define F_time "%hd"
235 # elif HAVE_BASIC_TIME_T==2
236 #define F_time "%hu"
237 # elif HAVE_BASIC_TIME_T==3
238 #define F_time "%""d"
239 # elif HAVE_BASIC_TIME_T==4
240 #define F_time "%u"
241 # elif HAVE_BASIC_TIME_T==5
242 #define F_time "%ld"
243 # elif HAVE_BASIC_TIME_T==6
244 #define F_time "%lu"
245 # elif HAVE_BASIC_TIME_T==7
246 #define F_time "%Ld"
247 # elif HAVE_BASIC_TIME_T==8
248 #define F_time "%Lu"
249 # else
250 #error "HAVE_BASIC_TIME_T is out of range:" HAVE_BASIC_TIME_T
251 # endif
252 #endif
255 /* default: int */
256 #if !defined(HAVE_BASIC_SOCKLEN_T) || !HAVE_BASIC_SOCKLEN_T
257 # undef HAVE_BASIC_SOCKLEN_T
258 # define HAVE_BASIC_SOCKLEN_T 3
259 #endif
260 #ifndef F_socklen
261 # if HAVE_BASIC_SOCKLEN_T==1
262 #define F_socklen "%hd"
263 # elif HAVE_BASIC_SOCKLEN_T==2
264 #define F_socklen "%hu"
265 # elif HAVE_BASIC_SOCKLEN_T==3
266 #define F_socklen "%""d"
267 # elif HAVE_BASIC_SOCKLEN_T==4
268 #define F_socklen "%u"
269 # elif HAVE_BASIC_SOCKLEN_T==5
270 #define F_socklen "%ld"
271 # elif HAVE_BASIC_SOCKLEN_T==6
272 #define F_socklen "%lu"
273 # elif HAVE_BASIC_SOCKLEN_T==7
274 #define F_socklen "%Ld"
275 # elif HAVE_BASIC_SOCKLEN_T==8
276 #define F_socklen "%Lu"
277 # else
278 #error "HAVE_BASIC_SOCKLEN_T is out of range:" HAVE_BASIC_SOCKLEN_T
279 # endif
280 #endif
282 #if !defined(HAVE_BASIC_OFF_T) || !HAVE_BASIC_OFF_T
283 # undef HAVE_BASIC_OFF_T
284 # define HAVE_BASIC_OFF_T 5 /*long*/
285 #endif
286 #ifndef F_off
287 # if HAVE_BASIC_OFF_T==3
288 # define F_off "%""d"
289 # elif HAVE_BASIC_OFF_T==5
290 # define F_off "%ld"
291 # elif HAVE_BASIC_OFF_T==7
292 # define F_off "%Ld"
293 # else
294 #error "HAVE_BASIC_OFF_T is out of range:" HAVE_BASIC_OFF_T
295 # endif
296 #endif
298 /* default: long long */
299 #if !defined(HAVE_BASIC_OFF64_T) || !HAVE_BASIC_OFF64_T
300 # undef HAVE_BASIC_OFF64_T
301 # define HAVE_BASIC_OFF64_T 7
302 #endif
303 #ifndef F_off64
304 # if HAVE_BASIC_OFF64_T==1
305 #define F_off64 "%hd"
306 # elif HAVE_BASIC_OFF64_T==2
307 #define F_off64 "%hu"
308 # elif HAVE_BASIC_OFF64_T==3
309 #define F_off64 "%""d"
310 # elif HAVE_BASIC_OFF64_T==4
311 #define F_off64 "%u"
312 # elif HAVE_BASIC_OFF64_T==5
313 #define F_off64 "%ld"
314 # elif HAVE_BASIC_OFF64_T==6
315 #define F_off64 "%lu"
316 # elif HAVE_BASIC_OFF64_T==7
317 #define F_off64 "%Ld"
318 # elif HAVE_BASIC_OFF64_T==8
319 #define F_off64 "%Lu"
320 # else
321 #error "HAVE_BASIC_OFF64_T is out of range:" HAVE_BASIC_OFF64_T
322 # endif
323 #endif
326 /* all unsigned; default: unsigned long */
327 #if !defined(HAVE_BASIC_DEV_T) || !HAVE_BASIC_DEV_T
328 # undef HAVE_BASIC_DEV_T
329 # define HAVE_BASIC_DEV_T 6
330 #endif
331 #ifndef F_dev
332 # if HAVE_BASIC_DEV_T==1
333 #define F_dev "%hd"
334 # elif HAVE_BASIC_DEV_T==2
335 #define F_dev "%hu"
336 # elif HAVE_BASIC_DEV_T==3
337 #define F_dev "%""d"
338 # elif HAVE_BASIC_DEV_T==4
339 #define F_dev "%u"
340 # elif HAVE_BASIC_DEV_T==5
341 #define F_dev "%ld"
342 # elif HAVE_BASIC_DEV_T==6
343 #define F_dev "%lu"
344 # elif HAVE_BASIC_DEV_T==7
345 #define F_dev "%Ld"
346 # elif HAVE_BASIC_DEV_T==8
347 #define F_dev "%Lu"
348 # else
349 #error "HAVE_BASIC_DEV_T is out of range:" HAVE_BASIC_DEV_T
350 # endif
351 #endif
354 #if _WITH_TERMIOS
355 #if !defined(HAVE_BASIC_SPEED_T) || !HAVE_BASIC_SPEED_T
356 # undef HAVE_BASIC_SPEED_T
357 # define HAVE_BASIC_SPEED_T 4
358 #endif
359 #ifndef F_speed
360 # if HAVE_BASIC_SPEED_T==1
361 #define F_speed "%hd"
362 # elif HAVE_BASIC_SPEED_T==2
363 #define F_speed "%hu"
364 # elif HAVE_BASIC_SPEED_T==3
365 #define F_speed "%""d"
366 # elif HAVE_BASIC_SPEED_T==4
367 #define F_speed "%u"
368 # elif HAVE_BASIC_SPEED_T==5
369 #define F_speed "%ld"
370 # elif HAVE_BASIC_SPEED_T==6
371 #define F_speed "%lu"
372 # elif HAVE_BASIC_SPEED_T==7
373 #define F_speed "%Ld"
374 # elif HAVE_BASIC_SPEED_T==8
375 #define F_speed "%Lu"
376 # else
377 #error "HAVE_BASIC_SPEED_T is out of range:" HAVE_BASIC_SPEED_T
378 # endif
379 #endif
380 #endif /* _WITH_TERMIOS */
382 /* all unsigned; default; unsigned long */
383 #if !defined(HAVE_TYPEOF_ST_INO) || !HAVE_TYPEOF_ST_INO
384 # undef HAVE_TYPEOF_ST_INO
385 # define HAVE_TYPEOF_ST_INO 6
386 #endif
387 #ifndef F_st_ino
388 # if HAVE_TYPEOF_ST_INO==1
389 #define F_st_ino "%hd"
390 # elif HAVE_TYPEOF_ST_INO==2
391 #define F_st_ino "%hu"
392 # elif HAVE_TYPEOF_ST_INO==3
393 #define F_st_ino "%""d"
394 # elif HAVE_TYPEOF_ST_INO==4
395 #define F_st_ino "%u"
396 # elif HAVE_TYPEOF_ST_INO==5
397 #define F_st_ino "%ld"
398 # elif HAVE_TYPEOF_ST_INO==6
399 #define F_st_ino "%lu"
400 # elif HAVE_TYPEOF_ST_INO==7 /* Cygwin 1.5 */
401 #define F_st_ino "%Ld"
402 # elif HAVE_TYPEOF_ST_INO==8
403 #define F_st_ino "%Lu"
404 # else
405 #error "HAVE_TYPEOF_ST_INO is out of range:" HAVE_TYPEOF_ST_INO
406 # endif
407 #endif
409 /* all unsigned; default; unsigned long long */
410 #if !defined(HAVE_TYPEOF_ST64_INO) || !HAVE_TYPEOF_ST64_INO
411 # undef HAVE_TYPEOF_ST64_INO
412 # define HAVE_TYPEOF_ST64_INO 8
413 #endif
414 #ifndef F_st64_ino
415 # if HAVE_TYPEOF_ST64_INO==1
416 #define F_st64_ino "%hd"
417 # elif HAVE_TYPEOF_ST64_INO==2
418 #define F_st64_ino "%hu"
419 # elif HAVE_TYPEOF_ST64_INO==3
420 #define F_st64_ino "%""d"
421 # elif HAVE_TYPEOF_ST64_INO==4
422 #define F_st64_ino "%u"
423 # elif HAVE_TYPEOF_ST64_INO==5
424 #define F_st64_ino "%ld"
425 # elif HAVE_TYPEOF_ST64_INO==6
426 #define F_st64_ino "%lu"
427 # elif HAVE_TYPEOF_ST64_INO==7
428 #define F_st64_ino "%Ld"
429 # elif HAVE_TYPEOF_ST64_INO==8
430 #define F_st64_ino "%Lu"
431 # else
432 #error "HAVE_TYPEOF_ST64_INO is out of range:" HAVE_TYPEOF_ST64_INO
433 # endif
434 #endif
436 /* default: unsigned short */
437 #if !defined(HAVE_TYPEOF_ST_NLINK) || !HAVE_TYPEOF_ST_NLINK
438 # undef HAVE_TYPEOF_ST_NLINK
439 # define HAVE_TYPEOF_ST_NLINK 2
440 #endif
441 #ifndef F_st_nlink
442 # if HAVE_TYPEOF_ST_NLINK==1
443 #define F_st_nlink "%hd"
444 # elif HAVE_TYPEOF_ST_NLINK==2
445 #define F_st_nlink "%hu"
446 # elif HAVE_TYPEOF_ST_NLINK==3
447 #define F_st_nlink "%""d"
448 # elif HAVE_TYPEOF_ST_NLINK==4
449 #define F_st_nlink "%u"
450 # elif HAVE_TYPEOF_ST_NLINK==5
451 #define F_st_nlink "%ld"
452 # elif HAVE_TYPEOF_ST_NLINK==6
453 #define F_st_nlink "%lu"
454 # elif HAVE_TYPEOF_ST_NLINK==7
455 #define F_st_nlink "%Ld"
456 # elif HAVE_TYPEOF_ST_NLINK==8
457 #define F_st_nlink "%Lu"
458 # else
459 #error "HAVE_TYPEOF_ST_NLINK is out of range:" HAVE_TYPEOF_ST_NLINK
460 # endif
461 #endif
463 /* all signed; default: long */
464 #if !defined(HAVE_TYPEOF_ST_SIZE) || !HAVE_TYPEOF_ST_SIZE
465 # undef HAVE_TYPEOF_ST_SIZE
466 # define HAVE_TYPEOF_ST_SIZE 5
467 #endif
468 #ifndef F_st_size
469 # if HAVE_TYPEOF_ST_SIZE==1
470 #define F_st_size "%hd"
471 # elif HAVE_TYPEOF_ST_SIZE==2
472 #define F_st_size "%hu"
473 # elif HAVE_TYPEOF_ST_SIZE==3
474 #define F_st_size "%""d"
475 # elif HAVE_TYPEOF_ST_SIZE==4
476 #define F_st_size "%u"
477 # elif HAVE_TYPEOF_ST_SIZE==5
478 #define F_st_size "%ld"
479 # elif HAVE_TYPEOF_ST_SIZE==6
480 #define F_st_size "%lu"
481 # elif HAVE_TYPEOF_ST_SIZE==7
482 #define F_st_size "%Ld"
483 # elif HAVE_TYPEOF_ST_SIZE==8
484 #define F_st_size "%Lu"
485 # else
486 #error "HAVE_TYPEOF_ST_SIZE is out of range:" HAVE_TYPEOF_ST_SIZE
487 # endif
488 #endif
490 /* all signed; default: long long */
491 #if !defined(HAVE_TYPEOF_ST64_SIZE) || !HAVE_TYPEOF_ST64_SIZE
492 # undef HAVE_TYPEOF_ST64_SIZE
493 # define HAVE_TYPEOF_ST64_SIZE 7
494 #endif
495 #ifndef F_st64_size
496 # if HAVE_TYPEOF_ST64_SIZE==1
497 #define F_st64_size "%hd"
498 # elif HAVE_TYPEOF_ST64_SIZE==2
499 #define F_st64_size "%hu"
500 # elif HAVE_TYPEOF_ST64_SIZE==3
501 #define F_st64_size "%""d"
502 # elif HAVE_TYPEOF_ST64_SIZE==4
503 #define F_st64_size "%u"
504 # elif HAVE_TYPEOF_ST64_SIZE==5
505 #define F_st64_size "%ld"
506 # elif HAVE_TYPEOF_ST64_SIZE==6
507 #define F_st64_size "%lu"
508 # elif HAVE_TYPEOF_ST64_SIZE==7
509 #define F_st64_size "%Ld"
510 # elif HAVE_TYPEOF_ST64_SIZE==8
511 #define F_st64_size "%Lu"
512 # else
513 #error "HAVE_TYPEOF_ST64_SIZE is out of range:" HAVE_TYPEOF_ST64_SIZE
514 # endif
515 #endif
517 /* very different results; default: long */
518 #if !defined(HAVE_TYPEOF_ST_BLKSIZE) || !HAVE_TYPEOF_ST_BLKSIZE
519 # undef HAVE_TYPEOF_ST_BLKSIZE
520 # define HAVE_TYPEOF_ST_BLKSIZE 5
521 #endif
522 #ifndef F_st_blksize
523 # if HAVE_TYPEOF_ST_BLKSIZE==1
524 #define F_st_blksize "%hd"
525 # elif HAVE_TYPEOF_ST_BLKSIZE==2
526 #define F_st_blksize "%hu"
527 # elif HAVE_TYPEOF_ST_BLKSIZE==3
528 #define F_st_blksize "%""d"
529 # elif HAVE_TYPEOF_ST_BLKSIZE==4
530 #define F_st_blksize "%u"
531 # elif HAVE_TYPEOF_ST_BLKSIZE==5
532 #define F_st_blksize "%ld"
533 # elif HAVE_TYPEOF_ST_BLKSIZE==6
534 #define F_st_blksize "%lu"
535 # elif HAVE_TYPEOF_ST_BLKSIZE==7
536 #define F_st_blksize "%Ld"
537 # elif HAVE_TYPEOF_ST_BLKSIZE==8
538 #define F_st_blksize "%Lu"
539 # else
540 #error "HAVE_TYPEOF_ST_BLKSIZE is out of range:" HAVE_TYPEOF_ST_BLKSIZE
541 # endif
542 #endif
544 /* default: long */
545 #if !defined(HAVE_TYPEOF_ST_BLOCKS) || !HAVE_TYPEOF_ST_BLOCKS
546 # undef HAVE_TYPEOF_ST_BLOCKS
547 # define HAVE_TYPEOF_ST_BLOCKS 5
548 #endif
549 #ifndef F_st_blocks
550 # if HAVE_TYPEOF_ST_BLOCKS==1
551 #define F_st_blocks "%hd"
552 # elif HAVE_TYPEOF_ST_BLOCKS==2
553 #define F_st_blocks "%hu"
554 # elif HAVE_TYPEOF_ST_BLOCKS==3
555 #define F_st_blocks "%""d"
556 # elif HAVE_TYPEOF_ST_BLOCKS==4
557 #define F_st_blocks "%u"
558 # elif HAVE_TYPEOF_ST_BLOCKS==5
559 #define F_st_blocks "%ld"
560 # elif HAVE_TYPEOF_ST_BLOCKS==6
561 #define F_st_blocks "%lu"
562 # elif HAVE_TYPEOF_ST_BLOCKS==7
563 #define F_st_blocks "%Ld"
564 # elif HAVE_TYPEOF_ST_BLOCKS==8
565 #define F_st_blocks "%Lu"
566 # else
567 #error "HAVE_TYPEOF_ST_BLOCKS is out of range:" HAVE_TYPEOF_ST_BLOCKS
568 # endif
569 #endif
571 /* default: long long */
572 #if !defined(HAVE_TYPEOF_ST64_BLOCKS) || !HAVE_TYPEOF_ST64_BLOCKS
573 # undef HAVE_TYPEOF_ST64_BLOCKS
574 # define HAVE_TYPEOF_ST64_BLOCKS 7
575 #endif
576 #ifndef F_st64_blocks
577 # if HAVE_TYPEOF_ST64_BLOCKS==1
578 #define F_st64_blocks "%hd"
579 # elif HAVE_TYPEOF_ST64_BLOCKS==2
580 #define F_st64_blocks "%hu"
581 # elif HAVE_TYPEOF_ST64_BLOCKS==3
582 #define F_st64_blocks "%""d"
583 # elif HAVE_TYPEOF_ST64_BLOCKS==4
584 #define F_st64_blocks "%u"
585 # elif HAVE_TYPEOF_ST64_BLOCKS==5
586 #define F_st64_blocks "%ld"
587 # elif HAVE_TYPEOF_ST64_BLOCKS==6
588 #define F_st64_blocks "%lu"
589 # elif HAVE_TYPEOF_ST64_BLOCKS==7
590 #define F_st64_blocks "%Ld"
591 # elif HAVE_TYPEOF_ST64_BLOCKS==8
592 #define F_st64_blocks "%Lu"
593 # else
594 #error "HAVE_TYPEOF_ST64_BLOCKS is out of range:" HAVE_TYPEOF_ST64_BLOCKS
595 # endif
596 #endif
599 /* at least for Linux */
600 #define F_tv_sec "%ld"
602 /* default: long */
603 #if !defined(HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC) || !HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
604 # undef HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
605 # define HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC 5
606 #endif
607 #ifndef F_tv_usec
608 # if HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==1
609 #define F_tv_usec "%06hd"
610 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==2
611 #define F_tv_usec "%06hu"
612 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==3
613 #define F_tv_usec "%06d"
614 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==4
615 #define F_tv_usec "%06u"
616 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==5
617 #define F_tv_usec "%06ld"
618 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==6
619 #define F_tv_usec "%06lu"
620 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==7
621 #define F_tv_usec "%06Ld"
622 # elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==8
623 #define F_tv_usec "%06Lu"
624 # else
625 #error "HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC is out of range:" HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
626 # endif
627 #endif
629 /* default: long */
630 #if !defined(HAVE_TYPEOF_RLIM_MAX) || !HAVE_TYPEOF_RLIM_MAX
631 # undef HAVE_TYPEOF_RLIM_MAX
632 # define HAVE_TYPEOF_RLIM_MAX 5
633 #endif
634 #ifndef F_rlim_max
635 # if HAVE_TYPEOF_RLIM_MAX==1
636 #define F_rlim_max "hd"
637 # elif HAVE_TYPEOF_RLIM_MAX==2
638 #define F_rlim_max "hu"
639 # elif HAVE_TYPEOF_RLIM_MAX==3
640 #define F_rlim_max "d"
641 # elif HAVE_TYPEOF_RLIM_MAX==4
642 #define F_rlim_max "u"
643 # elif HAVE_TYPEOF_RLIM_MAX==5
644 #define F_rlim_max "ld"
645 # elif HAVE_TYPEOF_RLIM_MAX==6
646 #define F_rlim_max "lu"
647 # elif HAVE_TYPEOF_RLIM_MAX==7
648 #define F_rlim_max "Ld"
649 # elif HAVE_TYPEOF_RLIM_MAX==8
650 #define F_rlim_max "Lu"
651 # else
652 #error "HAVE_TYPEOF_RLIM_MAX is out of range:" HAVE_TYPEOF_RLIM_MAX
653 # endif
654 #endif
656 /* default: socklen_t */
657 #if !defined(HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN) || !HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
658 # undef HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
659 # define HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN HAVE_BASIC_SOCKLEN_T
660 #endif
661 #ifndef F_cmsg_len
662 # if HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==1
663 #define F_cmsg_len "%""hd"
664 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==2
665 #define F_cmsg_len "%""hu"
666 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==3
667 #define F_cmsg_len "%""d"
668 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==4
669 #define F_cmsg_len "%""u"
670 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==5
671 #define F_cmsg_len "%""ld"
672 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==6
673 #define F_cmsg_len "%""lu"
674 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==7
675 #define F_cmsg_len "%""Ld"
676 # elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==8
677 #define F_cmsg_len "%""Lu"
678 # else
679 #error "HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN is out of range:" HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
680 # endif
681 #endif
683 /* Cygwin 1.3.22 has the prototypes, but not the type... */
684 #ifndef HAVE_TYPE_STAT64
685 # undef HAVE_STAT64
686 # undef HAVE_FSTAT64
687 # undef HAVE_LSTAT64
688 #endif
689 #ifndef HAVE_TYPE_OFF64
690 # undef HAVE_LSEEK64
691 # undef HAVE_FTRUNCATE64
692 #endif
694 #if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
695 # define NETDB_INTERNAL h_NETDB_INTERNAL
696 #endif
698 #ifndef INET_ADDRSTRLEN
699 # define INET_ADDRSTRLEN sizeof(struct sockaddr_in)
700 #endif
702 #if !HAVE_PROTOTYPE_HSTRERROR
703 /* with MacOSX this is char * */
704 extern const char *hstrerror(int);
705 #endif
707 #endif /* !defined(__compat_h_included) */