curl-reentrant.m4 12 KB

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