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