You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

707 lines
18 KiB

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