This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / reentr.h
1 /* -*- buffer-read-only: t -*-
2  *
3  *    reentr.h
4  *
5  *    Copyright (C) 2002, 2003, 2005 by Larry Wall and others
6  *
7  *    You may distribute under the terms of either the GNU General Public
8  *    License or the Artistic License, as specified in the README file.
9  *
10  *  !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
11  *  This file is built by reentr.pl from data in reentr.pl.
12  */
13
14 #ifndef REENTR_H
15 #define REENTR_H
16
17 #ifdef USE_REENTRANT_API
18
19 #ifdef PERL_CORE
20 #   define PL_REENTRANT_RETINT PL_reentrant_retint
21 #endif
22
23 /* Deprecations: some platforms have the said reentrant interfaces
24  * but they are declared obsolete and are not to be used.  Often this
25  * means that the platform has threadsafed the interfaces (hopefully).
26  * All this is OS version dependent, so we are of course fooling ourselves.
27  * If you know of more deprecations on some platforms, please add your own. */
28
29 #ifdef __hpux
30 #   undef HAS_CRYPT_R
31 #   undef HAS_DRAND48_R
32 #   undef HAS_ENDGRENT_R
33 #   undef HAS_ENDPWENT_R
34 #   undef HAS_GETGRENT_R
35 #   undef HAS_GETPWENT_R
36 #   undef HAS_SETLOCALE_R
37 #   undef HAS_SRAND48_R
38 #   undef HAS_STRERROR_R
39 #   define NETDB_R_OBSOLETE
40 #endif
41
42 #if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
43 #   undef HAS_CRYPT_R
44 #   undef HAS_STRERROR_R
45 #   define NETDB_R_OBSOLETE
46 #endif
47
48 #ifdef NETDB_R_OBSOLETE
49 #   undef HAS_ENDHOSTENT_R
50 #   undef HAS_ENDNETENT_R
51 #   undef HAS_ENDPROTOENT_R
52 #   undef HAS_ENDSERVENT_R
53 #   undef HAS_GETHOSTBYADDR_R
54 #   undef HAS_GETHOSTBYNAME_R
55 #   undef HAS_GETHOSTENT_R
56 #   undef HAS_GETNETBYADDR_R
57 #   undef HAS_GETNETBYNAME_R
58 #   undef HAS_GETNETENT_R
59 #   undef HAS_GETPROTOBYNAME_R
60 #   undef HAS_GETPROTOBYNUMBER_R
61 #   undef HAS_GETPROTOENT_R
62 #   undef HAS_GETSERVBYNAME_R
63 #   undef HAS_GETSERVBYPORT_R
64 #   undef HAS_GETSERVENT_R
65 #   undef HAS_SETHOSTENT_R
66 #   undef HAS_SETNETENT_R
67 #   undef HAS_SETPROTOENT_R
68 #   undef HAS_SETSERVENT_R
69 #endif
70
71 #ifdef I_PWD
72 #   include <pwd.h>
73 #endif
74 #ifdef I_GRP
75 #   include <grp.h>
76 #endif
77 #ifdef I_NETDB
78 #   include <netdb.h>
79 #endif
80 #ifdef I_STDLIB
81 #   include <stdlib.h>  /* drand48_data */
82 #endif
83 #ifdef I_CRYPT
84 #   ifdef I_CRYPT
85 #       include <crypt.h>
86 #   endif
87 #endif
88 #ifdef HAS_GETSPNAM_R
89 #   ifdef I_SHADOW
90 #       include <shadow.h>
91 #   endif
92 #endif
93
94 #define REENTRANT_PROTO_B_B     1
95 #define REENTRANT_PROTO_B_BI    2
96 #define REENTRANT_PROTO_B_BW    3
97 #define REENTRANT_PROTO_B_CCD   4
98 #define REENTRANT_PROTO_B_CCS   5
99 #define REENTRANT_PROTO_B_IBI   6
100 #define REENTRANT_PROTO_B_IBW   7
101 #define REENTRANT_PROTO_B_SB    8
102 #define REENTRANT_PROTO_B_SBI   9
103 #define REENTRANT_PROTO_I_BI    10
104 #define REENTRANT_PROTO_I_BW    11
105 #define REENTRANT_PROTO_I_CCSBWR        12
106 #define REENTRANT_PROTO_I_CCSD  13
107 #define REENTRANT_PROTO_I_CII   14
108 #define REENTRANT_PROTO_I_CIISD 15
109 #define REENTRANT_PROTO_I_CSBI  16
110 #define REENTRANT_PROTO_I_CSBIR 17
111 #define REENTRANT_PROTO_I_CSBWR 18
112 #define REENTRANT_PROTO_I_CSBWRE        19
113 #define REENTRANT_PROTO_I_CSD   20
114 #define REENTRANT_PROTO_I_CWISBWRE      21
115 #define REENTRANT_PROTO_I_CWISD 22
116 #define REENTRANT_PROTO_I_D     23
117 #define REENTRANT_PROTO_I_H     24
118 #define REENTRANT_PROTO_I_IBI   25
119 #define REENTRANT_PROTO_I_IBW   26
120 #define REENTRANT_PROTO_I_ICBI  27
121 #define REENTRANT_PROTO_I_ICSBWR        28
122 #define REENTRANT_PROTO_I_ICSD  29
123 #define REENTRANT_PROTO_I_ID    30
124 #define REENTRANT_PROTO_I_IISD  31
125 #define REENTRANT_PROTO_I_ISBWR 32
126 #define REENTRANT_PROTO_I_ISD   33
127 #define REENTRANT_PROTO_I_LISBI 34
128 #define REENTRANT_PROTO_I_LISD  35
129 #define REENTRANT_PROTO_I_LS    36
130 #define REENTRANT_PROTO_I_SB    37
131 #define REENTRANT_PROTO_I_SBI   38
132 #define REENTRANT_PROTO_I_SBIE  39
133 #define REENTRANT_PROTO_I_SBIH  40
134 #define REENTRANT_PROTO_I_SBIR  41
135 #define REENTRANT_PROTO_I_SBWR  42
136 #define REENTRANT_PROTO_I_SBWRE 43
137 #define REENTRANT_PROTO_I_SD    44
138 #define REENTRANT_PROTO_I_ST    45
139 #define REENTRANT_PROTO_I_St    46
140 #define REENTRANT_PROTO_I_TISD  47
141 #define REENTRANT_PROTO_I_TS    48
142 #define REENTRANT_PROTO_I_TSBI  49
143 #define REENTRANT_PROTO_I_TSBIR 50
144 #define REENTRANT_PROTO_I_TSBWR 51
145 #define REENTRANT_PROTO_I_TSR   52
146 #define REENTRANT_PROTO_I_TsISBWRE      53
147 #define REENTRANT_PROTO_I_UISBWRE       54
148 #define REENTRANT_PROTO_I_iS    55
149 #define REENTRANT_PROTO_I_lS    56
150 #define REENTRANT_PROTO_I_uISBWRE       57
151 #define REENTRANT_PROTO_S_CBI   58
152 #define REENTRANT_PROTO_S_CCSBI 59
153 #define REENTRANT_PROTO_S_CIISBIE       60
154 #define REENTRANT_PROTO_S_CSBI  61
155 #define REENTRANT_PROTO_S_CSBIE 62
156 #define REENTRANT_PROTO_S_CWISBIE       63
157 #define REENTRANT_PROTO_S_CWISBWIE      64
158 #define REENTRANT_PROTO_S_ICSBI 65
159 #define REENTRANT_PROTO_S_ISBI  66
160 #define REENTRANT_PROTO_S_LISBI 67
161 #define REENTRANT_PROTO_S_SBI   68
162 #define REENTRANT_PROTO_S_SBIE  69
163 #define REENTRANT_PROTO_S_SBW   70
164 #define REENTRANT_PROTO_S_TISBI 71
165 #define REENTRANT_PROTO_S_TS    72
166 #define REENTRANT_PROTO_S_TSBI  73
167 #define REENTRANT_PROTO_S_TSBIE 74
168 #define REENTRANT_PROTO_S_TWISBIE       75
169 #define REENTRANT_PROTO_V_D     76
170 #define REENTRANT_PROTO_V_H     77
171 #define REENTRANT_PROTO_V_ID    78
172
173 /* Defines for indicating which special features are supported. */
174
175 /* The getgrent getgrgid getgrnam using buffer? */
176
177 #if defined(HAS_GETGRENT_R) && (GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIR || GETGRENT_R_PROTO == REENTRANT_PROTO_S_SBW || GETGRENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIH)
178 #   define GETGRENT_R_HAS_BUFFER
179 #else
180 #   undef  GETGRENT_R_HAS_BUFFER
181 #endif
182 #if defined(HAS_GETGRGID_R) && (GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBWR || GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBIR || GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBI || GETGRGID_R_PROTO == REENTRANT_PROTO_S_TSBI)
183 #   define GETGRGID_R_HAS_BUFFER
184 #else
185 #   undef  GETGRGID_R_HAS_BUFFER
186 #endif
187 #if defined(HAS_GETGRNAM_R) && (GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR || GETGRNAM_R_PROTO == REENTRANT_PROTO_S_CBI || GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBI || GETGRNAM_R_PROTO == REENTRANT_PROTO_S_CSBI)
188 #   define GETGRNAM_R_HAS_BUFFER
189 #else
190 #   undef  GETGRNAM_R_HAS_BUFFER
191 #endif
192
193 /* Any of the getgrent getgrgid getgrnam using buffer? */
194
195 #if (defined(GETGRENT_R_HAS_BUFFER) || defined(GETGRGID_R_HAS_BUFFER) || defined(GETGRNAM_R_HAS_BUFFER))
196 #   define USE_GRENT_BUFFER
197 #else
198 #   undef  USE_GRENT_BUFFER
199 #endif
200
201 /* The getgrent getgrgid getgrnam using ptr? */
202
203 #if defined(HAS_GETGRENT_R) && (GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIR)
204 #   define GETGRENT_R_HAS_PTR
205 #else
206 #   undef  GETGRENT_R_HAS_PTR
207 #endif
208 #if defined(HAS_GETGRGID_R) && (GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBWR || GETGRGID_R_PROTO == REENTRANT_PROTO_I_TSBIR)
209 #   define GETGRGID_R_HAS_PTR
210 #else
211 #   undef  GETGRGID_R_HAS_PTR
212 #endif
213 #if defined(HAS_GETGRNAM_R) && (GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETGRNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR)
214 #   define GETGRNAM_R_HAS_PTR
215 #else
216 #   undef  GETGRNAM_R_HAS_PTR
217 #endif
218
219 /* Any of the getgrent getgrgid getgrnam using ptr? */
220
221 #if (defined(GETGRENT_R_HAS_PTR) || defined(GETGRGID_R_HAS_PTR) || defined(GETGRNAM_R_HAS_PTR))
222 #   define USE_GRENT_PTR
223 #else
224 #   undef  USE_GRENT_PTR
225 #endif
226
227 /* The getpwent getpwnam getpwuid using ptr? */
228
229 #if defined(HAS_GETPWENT_R) && (GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIR)
230 #   define GETPWENT_R_HAS_PTR
231 #else
232 #   undef  GETPWENT_R_HAS_PTR
233 #endif
234 #if defined(HAS_GETPWNAM_R) && (GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR)
235 #   define GETPWNAM_R_HAS_PTR
236 #else
237 #   undef  GETPWNAM_R_HAS_PTR
238 #endif
239 #if defined(HAS_GETPWUID_R) && (GETPWUID_R_PROTO == REENTRANT_PROTO_I_TSBWR || GETPWUID_R_PROTO == REENTRANT_PROTO_I_TSBIR)
240 #   define GETPWUID_R_HAS_PTR
241 #else
242 #   undef  GETPWUID_R_HAS_PTR
243 #endif
244
245 /* Any of the getpwent getpwnam getpwuid using ptr? */
246
247 #if (defined(GETPWENT_R_HAS_PTR) || defined(GETPWNAM_R_HAS_PTR) || defined(GETPWUID_R_HAS_PTR))
248 #   define USE_PWENT_PTR
249 #else
250 #   undef  USE_PWENT_PTR
251 #endif
252
253 /* The getspent getspnam using ptr? */
254
255 #if defined(HAS_GETSPNAM_R) && (GETSPNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR)
256 #   define GETSPNAM_R_HAS_PTR
257 #else
258 #   undef  GETSPNAM_R_HAS_PTR
259 #endif
260
261 /* Any of the getspent getspnam using ptr? */
262
263 #if (defined(GETSPENT_R_HAS_PTR) || defined(GETSPNAM_R_HAS_PTR))
264 #   define USE_SPENT_PTR
265 #else
266 #   undef  USE_SPENT_PTR
267 #endif
268
269 /* The getgrent getgrgid getgrnam setgrent endgrent using fptr? */
270
271 #if defined(HAS_GETGRENT_R) && (GETGRENT_R_PROTO == REENTRANT_PROTO_I_SBIH)
272 #   define GETGRENT_R_HAS_FPTR
273 #else
274 #   undef  GETGRENT_R_HAS_FPTR
275 #endif
276 #if defined(HAS_SETGRENT_R) && (SETGRENT_R_PROTO == REENTRANT_PROTO_I_H || SETGRENT_R_PROTO == REENTRANT_PROTO_V_H)
277 #   define SETGRENT_R_HAS_FPTR
278 #else
279 #   undef  SETGRENT_R_HAS_FPTR
280 #endif
281 #if defined(HAS_ENDGRENT_R) && (ENDGRENT_R_PROTO == REENTRANT_PROTO_I_H || ENDGRENT_R_PROTO == REENTRANT_PROTO_V_H)
282 #   define ENDGRENT_R_HAS_FPTR
283 #else
284 #   undef  ENDGRENT_R_HAS_FPTR
285 #endif
286
287 /* Any of the getgrent getgrgid getgrnam setgrent endgrent using fptr? */
288
289 #if (defined(GETGRENT_R_HAS_FPTR) || defined(GETGRGID_R_HAS_FPTR) || defined(GETGRNAM_R_HAS_FPTR) || defined(SETGRENT_R_HAS_FPTR) || defined(ENDGRENT_R_HAS_FPTR))
290 #   define USE_GRENT_FPTR
291 #else
292 #   undef  USE_GRENT_FPTR
293 #endif
294
295 /* The getpwent getpwnam getpwuid setpwent endpwent using fptr? */
296
297 #if defined(HAS_GETPWENT_R) && (GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIH)
298 #   define GETPWENT_R_HAS_FPTR
299 #else
300 #   undef  GETPWENT_R_HAS_FPTR
301 #endif
302 #if defined(HAS_SETPWENT_R) && (SETPWENT_R_PROTO == REENTRANT_PROTO_I_H || SETPWENT_R_PROTO == REENTRANT_PROTO_V_H)
303 #   define SETPWENT_R_HAS_FPTR
304 #else
305 #   undef  SETPWENT_R_HAS_FPTR
306 #endif
307 #if defined(HAS_ENDPWENT_R) && (ENDPWENT_R_PROTO == REENTRANT_PROTO_I_H || ENDPWENT_R_PROTO == REENTRANT_PROTO_V_H)
308 #   define ENDPWENT_R_HAS_FPTR
309 #else
310 #   undef  ENDPWENT_R_HAS_FPTR
311 #endif
312
313 /* Any of the getpwent getpwnam getpwuid setpwent endpwent using fptr? */
314
315 #if (defined(GETPWENT_R_HAS_FPTR) || defined(GETPWNAM_R_HAS_FPTR) || defined(GETPWUID_R_HAS_FPTR) || defined(SETPWENT_R_HAS_FPTR) || defined(ENDPWENT_R_HAS_FPTR))
316 #   define USE_PWENT_FPTR
317 #else
318 #   undef  USE_PWENT_FPTR
319 #endif
320
321 /* The getpwent getpwgid getpwnam using buffer? */
322
323 #if defined(HAS_GETPWENT_R) && (GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIR || GETPWENT_R_PROTO == REENTRANT_PROTO_S_SBW || GETPWENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETPWENT_R_PROTO == REENTRANT_PROTO_I_SBIH)
324 #   define GETPWENT_R_HAS_BUFFER
325 #else
326 #   undef  GETPWENT_R_HAS_BUFFER
327 #endif
328 #if defined(HAS_GETPWNAM_R) && (GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBIR || GETPWNAM_R_PROTO == REENTRANT_PROTO_S_CSBI || GETPWNAM_R_PROTO == REENTRANT_PROTO_I_CSBI)
329 #   define GETPWNAM_R_HAS_BUFFER
330 #else
331 #   undef  GETPWNAM_R_HAS_BUFFER
332 #endif
333
334 /* Any of the getpwent getpwgid getpwnam using buffer? */
335
336 #if (defined(GETPWENT_R_HAS_BUFFER) || defined(GETPWGID_R_HAS_BUFFER) || defined(GETPWNAM_R_HAS_BUFFER))
337 #   define USE_PWENT_BUFFER
338 #else
339 #   undef  USE_PWENT_BUFFER
340 #endif
341
342 /* The gethostent gethostbyaddr gethostbyname using ptr? */
343
344 #if defined(HAS_GETHOSTENT_R) && (GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE)
345 #   define GETHOSTENT_R_HAS_PTR
346 #else
347 #   undef  GETHOSTENT_R_HAS_PTR
348 #endif
349 #if defined(HAS_GETHOSTBYADDR_R) && (GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CWISBWRE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_TsISBWRE)
350 #   define GETHOSTBYADDR_R_HAS_PTR
351 #else
352 #   undef  GETHOSTBYADDR_R_HAS_PTR
353 #endif
354 #if defined(HAS_GETHOSTBYNAME_R) && (GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE)
355 #   define GETHOSTBYNAME_R_HAS_PTR
356 #else
357 #   undef  GETHOSTBYNAME_R_HAS_PTR
358 #endif
359
360 /* Any of the gethostent gethostbyaddr gethostbyname using ptr? */
361
362 #if (defined(GETHOSTENT_R_HAS_PTR) || defined(GETHOSTBYADDR_R_HAS_PTR) || defined(GETHOSTBYNAME_R_HAS_PTR))
363 #   define USE_HOSTENT_PTR
364 #else
365 #   undef  USE_HOSTENT_PTR
366 #endif
367
368 /* The getnetent getnetbyaddr getnetbyname using ptr? */
369
370 #if defined(HAS_GETNETENT_R) && (GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBWRE)
371 #   define GETNETENT_R_HAS_PTR
372 #else
373 #   undef  GETNETENT_R_HAS_PTR
374 #endif
375 #if defined(HAS_GETNETBYADDR_R) && (GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_UISBWRE || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_uISBWRE)
376 #   define GETNETBYADDR_R_HAS_PTR
377 #else
378 #   undef  GETNETBYADDR_R_HAS_PTR
379 #endif
380 #if defined(HAS_GETNETBYNAME_R) && (GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE)
381 #   define GETNETBYNAME_R_HAS_PTR
382 #else
383 #   undef  GETNETBYNAME_R_HAS_PTR
384 #endif
385
386 /* Any of the getnetent getnetbyaddr getnetbyname using ptr? */
387
388 #if (defined(GETNETENT_R_HAS_PTR) || defined(GETNETBYADDR_R_HAS_PTR) || defined(GETNETBYNAME_R_HAS_PTR))
389 #   define USE_NETENT_PTR
390 #else
391 #   undef  USE_NETENT_PTR
392 #endif
393
394 /* The getprotoent getprotobyname getprotobynumber using ptr? */
395
396 #if defined(HAS_GETPROTOENT_R) && (GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SBWR)
397 #   define GETPROTOENT_R_HAS_PTR
398 #else
399 #   undef  GETPROTOENT_R_HAS_PTR
400 #endif
401 #if defined(HAS_GETPROTOBYNAME_R) && (GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWR)
402 #   define GETPROTOBYNAME_R_HAS_PTR
403 #else
404 #   undef  GETPROTOBYNAME_R_HAS_PTR
405 #endif
406 #if defined(HAS_GETPROTOBYNUMBER_R) && (GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_I_ISBWR)
407 #   define GETPROTOBYNUMBER_R_HAS_PTR
408 #else
409 #   undef  GETPROTOBYNUMBER_R_HAS_PTR
410 #endif
411
412 /* Any of the getprotoent getprotobyname getprotobynumber using ptr? */
413
414 #if (defined(GETPROTOENT_R_HAS_PTR) || defined(GETPROTOBYNAME_R_HAS_PTR) || defined(GETPROTOBYNUMBER_R_HAS_PTR))
415 #   define USE_PROTOENT_PTR
416 #else
417 #   undef  USE_PROTOENT_PTR
418 #endif
419
420 /* The getservent getservbyname getservbyport using ptr? */
421
422 #if defined(HAS_GETSERVENT_R) && (GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SBWR)
423 #   define GETSERVENT_R_HAS_PTR
424 #else
425 #   undef  GETSERVENT_R_HAS_PTR
426 #endif
427 #if defined(HAS_GETSERVBYNAME_R) && (GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSBWR)
428 #   define GETSERVBYNAME_R_HAS_PTR
429 #else
430 #   undef  GETSERVBYNAME_R_HAS_PTR
431 #endif
432 #if defined(HAS_GETSERVBYPORT_R) && (GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_I_ICSBWR)
433 #   define GETSERVBYPORT_R_HAS_PTR
434 #else
435 #   undef  GETSERVBYPORT_R_HAS_PTR
436 #endif
437
438 /* Any of the getservent getservbyname getservbyport using ptr? */
439
440 #if (defined(GETSERVENT_R_HAS_PTR) || defined(GETSERVBYNAME_R_HAS_PTR) || defined(GETSERVBYPORT_R_HAS_PTR))
441 #   define USE_SERVENT_PTR
442 #else
443 #   undef  USE_SERVENT_PTR
444 #endif
445
446 /* The gethostent gethostbyaddr gethostbyname using buffer? */
447
448 #if defined(HAS_GETHOSTENT_R) && (GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBIE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBIE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBI)
449 #   define GETHOSTENT_R_HAS_BUFFER
450 #else
451 #   undef  GETHOSTENT_R_HAS_BUFFER
452 #endif
453 #if defined(HAS_GETHOSTBYADDR_R) && (GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CWISBWRE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBWIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TWISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CIISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CSBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TSBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_TsISBWRE)
454 #   define GETHOSTBYADDR_R_HAS_BUFFER
455 #else
456 #   undef  GETHOSTBYADDR_R_HAS_BUFFER
457 #endif
458 #if defined(HAS_GETHOSTBYNAME_R) && (GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE || GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBIE)
459 #   define GETHOSTBYNAME_R_HAS_BUFFER
460 #else
461 #   undef  GETHOSTBYNAME_R_HAS_BUFFER
462 #endif
463
464 /* Any of the gethostent gethostbyaddr gethostbyname using buffer? */
465
466 #if (defined(GETHOSTENT_R_HAS_BUFFER) || defined(GETHOSTBYADDR_R_HAS_BUFFER) || defined(GETHOSTBYNAME_R_HAS_BUFFER))
467 #   define USE_HOSTENT_BUFFER
468 #else
469 #   undef  USE_HOSTENT_BUFFER
470 #endif
471
472 /* The getnetent getnetbyaddr getnetbyname using buffer? */
473
474 #if defined(HAS_GETNETENT_R) && (GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBWRE || GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBIE || GETNETENT_R_PROTO == REENTRANT_PROTO_S_SBIE || GETNETENT_R_PROTO == REENTRANT_PROTO_S_SBI || GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBI)
475 #   define GETNETENT_R_HAS_BUFFER
476 #else
477 #   undef  GETNETENT_R_HAS_BUFFER
478 #endif
479 #if defined(HAS_GETNETBYADDR_R) && (GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_UISBWRE || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_LISBI || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_S_TISBI || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_S_LISBI || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_uISBWRE)
480 #   define GETNETBYADDR_R_HAS_BUFFER
481 #else
482 #   undef  GETNETBYADDR_R_HAS_BUFFER
483 #endif
484 #if defined(HAS_GETNETBYNAME_R) && (GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE || GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBI || GETNETBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBI)
485 #   define GETNETBYNAME_R_HAS_BUFFER
486 #else
487 #   undef  GETNETBYNAME_R_HAS_BUFFER
488 #endif
489
490 /* Any of the getnetent getnetbyaddr getnetbyname using buffer? */
491
492 #if (defined(GETNETENT_R_HAS_BUFFER) || defined(GETNETBYADDR_R_HAS_BUFFER) || defined(GETNETBYNAME_R_HAS_BUFFER))
493 #   define USE_NETENT_BUFFER
494 #else
495 #   undef  USE_NETENT_BUFFER
496 #endif
497
498 /* The getprotoent getprotobyname getprotobynumber using buffer? */
499
500 #if defined(HAS_GETPROTOENT_R) && (GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETPROTOENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETPROTOENT_R_PROTO == REENTRANT_PROTO_S_SBI)
501 #   define GETPROTOENT_R_HAS_BUFFER
502 #else
503 #   undef  GETPROTOENT_R_HAS_BUFFER
504 #endif
505 #if defined(HAS_GETPROTOBYNAME_R) && (GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWR || GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBI)
506 #   define GETPROTOBYNAME_R_HAS_BUFFER
507 #else
508 #   undef  GETPROTOBYNAME_R_HAS_BUFFER
509 #endif
510 #if defined(HAS_GETPROTOBYNUMBER_R) && (GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_I_ISBWR || GETPROTOBYNUMBER_R_PROTO == REENTRANT_PROTO_S_ISBI)
511 #   define GETPROTOBYNUMBER_R_HAS_BUFFER
512 #else
513 #   undef  GETPROTOBYNUMBER_R_HAS_BUFFER
514 #endif
515
516 /* Any of the getprotoent getprotobyname getprotobynumber using buffer? */
517
518 #if (defined(GETPROTOENT_R_HAS_BUFFER) || defined(GETPROTOBYNAME_R_HAS_BUFFER) || defined(GETPROTOBYNUMBER_R_HAS_BUFFER))
519 #   define USE_PROTOENT_BUFFER
520 #else
521 #   undef  USE_PROTOENT_BUFFER
522 #endif
523
524 /* The getservent getservbyname getservbyport using buffer? */
525
526 #if defined(HAS_GETSERVENT_R) && (GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SBWR || GETSERVENT_R_PROTO == REENTRANT_PROTO_I_SBI || GETSERVENT_R_PROTO == REENTRANT_PROTO_S_SBI)
527 #   define GETSERVENT_R_HAS_BUFFER
528 #else
529 #   undef  GETSERVENT_R_HAS_BUFFER
530 #endif
531 #if defined(HAS_GETSERVBYNAME_R) && (GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSBWR || GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_S_CCSBI)
532 #   define GETSERVBYNAME_R_HAS_BUFFER
533 #else
534 #   undef  GETSERVBYNAME_R_HAS_BUFFER
535 #endif
536 #if defined(HAS_GETSERVBYPORT_R) && (GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_I_ICSBWR || GETSERVBYPORT_R_PROTO == REENTRANT_PROTO_S_ICSBI)
537 #   define GETSERVBYPORT_R_HAS_BUFFER
538 #else
539 #   undef  GETSERVBYPORT_R_HAS_BUFFER
540 #endif
541
542 /* Any of the getservent getservbyname getservbyport using buffer? */
543
544 #if (defined(GETSERVENT_R_HAS_BUFFER) || defined(GETSERVBYNAME_R_HAS_BUFFER) || defined(GETSERVBYPORT_R_HAS_BUFFER))
545 #   define USE_SERVENT_BUFFER
546 #else
547 #   undef  USE_SERVENT_BUFFER
548 #endif
549
550 /* The gethostent gethostbyaddr gethostbyname using errno? */
551
552 #if defined(HAS_GETHOSTENT_R) && (GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBWRE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_I_SBIE || GETHOSTENT_R_PROTO == REENTRANT_PROTO_S_SBIE)
553 #   define GETHOSTENT_R_HAS_ERRNO
554 #else
555 #   undef  GETHOSTENT_R_HAS_ERRNO
556 #endif
557 #if defined(HAS_GETHOSTBYADDR_R) && (GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_CWISBWRE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBWIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CWISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TWISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CIISBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_CSBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_S_TSBIE || GETHOSTBYADDR_R_PROTO == REENTRANT_PROTO_I_TsISBWRE)
558 #   define GETHOSTBYADDR_R_HAS_ERRNO
559 #else
560 #   undef  GETHOSTBYADDR_R_HAS_ERRNO
561 #endif
562 #if defined(HAS_GETHOSTBYNAME_R) && (GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE || GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_S_CSBIE)
563 #   define GETHOSTBYNAME_R_HAS_ERRNO
564 #else
565 #   undef  GETHOSTBYNAME_R_HAS_ERRNO
566 #endif
567
568 /* Any of the gethostent gethostbyaddr gethostbyname using errno? */
569
570 #if (defined(GETHOSTENT_R_HAS_ERRNO) || defined(GETHOSTBYADDR_R_HAS_ERRNO) || defined(GETHOSTBYNAME_R_HAS_ERRNO))
571 #   define USE_HOSTENT_ERRNO
572 #else
573 #   undef  USE_HOSTENT_ERRNO
574 #endif
575
576 /* The getnetent getnetbyaddr getnetbyname using errno? */
577
578 #if defined(HAS_GETNETENT_R) && (GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBWRE || GETNETENT_R_PROTO == REENTRANT_PROTO_I_SBIE || GETNETENT_R_PROTO == REENTRANT_PROTO_S_SBIE)
579 #   define GETNETENT_R_HAS_ERRNO
580 #else
581 #   undef  GETNETENT_R_HAS_ERRNO
582 #endif
583 #if defined(HAS_GETNETBYADDR_R) && (GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_UISBWRE || GETNETBYADDR_R_PROTO == REENTRANT_PROTO_I_uISBWRE)
584 #   define GETNETBYADDR_R_HAS_ERRNO
585 #else
586 #   undef  GETNETBYADDR_R_HAS_ERRNO
587 #endif
588 #if defined(HAS_GETNETBYNAME_R) && (GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSBWRE)
589 #   define GETNETBYNAME_R_HAS_ERRNO
590 #else
591 #   undef  GETNETBYNAME_R_HAS_ERRNO
592 #endif
593
594 /* Any of the getnetent getnetbyaddr getnetbyname using errno? */
595
596 #if (defined(GETNETENT_R_HAS_ERRNO) || defined(GETNETBYADDR_R_HAS_ERRNO) || defined(GETNETBYNAME_R_HAS_ERRNO))
597 #   define USE_NETENT_ERRNO
598 #else
599 #   undef  USE_NETENT_ERRNO
600 #endif
601
602
603 typedef struct {
604 #ifdef HAS_ASCTIME_R
605         char*   _asctime_buffer;
606         size_t  _asctime_size;
607 #endif /* HAS_ASCTIME_R */
608 #ifdef HAS_CRYPT_R
609 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
610         CRYPTD* _crypt_data;
611 #else
612         struct crypt_data _crypt_struct;
613 #endif
614 #endif /* HAS_CRYPT_R */
615 #ifdef HAS_CTIME_R
616         char*   _ctime_buffer;
617         size_t  _ctime_size;
618 #endif /* HAS_CTIME_R */
619 #ifdef HAS_DRAND48_R
620         struct drand48_data _drand48_struct;
621         double  _drand48_double;
622 #endif /* HAS_DRAND48_R */
623 #ifdef HAS_GETGRNAM_R
624         struct group    _grent_struct;
625         char*   _grent_buffer;
626         size_t  _grent_size;
627 #   ifdef USE_GRENT_PTR
628         struct group*   _grent_ptr;
629 #   endif
630 #   ifdef USE_GRENT_FPTR
631         FILE*   _grent_fptr;
632 #   endif
633 #endif /* HAS_GETGRNAM_R */
634 #ifdef HAS_GETHOSTBYNAME_R
635         struct hostent  _hostent_struct;
636 #   if GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD
637         struct hostent_data     _hostent_data;
638 #   else
639         char*   _hostent_buffer;
640         size_t  _hostent_size;
641 #   endif
642 #   ifdef USE_HOSTENT_PTR
643         struct hostent* _hostent_ptr;
644 #   endif
645 #   ifdef USE_HOSTENT_ERRNO
646         int     _hostent_errno;
647 #   endif 
648 #endif /* HAS_GETHOSTBYNAME_R */
649 #ifdef HAS_GETLOGIN_R
650         char*   _getlogin_buffer;
651         size_t  _getlogin_size;
652 #endif /* HAS_GETLOGIN_R */
653 #ifdef HAS_GETNETBYNAME_R
654         struct netent   _netent_struct;
655 #   if GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD
656         struct netent_data      _netent_data;
657 #   else
658         char*   _netent_buffer;
659         size_t  _netent_size;
660 #   endif
661 #   ifdef USE_NETENT_PTR
662         struct netent*  _netent_ptr;
663 #   endif
664 #   ifdef USE_NETENT_ERRNO
665         int     _netent_errno;
666 #   endif 
667 #endif /* HAS_GETNETBYNAME_R */
668 #ifdef HAS_GETPROTOBYNAME_R
669         struct protoent _protoent_struct;
670 #   if GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD
671         struct protoent_data    _protoent_data;
672 #   else
673         char*   _protoent_buffer;
674         size_t  _protoent_size;
675 #   endif
676 #   ifdef USE_PROTOENT_PTR
677         struct protoent*        _protoent_ptr;
678 #   endif
679 #   ifdef USE_PROTOENT_ERRNO
680         int     _protoent_errno;
681 #   endif 
682 #endif /* HAS_GETPROTOBYNAME_R */
683 #ifdef HAS_GETPWNAM_R
684         struct passwd   _pwent_struct;
685         char*   _pwent_buffer;
686         size_t  _pwent_size;
687 #   ifdef USE_PWENT_PTR
688         struct passwd*  _pwent_ptr;
689 #   endif
690 #   ifdef USE_PWENT_FPTR
691         FILE*   _pwent_fptr;
692 #   endif
693 #endif /* HAS_GETPWNAM_R */
694 #ifdef HAS_GETSERVBYNAME_R
695         struct servent  _servent_struct;
696 #   if GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD
697         struct servent_data     _servent_data;
698 #   else
699         char*   _servent_buffer;
700         size_t  _servent_size;
701 #   endif
702 #   ifdef USE_SERVENT_PTR
703         struct servent* _servent_ptr;
704 #   endif
705 #   ifdef USE_SERVENT_ERRNO
706         int     _servent_errno;
707 #   endif 
708 #endif /* HAS_GETSERVBYNAME_R */
709 #ifdef HAS_GETSPNAM_R
710         struct spwd     _spent_struct;
711         char*   _spent_buffer;
712         size_t  _spent_size;
713 #   ifdef USE_SPENT_PTR
714         struct spwd*    _spent_ptr;
715 #   endif
716 #   ifdef USE_SPENT_FPTR
717         FILE*   _spent_fptr;
718 #   endif
719 #endif /* HAS_GETSPNAM_R */
720 #ifdef HAS_GMTIME_R
721         struct tm _gmtime_struct;
722 #endif /* HAS_GMTIME_R */
723 #ifdef HAS_LOCALTIME_R
724         struct tm _localtime_struct;
725 #endif /* HAS_LOCALTIME_R */
726 #ifdef HAS_RANDOM_R
727 #   if RANDOM_R_PROTO != REENTRANT_PROTO_I_St
728         struct random_data _random_struct;
729 #   endif
730 #endif /* HAS_RANDOM_R */
731 #ifdef HAS_READDIR_R
732         struct dirent*  _readdir_struct;
733         size_t  _readdir_size;
734 #   if READDIR_R_PROTO == REENTRANT_PROTO_I_TSR
735         struct dirent*  _readdir_ptr;
736 #   endif
737 #endif /* HAS_READDIR_R */
738 #ifdef HAS_READDIR64_R
739         struct dirent64*        _readdir64_struct;
740         size_t  _readdir64_size;
741 #   if READDIR64_R_PROTO == REENTRANT_PROTO_I_TSR
742         struct dirent64*        _readdir64_ptr;
743 #   endif
744 #endif /* HAS_READDIR64_R */
745 #ifdef HAS_SETLOCALE_R
746         char*   _setlocale_buffer;
747         size_t  _setlocale_size;
748 #endif /* HAS_SETLOCALE_R */
749 #ifdef HAS_STRERROR_R
750         char*   _strerror_buffer;
751         size_t  _strerror_size;
752 #endif /* HAS_STRERROR_R */
753 #ifdef HAS_TTYNAME_R
754         char*   _ttyname_buffer;
755         size_t  _ttyname_size;
756 #endif /* HAS_TTYNAME_R */
757 #ifdef HAS_CRYPT_R
758 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
759 #else
760         struct crypt_data *_crypt_struct_buffer;
761 #endif
762 #endif /* HAS_CRYPT_R */
763 #ifdef HAS_RANDOM_R
764 #   if RANDOM_R_PROTO == REENTRANT_PROTO_I_iS
765         int     _random_retval;
766 #   endif
767 #   if RANDOM_R_PROTO == REENTRANT_PROTO_I_lS
768         long    _random_retval;
769 #   endif
770 #   if RANDOM_R_PROTO == REENTRANT_PROTO_I_St
771         struct random_data _random_struct;
772         int32_t _random_retval;
773 #   endif
774 #endif /* HAS_RANDOM_R */
775 #ifdef HAS_SRANDOM_R
776         struct random_data _srandom_struct;
777 #endif /* HAS_SRANDOM_R */
778
779     int dummy; /* cannot have empty structs */
780 } REENTR;
781
782 #endif /* USE_REENTRANT_API */
783
784 #endif