• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21#***************************************************************************
22
23# File version for 'aclocal' use. Keep it a single number.
24# serial 10
25
26dnl Note 1
27dnl ------
28dnl None of the CURL_CHECK_NEED_REENTRANT_* macros shall use HAVE_FOO_H to
29dnl conditionally include header files. These macros are used early in the
30dnl configure process much before header file availability is known.
31
32
33dnl CURL_CHECK_NEED_REENTRANT_ERRNO
34dnl -------------------------------------------------
35dnl Checks if the preprocessor _REENTRANT definition
36dnl makes errno available as a preprocessor macro.
37
38AC_DEFUN([CURL_CHECK_NEED_REENTRANT_ERRNO], [
39  AC_COMPILE_IFELSE([
40    AC_LANG_PROGRAM([[
41#include <errno.h>
42    ]],[[
43      if(0 != errno)
44        return 1;
45    ]])
46  ],[
47    tmp_errno="yes"
48  ],[
49    tmp_errno="no"
50  ])
51  if test "$tmp_errno" = "yes"; then
52    AC_COMPILE_IFELSE([
53      AC_LANG_PROGRAM([[
54#include <errno.h>
55      ]],[[
56#ifdef errno
57        int dummy=1;
58#else
59        force compilation error
60#endif
61      ]])
62    ],[
63      tmp_errno="errno_macro_defined"
64    ],[
65      AC_COMPILE_IFELSE([
66        AC_LANG_PROGRAM([[
67#define _REENTRANT
68#include <errno.h>
69        ]],[[
70#ifdef errno
71          int dummy=1;
72#else
73          force compilation error
74#endif
75        ]])
76      ],[
77        tmp_errno="errno_macro_needs_reentrant"
78        tmp_need_reentrant="yes"
79      ])
80    ])
81  fi
82])
83
84
85dnl CURL_CHECK_NEED_REENTRANT_GMTIME_R
86dnl -------------------------------------------------
87dnl Checks if the preprocessor _REENTRANT definition
88dnl makes function gmtime_r compiler visible.
89
90AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GMTIME_R], [
91  AC_LINK_IFELSE([
92    AC_LANG_FUNC_LINK_TRY([gmtime_r])
93  ],[
94    tmp_gmtime_r="yes"
95  ],[
96    tmp_gmtime_r="no"
97  ])
98  if test "$tmp_gmtime_r" = "yes"; then
99    AC_EGREP_CPP([gmtime_r],[
100#include <sys/types.h>
101#include <time.h>
102    ],[
103      tmp_gmtime_r="proto_declared"
104    ],[
105      AC_EGREP_CPP([gmtime_r],[
106#define _REENTRANT
107#include <sys/types.h>
108#include <time.h>
109      ],[
110        tmp_gmtime_r="proto_needs_reentrant"
111        tmp_need_reentrant="yes"
112      ])
113    ])
114  fi
115])
116
117
118dnl CURL_CHECK_NEED_REENTRANT_LOCALTIME_R
119dnl -------------------------------------------------
120dnl Checks if the preprocessor _REENTRANT definition
121dnl makes function localtime_r compiler visible.
122
123AC_DEFUN([CURL_CHECK_NEED_REENTRANT_LOCALTIME_R], [
124  AC_LINK_IFELSE([
125    AC_LANG_FUNC_LINK_TRY([localtime_r])
126  ],[
127    tmp_localtime_r="yes"
128  ],[
129    tmp_localtime_r="no"
130  ])
131  if test "$tmp_localtime_r" = "yes"; then
132    AC_EGREP_CPP([localtime_r],[
133#include <sys/types.h>
134#include <time.h>
135    ],[
136      tmp_localtime_r="proto_declared"
137    ],[
138      AC_EGREP_CPP([localtime_r],[
139#define _REENTRANT
140#include <sys/types.h>
141#include <time.h>
142      ],[
143        tmp_localtime_r="proto_needs_reentrant"
144        tmp_need_reentrant="yes"
145      ])
146    ])
147  fi
148])
149
150
151dnl CURL_CHECK_NEED_REENTRANT_STRERROR_R
152dnl -------------------------------------------------
153dnl Checks if the preprocessor _REENTRANT definition
154dnl makes function strerror_r compiler visible.
155
156AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRERROR_R], [
157  AC_LINK_IFELSE([
158    AC_LANG_FUNC_LINK_TRY([strerror_r])
159  ],[
160    tmp_strerror_r="yes"
161  ],[
162    tmp_strerror_r="no"
163  ])
164  if test "$tmp_strerror_r" = "yes"; then
165    AC_EGREP_CPP([strerror_r],[
166#include <sys/types.h>
167#include <string.h>
168    ],[
169      tmp_strerror_r="proto_declared"
170    ],[
171      AC_EGREP_CPP([strerror_r],[
172#define _REENTRANT
173#include <sys/types.h>
174#include <string.h>
175      ],[
176        tmp_strerror_r="proto_needs_reentrant"
177        tmp_need_reentrant="yes"
178      ])
179    ])
180  fi
181])
182
183
184dnl CURL_CHECK_NEED_REENTRANT_STRTOK_R
185dnl -------------------------------------------------
186dnl Checks if the preprocessor _REENTRANT definition
187dnl makes function strtok_r compiler visible.
188
189AC_DEFUN([CURL_CHECK_NEED_REENTRANT_STRTOK_R], [
190  AC_LINK_IFELSE([
191    AC_LANG_FUNC_LINK_TRY([strtok_r])
192  ],[
193    tmp_strtok_r="yes"
194  ],[
195    tmp_strtok_r="no"
196  ])
197  if test "$tmp_strtok_r" = "yes"; then
198    AC_EGREP_CPP([strtok_r],[
199#include <sys/types.h>
200#include <string.h>
201    ],[
202      tmp_strtok_r="proto_declared"
203    ],[
204      AC_EGREP_CPP([strtok_r],[
205#define _REENTRANT
206#include <sys/types.h>
207#include <string.h>
208      ],[
209        tmp_strtok_r="proto_needs_reentrant"
210        tmp_need_reentrant="yes"
211      ])
212    ])
213  fi
214])
215
216
217dnl CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
218dnl -------------------------------------------------
219dnl Checks if the preprocessor _REENTRANT definition
220dnl makes function gethostbyname_r compiler visible.
221
222AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R], [
223  AC_LINK_IFELSE([
224    AC_LANG_FUNC_LINK_TRY([gethostbyname_r])
225  ],[
226    tmp_gethostbyname_r="yes"
227  ],[
228    tmp_gethostbyname_r="no"
229  ])
230  if test "$tmp_gethostbyname_r" = "yes"; then
231    AC_EGREP_CPP([gethostbyname_r],[
232#include <sys/types.h>
233#include <netdb.h>
234    ],[
235      tmp_gethostbyname_r="proto_declared"
236    ],[
237      AC_EGREP_CPP([gethostbyname_r],[
238#define _REENTRANT
239#include <sys/types.h>
240#include <netdb.h>
241      ],[
242        tmp_gethostbyname_r="proto_needs_reentrant"
243        tmp_need_reentrant="yes"
244      ])
245    ])
246  fi
247])
248
249
250dnl CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
251dnl -------------------------------------------------
252dnl Checks if the preprocessor _REENTRANT definition
253dnl makes function getprotobyname_r compiler visible.
254
255AC_DEFUN([CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R], [
256  AC_LINK_IFELSE([
257    AC_LANG_FUNC_LINK_TRY([getprotobyname_r])
258  ],[
259    tmp_getprotobyname_r="yes"
260  ],[
261    tmp_getprotobyname_r="no"
262  ])
263  if test "$tmp_getprotobyname_r" = "yes"; then
264    AC_EGREP_CPP([getprotobyname_r],[
265#include <sys/types.h>
266#include <netdb.h>
267    ],[
268      tmp_getprotobyname_r="proto_declared"
269    ],[
270      AC_EGREP_CPP([getprotobyname_r],[
271#define _REENTRANT
272#include <sys/types.h>
273#include <netdb.h>
274      ],[
275        tmp_getprotobyname_r="proto_needs_reentrant"
276        tmp_need_reentrant="yes"
277      ])
278    ])
279  fi
280])
281
282
283dnl CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R
284dnl -------------------------------------------------
285dnl Checks if the preprocessor _REENTRANT definition
286dnl makes several _r functions compiler visible.
287dnl Internal macro for CURL_CONFIGURE_REENTRANT.
288
289AC_DEFUN([CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R], [
290  if test "$tmp_need_reentrant" = "no"; then
291    CURL_CHECK_NEED_REENTRANT_GMTIME_R
292  fi
293  if test "$tmp_need_reentrant" = "no"; then
294    CURL_CHECK_NEED_REENTRANT_LOCALTIME_R
295  fi
296  if test "$tmp_need_reentrant" = "no"; then
297    CURL_CHECK_NEED_REENTRANT_STRERROR_R
298  fi
299  if test "$tmp_need_reentrant" = "no"; then
300    CURL_CHECK_NEED_REENTRANT_STRTOK_R
301  fi
302  if test "$tmp_need_reentrant" = "no"; then
303    CURL_CHECK_NEED_REENTRANT_GETHOSTBYNAME_R
304  fi
305  if test "$tmp_need_reentrant" = "no"; then
306    CURL_CHECK_NEED_REENTRANT_GETPROTOBYNAME_R
307  fi
308])
309
310
311dnl CURL_CHECK_NEED_REENTRANT_SYSTEM
312dnl -------------------------------------------------
313dnl Checks if the preprocessor _REENTRANT definition
314dnl must be unconditionally done for this platform.
315dnl Internal macro for CURL_CONFIGURE_REENTRANT.
316
317AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
318  case $host_os in
319    solaris*)
320      tmp_need_reentrant="yes"
321      ;;
322    *)
323      tmp_need_reentrant="no"
324      ;;
325  esac
326])
327
328
329dnl CURL_CHECK_NEED_THREAD_SAFE_SYSTEM
330dnl -------------------------------------------------
331dnl Checks if the preprocessor _THREAD_SAFE definition
332dnl must be unconditionally done for this platform.
333dnl Internal macro for CURL_CONFIGURE_THREAD_SAFE.
334
335AC_DEFUN([CURL_CHECK_NEED_THREAD_SAFE_SYSTEM], [
336  case $host_os in
337    aix[[123]].* | aix4.[[012]].*)
338      dnl aix 4.2 and older
339      tmp_need_thread_safe="no"
340      ;;
341    aix*)
342      dnl AIX 4.3 and newer
343      tmp_need_thread_safe="yes"
344      ;;
345    *)
346      tmp_need_thread_safe="no"
347      ;;
348  esac
349])
350
351
352dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
353dnl -------------------------------------------------
354dnl This macro ensures that configuration tests done
355dnl after this will execute with preprocessor symbol
356dnl _REENTRANT defined. This macro also ensures that
357dnl the generated config file defines NEED_REENTRANT
358dnl and that in turn curl_setup.h will define _REENTRANT.
359dnl Internal macro for CURL_CONFIGURE_REENTRANT.
360
361AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
362AC_DEFINE(NEED_REENTRANT, 1,
363  [Define to 1 if _REENTRANT preprocessor symbol must be defined.])
364cat >>confdefs.h <<_EOF
365#ifndef _REENTRANT
366#  define _REENTRANT
367#endif
368_EOF
369])
370
371
372dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE
373dnl -------------------------------------------------
374dnl This macro ensures that configuration tests done
375dnl after this will execute with preprocessor symbol
376dnl _THREAD_SAFE defined. This macro also ensures that
377dnl the generated config file defines NEED_THREAD_SAFE
378dnl and that in turn curl_setup.h will define _THREAD_SAFE.
379dnl Internal macro for CURL_CONFIGURE_THREAD_SAFE.
380
381AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE], [
382AC_DEFINE(NEED_THREAD_SAFE, 1,
383  [Define to 1 if _THREAD_SAFE preprocessor symbol must be defined.])
384cat >>confdefs.h <<_EOF
385#ifndef _THREAD_SAFE
386#  define _THREAD_SAFE
387#endif
388_EOF
389])
390
391
392dnl CURL_CONFIGURE_REENTRANT
393dnl -------------------------------------------------
394dnl This first checks if the preprocessor _REENTRANT
395dnl symbol is already defined. If it isn't currently
396dnl defined a set of checks are performed to verify
397dnl if its definition is required to make visible to
398dnl the compiler a set of *_r functions. Finally, if
399dnl _REENTRANT is already defined or needed it takes
400dnl care of making adjustments necessary to ensure
401dnl that it is defined equally for further configure
402dnl tests and generated config file.
403
404AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
405  AC_PREREQ([2.50])dnl
406  #
407  AC_MSG_CHECKING([if _REENTRANT is already defined])
408  AC_COMPILE_IFELSE([
409    AC_LANG_PROGRAM([[
410    ]],[[
411#ifdef _REENTRANT
412      int dummy=1;
413#else
414      force compilation error
415#endif
416    ]])
417  ],[
418    AC_MSG_RESULT([yes])
419    tmp_reentrant_initially_defined="yes"
420  ],[
421    AC_MSG_RESULT([no])
422    tmp_reentrant_initially_defined="no"
423  ])
424  #
425  if test "$tmp_reentrant_initially_defined" = "no"; then
426    AC_MSG_CHECKING([if _REENTRANT is actually needed])
427    CURL_CHECK_NEED_REENTRANT_SYSTEM
428    if test "$tmp_need_reentrant" = "no"; then
429      CURL_CHECK_NEED_REENTRANT_ERRNO
430    fi
431    if test "$tmp_need_reentrant" = "no"; then
432      CURL_CHECK_NEED_REENTRANT_FUNCTIONS_R
433    fi
434    if test "$tmp_need_reentrant" = "yes"; then
435      AC_MSG_RESULT([yes])
436    else
437      AC_MSG_RESULT([no])
438    fi
439  fi
440  #
441  AC_MSG_CHECKING([if _REENTRANT is onwards defined])
442  if test "$tmp_reentrant_initially_defined" = "yes" ||
443    test "$tmp_need_reentrant" = "yes"; then
444    CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
445    AC_MSG_RESULT([yes])
446  else
447    AC_MSG_RESULT([no])
448  fi
449  #
450])
451
452
453dnl CURL_CONFIGURE_THREAD_SAFE
454dnl -------------------------------------------------
455dnl This first checks if the preprocessor _THREAD_SAFE
456dnl symbol is already defined. If it isn't currently
457dnl defined a set of checks are performed to verify
458dnl if its definition is required. Finally, if
459dnl _THREAD_SAFE is already defined or needed it takes
460dnl care of making adjustments necessary to ensure
461dnl that it is defined equally for further configure
462dnl tests and generated config file.
463
464AC_DEFUN([CURL_CONFIGURE_THREAD_SAFE], [
465  AC_PREREQ([2.50])dnl
466  #
467  AC_MSG_CHECKING([if _THREAD_SAFE is already defined])
468  AC_COMPILE_IFELSE([
469    AC_LANG_PROGRAM([[
470    ]],[[
471#ifdef _THREAD_SAFE
472      int dummy=1;
473#else
474      force compilation error
475#endif
476    ]])
477  ],[
478    AC_MSG_RESULT([yes])
479    tmp_thread_safe_initially_defined="yes"
480  ],[
481    AC_MSG_RESULT([no])
482    tmp_thread_safe_initially_defined="no"
483  ])
484  #
485  if test "$tmp_thread_safe_initially_defined" = "no"; then
486    AC_MSG_CHECKING([if _THREAD_SAFE is actually needed])
487    CURL_CHECK_NEED_THREAD_SAFE_SYSTEM
488    if test "$tmp_need_thread_safe" = "yes"; then
489      AC_MSG_RESULT([yes])
490    else
491      AC_MSG_RESULT([no])
492    fi
493  fi
494  #
495  AC_MSG_CHECKING([if _THREAD_SAFE is onwards defined])
496  if test "$tmp_thread_safe_initially_defined" = "yes" ||
497    test "$tmp_need_thread_safe" = "yes"; then
498    CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE
499    AC_MSG_RESULT([yes])
500  else
501    AC_MSG_RESULT([no])
502  fi
503  #
504])
505