add checks for strtok_r and getprotobyname_r
[platform/upstream/curl.git] / ares / reentrant.m4
1
2
3 dnl CHECK_NEED_REENTRANT_STRERROR_R
4 dnl -------------------------------------------------
5 dnl Checks if the preprocessor _REENTRANT definition
6 dnl makes function strerror_r compiler visible.
7
8 AC_DEFUN([CHECK_NEED_REENTRANT_STRERROR_R], [
9   #
10   AC_MSG_NOTICE([DEBUG:])
11   AC_MSG_NOTICE([DEBUG:])
12   AC_LINK_IFELSE([
13     AC_LANG_FUNC_LINK_TRY([strerror_r])
14   ],[
15     AC_MSG_NOTICE([DEBUG: strerror_r links... yes])
16     tmp_strerror_r="yes"
17   ],[
18     AC_MSG_NOTICE([DEBUG: strerror_r links... no])
19     tmp_strerror_r="no"
20   ])
21   #
22   if test "$tmp_strerror_r" = "yes"; then
23     AC_EGREP_CPP([strerror_r],[
24 #include <sys/types.h>
25 #include <string.h>
26     ],[
27       AC_MSG_NOTICE([DEBUG: strerror_r proto... without our definition])
28       tmp_strerror_r="proto_wout_def"
29     ],[
30       AC_EGREP_CPP([strerror_r],[
31 #define _REENTRANT
32 #include <sys/types.h>
33 #include <string.h>
34       ],[
35         AC_MSG_NOTICE([DEBUG: strerror_r proto... with our _reentrant])
36         tmp_strerror_r="proto_with_def"
37       ],[
38         AC_MSG_NOTICE([DEBUG: strerror_r proto... not found])
39       ])
40     ])
41   fi
42   #
43   if test "$tmp_strerror_r" = "proto_wout_def"; then
44     AC_COMPILE_IFELSE([
45       AC_LANG_PROGRAM([[
46 #include <sys/types.h>
47 #include <string.h>
48       ]],[[
49         strerror_r(0, 0, 0);
50       ]])
51     ],[
52       AC_MSG_NOTICE([DEBUG: strerror_r proto wout finds... 3 args])
53       tmp_strerror_r="done"
54     ])
55   fi
56   #
57   if test "$tmp_strerror_r" = "proto_with_def"; then
58     AC_COMPILE_IFELSE([
59       AC_LANG_PROGRAM([[
60 #define _REENTRANT
61 #include <sys/types.h>
62 #include <string.h>
63       ]],[[
64         strerror_r(0, 0, 0);
65       ]])
66     ],[
67       AC_MSG_NOTICE([DEBUG: strerror_r proto with finds... 3 args])
68       tmp_strerror_r="needs_reentrant"
69     ])
70   fi
71   #
72   if test "$tmp_strerror_r" = "needs_reentrant"; then
73     ac_cv_need_reentrant="yes"
74   fi
75 ])
76
77
78 dnl CHECK_NEED_REENTRANT_STRTOK_R
79 dnl -------------------------------------------------
80 dnl Checks if the preprocessor _REENTRANT definition
81 dnl makes function strtok_r compiler visible.
82
83 AC_DEFUN([CHECK_NEED_REENTRANT_STRTOK_R], [
84   #
85   AC_MSG_NOTICE([DEBUG:])
86   AC_MSG_NOTICE([DEBUG:])
87   AC_LINK_IFELSE([
88     AC_LANG_FUNC_LINK_TRY([strtok_r])
89   ],[
90     AC_MSG_NOTICE([DEBUG: strtok_r links... yes])
91     tmp_strtok_r="yes"
92   ],[
93     AC_MSG_NOTICE([DEBUG: strtok_r links... no])
94     tmp_strtok_r="no"
95   ])
96   #
97   if test "$tmp_strtok_r" = "yes"; then
98     AC_EGREP_CPP([strtok_r],[
99 #include <sys/types.h>
100 #include <string.h>
101     ],[
102       AC_MSG_NOTICE([DEBUG: strtok_r proto... without our definition])
103       tmp_strtok_r="proto_wout_def"
104     ],[
105       AC_EGREP_CPP([strtok_r],[
106 #define _REENTRANT
107 #include <sys/types.h>
108 #include <string.h>
109       ],[
110         AC_MSG_NOTICE([DEBUG: strtok_r proto... with our _reentrant])
111         tmp_strtok_r="proto_with_def"
112       ],[
113         AC_MSG_NOTICE([DEBUG: strtok_r proto... not found])
114       ])
115     ])
116   fi
117   #
118   if test "$tmp_strtok_r" = "proto_wout_def"; then
119     AC_COMPILE_IFELSE([
120       AC_LANG_PROGRAM([[
121 #include <sys/types.h>
122 #include <string.h>
123       ]],[[
124         strtok_r(0, 0, 0);
125       ]])
126     ],[
127       AC_MSG_NOTICE([DEBUG: strtok_r proto wout finds... 3 args])
128       tmp_strtok_r="done"
129     ])
130   fi
131   #
132   if test "$tmp_strtok_r" = "proto_with_def"; then
133     AC_COMPILE_IFELSE([
134       AC_LANG_PROGRAM([[
135 #define _REENTRANT
136 #include <sys/types.h>
137 #include <string.h>
138       ]],[[
139         strtok_r(0, 0, 0);
140       ]])
141     ],[
142       AC_MSG_NOTICE([DEBUG: strtok_r proto with finds... 3 args])
143       tmp_strtok_r="needs_reentrant"
144     ])
145   fi
146   #
147   if test "$tmp_strtok_r" = "needs_reentrant"; then
148     ac_cv_need_reentrant="yes"
149   fi
150 ])
151
152
153 dnl CHECK_NEED_REENTRANT_LOCALTIME_R
154 dnl -------------------------------------------------
155 dnl Checks if the preprocessor _REENTRANT definition
156 dnl makes function localtime_r compiler visible.
157
158 AC_DEFUN([CHECK_NEED_REENTRANT_LOCALTIME_R], [
159   #
160   AC_MSG_NOTICE([DEBUG:])
161   AC_LINK_IFELSE([
162     AC_LANG_FUNC_LINK_TRY([localtime_r])
163   ],[
164     AC_MSG_NOTICE([DEBUG: localtime_r links... yes])
165     tmp_localtime_r="yes"
166   ],[
167     AC_MSG_NOTICE([DEBUG: localtime_r links... no])
168     tmp_localtime_r="no"
169   ])
170   #
171   if test "$tmp_localtime_r" = "yes"; then
172     AC_EGREP_CPP([localtime_r],[
173 #include <sys/types.h>
174 #include <time.h>
175     ],[
176       AC_MSG_NOTICE([DEBUG: localtime_r proto... without our definition])
177       tmp_localtime_r="proto_wout_def"
178     ],[
179       AC_EGREP_CPP([localtime_r],[
180 #define _REENTRANT
181 #include <sys/types.h>
182 #include <time.h>
183       ],[
184         AC_MSG_NOTICE([DEBUG: localtime_r proto... with our _reentrant])
185         tmp_localtime_r="proto_with_def"
186       ],[
187         AC_MSG_NOTICE([DEBUG: localtime_r proto... not found])
188       ])
189     ])
190   fi
191   #
192   if test "$tmp_localtime_r" = "proto_wout_def"; then
193     AC_COMPILE_IFELSE([
194       AC_LANG_PROGRAM([[
195 #include <sys/types.h>
196 #include <time.h>
197       ]],[[
198         localtime_r(0, 0);
199       ]])
200     ],[
201       AC_MSG_NOTICE([DEBUG: localtime_r proto wout finds... 2 args])
202       tmp_localtime_r="done"
203     ])
204   fi
205   #
206   if test "$tmp_localtime_r" = "proto_with_def"; then
207     AC_COMPILE_IFELSE([
208       AC_LANG_PROGRAM([[
209 #define _REENTRANT
210 #include <sys/types.h>
211 #include <time.h>
212       ]],[[
213         localtime_r(0, 0);
214       ]])
215     ],[
216       AC_MSG_NOTICE([DEBUG: localtime_r proto with finds... 2 args])
217       tmp_localtime_r="needs_reentrant"
218     ])
219   fi
220   #
221   if test "$tmp_localtime_r" = "needs_reentrant"; then
222     ac_cv_need_reentrant="yes"
223   fi
224 ])
225
226
227 dnl CHECK_NEED_REENTRANT_GMTIME_R
228 dnl -------------------------------------------------
229 dnl Checks if the preprocessor _REENTRANT definition
230 dnl makes function gmtime_r compiler visible.
231
232 AC_DEFUN([CHECK_NEED_REENTRANT_GMTIME_R], [
233   #
234   AC_MSG_NOTICE([DEBUG:])
235   AC_LINK_IFELSE([
236     AC_LANG_FUNC_LINK_TRY([gmtime_r])
237   ],[
238     AC_MSG_NOTICE([DEBUG: gmtime_r links... yes])
239     tmp_gmtime_r="yes"
240   ],[
241     AC_MSG_NOTICE([DEBUG: gmtime_r links... no])
242     tmp_gmtime_r="no"
243   ])
244   #
245   if test "$tmp_gmtime_r" = "yes"; then
246     AC_EGREP_CPP([gmtime_r],[
247 #include <sys/types.h>
248 #include <time.h>
249     ],[
250       AC_MSG_NOTICE([DEBUG: gmtime_r proto... without our definition])
251       tmp_gmtime_r="proto_wout_def"
252     ],[
253       AC_EGREP_CPP([gmtime_r],[
254 #define _REENTRANT
255 #include <sys/types.h>
256 #include <time.h>
257       ],[
258         AC_MSG_NOTICE([DEBUG: gmtime_r proto... with our _reentrant])
259         tmp_gmtime_r="proto_with_def"
260       ],[
261         AC_MSG_NOTICE([DEBUG: gmtime_r proto... not found])
262       ])
263     ])
264   fi
265   #
266   if test "$tmp_gmtime_r" = "proto_wout_def"; then
267     AC_COMPILE_IFELSE([
268       AC_LANG_PROGRAM([[
269 #include <sys/types.h>
270 #include <time.h>
271       ]],[[
272         gmtime_r(0, 0);
273       ]])
274     ],[
275       AC_MSG_NOTICE([DEBUG: gmtime_r proto wout finds... 2 args])
276       tmp_gmtime_r="done"
277     ])
278   fi
279   #
280   if test "$tmp_gmtime_r" = "proto_with_def"; then
281     AC_COMPILE_IFELSE([
282       AC_LANG_PROGRAM([[
283 #define _REENTRANT
284 #include <sys/types.h>
285 #include <time.h>
286       ]],[[
287         gmtime_r(0, 0);
288       ]])
289     ],[
290       AC_MSG_NOTICE([DEBUG: gmtime_r proto with finds... 2 args])
291       tmp_gmtime_r="needs_reentrant"
292     ])
293   fi
294   #
295   if test "$tmp_gmtime_r" = "needs_reentrant"; then
296     ac_cv_need_reentrant="yes"
297   fi
298 ])
299
300
301 dnl CHECK_NEED_REENTRANT_INET_NTOA_R
302 dnl -------------------------------------------------
303 dnl Checks if the preprocessor _REENTRANT definition
304 dnl makes function inet_ntoa_r compiler visible.
305
306 AC_DEFUN([CHECK_NEED_REENTRANT_INET_NTOA_R], [
307   #
308   AC_MSG_NOTICE([DEBUG:])
309   AC_LINK_IFELSE([
310     AC_LANG_FUNC_LINK_TRY([inet_ntoa_r])
311   ],[
312     AC_MSG_NOTICE([DEBUG: inet_ntoa_r links... yes])
313     tmp_inet_ntoa_r="yes"
314   ],[
315     AC_MSG_NOTICE([DEBUG: inet_ntoa_r links... no])
316     tmp_inet_ntoa_r="no"
317   ])
318   #
319   if test "$tmp_inet_ntoa_r" = "yes"; then
320     AC_EGREP_CPP([inet_ntoa_r],[
321 #include <sys/types.h>
322 #include <sys/socket.h>
323 #include <netinet/in.h>
324 #include <arpa/inet.h>
325     ],[
326       AC_MSG_NOTICE([DEBUG: inet_ntoa_r proto... without our definition])
327       tmp_inet_ntoa_r="proto_wout_def"
328     ],[
329       AC_EGREP_CPP([inet_ntoa_r],[
330 #define _REENTRANT
331 #include <sys/types.h>
332 #include <sys/socket.h>
333 #include <netinet/in.h>
334 #include <arpa/inet.h>
335       ],[
336         AC_MSG_NOTICE([DEBUG: inet_ntoa_r proto... with our _reentrant])
337         tmp_inet_ntoa_r="proto_with_def"
338       ],[
339         AC_MSG_NOTICE([DEBUG: inet_ntoa_r proto... not found])
340       ])
341     ])
342   fi
343   #
344   if test "$tmp_inet_ntoa_r" = "proto_wout_def"; then
345     AC_COMPILE_IFELSE([
346       AC_LANG_PROGRAM([[
347 #include <sys/types.h>
348 #include <sys/socket.h>
349 #include <netinet/in.h>
350 #include <arpa/inet.h>
351       ]],[[
352         struct in_addr addr;
353         inet_ntoa_r(addr, 0);
354       ]])
355     ],[
356       AC_MSG_NOTICE([DEBUG: inet_ntoa_r proto wout finds... 2 args])
357       tmp_inet_ntoa_r="done"
358     ])
359   fi
360   if test "$tmp_inet_ntoa_r" = "proto_wout_def"; then
361     AC_COMPILE_IFELSE([
362       AC_LANG_PROGRAM([[
363 #include <sys/types.h>
364 #include <sys/socket.h>
365 #include <netinet/in.h>
366 #include <arpa/inet.h>
367       ]],[[
368         struct in_addr addr;
369         inet_ntoa_r(addr, 0, 0);
370       ]])
371     ],[
372       AC_MSG_NOTICE([DEBUG: inet_ntoa_r proto wout finds... 3 args])
373       tmp_inet_ntoa_r="done"
374     ])
375   fi
376   #
377   if test "$tmp_inet_ntoa_r" = "proto_with_def"; then
378     AC_COMPILE_IFELSE([
379       AC_LANG_PROGRAM([[
380 #define _REENTRANT
381 #include <sys/types.h>
382 #include <sys/socket.h>
383 #include <netinet/in.h>
384 #include <arpa/inet.h>
385       ]],[[
386         struct in_addr addr;
387         inet_ntoa_r(addr, 0);
388       ]])
389     ],[
390       AC_MSG_NOTICE([DEBUG: inet_ntoa_r proto with finds... 2 args])
391       tmp_inet_ntoa_r="needs_reentrant"
392     ])
393   fi
394   if test "$tmp_inet_ntoa_r" = "proto_with_def"; then
395     AC_COMPILE_IFELSE([
396       AC_LANG_PROGRAM([[
397 #define _REENTRANT
398 #include <sys/types.h>
399 #include <sys/socket.h>
400 #include <netinet/in.h>
401 #include <arpa/inet.h>
402       ]],[[
403         struct in_addr addr;
404         inet_ntoa_r(addr, 0, 0);
405       ]])
406     ],[
407       AC_MSG_NOTICE([DEBUG: inet_ntoa_r proto with finds... 3 args])
408       tmp_inet_ntoa_r="needs_reentrant"
409     ])
410   fi
411   #
412   if test "$tmp_inet_ntoa_r" = "needs_reentrant"; then
413     ac_cv_need_reentrant="yes"
414   fi
415 ])
416
417
418 dnl CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
419 dnl -------------------------------------------------
420 dnl Checks if the preprocessor _REENTRANT definition
421 dnl makes function gethostbyaddr_r compiler visible.
422
423 AC_DEFUN([CHECK_NEED_REENTRANT_GETHOSTBYADDR_R], [
424   #
425   AC_MSG_NOTICE([DEBUG:])
426   AC_LINK_IFELSE([
427     AC_LANG_FUNC_LINK_TRY([gethostbyaddr_r])
428   ],[
429     AC_MSG_NOTICE([DEBUG: gethostbyaddr_r links... yes])
430     tmp_gethostbyaddr_r="yes"
431   ],[
432     AC_MSG_NOTICE([DEBUG: gethostbyaddr_r links... no])
433     tmp_gethostbyaddr_r="no"
434   ])
435   #
436   if test "$tmp_gethostbyaddr_r" = "yes"; then
437     AC_EGREP_CPP([gethostbyaddr_r],[
438 #include <sys/types.h>
439 #include <netdb.h>
440     ],[
441       AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto... without our definition])
442       tmp_gethostbyaddr_r="proto_wout_def"
443     ],[
444       AC_EGREP_CPP([gethostbyaddr_r],[
445 #define _REENTRANT
446 #include <sys/types.h>
447 #include <netdb.h>
448       ],[
449         AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto... with our _reentrant])
450         tmp_gethostbyaddr_r="proto_with_def"
451       ],[
452         AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto... not found])
453       ])
454     ])
455   fi
456   #
457   if test "$tmp_gethostbyaddr_r" = "proto_wout_def"; then
458     AC_COMPILE_IFELSE([
459       AC_LANG_PROGRAM([[
460 #include <sys/types.h>
461 #include <netdb.h>
462       ]],[[
463         gethostbyaddr_r(0, 0, 0, 0, 0);
464       ]])
465     ],[
466       AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto wout finds... 5 args])
467       tmp_gethostbyaddr_r="done"
468     ])
469   fi
470   if test "$tmp_gethostbyaddr_r" = "proto_wout_def"; then
471     AC_COMPILE_IFELSE([
472       AC_LANG_PROGRAM([[
473 #include <sys/types.h>
474 #include <netdb.h>
475       ]],[[
476         gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0);
477       ]])
478     ],[
479       AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto wout finds... 7 args])
480       tmp_gethostbyaddr_r="done"
481     ])
482   fi
483   if test "$tmp_gethostbyaddr_r" = "proto_wout_def"; then
484     AC_COMPILE_IFELSE([
485       AC_LANG_PROGRAM([[
486 #include <sys/types.h>
487 #include <netdb.h>
488       ]],[[
489         gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0, 0);
490       ]])
491     ],[
492       AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto wout finds... 8 args])
493       tmp_gethostbyaddr_r="done"
494     ])
495   fi
496   #
497   if test "$tmp_gethostbyaddr_r" = "proto_with_def"; then
498     AC_COMPILE_IFELSE([
499       AC_LANG_PROGRAM([[
500 #define _REENTRANT
501 #include <sys/types.h>
502 #include <netdb.h>
503       ]],[[
504         gethostbyaddr_r(0, 0, 0, 0, 0);
505       ]])
506     ],[
507       AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto with finds... 5 args])
508       tmp_gethostbyaddr_r="needs_reentrant"
509     ])
510   fi
511   if test "$tmp_gethostbyaddr_r" = "proto_with_def"; then
512     AC_COMPILE_IFELSE([
513       AC_LANG_PROGRAM([[
514 #define _REENTRANT
515 #include <sys/types.h>
516 #include <netdb.h>
517       ]],[[
518         gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0);
519       ]])
520     ],[
521       AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto with finds... 7 args])
522       tmp_gethostbyaddr_r="needs_reentrant"
523     ])
524   fi
525   if test "$tmp_gethostbyaddr_r" = "proto_with_def"; then
526     AC_COMPILE_IFELSE([
527       AC_LANG_PROGRAM([[
528 #define _REENTRANT
529 #include <sys/types.h>
530 #include <netdb.h>
531       ]],[[
532         gethostbyaddr_r(0, 0, 0, 0, 0, 0, 0, 0);
533       ]])
534     ],[
535       AC_MSG_NOTICE([DEBUG: gethostbyaddr_r proto with finds... 8 args])
536       tmp_gethostbyaddr_r="needs_reentrant"
537     ])
538   fi
539   #
540   if test "$tmp_gethostbyaddr_r" = "needs_reentrant"; then
541     ac_cv_need_reentrant="yes"
542   fi
543 ])
544
545
546 dnl CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
547 dnl -------------------------------------------------
548 dnl Checks if the preprocessor _REENTRANT definition
549 dnl makes function gethostbyname_r compiler visible.
550
551 AC_DEFUN([CHECK_NEED_REENTRANT_GETHOSTBYNAME_R], [
552   #
553   AC_MSG_NOTICE([DEBUG:])
554   AC_LINK_IFELSE([
555     AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
556   ],[
557     AC_MSG_NOTICE([DEBUG: gethostbyname_r links... yes])
558     tmp_gethostbyname_r="yes"
559   ],[
560     AC_MSG_NOTICE([DEBUG: gethostbyname_r links... no])
561     tmp_gethostbyname_r="no"
562   ])
563   #
564   if test "$tmp_gethostbyname_r" = "yes"; then
565     AC_EGREP_CPP([gethostbyname_r],[
566 #include <sys/types.h>
567 #include <netdb.h>
568     ],[
569       AC_MSG_NOTICE([DEBUG: gethostbyname_r proto... without our definition])
570       tmp_gethostbyname_r="proto_wout_def"
571     ],[
572       AC_EGREP_CPP([gethostbyname_r],[
573 #define _REENTRANT
574 #include <sys/types.h>
575 #include <netdb.h>
576       ],[
577         AC_MSG_NOTICE([DEBUG: gethostbyname_r proto... with our _reentrant])
578         tmp_gethostbyname_r="proto_with_def"
579       ],[
580         AC_MSG_NOTICE([DEBUG: gethostbyname_r proto... not found])
581       ])
582     ])
583   fi
584   #
585   if test "$tmp_gethostbyname_r" = "proto_wout_def"; then
586     AC_COMPILE_IFELSE([
587       AC_LANG_PROGRAM([[
588 #include <sys/types.h>
589 #include <netdb.h>
590       ]],[[
591         gethostbyname_r(0, 0, 0);
592       ]])
593     ],[
594       AC_MSG_NOTICE([DEBUG: gethostbyname_r proto wout finds... 3 args])
595       tmp_gethostbyname_r="done"
596     ])
597   fi
598   if test "$tmp_gethostbyname_r" = "proto_wout_def"; then
599     AC_COMPILE_IFELSE([
600       AC_LANG_PROGRAM([[
601 #include <sys/types.h>
602 #include <netdb.h>
603       ]],[[
604         gethostbyname_r(0, 0, 0, 0, 0);
605       ]])
606     ],[
607       AC_MSG_NOTICE([DEBUG: gethostbyname_r proto wout finds... 5 args])
608       tmp_gethostbyname_r="done"
609     ])
610   fi
611   if test "$tmp_gethostbyname_r" = "proto_wout_def"; then
612     AC_COMPILE_IFELSE([
613       AC_LANG_PROGRAM([[
614 #include <sys/types.h>
615 #include <netdb.h>
616       ]],[[
617         gethostbyname_r(0, 0, 0, 0, 0, 0);
618       ]])
619     ],[
620       AC_MSG_NOTICE([DEBUG: gethostbyname_r proto wout finds... 6 args])
621       tmp_gethostbyname_r="done"
622     ])
623   fi
624   #
625   if test "$tmp_gethostbyname_r" = "proto_with_def"; then
626     AC_COMPILE_IFELSE([
627       AC_LANG_PROGRAM([[
628 #define _REENTRANT
629 #include <sys/types.h>
630 #include <netdb.h>
631       ]],[[
632         gethostbyname_r(0, 0, 0);
633       ]])
634     ],[
635       AC_MSG_NOTICE([DEBUG: gethostbyname_r proto with finds... 3 args])
636       tmp_gethostbyname_r="needs_reentrant"
637     ])
638   fi
639   if test "$tmp_gethostbyname_r" = "proto_with_def"; then
640     AC_COMPILE_IFELSE([
641       AC_LANG_PROGRAM([[
642 #define _REENTRANT
643 #include <sys/types.h>
644 #include <netdb.h>
645       ]],[[
646         gethostbyname_r(0, 0, 0, 0, 0);
647       ]])
648     ],[
649       AC_MSG_NOTICE([DEBUG: gethostbyname_r proto with finds... 5 args])
650       tmp_gethostbyname_r="needs_reentrant"
651     ])
652   fi
653   if test "$tmp_gethostbyname_r" = "proto_with_def"; then
654     AC_COMPILE_IFELSE([
655       AC_LANG_PROGRAM([[
656 #define _REENTRANT
657 #include <sys/types.h>
658 #include <netdb.h>
659       ]],[[
660         gethostbyname_r(0, 0, 0, 0, 0, 0);
661       ]])
662     ],[
663       AC_MSG_NOTICE([DEBUG: gethostbyname_r proto with finds... 6 args])
664       tmp_gethostbyname_r="needs_reentrant"
665     ])
666   fi
667   #
668   if test "$tmp_gethostbyname_r" = "needs_reentrant"; then
669     ac_cv_need_reentrant="yes"
670   fi
671 ])
672
673
674 dnl CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
675 dnl -------------------------------------------------
676 dnl Checks if the preprocessor _REENTRANT definition
677 dnl makes function getprotobyname_r compiler visible.
678
679 AC_DEFUN([CHECK_NEED_REENTRANT_GETPROTOBYNAME_R], [
680   #
681   AC_MSG_NOTICE([DEBUG:])
682   AC_LINK_IFELSE([
683     AC_LANG_FUNC_LINK_TRY([getprotobyname_r])
684   ],[
685     AC_MSG_NOTICE([DEBUG: getprotobyname_r links... yes])
686     tmp_getprotobyname_r="yes"
687   ],[
688     AC_MSG_NOTICE([DEBUG: getprotobyname_r links... no])
689     tmp_getprotobyname_r="no"
690   ])
691   #
692   if test "$tmp_getprotobyname_r" = "yes"; then
693     AC_EGREP_CPP([getprotobyname_r],[
694 #include <sys/types.h>
695 #include <netdb.h>
696     ],[
697       AC_MSG_NOTICE([DEBUG: getprotobyname_r proto... without our definition])
698       tmp_getprotobyname_r="proto_wout_def"
699     ],[
700       AC_EGREP_CPP([getprotobyname_r],[
701 #define _REENTRANT
702 #include <sys/types.h>
703 #include <netdb.h>
704       ],[
705         AC_MSG_NOTICE([DEBUG: getprotobyname_r proto... with our _reentrant])
706         tmp_getprotobyname_r="proto_with_def"
707       ],[
708         AC_MSG_NOTICE([DEBUG: getprotobyname_r proto... not found])
709       ])
710     ])
711   fi
712   #
713   if test "$tmp_getprotobyname_r" = "proto_wout_def"; then
714     AC_COMPILE_IFELSE([
715       AC_LANG_PROGRAM([[
716 #include <sys/types.h>
717 #include <netdb.h>
718       ]],[[
719         getprotobyname_r(0, 0, 0, 0);
720       ]])
721     ],[
722       AC_MSG_NOTICE([DEBUG: getprotobyname_r proto wout finds... 4 args])
723       tmp_getprotobyname_r="done"
724     ])
725   fi
726   if test "$tmp_getprotobyname_r" = "proto_wout_def"; then
727     AC_COMPILE_IFELSE([
728       AC_LANG_PROGRAM([[
729 #include <sys/types.h>
730 #include <netdb.h>
731       ]],[[
732         getprotobyname_r(0, 0, 0, 0, 0);
733       ]])
734     ],[
735       AC_MSG_NOTICE([DEBUG: getprotobyname_r proto wout finds... 5 args])
736       tmp_getprotobyname_r="done"
737     ])
738   fi
739   #
740   if test "$tmp_getprotobyname_r" = "proto_with_def"; then
741     AC_COMPILE_IFELSE([
742       AC_LANG_PROGRAM([[
743 #define _REENTRANT
744 #include <sys/types.h>
745 #include <netdb.h>
746       ]],[[
747         getprotobyname_r(0, 0, 0, 0);
748       ]])
749     ],[
750       AC_MSG_NOTICE([DEBUG: getprotobyname_r proto with finds... 4 args])
751       tmp_getprotobyname_r="needs_reentrant"
752     ])
753   fi
754   if test "$tmp_getprotobyname_r" = "proto_with_def"; then
755     AC_COMPILE_IFELSE([
756       AC_LANG_PROGRAM([[
757 #define _REENTRANT
758 #include <sys/types.h>
759 #include <netdb.h>
760       ]],[[
761         getprotobyname_r(0, 0, 0, 0, 0);
762       ]])
763     ],[
764       AC_MSG_NOTICE([DEBUG: getprotobyname_r proto with finds... 5 args])
765       tmp_getprotobyname_r="needs_reentrant"
766     ])
767   fi
768   #
769   if test "$tmp_getprotobyname_r" = "needs_reentrant"; then
770     ac_cv_need_reentrant="yes"
771   fi
772 ])
773
774
775 dnl CHECK_NEED_REENTRANT_GETSERVBYPORT_R
776 dnl -------------------------------------------------
777 dnl Checks if the preprocessor _REENTRANT definition
778 dnl makes function getservbyport_r compiler visible.
779
780 AC_DEFUN([CHECK_NEED_REENTRANT_GETSERVBYPORT_R], [
781   #
782   AC_MSG_NOTICE([DEBUG:])
783   AC_LINK_IFELSE([
784     AC_LANG_FUNC_LINK_TRY([getservbyport_r])
785   ],[
786     AC_MSG_NOTICE([DEBUG: getservbyport_r links... yes])
787     tmp_getservbyport_r="yes"
788   ],[
789     AC_MSG_NOTICE([DEBUG: getservbyport_r links... no])
790     tmp_getservbyport_r="no"
791   ])
792   #
793   if test "$tmp_getservbyport_r" = "yes"; then
794     AC_EGREP_CPP([getservbyport_r],[
795 #include <sys/types.h>
796 #include <netdb.h>
797     ],[
798       AC_MSG_NOTICE([DEBUG: getservbyport_r proto... without our definition])
799       tmp_getservbyport_r="proto_wout_def"
800     ],[
801       AC_EGREP_CPP([getservbyport_r],[
802 #define _REENTRANT
803 #include <sys/types.h>
804 #include <netdb.h>
805       ],[
806         AC_MSG_NOTICE([DEBUG: getservbyport_r proto... with our _reentrant])
807         tmp_getservbyport_r="proto_with_def"
808       ],[
809         AC_MSG_NOTICE([DEBUG: getservbyport_r proto... not found])
810       ])
811     ])
812   fi
813   #
814   if test "$tmp_getservbyport_r" = "proto_wout_def"; then
815     AC_COMPILE_IFELSE([
816       AC_LANG_PROGRAM([[
817 #include <sys/types.h>
818 #include <netdb.h>
819       ]],[[
820         getservbyport_r(0, 0, 0, 0);
821       ]])
822     ],[
823       AC_MSG_NOTICE([DEBUG: getservbyport_r proto wout finds... 4 args])
824       tmp_getservbyport_r="done"
825     ])
826   fi
827   if test "$tmp_getservbyport_r" = "proto_wout_def"; then
828     AC_COMPILE_IFELSE([
829       AC_LANG_PROGRAM([[
830 #include <sys/types.h>
831 #include <netdb.h>
832       ]],[[
833         getservbyport_r(0, 0, 0, 0, 0);
834       ]])
835     ],[
836       AC_MSG_NOTICE([DEBUG: getservbyport_r proto wout finds... 5 args])
837       tmp_getservbyport_r="done"
838     ])
839   fi
840   if test "$tmp_getservbyport_r" = "proto_wout_def"; then
841     AC_COMPILE_IFELSE([
842       AC_LANG_PROGRAM([[
843 #include <sys/types.h>
844 #include <netdb.h>
845       ]],[[
846         getservbyport_r(0, 0, 0, 0, 0, 0);
847       ]])
848     ],[
849       AC_MSG_NOTICE([DEBUG: getservbyport_r proto wout finds... 6 args])
850       tmp_getservbyport_r="done"
851     ])
852   fi
853   #
854   if test "$tmp_getservbyport_r" = "proto_with_def"; then
855     AC_COMPILE_IFELSE([
856       AC_LANG_PROGRAM([[
857 #define _REENTRANT
858 #include <sys/types.h>
859 #include <netdb.h>
860       ]],[[
861         getservbyport_r(0, 0, 0, 0);
862       ]])
863     ],[
864       AC_MSG_NOTICE([DEBUG: getservbyport_r proto with finds... 4 args])
865       tmp_getservbyport_r="needs_reentrant"
866     ])
867   fi
868   if test "$tmp_getservbyport_r" = "proto_with_def"; then
869     AC_COMPILE_IFELSE([
870       AC_LANG_PROGRAM([[
871 #define _REENTRANT
872 #include <sys/types.h>
873 #include <netdb.h>
874       ]],[[
875         getservbyport_r(0, 0, 0, 0, 0);
876       ]])
877     ],[
878       AC_MSG_NOTICE([DEBUG: getservbyport_r proto with finds... 5 args])
879       tmp_getservbyport_r="needs_reentrant"
880     ])
881   fi
882   if test "$tmp_getservbyport_r" = "proto_with_def"; then
883     AC_COMPILE_IFELSE([
884       AC_LANG_PROGRAM([[
885 #define _REENTRANT
886 #include <sys/types.h>
887 #include <netdb.h>
888       ]],[[
889         getservbyport_r(0, 0, 0, 0, 0, 0);
890       ]])
891     ],[
892       AC_MSG_NOTICE([DEBUG: getservbyport_r proto with finds... 6 args])
893       tmp_getservbyport_r="needs_reentrant"
894     ])
895   fi
896   #
897   if test "$tmp_getservbyport_r" = "needs_reentrant"; then
898     ac_cv_need_reentrant="yes"
899   fi
900 ])
901
902
903 dnl CHECK_NEED_REENTRANT_FUNCTIONS_R
904 dnl -------------------------------------------------
905 dnl Checks if the preprocessor _REENTRANT definition
906 dnl makes several _r functions compiler visible.
907 dnl Internal macro for CONFIGURE_REENTRANT.
908
909 AC_DEFUN([CHECK_NEED_REENTRANT_FUNCTIONS_R], [
910   if test "$ac_cv_need_reentrant" = "no"; then
911     CHECK_NEED_REENTRANT_STRERROR_R
912   fi
913   if test "$ac_cv_need_reentrant" = "no"; then
914     CHECK_NEED_REENTRANT_STRTOK_R
915   fi
916   if test "$ac_cv_need_reentrant" = "no"; then
917     CHECK_NEED_REENTRANT_LOCALTIME_R
918   fi
919   if test "$ac_cv_need_reentrant" = "no"; then
920     CHECK_NEED_REENTRANT_GMTIME_R
921   fi
922   if test "$ac_cv_need_reentrant" = "no"; then
923     CHECK_NEED_REENTRANT_INET_NTOA_R
924   fi
925   if test "$ac_cv_need_reentrant" = "no"; then
926     CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
927   fi
928   if test "$ac_cv_need_reentrant" = "no"; then
929     CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
930   fi
931   if test "$ac_cv_need_reentrant" = "no"; then
932     CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
933   fi
934   if test "$ac_cv_need_reentrant" = "no"; then
935     CHECK_NEED_REENTRANT_GETSERVBYPORT_R
936   fi
937 ])
938
939 AC_DEFUN([CHECK_NEED_REENTRANT_FUNCTIONS_R_DEBUG], [
940     CHECK_NEED_REENTRANT_STRERROR_R
941     CHECK_NEED_REENTRANT_STRTOK_R
942     CHECK_NEED_REENTRANT_LOCALTIME_R
943     CHECK_NEED_REENTRANT_GMTIME_R
944     CHECK_NEED_REENTRANT_INET_NTOA_R
945     CHECK_NEED_REENTRANT_GETHOSTBYADDR_R
946     CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
947     CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
948     CHECK_NEED_REENTRANT_GETSERVBYPORT_R
949 ])
950
951
952 dnl CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
953 dnl -------------------------------------------------
954 dnl This macro ensures that configuration tests done
955 dnl after this will execute with preprocessor symbol
956 dnl _REENTRANT defined. This macro also ensures that
957 dnl the generated config file will equally define it.
958 dnl Internal macro for CONFIGURE_REENTRANT.
959
960 AC_DEFUN([CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
961 AH_VERBATIM([NEED_REENTRANT],
962 [/* Configure process defines NEED_REENTRANT to 1 when it finds out that */
963 /* _REENTRANT is required or already defined for proper configuration.  */
964 @%:@undef NEED_REENTRANT
965 @%:@if defined(NEED_REENTRANT) && !defined(_REENTRANT)
966 @%:@ define _REENTRANT
967 @%:@endif])
968 cat >>confdefs.h <<_ACEOF
969 [@%:@ifndef _REENTRANT
970 @%:@ define _REENTRANT
971 @%:@endif]
972 _ACEOF
973 AC_DEFINE(NEED_REENTRANT, 1, [])
974 ])
975
976
977 dnl CONFIGURE_REENTRANT
978 dnl -------------------------------------------------
979 dnl This first checks if the preprocessor _REENTRANT
980 dnl symbol is already defined. If it isn't currently
981 dnl defined a set of checks are performed to verify
982 dnl if its definition is required to make visible to
983 dnl the compiler a set of *_r functions. Finally, if
984 dnl _REENTRANT is already defined or needed it takes
985 dnl care of making adjustments necessary to ensure
986 dnl that it is defined equally for further configure
987 dnl tests and generated config file.
988
989 AC_DEFUN([CONFIGURE_REENTRANT], [
990   #
991   AC_MSG_CHECKING([if _REENTRANT is already defined])
992   AC_COMPILE_IFELSE([
993     AC_LANG_PROGRAM([[
994     ]],[[
995 #ifdef _REENTRANT
996       int dummy=1;
997 #else
998       force compilation error
999 #endif
1000     ]])
1001   ],[
1002     AC_MSG_RESULT([yes])
1003     tmp_reentrant_initially_defined="yes"
1004   ],[
1005     AC_MSG_RESULT([no])
1006     tmp_reentrant_initially_defined="no"
1007   ])
1008   #
1009   if test "$tmp_reentrant_initially_defined" = "no"; then
1010     AC_MSG_CHECKING([if _REENTRANT is actually needed])
1011     ac_cv_need_reentrant="no"
1012     CHECK_NEED_REENTRANT_FUNCTIONS_R_DEBUG
1013     if test "$ac_cv_need_reentrant" = "yes"; then
1014       AC_MSG_RESULT([yes])
1015     else
1016       AC_MSG_RESULT([no])
1017     fi
1018   fi
1019   #
1020   AC_MSG_CHECKING([if _REENTRANT is onwards defined])
1021   if test "$tmp_reentrant_initially_defined" = "yes" ||
1022     test "$ac_cv_need_reentrant" = "yes"; then
1023     CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
1024     AC_MSG_RESULT([yes])
1025   else
1026     AC_MSG_RESULT([no])
1027   fi
1028   #
1029 ])
1030