File: compat.h

package info (click to toggle)
socat 2.0.0~beta9-1
  • links: PTS
  • area: main
  • in suites: experimental
  • size: 3,740 kB
  • sloc: ansic: 30,875; sh: 11,630; makefile: 149
file content (680 lines) | stat: -rw-r--r-- 17,342 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
/* source: compat.h */
/* Copyright Gerhard Rieger */
/* Published under the GNU General Public License V.2, see file COPYING */

#ifndef __compat_h_included
#define __compat_h_included 1

#if !HAVE_DECL_ENVIRON && HAVE_VAR_ENVIRON
extern char **environ;
#endif

/*****************************************************************************/
/* I dont like this system dependent part, but it would be quite a challenge
   for configure */

/* define if the following does not work:
   socket()
   connect() -> Connection refused
   connect() -> ok
   instead, it needs close() and socket() between the two connect() attmpts: */
#if __FreeBSD__ || __APPLE__ || _AIX || __hpux__ || __osf__
#  undef SOCKET_CAN_RECOVER
#else
#  define SOCKET_CAN_RECOVER 1
#endif

/* define if stat() says that pipes are sockets */
#if __APPLE__
#  define PIPE_STATES_SOCKET 1
#else
#  undef PIPE_STATES_SOCKET
#endif

/*****************************************************************************/

/* substitute some features that might be missing on some platforms */

#if !HAVE_TYPE_SIG_ATOMIC_T
typedef int sig_atomic_t;
#endif

#ifndef SHUT_RD
#  define SHUT_RD 0
#endif
#ifndef SHUT_WR
#  define SHUT_WR 1
#endif
#ifndef SHUT_RDWR
#  define SHUT_RDWR 2
#endif

#ifndef MIN
#  define MIN(x,y) ((x)<=(y)?(x):(y))
#endif

#ifndef MAX
#  define MAX(x,y) ((x)>=(y)?(x):(y))
#endif

/* O_ASYNC: Linux 2.2.10 */
#if !defined(O_ASYNC) && defined(FASYNC)
#  define O_ASYNC FASYNC
#endif

/* NGROUPS not defined on Solaris */
#if !defined(NGROUPS) && defined(NGROUPS_MAX)
#  define NGROUPS NGROUPS_MAX
#endif

/* UNIX_PATH_MAX: AIX 4.3.3 */
#ifndef UNIX_PATH_MAX
#  define UNIX_PATH_MAX 104	/*! why 104? Linux: 108 ! */
#endif


/* SOL_IP: AIX 4.3.3 */
#ifndef SOL_IP
#  define SOL_IP 0
#endif

/* SOL_TCP: AIX 4.3.3 */
#ifndef SOL_TCP
#  ifdef IPPROTO_TCP
#     define SOL_TCP IPPROTO_TCP
#  endif
#endif

/* POSIX.1 doesn't seem to know sockets */
#ifndef S_ISSOCK
#  define S_ISSOCK(fmode) 0
#endif

#if defined(IPPROTO_IPV6) && !defined(SOL_IPV6)
#  define SOL_IPV6 IPPROTO_IPV6
#endif

/* all unsigned */
#if !defined(HAVE_BASIC_SIZE_T) || !HAVE_BASIC_SIZE_T
#  undef HAVE_BASIC_SIZE_T
#  define HAVE_BASIC_SIZE_T 6
#endif
#if HAVE_BASIC_SIZE_T==2
#  define SIZET_MAX USHRT_MAX
#  define SSIZET_MIN SHRT_MIN
#  define SSIZET_MAX SHRT_MAX
#  define F_Zd "%hd"
#  define F_Zu "%hu"
#elif HAVE_BASIC_SIZE_T==4
#  define SIZET_MAX UINT_MAX
#  define SSIZET_MIN INT_MIN
#  define SSIZET_MAX INT_MAX
#  define F_Zd "%""d"
#  define F_Zu "%u"
#elif HAVE_BASIC_SIZE_T==6
#  define SIZET_MAX ULONG_MAX
#  define SSIZET_MIN LONG_MIN
#  define SSIZET_MAX LONG_MAX
#  define F_Zd "%ld"
#  define F_Zu "%lu"
#elif HAVE_BASIC_SIZE_T==8
#  define SIZET_MAX ULLONG_MAX
#  define SSIZET_MIN LLONG_MIN
#  define SSIZET_MAX LLONG_MAX
#  define F_Zd "%Ld"
#  define F_Zu "%Lu"
#else
#  error "HAVE_BASIC_SIZE_T is out of range:" HAVE_BASIC_SIZE_T
#endif
#if HAVE_FORMAT_Z
#  undef F_Zd
#  undef F_Zu
#  define F_Zd "%Zd"
#  define F_Zu "%Zu"
#endif


/* mode_t is always unsigned; default: unsigned int */
#if !defined(HAVE_BASIC_MODE_T) || !HAVE_BASIC_MODE_T
#  undef HAVE_BASIC_MODE_T
#  define HAVE_BASIC_MODE_T 4
#endif
#ifndef F_mode
#  if HAVE_BASIC_MODE_T==1 || HAVE_BASIC_MODE_T==2
#define F_mode "0%03ho"
#  elif HAVE_BASIC_MODE_T==3 || HAVE_BASIC_MODE_T==4
#define F_mode "0%03o"
#  elif HAVE_BASIC_MODE_T==5 || HAVE_BASIC_MODE_T==6
#define F_mode "0%03lo"
#  else
#error "HAVE_BASIC_MODE_T is out of range:" HAVE_BASIC_MODE_T
#  endif
#endif


/* default: unsigned int */
#if !defined(HAVE_BASIC_PID_T) || !HAVE_BASIC_PID_T
#  undef HAVE_BASIC_PID_T
#  define HAVE_BASIC_PID_T 4
#endif
#ifndef F_pid
#  if HAVE_BASIC_PID_T==1
#define F_pid "%hd"
#  elif HAVE_BASIC_PID_T==2
#define F_pid "%hu"
#  elif HAVE_BASIC_PID_T==3
#define F_pid "%""d"
#  elif HAVE_BASIC_PID_T==4
#define F_pid "%u"
#  elif HAVE_BASIC_PID_T==5
#define F_pid "%ld"
#  elif HAVE_BASIC_PID_T==6
#define F_pid "%lu"
#  else
#error "HAVE_BASIC_PID_T is out of range:" HAVE_BASIC_PID_T
#  endif
#endif


/* default: unsigned int */
#if !defined(HAVE_BASIC_UID_T) || !HAVE_BASIC_UID_T
#  undef HAVE_BASIC_UID_T
#  define HAVE_BASIC_UID_T 4
#endif
#ifndef F_uid
#  if HAVE_BASIC_UID_T==1
#define F_uid "%hd"
#  elif HAVE_BASIC_UID_T==2
#define F_uid "%hu"
#  elif HAVE_BASIC_UID_T==3
#define F_uid "%""d"
#  elif HAVE_BASIC_UID_T==4
#define F_uid "%u"
#  elif HAVE_BASIC_UID_T==5
#define F_uid "%ld"
#  elif HAVE_BASIC_UID_T==6
#define F_uid "%lu"
#  else
#error "HAVE_BASIC_UID_T is out of range:" HAVE_BASIC_UID_T
#  endif
#endif


/* default: unsigned int */
#if !defined(HAVE_BASIC_GID_T) || !HAVE_BASIC_GID_T
#  undef HAVE_BASIC_GID_T
#  define HAVE_BASIC_GID_T 4
#endif
#ifndef F_gid
#  if HAVE_BASIC_GID_T==1
#define F_gid "%hd"
#  elif HAVE_BASIC_GID_T==2
#define F_gid "%hu"
#  elif HAVE_BASIC_GID_T==3
#define F_gid "%""d"
#  elif HAVE_BASIC_GID_T==4
#define F_gid "%u"
#  elif HAVE_BASIC_GID_T==5
#define F_gid "%ld"
#  elif HAVE_BASIC_GID_T==6
#define F_gid "%lu"
#  else
#error "HAVE_BASIC_GID_T is out of range:" HAVE_BASIC_GID_T
#  endif
#endif


/* all signed; default: long */
#if !defined(HAVE_BASIC_TIME_T) || !HAVE_BASIC_TIME_T
#  undef HAVE_BASIC_TIME_T
#  define HAVE_BASIC_TIME_T 5
#endif
#ifndef F_time
#  if HAVE_BASIC_TIME_T==1
#define F_time "%hd"
#  elif HAVE_BASIC_TIME_T==2
#define F_time "%hu"
#  elif HAVE_BASIC_TIME_T==3
#define F_time "%""d"
#  elif HAVE_BASIC_TIME_T==4
#define F_time "%u"
#  elif HAVE_BASIC_TIME_T==5
#define F_time "%ld"
#  elif HAVE_BASIC_TIME_T==6
#define F_time "%lu"
#  elif HAVE_BASIC_TIME_T==7
#define F_time "%Ld"
#  elif HAVE_BASIC_TIME_T==8
#define F_time "%Lu"
#  else
#error "HAVE_BASIC_TIME_T is out of range:" HAVE_BASIC_TIME_T
#  endif
#endif


/* default: int */
#if !defined(HAVE_BASIC_SOCKLEN_T) || !HAVE_BASIC_SOCKLEN_T
#  undef HAVE_BASIC_SOCKLEN_T
#  define HAVE_BASIC_SOCKLEN_T 3
#endif
#ifndef F_socklen
#  if HAVE_BASIC_SOCKLEN_T==1
#define F_socklen "%hd"
#  elif HAVE_BASIC_SOCKLEN_T==2
#define F_socklen "%hu"
#  elif HAVE_BASIC_SOCKLEN_T==3
#define F_socklen "%""d"
#  elif HAVE_BASIC_SOCKLEN_T==4
#define F_socklen "%u"
#  elif HAVE_BASIC_SOCKLEN_T==5
#define F_socklen "%ld"
#  elif HAVE_BASIC_SOCKLEN_T==6
#define F_socklen "%lu"
#  elif HAVE_BASIC_SOCKLEN_T==7
#define F_socklen "%Ld"
#  elif HAVE_BASIC_SOCKLEN_T==8
#define F_socklen "%Lu"
#  else
#error "HAVE_BASIC_SOCKLEN_T is out of range:" HAVE_BASIC_SOCKLEN_T
#  endif
#endif

#if !defined(HAVE_BASIC_OFF_T) || !HAVE_BASIC_OFF_T
#  undef HAVE_BASIC_OFF_T
#  define HAVE_BASIC_OFF_T 5 /*long*/
#endif
#ifndef F_off
#  if HAVE_BASIC_OFF_T==3
#     define F_off "%""d"
#  elif HAVE_BASIC_OFF_T==5
#     define F_off "%ld"
#  elif HAVE_BASIC_OFF_T==7
#     define F_off "%Ld"
#  else
#error "HAVE_BASIC_OFF_T is out of range:" HAVE_BASIC_OFF_T
#  endif
#endif

/* default: long long */
#if !defined(HAVE_BASIC_OFF64_T) || !HAVE_BASIC_OFF64_T
#  undef HAVE_BASIC_OFF64_T
#  define HAVE_BASIC_OFF64_T 7
#endif
#ifndef F_off64
#  if HAVE_BASIC_OFF64_T==1
#define F_off64 "%hd"
#  elif HAVE_BASIC_OFF64_T==2
#define F_off64 "%hu"
#  elif HAVE_BASIC_OFF64_T==3
#define F_off64 "%""d"
#  elif HAVE_BASIC_OFF64_T==4
#define F_off64 "%u"
#  elif HAVE_BASIC_OFF64_T==5
#define F_off64 "%ld"
#  elif HAVE_BASIC_OFF64_T==6
#define F_off64 "%lu"
#  elif HAVE_BASIC_OFF64_T==7
#define F_off64 "%Ld"
#  elif HAVE_BASIC_OFF64_T==8
#define F_off64 "%Lu"
#  else
#error "HAVE_BASIC_OFF64_T is out of range:" HAVE_BASIC_OFF64_T
#  endif
#endif


/* all unsigned; default: unsigned long */
#if !defined(HAVE_BASIC_DEV_T) || !HAVE_BASIC_DEV_T
#  undef HAVE_BASIC_DEV_T
#  define HAVE_BASIC_DEV_T 6
#endif
#ifndef F_dev
#  if HAVE_BASIC_DEV_T==1
#define F_dev "%hd"
#  elif HAVE_BASIC_DEV_T==2
#define F_dev "%hu"
#  elif HAVE_BASIC_DEV_T==3
#define F_dev "%""d"
#  elif HAVE_BASIC_DEV_T==4
#define F_dev "%u"
#  elif HAVE_BASIC_DEV_T==5
#define F_dev "%ld"
#  elif HAVE_BASIC_DEV_T==6
#define F_dev "%lu"
#  elif HAVE_BASIC_DEV_T==7
#define F_dev "%Ld"
#  elif HAVE_BASIC_DEV_T==8
#define F_dev "%Lu"
#  else
#error "HAVE_BASIC_DEV_T is out of range:" HAVE_BASIC_DEV_T
#  endif
#endif

/* all unsigned; default; unsigned long */
#if !defined(HAVE_TYPEOF_ST_INO) || !HAVE_TYPEOF_ST_INO
#  undef HAVE_TYPEOF_ST_INO
#  define HAVE_TYPEOF_ST_INO 6
#endif
#ifndef F_st_ino
#  if HAVE_TYPEOF_ST_INO==1
#define F_st_ino "%hd"
#  elif HAVE_TYPEOF_ST_INO==2
#define F_st_ino "%hu"
#  elif HAVE_TYPEOF_ST_INO==3
#define F_st_ino "%""d"
#  elif HAVE_TYPEOF_ST_INO==4
#define F_st_ino "%u"
#  elif HAVE_TYPEOF_ST_INO==5
#define F_st_ino "%ld"
#  elif HAVE_TYPEOF_ST_INO==6
#define F_st_ino "%lu"
#  elif HAVE_TYPEOF_ST_INO==7	/* Cygwin 1.5 */
#define F_st_ino "%Ld"
#  elif HAVE_TYPEOF_ST_INO==8
#define F_st_ino "%Lu"
#  else
#error "HAVE_TYPEOF_ST_INO is out of range:" HAVE_TYPEOF_ST_INO
#  endif
#endif

/* all unsigned; default; unsigned long long */
#if !defined(HAVE_TYPEOF_ST64_INO) || !HAVE_TYPEOF_ST64_INO
#  undef HAVE_TYPEOF_ST64_INO
#  define HAVE_TYPEOF_ST64_INO 8
#endif
#ifndef F_st64_ino
#  if HAVE_TYPEOF_ST64_INO==1
#define F_st64_ino "%hd"
#  elif HAVE_TYPEOF_ST64_INO==2
#define F_st64_ino "%hu"
#  elif HAVE_TYPEOF_ST64_INO==3
#define F_st64_ino "%""d"
#  elif HAVE_TYPEOF_ST64_INO==4
#define F_st64_ino "%u"
#  elif HAVE_TYPEOF_ST64_INO==5
#define F_st64_ino "%ld"
#  elif HAVE_TYPEOF_ST64_INO==6
#define F_st64_ino "%lu"
#  elif HAVE_TYPEOF_ST64_INO==7
#define F_st64_ino "%Ld"
#  elif HAVE_TYPEOF_ST64_INO==8
#define F_st64_ino "%Lu"
#  else
#error "HAVE_TYPEOF_ST64_INO is out of range:" HAVE_TYPEOF_ST64_INO
#  endif
#endif

/* default: unsigned short */
#if !defined(HAVE_TYPEOF_ST_NLINK) || !HAVE_TYPEOF_ST_NLINK
#  undef HAVE_TYPEOF_ST_NLINK
#  define HAVE_TYPEOF_ST_NLINK 2
#endif
#ifndef F_st_nlink
#  if HAVE_TYPEOF_ST_NLINK==1
#define F_st_nlink "%hd"
#  elif HAVE_TYPEOF_ST_NLINK==2
#define F_st_nlink "%hu"
#  elif HAVE_TYPEOF_ST_NLINK==3
#define F_st_nlink "%""d"
#  elif HAVE_TYPEOF_ST_NLINK==4
#define F_st_nlink "%u"
#  elif HAVE_TYPEOF_ST_NLINK==5
#define F_st_nlink "%ld"
#  elif HAVE_TYPEOF_ST_NLINK==6
#define F_st_nlink "%lu"
#  elif HAVE_TYPEOF_ST_NLINK==7
#define F_st_nlink "%Ld"
#  elif HAVE_TYPEOF_ST_NLINK==8
#define F_st_nlink "%Lu"
#  else
#error "HAVE_TYPEOF_ST_NLINK is out of range:" HAVE_TYPEOF_ST_NLINK
#  endif
#endif

/* all signed; default: long */
#if !defined(HAVE_TYPEOF_ST_SIZE) || !HAVE_TYPEOF_ST_SIZE
#  undef HAVE_TYPEOF_ST_SIZE
#  define HAVE_TYPEOF_ST_SIZE 5
#endif
#ifndef F_st_size
#  if HAVE_TYPEOF_ST_SIZE==1
#define F_st_size "%hd"
#  elif HAVE_TYPEOF_ST_SIZE==2
#define F_st_size "%hu"
#  elif HAVE_TYPEOF_ST_SIZE==3
#define F_st_size "%""d"
#  elif HAVE_TYPEOF_ST_SIZE==4
#define F_st_size "%u"
#  elif HAVE_TYPEOF_ST_SIZE==5
#define F_st_size "%ld"
#  elif HAVE_TYPEOF_ST_SIZE==6
#define F_st_size "%lu"
#  elif HAVE_TYPEOF_ST_SIZE==7
#define F_st_size "%Ld"
#  elif HAVE_TYPEOF_ST_SIZE==8
#define F_st_size "%Lu"
#  else
#error "HAVE_TYPEOF_ST_SIZE is out of range:" HAVE_TYPEOF_ST_SIZE
#  endif
#endif

/* all signed; default: long long */
#if !defined(HAVE_TYPEOF_ST64_SIZE) || !HAVE_TYPEOF_ST64_SIZE
#  undef HAVE_TYPEOF_ST64_SIZE
#  define HAVE_TYPEOF_ST64_SIZE 7
#endif
#ifndef F_st64_size
#  if HAVE_TYPEOF_ST64_SIZE==1
#define F_st64_size "%hd"
#  elif HAVE_TYPEOF_ST64_SIZE==2
#define F_st64_size "%hu"
#  elif HAVE_TYPEOF_ST64_SIZE==3
#define F_st64_size "%""d"
#  elif HAVE_TYPEOF_ST64_SIZE==4
#define F_st64_size "%u"
#  elif HAVE_TYPEOF_ST64_SIZE==5
#define F_st64_size "%ld"
#  elif HAVE_TYPEOF_ST64_SIZE==6
#define F_st64_size "%lu"
#  elif HAVE_TYPEOF_ST64_SIZE==7
#define F_st64_size "%Ld"
#  elif HAVE_TYPEOF_ST64_SIZE==8
#define F_st64_size "%Lu"
#  else
#error "HAVE_TYPEOF_ST64_SIZE is out of range:" HAVE_TYPEOF_ST64_SIZE
#  endif
#endif

/* very different results; default: long */
#if !defined(HAVE_TYPEOF_ST_BLKSIZE) || !HAVE_TYPEOF_ST_BLKSIZE
#  undef HAVE_TYPEOF_ST_BLKSIZE
#  define HAVE_TYPEOF_ST_BLKSIZE 5
#endif
#ifndef F_st_blksize
#  if HAVE_TYPEOF_ST_BLKSIZE==1
#define F_st_blksize "%hd"
#  elif HAVE_TYPEOF_ST_BLKSIZE==2
#define F_st_blksize "%hu"
#  elif HAVE_TYPEOF_ST_BLKSIZE==3
#define F_st_blksize "%""d"
#  elif HAVE_TYPEOF_ST_BLKSIZE==4
#define F_st_blksize "%u"
#  elif HAVE_TYPEOF_ST_BLKSIZE==5
#define F_st_blksize "%ld"
#  elif HAVE_TYPEOF_ST_BLKSIZE==6
#define F_st_blksize "%lu"
#  elif HAVE_TYPEOF_ST_BLKSIZE==7
#define F_st_blksize "%Ld"
#  elif HAVE_TYPEOF_ST_BLKSIZE==8
#define F_st_blksize "%Lu"
#  else
#error "HAVE_TYPEOF_ST_BLKSIZE is out of range:" HAVE_TYPEOF_ST_BLKSIZE
#  endif
#endif

/* default: long */
#if !defined(HAVE_TYPEOF_ST_BLOCKS) || !HAVE_TYPEOF_ST_BLOCKS
#  undef HAVE_TYPEOF_ST_BLOCKS
#  define HAVE_TYPEOF_ST_BLOCKS 5
#endif
#ifndef F_st_blocks
#  if HAVE_TYPEOF_ST_BLOCKS==1
#define F_st_blocks "%hd"
#  elif HAVE_TYPEOF_ST_BLOCKS==2
#define F_st_blocks "%hu"
#  elif HAVE_TYPEOF_ST_BLOCKS==3
#define F_st_blocks "%""d"
#  elif HAVE_TYPEOF_ST_BLOCKS==4
#define F_st_blocks "%u"
#  elif HAVE_TYPEOF_ST_BLOCKS==5
#define F_st_blocks "%ld"
#  elif HAVE_TYPEOF_ST_BLOCKS==6
#define F_st_blocks "%lu"
#  elif HAVE_TYPEOF_ST_BLOCKS==7
#define F_st_blocks "%Ld"
#  elif HAVE_TYPEOF_ST_BLOCKS==8
#define F_st_blocks "%Lu"
#  else
#error "HAVE_TYPEOF_ST_BLOCKS is out of range:" HAVE_TYPEOF_ST_BLOCKS
#  endif
#endif

/* default: long long */
#if !defined(HAVE_TYPEOF_ST64_BLOCKS) || !HAVE_TYPEOF_ST64_BLOCKS
#  undef HAVE_TYPEOF_ST64_BLOCKS
#  define HAVE_TYPEOF_ST64_BLOCKS 7
#endif
#ifndef F_st64_blocks
#  if HAVE_TYPEOF_ST64_BLOCKS==1
#define F_st64_blocks "%hd"
#  elif HAVE_TYPEOF_ST64_BLOCKS==2
#define F_st64_blocks "%hu"
#  elif HAVE_TYPEOF_ST64_BLOCKS==3
#define F_st64_blocks "%""d"
#  elif HAVE_TYPEOF_ST64_BLOCKS==4
#define F_st64_blocks "%u"
#  elif HAVE_TYPEOF_ST64_BLOCKS==5
#define F_st64_blocks "%ld"
#  elif HAVE_TYPEOF_ST64_BLOCKS==6
#define F_st64_blocks "%lu"
#  elif HAVE_TYPEOF_ST64_BLOCKS==7
#define F_st64_blocks "%Ld"
#  elif HAVE_TYPEOF_ST64_BLOCKS==8
#define F_st64_blocks "%Lu"
#  else
#error "HAVE_TYPEOF_ST64_BLOCKS is out of range:" HAVE_TYPEOF_ST64_BLOCKS
#  endif
#endif


/* at least for Linux */
#define F_tv_sec "%ld"

/* default: long */
#if !defined(HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC) || !HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
#  undef HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
#  define HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC 5
#endif
#ifndef F_tv_usec
#  if HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==1
#define F_tv_usec "%06hd"
#  elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==2
#define F_tv_usec "%06hu"
#  elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==3
#define F_tv_usec "%06d"
#  elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==4
#define F_tv_usec "%06u"
#  elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==5
#define F_tv_usec "%06ld"
#  elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==6
#define F_tv_usec "%06lu"
#  elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==7
#define F_tv_usec "%06Ld"
#  elif HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC==8
#define F_tv_usec "%06Lu"
#  else
#error "HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC is out of range:" HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC
#  endif
#endif

/* default: long */
#if !defined(HAVE_TYPEOF_RLIM_MAX) || !HAVE_TYPEOF_RLIM_MAX
#  undef HAVE_TYPEOF_RLIM_MAX
#  define HAVE_TYPEOF_RLIM_MAX 5
#endif
#ifndef F_rlim_max
#  if HAVE_TYPEOF_RLIM_MAX==1
#define F_rlim_max "hd"
#  elif HAVE_TYPEOF_RLIM_MAX==2
#define F_rlim_max "hu"
#  elif HAVE_TYPEOF_RLIM_MAX==3
#define F_rlim_max "d"
#  elif HAVE_TYPEOF_RLIM_MAX==4
#define F_rlim_max "u"
#  elif HAVE_TYPEOF_RLIM_MAX==5
#define F_rlim_max "ld"
#  elif HAVE_TYPEOF_RLIM_MAX==6
#define F_rlim_max "lu"
#  elif HAVE_TYPEOF_RLIM_MAX==7
#define F_rlim_max "Ld"
#  elif HAVE_TYPEOF_RLIM_MAX==8
#define F_rlim_max "Lu"
#  else
#error "HAVE_TYPEOF_RLIM_MAX is out of range:" HAVE_TYPEOF_RLIM_MAX
#  endif
#endif

/* default: socklen_t */
#if !defined(HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN) || !HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
#  undef HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
#  define HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN HAVE_BASIC_SOCKLEN_T
#endif
#ifndef F_cmsg_len
#  if HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==1
#define F_cmsg_len "%""hd"
#  elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==2
#define F_cmsg_len "%""hu"
#  elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==3
#define F_cmsg_len "%""d"
#  elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==4
#define F_cmsg_len "%""u"
#  elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==5
#define F_cmsg_len "%""ld"
#  elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==6
#define F_cmsg_len "%""lu"
#  elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==7
#define F_cmsg_len "%""Ld"
#  elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==8
#define F_cmsg_len "%""Lu"
#  else
#error "HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN is out of range:" HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
#  endif
#endif

#define F_thread "%lu"

/* Cygwin 1.3.22 has the prototypes, but not the type... */
#ifndef HAVE_TYPE_STAT64
#  undef HAVE_STAT64
#  undef HAVE_FSTAT64
#  undef HAVE_LSTAT64
#endif
#ifndef HAVE_TYPE_OFF64
#  undef HAVE_LSEEK64
#  undef HAVE_FTRUNCATE64
#endif

#if !defined(NETDB_INTERNAL) && defined(h_NETDB_INTERNAL)
#  define NETDB_INTERNAL h_NETDB_INTERNAL
#endif

#ifndef INET_ADDRSTRLEN
#  define INET_ADDRSTRLEN sizeof(struct sockaddr_in)
#endif

#if !HAVE_PROTOTYPE_HSTRERROR
/* with MacOSX this is  char *  */
extern const char *hstrerror(int);
#endif

#endif /* !defined(__compat_h_included) */