quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl-reentrant.m4 (12915B)


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