functions.m4 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. # This file is part of Autoconf. -*- Autoconf -*-
  2. # Checking for functions.
  3. # Copyright (C) 2000-2012 Free Software Foundation, Inc.
  4. # This file is part of Autoconf. This program is free
  5. # software; you can redistribute it and/or modify it under the
  6. # terms of the GNU General Public License as published by the
  7. # Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # Under Section 7 of GPL version 3, you are granted additional
  16. # permissions described in the Autoconf Configure Script Exception,
  17. # version 3.0, as published by the Free Software Foundation.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # and a copy of the Autoconf Configure Script Exception along with
  21. # this program; see the files COPYINGv3 and COPYING.EXCEPTION
  22. # respectively. If not, see <http://www.gnu.org/licenses/>.
  23. # Written by David MacKenzie, with help from
  24. # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  25. # Roland McGrath, Noah Friedman, david d zuhn, and many others.
  26. # Table of contents
  27. #
  28. # 1. Generic tests for functions.
  29. # 2. Functions to check with AC_CHECK_FUNCS
  30. # 3. Tests for specific functions.
  31. ## -------------------------------- ##
  32. ## 1. Generic tests for functions. ##
  33. ## -------------------------------- ##
  34. # _AC_CHECK_FUNC_BODY
  35. # -------------------
  36. # Shell function body for AC_CHECK_FUNC.
  37. m4_define([_AC_CHECK_FUNC_BODY],
  38. [ AS_LINENO_PUSH([$[]1])
  39. AC_CACHE_CHECK([for $[]2], [$[]3],
  40. [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY($[]2)],
  41. [AS_VAR_SET([$[]3], [yes])],
  42. [AS_VAR_SET([$[]3], [no])])])
  43. AS_LINENO_POP
  44. ])# _AC_CHECK_FUNC_BODY
  45. # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  46. # -----------------------------------------------------------------
  47. # Check whether FUNCTION links in the current language. Set the cache
  48. # variable ac_cv_func_FUNCTION accordingly, then execute
  49. # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
  50. AC_DEFUN([AC_CHECK_FUNC],
  51. [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_func],
  52. [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_func],
  53. [LINENO FUNC VAR],
  54. [Tests whether FUNC exists, setting the cache variable VAR accordingly])],
  55. [_$0_BODY])]dnl
  56. [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])]dnl
  57. [ac_fn_[]_AC_LANG_ABBREV[]_check_func "$LINENO" "$1" "ac_var"
  58. AS_VAR_IF([ac_var], [yes], [$2], [$3])
  59. AS_VAR_POPDEF([ac_var])])# AC_CHECK_FUNC
  60. # _AH_CHECK_FUNC(FUNCTION)
  61. # ------------------------
  62. # Prepare the autoheader snippet for FUNCTION.
  63. m4_define([_AH_CHECK_FUNC],
  64. [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
  65. [Define to 1 if you have the `$1' function.])])
  66. # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  67. # ---------------------------------------------------------------------
  68. # Check for each whitespace-separated FUNCTION, and perform
  69. # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND for each function.
  70. # Additionally, make the preprocessor definition HAVE_FUNCTION
  71. # available for each found function. Either ACTION may include
  72. # `break' to stop the search.
  73. AC_DEFUN([AC_CHECK_FUNCS],
  74. [m4_map_args_w([$1], [_AH_CHECK_FUNC(], [)])]dnl
  75. [AS_FOR([AC_func], [ac_func], [$1],
  76. [AC_CHECK_FUNC(AC_func,
  77. [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_func)) $2],
  78. [$3])dnl])
  79. ])# AC_CHECK_FUNCS
  80. # _AC_CHECK_FUNC_ONCE(FUNCTION)
  81. # -----------------------------
  82. # Check for a single FUNCTION once.
  83. m4_define([_AC_CHECK_FUNC_ONCE],
  84. [_AH_CHECK_FUNC([$1])AC_DEFUN([_AC_Func_$1],
  85. [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_func_list], [" $1"])])
  86. _AC_FUNCS_EXPANSION])AC_REQUIRE([_AC_Func_$1])])
  87. # AC_CHECK_FUNCS_ONCE(FUNCTION...)
  88. # --------------------------------
  89. # Add each whitespace-separated name in FUNCTION to the list of functions
  90. # to check once.
  91. AC_DEFUN([AC_CHECK_FUNCS_ONCE],
  92. [m4_map_args_w([$1], [_AC_CHECK_FUNC_ONCE(], [)])])
  93. m4_define([_AC_FUNCS_EXPANSION],
  94. [
  95. m4_divert_text([DEFAULTS], [ac_func_list=])
  96. AC_CHECK_FUNCS([$ac_func_list])
  97. m4_define([_AC_FUNCS_EXPANSION], [])
  98. ])
  99. # _AC_REPLACE_FUNC(FUNCTION)
  100. # --------------------------
  101. # If FUNCTION exists, define HAVE_FUNCTION; else add FUNCTION.c
  102. # to the list of library objects. FUNCTION must be literal.
  103. m4_define([_AC_REPLACE_FUNC],
  104. [AC_CHECK_FUNC([$1],
  105. [_AH_CHECK_FUNC([$1])AC_DEFINE(AS_TR_CPP([HAVE_$1]))],
  106. [_AC_LIBOBJ([$1])AC_LIBSOURCE([$1.c])])])
  107. # AC_REPLACE_FUNCS(FUNCTION...)
  108. # -----------------------------
  109. # For each FUNCTION in the whitespace separated list, perform the
  110. # equivalent of AC_CHECK_FUNC, then call AC_LIBOBJ if the function
  111. # was not found.
  112. AC_DEFUN([AC_REPLACE_FUNCS],
  113. [_$0(m4_flatten([$1]))])
  114. m4_define([_AC_REPLACE_FUNCS],
  115. [AS_LITERAL_IF([$1],
  116. [m4_map_args_w([$1], [_AC_REPLACE_FUNC(], [)
  117. ])],
  118. [AC_CHECK_FUNCS([$1],
  119. [_AH_CHECK_FUNC([$ac_func])],
  120. [_AC_LIBOBJ([$ac_func])])])])
  121. # AC_TRY_LINK_FUNC(FUNC, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
  122. # ------------------------------------------------------------
  123. # Try to link a program that calls FUNC, handling GCC builtins. If
  124. # the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
  125. # ACTION-IF-NOT-FOUND.
  126. AC_DEFUN([AC_TRY_LINK_FUNC],
  127. [AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])])
  128. # AU::AC_FUNC_CHECK
  129. # -----------------
  130. AU_ALIAS([AC_FUNC_CHECK], [AC_CHECK_FUNC])
  131. # AU::AC_HAVE_FUNCS
  132. # -----------------
  133. AU_ALIAS([AC_HAVE_FUNCS], [AC_CHECK_FUNCS])
  134. ## ------------------------------------------- ##
  135. ## 2. Functions to check with AC_CHECK_FUNCS. ##
  136. ## ------------------------------------------- ##
  137. AN_FUNCTION([__argz_count], [AC_CHECK_FUNCS])
  138. AN_FUNCTION([__argz_next], [AC_CHECK_FUNCS])
  139. AN_FUNCTION([__argz_stringify], [AC_CHECK_FUNCS])
  140. AN_FUNCTION([__fpending], [AC_CHECK_FUNCS])
  141. AN_FUNCTION([acl], [AC_CHECK_FUNCS])
  142. AN_FUNCTION([alarm], [AC_CHECK_FUNCS])
  143. AN_FUNCTION([atexit], [AC_CHECK_FUNCS])
  144. AN_FUNCTION([btowc], [AC_CHECK_FUNCS])
  145. AN_FUNCTION([bzero], [AC_CHECK_FUNCS])
  146. AN_FUNCTION([clock_gettime], [AC_CHECK_FUNCS])
  147. AN_FUNCTION([doprnt], [AC_CHECK_FUNCS])
  148. AN_FUNCTION([dup2], [AC_CHECK_FUNCS])
  149. AN_FUNCTION([endgrent], [AC_CHECK_FUNCS])
  150. AN_FUNCTION([endpwent], [AC_CHECK_FUNCS])
  151. AN_FUNCTION([euidaccess], [AC_CHECK_FUNCS])
  152. AN_FUNCTION([fchdir], [AC_CHECK_FUNCS])
  153. AN_FUNCTION([fdatasync], [AC_CHECK_FUNCS])
  154. AN_FUNCTION([fesetround], [AC_CHECK_FUNCS])
  155. AN_FUNCTION([floor], [AC_CHECK_FUNCS])
  156. AN_FUNCTION([fs_stat_dev], [AC_CHECK_FUNCS])
  157. AN_FUNCTION([ftime], [AC_CHECK_FUNCS])
  158. AN_FUNCTION([ftruncate], [AC_CHECK_FUNCS])
  159. AN_FUNCTION([getcwd], [AC_CHECK_FUNCS])
  160. AN_FUNCTION([getdelim], [AC_CHECK_FUNCS])
  161. AN_FUNCTION([gethostbyaddr], [AC_CHECK_FUNCS])
  162. AN_FUNCTION([gethostbyname], [AC_CHECK_FUNCS])
  163. AN_FUNCTION([gethostname], [AC_CHECK_FUNCS])
  164. AN_FUNCTION([gethrtime], [AC_CHECK_FUNCS])
  165. AN_FUNCTION([getmntent], [AC_CHECK_FUNCS])
  166. AN_FUNCTION([getmntinfo], [AC_CHECK_FUNCS])
  167. AN_FUNCTION([getpagesize], [AC_CHECK_FUNCS])
  168. AN_FUNCTION([getpass], [AC_CHECK_FUNCS])
  169. AN_FUNCTION([getspnam], [AC_CHECK_FUNCS])
  170. AN_FUNCTION([gettimeofday], [AC_CHECK_FUNCS])
  171. AN_FUNCTION([getusershell], [AC_CHECK_FUNCS])
  172. AN_FUNCTION([hasmntopt], [AC_CHECK_FUNCS])
  173. AN_FUNCTION([inet_ntoa], [AC_CHECK_FUNCS])
  174. AN_FUNCTION([isascii], [AC_CHECK_FUNCS])
  175. AN_FUNCTION([iswprint], [AC_CHECK_FUNCS])
  176. AN_FUNCTION([lchown], [AC_CHECK_FUNCS])
  177. AN_FUNCTION([listmntent], [AC_CHECK_FUNCS])
  178. AN_FUNCTION([localeconv], [AC_CHECK_FUNCS])
  179. AN_FUNCTION([localtime_r], [AC_CHECK_FUNCS])
  180. AN_FUNCTION([mblen], [AC_CHECK_FUNCS])
  181. AN_FUNCTION([mbrlen], [AC_CHECK_FUNCS])
  182. AN_FUNCTION([memchr], [AC_CHECK_FUNCS])
  183. AN_FUNCTION([memmove], [AC_CHECK_FUNCS])
  184. AN_FUNCTION([mempcpy], [AC_CHECK_FUNCS])
  185. AN_FUNCTION([memset], [AC_CHECK_FUNCS])
  186. AN_FUNCTION([mkdir], [AC_CHECK_FUNCS])
  187. AN_FUNCTION([mkfifo], [AC_CHECK_FUNCS])
  188. AN_FUNCTION([modf], [AC_CHECK_FUNCS])
  189. AN_FUNCTION([munmap], [AC_CHECK_FUNCS])
  190. AN_FUNCTION([next_dev], [AC_CHECK_FUNCS])
  191. AN_FUNCTION([nl_langinfo], [AC_CHECK_FUNCS])
  192. AN_FUNCTION([pathconf], [AC_CHECK_FUNCS])
  193. AN_FUNCTION([pow], [AC_CHECK_FUNCS])
  194. AN_FUNCTION([pstat_getdynamic], [AC_CHECK_FUNCS])
  195. AN_FUNCTION([putenv], [AC_CHECK_FUNCS])
  196. AN_FUNCTION([re_comp], [AC_CHECK_FUNCS])
  197. AN_FUNCTION([realpath], [AC_CHECK_FUNCS])
  198. AN_FUNCTION([regcmp], [AC_CHECK_FUNCS])
  199. AN_FUNCTION([regcomp], [AC_CHECK_FUNCS])
  200. AN_FUNCTION([resolvepath], [AC_CHECK_FUNCS])
  201. AN_FUNCTION([rint], [AC_CHECK_FUNCS])
  202. AN_FUNCTION([rmdir], [AC_CHECK_FUNCS])
  203. AN_FUNCTION([rpmatch], [AC_CHECK_FUNCS])
  204. AN_FUNCTION([select], [AC_CHECK_FUNCS])
  205. AN_FUNCTION([setenv], [AC_CHECK_FUNCS])
  206. AN_FUNCTION([sethostname], [AC_CHECK_FUNCS])
  207. AN_FUNCTION([setlocale], [AC_CHECK_FUNCS])
  208. AN_FUNCTION([socket], [AC_CHECK_FUNCS])
  209. AN_FUNCTION([sqrt], [AC_CHECK_FUNCS])
  210. AN_FUNCTION([stime], [AC_CHECK_FUNCS])
  211. AN_FUNCTION([stpcpy], [AC_CHECK_FUNCS])
  212. AN_FUNCTION([strcasecmp], [AC_CHECK_FUNCS])
  213. AN_FUNCTION([strchr], [AC_CHECK_FUNCS])
  214. AN_FUNCTION([strcspn], [AC_CHECK_FUNCS])
  215. AN_FUNCTION([strdup], [AC_CHECK_FUNCS])
  216. AN_FUNCTION([strerror], [AC_CHECK_FUNCS])
  217. AN_FUNCTION([strncasecmp], [AC_CHECK_FUNCS])
  218. AN_FUNCTION([strndup], [AC_CHECK_FUNCS])
  219. AN_FUNCTION([strpbrk], [AC_CHECK_FUNCS])
  220. AN_FUNCTION([strrchr], [AC_CHECK_FUNCS])
  221. AN_FUNCTION([strspn], [AC_CHECK_FUNCS])
  222. AN_FUNCTION([strstr], [AC_CHECK_FUNCS])
  223. AN_FUNCTION([strtol], [AC_CHECK_FUNCS])
  224. AN_FUNCTION([strtoul], [AC_CHECK_FUNCS])
  225. AN_FUNCTION([strtoull], [AC_CHECK_FUNCS])
  226. AN_FUNCTION([strtoumax], [AC_CHECK_FUNCS])
  227. AN_FUNCTION([strverscmp], [AC_CHECK_FUNCS])
  228. AN_FUNCTION([sysinfo], [AC_CHECK_FUNCS])
  229. AN_FUNCTION([tzset], [AC_CHECK_FUNCS])
  230. AN_FUNCTION([uname], [AC_CHECK_FUNCS])
  231. AN_FUNCTION([utime], [AC_CHECK_FUNCS])
  232. AN_FUNCTION([utmpname], [AC_CHECK_FUNCS])
  233. AN_FUNCTION([utmpxname], [AC_CHECK_FUNCS])
  234. AN_FUNCTION([wcwidth], [AC_CHECK_FUNCS])
  235. AN_FUNCTION([dcgettext], [AM_GNU_GETTEXT])
  236. AN_FUNCTION([getwd], [warn: getwd is deprecated, use getcwd instead])
  237. ## --------------------------------- ##
  238. ## 3. Tests for specific functions. ##
  239. ## --------------------------------- ##
  240. # The macros are sorted:
  241. #
  242. # 1. AC_FUNC_* macros are sorted by alphabetical order.
  243. #
  244. # 2. Helping macros such as _AC_LIBOBJ_* are before the macro that
  245. # uses it.
  246. #
  247. # 3. Obsolete macros are right after the modern macro.
  248. # _AC_LIBOBJ_ALLOCA
  249. # -----------------
  250. # Set up the LIBOBJ replacement of `alloca'. Well, not exactly
  251. # AC_LIBOBJ since we actually set the output variable `ALLOCA'.
  252. # Nevertheless, for Automake, AC_LIBSOURCES it.
  253. m4_define([_AC_LIBOBJ_ALLOCA],
  254. [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
  255. # that cause trouble. Some versions do not even contain alloca or
  256. # contain a buggy version. If you still want to use their alloca,
  257. # use ar to extract alloca.o from them instead of compiling alloca.c.
  258. AC_LIBSOURCES(alloca.c)
  259. AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
  260. AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
  261. AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
  262. [AC_EGREP_CPP(webecray,
  263. [#if defined CRAY && ! defined CRAY2
  264. webecray
  265. #else
  266. wenotbecray
  267. #endif
  268. ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
  269. if test $ac_cv_os_cray = yes; then
  270. for ac_func in _getb67 GETB67 getb67; do
  271. AC_CHECK_FUNC($ac_func,
  272. [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
  273. [Define to one of `_getb67', `GETB67',
  274. `getb67' for Cray-2 and Cray-YMP
  275. systems. This function is required for
  276. `alloca.c' support on those systems.])
  277. break])
  278. done
  279. fi
  280. AC_CACHE_CHECK([stack direction for C alloca],
  281. [ac_cv_c_stack_direction],
  282. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  283. [AC_INCLUDES_DEFAULT
  284. int
  285. find_stack_direction (int *addr, int depth)
  286. {
  287. int dir, dummy = 0;
  288. if (! addr)
  289. addr = &dummy;
  290. *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
  291. dir = depth ? find_stack_direction (addr, depth - 1) : 0;
  292. return dir + dummy;
  293. }
  294. int
  295. main (int argc, char **argv)
  296. {
  297. return find_stack_direction (0, argc + !argv + 20) < 0;
  298. }])],
  299. [ac_cv_c_stack_direction=1],
  300. [ac_cv_c_stack_direction=-1],
  301. [ac_cv_c_stack_direction=0])])
  302. AH_VERBATIM([STACK_DIRECTION],
  303. [/* If using the C implementation of alloca, define if you know the
  304. direction of stack growth for your system; otherwise it will be
  305. automatically deduced at runtime.
  306. STACK_DIRECTION > 0 => grows toward higher addresses
  307. STACK_DIRECTION < 0 => grows toward lower addresses
  308. STACK_DIRECTION = 0 => direction of growth unknown */
  309. @%:@undef STACK_DIRECTION])dnl
  310. AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
  311. ])# _AC_LIBOBJ_ALLOCA
  312. # AC_FUNC_ALLOCA
  313. # --------------
  314. AN_FUNCTION([alloca], [AC_FUNC_ALLOCA])
  315. AN_HEADER([alloca.h], [AC_FUNC_ALLOCA])
  316. AC_DEFUN([AC_FUNC_ALLOCA],
  317. [AC_REQUIRE([AC_TYPE_SIZE_T])]dnl
  318. [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  319. # for constant arguments. Useless!
  320. AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
  321. [AC_LINK_IFELSE(
  322. [AC_LANG_PROGRAM([[@%:@include <alloca.h>]],
  323. [[char *p = (char *) alloca (2 * sizeof (int));
  324. if (p) return 0;]])],
  325. [ac_cv_working_alloca_h=yes],
  326. [ac_cv_working_alloca_h=no])])
  327. if test $ac_cv_working_alloca_h = yes; then
  328. AC_DEFINE(HAVE_ALLOCA_H, 1,
  329. [Define to 1 if you have <alloca.h> and it should be used
  330. (not on Ultrix).])
  331. fi
  332. AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
  333. [AC_LINK_IFELSE([AC_LANG_PROGRAM(
  334. [[#ifdef __GNUC__
  335. # define alloca __builtin_alloca
  336. #else
  337. # ifdef _MSC_VER
  338. # include <malloc.h>
  339. # define alloca _alloca
  340. # else
  341. # ifdef HAVE_ALLOCA_H
  342. # include <alloca.h>
  343. # else
  344. # ifdef _AIX
  345. #pragma alloca
  346. # else
  347. # ifndef alloca /* predefined by HP cc +Olibcalls */
  348. void *alloca (size_t);
  349. # endif
  350. # endif
  351. # endif
  352. # endif
  353. #endif
  354. ]], [[char *p = (char *) alloca (1);
  355. if (p) return 0;]])],
  356. [ac_cv_func_alloca_works=yes],
  357. [ac_cv_func_alloca_works=no])])
  358. if test $ac_cv_func_alloca_works = yes; then
  359. AC_DEFINE(HAVE_ALLOCA, 1,
  360. [Define to 1 if you have `alloca', as a function or macro.])
  361. else
  362. _AC_LIBOBJ_ALLOCA
  363. fi
  364. ])# AC_FUNC_ALLOCA
  365. # AU::AC_ALLOCA
  366. # -------------
  367. AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
  368. # AC_FUNC_CHOWN
  369. # -------------
  370. # Determine whether chown accepts arguments of -1 for uid and gid.
  371. AN_FUNCTION([chown], [AC_FUNC_CHOWN])
  372. AC_DEFUN([AC_FUNC_CHOWN],
  373. [AC_REQUIRE([AC_TYPE_UID_T])dnl
  374. AC_CHECK_HEADERS(unistd.h)
  375. AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
  376. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
  377. #include <fcntl.h>
  378. ],
  379. [[ char *f = "conftest.chown";
  380. struct stat before, after;
  381. if (creat (f, 0600) < 0)
  382. return 1;
  383. if (stat (f, &before) < 0)
  384. return 1;
  385. if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
  386. return 1;
  387. if (stat (f, &after) < 0)
  388. return 1;
  389. return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
  390. ]])],
  391. [ac_cv_func_chown_works=yes],
  392. [ac_cv_func_chown_works=no],
  393. [ac_cv_func_chown_works=no])
  394. rm -f conftest.chown
  395. ])
  396. if test $ac_cv_func_chown_works = yes; then
  397. AC_DEFINE(HAVE_CHOWN, 1,
  398. [Define to 1 if your system has a working `chown' function.])
  399. fi
  400. ])# AC_FUNC_CHOWN
  401. # AC_FUNC_CLOSEDIR_VOID
  402. # ---------------------
  403. # Check whether closedir returns void, and #define CLOSEDIR_VOID in
  404. # that case.
  405. AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
  406. [AC_REQUIRE([AC_HEADER_DIRENT])dnl
  407. AC_CACHE_CHECK([whether closedir returns void],
  408. [ac_cv_func_closedir_void],
  409. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
  410. #include <$ac_header_dirent>
  411. #ifndef __cplusplus
  412. int closedir ();
  413. #endif
  414. ],
  415. [[return closedir (opendir (".")) != 0;]])],
  416. [ac_cv_func_closedir_void=no],
  417. [ac_cv_func_closedir_void=yes],
  418. [ac_cv_func_closedir_void=yes])])
  419. if test $ac_cv_func_closedir_void = yes; then
  420. AC_DEFINE(CLOSEDIR_VOID, 1,
  421. [Define to 1 if the `closedir' function returns void instead
  422. of `int'.])
  423. fi
  424. ])
  425. # AC_FUNC_ERROR_AT_LINE
  426. # ---------------------
  427. AN_FUNCTION([error], [AC_FUNC_ERROR_AT_LINE])
  428. AN_FUNCTION([error_at_line], [AC_FUNC_ERROR_AT_LINE])
  429. AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
  430. [AC_LIBSOURCES([error.h, error.c])dnl
  431. AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
  432. [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <error.h>],
  433. [error_at_line (0, 0, "", 0, "an error occurred");])],
  434. [ac_cv_lib_error_at_line=yes],
  435. [ac_cv_lib_error_at_line=no])])
  436. if test $ac_cv_lib_error_at_line = no; then
  437. AC_LIBOBJ(error)
  438. fi
  439. ])
  440. # AU::AM_FUNC_ERROR_AT_LINE
  441. # -------------------------
  442. AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
  443. # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
  444. # -------------------------------------------------------------------------
  445. # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
  446. # IF-FALSE. Use CACHE_VAR.
  447. AC_DEFUN([_AC_FUNC_FNMATCH_IF],
  448. [AC_CACHE_CHECK(
  449. [for working $1 fnmatch],
  450. [$2],
  451. [# Some versions of Solaris, SCO, and the GNU C Library
  452. # have a broken or incompatible fnmatch.
  453. # So we run a test program. If we are cross-compiling, take no chance.
  454. # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
  455. AC_RUN_IFELSE(
  456. [AC_LANG_PROGRAM(
  457. [#include <fnmatch.h>
  458. # define y(a, b, c) (fnmatch (a, b, c) == 0)
  459. # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
  460. ],
  461. [return
  462. (!(y ("a*", "abc", 0)
  463. && n ("d*/*1", "d/s/1", FNM_PATHNAME)
  464. && y ("a\\\\bc", "abc", 0)
  465. && n ("a\\\\bc", "abc", FNM_NOESCAPE)
  466. && y ("*x", ".x", 0)
  467. && n ("*x", ".x", FNM_PERIOD)
  468. && m4_if([$1], [GNU],
  469. [y ("xxXX", "xXxX", FNM_CASEFOLD)
  470. && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
  471. && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
  472. && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
  473. && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
  474. && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
  475. 1)));])],
  476. [$2=yes],
  477. [$2=no],
  478. [$2=cross])])
  479. AS_IF([test $$2 = yes], [$3], [$4])
  480. ])# _AC_FUNC_FNMATCH_IF
  481. # AC_FUNC_FNMATCH
  482. # ---------------
  483. AC_DEFUN([AC_FUNC_FNMATCH],
  484. [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
  485. [AC_DEFINE([HAVE_FNMATCH], 1,
  486. [Define to 1 if your system has a working POSIX `fnmatch'
  487. function.])])
  488. ])# AC_FUNC_FNMATCH
  489. # _AC_LIBOBJ_FNMATCH
  490. # ------------------
  491. # Prepare the replacement of fnmatch.
  492. AC_DEFUN([_AC_LIBOBJ_FNMATCH],
  493. [AC_REQUIRE([AC_C_CONST])dnl
  494. AC_REQUIRE([AC_FUNC_ALLOCA])dnl
  495. AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
  496. AC_CHECK_DECLS([getenv])
  497. AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmempcpy])
  498. AC_CHECK_HEADERS([wchar.h wctype.h])
  499. AC_LIBOBJ([fnmatch])
  500. AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
  501. AC_DEFINE(fnmatch, rpl_fnmatch,
  502. [Define to rpl_fnmatch if the replacement function should be used.])
  503. ])# _AC_LIBOBJ_FNMATCH
  504. # AC_REPLACE_FNMATCH
  505. # ------------------
  506. AC_DEFUN([AC_REPLACE_FNMATCH],
  507. [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
  508. [rm -f "$ac_config_libobj_dir/fnmatch.h"],
  509. [_AC_LIBOBJ_FNMATCH])
  510. ])# AC_REPLACE_FNMATCH
  511. # AC_FUNC_FNMATCH_GNU
  512. # -------------------
  513. AC_DEFUN([AC_FUNC_FNMATCH_GNU],
  514. [AC_REQUIRE([AC_GNU_SOURCE])
  515. _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
  516. [rm -f "$ac_config_libobj_dir/fnmatch.h"],
  517. [_AC_LIBOBJ_FNMATCH])
  518. ])# AC_FUNC_FNMATCH_GNU
  519. # AU::AM_FUNC_FNMATCH
  520. # AU::fp_FUNC_FNMATCH
  521. # -------------------
  522. AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
  523. AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
  524. # AC_FUNC_FSEEKO
  525. # --------------
  526. AN_FUNCTION([ftello], [AC_FUNC_FSEEKO])
  527. AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO])
  528. AC_DEFUN([AC_FUNC_FSEEKO],
  529. [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  530. [ac_cv_sys_largefile_source],
  531. [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
  532. [[#include <sys/types.h> /* for off_t */
  533. #include <stdio.h>]],
  534. [[int (*fp) (FILE *, off_t, int) = fseeko;
  535. return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]])
  536. # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
  537. # in glibc 2.1.3, but that breaks too many other things.
  538. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
  539. if test $ac_cv_sys_largefile_source != unknown; then
  540. AC_DEFINE(HAVE_FSEEKO, 1,
  541. [Define to 1 if fseeko (and presumably ftello) exists and is declared.])
  542. fi
  543. ])# AC_FUNC_FSEEKO
  544. # AC_FUNC_GETGROUPS
  545. # -----------------
  546. # Try to find `getgroups', and check that it works.
  547. # When cross-compiling, assume getgroups is broken.
  548. AN_FUNCTION([getgroups], [AC_FUNC_GETGROUPS])
  549. AC_DEFUN([AC_FUNC_GETGROUPS],
  550. [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
  551. AC_REQUIRE([AC_TYPE_SIZE_T])dnl
  552. AC_CHECK_FUNC(getgroups)
  553. # If we don't yet have getgroups, see if it's in -lbsd.
  554. # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
  555. ac_save_LIBS=$LIBS
  556. if test $ac_cv_func_getgroups = no; then
  557. AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
  558. fi
  559. # Run the program to test the functionality of the system-supplied
  560. # getgroups function only if there is such a function.
  561. if test $ac_cv_func_getgroups = yes; then
  562. AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
  563. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  564. [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
  565. return getgroups (0, 0) == -1;]])],
  566. [ac_cv_func_getgroups_works=yes],
  567. [ac_cv_func_getgroups_works=no],
  568. [ac_cv_func_getgroups_works=no])
  569. ])
  570. else
  571. ac_cv_func_getgroups_works=no
  572. fi
  573. if test $ac_cv_func_getgroups_works = yes; then
  574. AC_DEFINE(HAVE_GETGROUPS, 1,
  575. [Define to 1 if your system has a working `getgroups' function.])
  576. fi
  577. LIBS=$ac_save_LIBS
  578. ])# AC_FUNC_GETGROUPS
  579. # _AC_LIBOBJ_GETLOADAVG
  580. # ---------------------
  581. # Set up the AC_LIBOBJ replacement of `getloadavg'.
  582. m4_define([_AC_LIBOBJ_GETLOADAVG],
  583. [AC_LIBOBJ(getloadavg)
  584. AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.])
  585. # Figure out what our getloadavg.c needs.
  586. ac_have_func=no
  587. AC_CHECK_HEADER(sys/dg_sys_info.h,
  588. [ac_have_func=yes
  589. AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
  590. AC_CHECK_LIB(dgc, dg_sys_info)])
  591. AC_CHECK_HEADER(locale.h)
  592. AC_CHECK_FUNCS(setlocale)
  593. # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
  594. # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
  595. # Irix 4.0.5F has the header but not the library.
  596. if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes \
  597. && test "$ac_cv_lib_kvm_kvm_open" = yes; then
  598. ac_have_func=yes
  599. AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.])
  600. fi
  601. if test $ac_have_func = no; then
  602. AC_CHECK_HEADER(inq_stats/cpustats.h,
  603. [ac_have_func=yes
  604. AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.])
  605. AC_DEFINE(UMAX4_3, 1,
  606. [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
  607. instead of <sys/cpustats.h>.])])
  608. fi
  609. if test $ac_have_func = no; then
  610. AC_CHECK_HEADER(sys/cpustats.h,
  611. [ac_have_func=yes; AC_DEFINE(UMAX)])
  612. fi
  613. if test $ac_have_func = no; then
  614. AC_CHECK_HEADERS(mach/mach.h)
  615. fi
  616. AC_CHECK_HEADERS(nlist.h,
  617. [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
  618. [AC_DEFINE(NLIST_NAME_UNION, 1,
  619. [Define to 1 if your `struct nlist' has an
  620. `n_un' member. Obsolete, depend on
  621. `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
  622. [@%:@include <nlist.h>])
  623. ])dnl
  624. ])# _AC_LIBOBJ_GETLOADAVG
  625. # AC_FUNC_GETLOADAVG
  626. # ------------------
  627. AC_DEFUN([AC_FUNC_GETLOADAVG],
  628. [ac_have_func=no # yes means we've found a way to get the load average.
  629. # Make sure getloadavg.c is where it belongs, at configure-time.
  630. test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
  631. AC_MSG_ERROR([$srcdir/$ac_config_libobj_dir/getloadavg.c is missing])
  632. ac_save_LIBS=$LIBS
  633. # Check for getloadavg, but be sure not to touch the cache variable.
  634. (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
  635. # On HPUX9, an unprivileged user can get load averages through this function.
  636. AC_CHECK_FUNCS(pstat_getdynamic)
  637. # Solaris has libkstat which does not require root.
  638. AC_CHECK_LIB(kstat, kstat_open)
  639. test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
  640. # Some systems with -lutil have (and need) -lkvm as well, some do not.
  641. # On Solaris, -lkvm requires nlist from -lelf, so check that first
  642. # to get the right answer into the cache.
  643. # For kstat on solaris, we need libelf to force the definition of SVR4 below.
  644. if test $ac_have_func = no; then
  645. AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
  646. fi
  647. if test $ac_have_func = no; then
  648. AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
  649. # Check for the 4.4BSD definition of getloadavg.
  650. AC_CHECK_LIB(util, getloadavg,
  651. [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
  652. fi
  653. # Make sure it is really in the library, if we think we found it,
  654. # otherwise set up the replacement function.
  655. AC_CHECK_FUNCS(getloadavg, [],
  656. [_AC_LIBOBJ_GETLOADAVG])
  657. # Some definitions of getloadavg require that the program be installed setgid.
  658. AC_CACHE_CHECK(whether getloadavg requires setgid,
  659. ac_cv_func_getloadavg_setgid,
  660. [AC_EGREP_CPP([Yowza Am I SETGID yet],
  661. [#include "$srcdir/$ac_config_libobj_dir/getloadavg.c"
  662. #ifdef LDAV_PRIVILEGED
  663. Yowza Am I SETGID yet
  664. @%:@endif],
  665. ac_cv_func_getloadavg_setgid=yes,
  666. ac_cv_func_getloadavg_setgid=no)])
  667. if test $ac_cv_func_getloadavg_setgid = yes; then
  668. NEED_SETGID=true
  669. AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
  670. [Define to 1 if the `getloadavg' function needs to be run setuid
  671. or setgid.])
  672. else
  673. NEED_SETGID=false
  674. fi
  675. AC_SUBST(NEED_SETGID)dnl
  676. if test $ac_cv_func_getloadavg_setgid = yes; then
  677. AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
  678. [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
  679. ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
  680. # If we got an error (system does not support symlinks), try without -L.
  681. test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
  682. ac_cv_group_kmem=`AS_ECHO(["$ac_ls_output"]) \
  683. | sed -ne ['s/[ ][ ]*/ /g;
  684. s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
  685. / /s/.* //;p;']`
  686. ])
  687. AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
  688. fi
  689. if test "x$ac_save_LIBS" = x; then
  690. GETLOADAVG_LIBS=$LIBS
  691. else
  692. GETLOADAVG_LIBS=`AS_ECHO(["$LIBS"]) | sed "s|$ac_save_LIBS||"`
  693. fi
  694. LIBS=$ac_save_LIBS
  695. AC_SUBST(GETLOADAVG_LIBS)dnl
  696. ])# AC_FUNC_GETLOADAVG
  697. # AU::AC_GETLOADAVG
  698. # -----------------
  699. AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
  700. # AC_FUNC_GETMNTENT
  701. # -----------------
  702. AN_FUNCTION([getmntent], [AC_FUNC_GETMNTENT])
  703. AC_DEFUN([AC_FUNC_GETMNTENT],
  704. [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
  705. # -lseq on Dynix/PTX, -lgen on Unixware.
  706. AC_SEARCH_LIBS(getmntent, [sun seq gen],
  707. [ac_cv_func_getmntent=yes
  708. AC_DEFINE([HAVE_GETMNTENT], 1,
  709. [Define to 1 if you have the `getmntent' function.])],
  710. [ac_cv_func_getmntent=no])
  711. ])
  712. # AC_FUNC_GETPGRP
  713. # ---------------
  714. # Figure out whether getpgrp requires zero arguments.
  715. AC_DEFUN([AC_FUNC_GETPGRP],
  716. [AC_CACHE_CHECK(whether getpgrp requires zero arguments,
  717. ac_cv_func_getpgrp_void,
  718. [# Use it with a single arg.
  719. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
  720. [ac_cv_func_getpgrp_void=no],
  721. [ac_cv_func_getpgrp_void=yes])
  722. ])
  723. if test $ac_cv_func_getpgrp_void = yes; then
  724. AC_DEFINE(GETPGRP_VOID, 1,
  725. [Define to 1 if the `getpgrp' function requires zero arguments.])
  726. fi
  727. ])# AC_FUNC_GETPGRP
  728. # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
  729. # -------------------------------------
  730. # When cross-compiling, be pessimistic so we will end up using the
  731. # replacement version of lstat that checks for trailing slashes and
  732. # calls lstat a second time when necessary.
  733. AN_FUNCTION([lstat], [AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
  734. AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
  735. [AC_CACHE_CHECK(
  736. [whether lstat correctly handles trailing slash],
  737. [ac_cv_func_lstat_dereferences_slashed_symlink],
  738. [rm -f conftest.sym conftest.file
  739. echo >conftest.file
  740. if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
  741. AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  742. [struct stat sbuf;
  743. /* Linux will dereference the symlink and fail, as required by POSIX.
  744. That is better in the sense that it means we will not
  745. have to compile and use the lstat wrapper. */
  746. return lstat ("conftest.sym/", &sbuf) == 0;])],
  747. [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
  748. [ac_cv_func_lstat_dereferences_slashed_symlink=no],
  749. [ac_cv_func_lstat_dereferences_slashed_symlink=no])
  750. else
  751. # If the `ln -s' command failed, then we probably don't even
  752. # have an lstat function.
  753. ac_cv_func_lstat_dereferences_slashed_symlink=no
  754. fi
  755. rm -f conftest.sym conftest.file
  756. ])
  757. test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
  758. AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
  759. [Define to 1 if `lstat' dereferences a symlink specified
  760. with a trailing slash.])
  761. if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then
  762. AC_LIBOBJ([lstat])
  763. fi
  764. ])
  765. # _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)
  766. # ------------------------------------
  767. # If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
  768. AC_DEFUN([_AC_FUNC_MALLOC_IF],
  769. [AC_REQUIRE([AC_HEADER_STDC])dnl
  770. AC_CHECK_HEADERS(stdlib.h)
  771. AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
  772. [AC_RUN_IFELSE(
  773. [AC_LANG_PROGRAM(
  774. [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
  775. # include <stdlib.h>
  776. #else
  777. char *malloc ();
  778. #endif
  779. ]],
  780. [return ! malloc (0);])],
  781. [ac_cv_func_malloc_0_nonnull=yes],
  782. [ac_cv_func_malloc_0_nonnull=no],
  783. [ac_cv_func_malloc_0_nonnull=no])])
  784. AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
  785. ])# _AC_FUNC_MALLOC_IF
  786. # AC_FUNC_MALLOC
  787. # --------------
  788. # Report whether `malloc (0)' properly handled, and replace malloc if
  789. # needed.
  790. AN_FUNCTION([malloc], [AC_FUNC_MALLOC])
  791. AC_DEFUN([AC_FUNC_MALLOC],
  792. [_AC_FUNC_MALLOC_IF(
  793. [AC_DEFINE([HAVE_MALLOC], 1,
  794. [Define to 1 if your system has a GNU libc compatible `malloc'
  795. function, and to 0 otherwise.])],
  796. [AC_DEFINE([HAVE_MALLOC], 0)
  797. AC_LIBOBJ(malloc)
  798. AC_DEFINE([malloc], [rpl_malloc],
  799. [Define to rpl_malloc if the replacement function should be used.])])
  800. ])# AC_FUNC_MALLOC
  801. # AC_FUNC_MBRTOWC
  802. # ---------------
  803. AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])
  804. AC_DEFUN([AC_FUNC_MBRTOWC],
  805. [
  806. AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
  807. ac_cv_func_mbrtowc,
  808. [AC_LINK_IFELSE(
  809. [AC_LANG_PROGRAM(
  810. [[@%:@include <wchar.h>]],
  811. [[wchar_t wc;
  812. char const s[] = "";
  813. size_t n = 1;
  814. mbstate_t state;
  815. return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
  816. ac_cv_func_mbrtowc=yes,
  817. ac_cv_func_mbrtowc=no)])
  818. if test $ac_cv_func_mbrtowc = yes; then
  819. AC_DEFINE([HAVE_MBRTOWC], 1,
  820. [Define to 1 if mbrtowc and mbstate_t are properly declared.])
  821. fi
  822. ])
  823. # AC_FUNC_MEMCMP
  824. # --------------
  825. AC_DEFUN([AC_FUNC_MEMCMP],
  826. [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
  827. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
  828. /* Some versions of memcmp are not 8-bit clean. */
  829. char c0 = '\100', c1 = '\200', c2 = '\201';
  830. if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
  831. return 1;
  832. /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
  833. or more and with at least one buffer not starting on a 4-byte boundary.
  834. William Lewis provided this test program. */
  835. {
  836. char foo[21];
  837. char bar[21];
  838. int i;
  839. for (i = 0; i < 4; i++)
  840. {
  841. char *a = foo + i;
  842. char *b = bar + i;
  843. strcpy (a, "--------01111111");
  844. strcpy (b, "--------10000000");
  845. if (memcmp (a, b, 16) >= 0)
  846. return 1;
  847. }
  848. return 0;
  849. }
  850. ]])],
  851. [ac_cv_func_memcmp_working=yes],
  852. [ac_cv_func_memcmp_working=no],
  853. [ac_cv_func_memcmp_working=no])])
  854. test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
  855. ])# AC_FUNC_MEMCMP
  856. # AC_FUNC_MKTIME
  857. # --------------
  858. AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
  859. AC_DEFUN([AC_FUNC_MKTIME],
  860. [AC_REQUIRE([AC_HEADER_TIME])dnl
  861. AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
  862. AC_CHECK_FUNCS_ONCE(alarm)
  863. AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
  864. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  865. [[/* Test program from Paul Eggert and Tony Leneis. */
  866. #ifdef TIME_WITH_SYS_TIME
  867. # include <sys/time.h>
  868. # include <time.h>
  869. #else
  870. # ifdef HAVE_SYS_TIME_H
  871. # include <sys/time.h>
  872. # else
  873. # include <time.h>
  874. # endif
  875. #endif
  876. #include <limits.h>
  877. #include <stdlib.h>
  878. #ifdef HAVE_UNISTD_H
  879. # include <unistd.h>
  880. #endif
  881. #ifndef HAVE_ALARM
  882. # define alarm(X) /* empty */
  883. #endif
  884. /* Work around redefinition to rpl_putenv by other config tests. */
  885. #undef putenv
  886. static time_t time_t_max;
  887. static time_t time_t_min;
  888. /* Values we'll use to set the TZ environment variable. */
  889. static const char *tz_strings[] = {
  890. (const char *) 0, "TZ=GMT0", "TZ=JST-9",
  891. "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
  892. };
  893. #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
  894. /* Return 0 if mktime fails to convert a date in the spring-forward gap.
  895. Based on a problem report from Andreas Jaeger. */
  896. static int
  897. spring_forward_gap ()
  898. {
  899. /* glibc (up to about 1998-10-07) failed this test. */
  900. struct tm tm;
  901. /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
  902. instead of "TZ=America/Vancouver" in order to detect the bug even
  903. on systems that don't support the Olson extension, or don't have the
  904. full zoneinfo tables installed. */
  905. putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
  906. tm.tm_year = 98;
  907. tm.tm_mon = 3;
  908. tm.tm_mday = 5;
  909. tm.tm_hour = 2;
  910. tm.tm_min = 0;
  911. tm.tm_sec = 0;
  912. tm.tm_isdst = -1;
  913. return mktime (&tm) != (time_t) -1;
  914. }
  915. static int
  916. mktime_test1 (time_t now)
  917. {
  918. struct tm *lt;
  919. return ! (lt = localtime (&now)) || mktime (lt) == now;
  920. }
  921. static int
  922. mktime_test (time_t now)
  923. {
  924. return (mktime_test1 (now)
  925. && mktime_test1 ((time_t) (time_t_max - now))
  926. && mktime_test1 ((time_t) (time_t_min + now)));
  927. }
  928. static int
  929. irix_6_4_bug ()
  930. {
  931. /* Based on code from Ariel Faigon. */
  932. struct tm tm;
  933. tm.tm_year = 96;
  934. tm.tm_mon = 3;
  935. tm.tm_mday = 0;
  936. tm.tm_hour = 0;
  937. tm.tm_min = 0;
  938. tm.tm_sec = 0;
  939. tm.tm_isdst = -1;
  940. mktime (&tm);
  941. return tm.tm_mon == 2 && tm.tm_mday == 31;
  942. }
  943. static int
  944. bigtime_test (int j)
  945. {
  946. struct tm tm;
  947. time_t now;
  948. tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
  949. now = mktime (&tm);
  950. if (now != (time_t) -1)
  951. {
  952. struct tm *lt = localtime (&now);
  953. if (! (lt
  954. && lt->tm_year == tm.tm_year
  955. && lt->tm_mon == tm.tm_mon
  956. && lt->tm_mday == tm.tm_mday
  957. && lt->tm_hour == tm.tm_hour
  958. && lt->tm_min == tm.tm_min
  959. && lt->tm_sec == tm.tm_sec
  960. && lt->tm_yday == tm.tm_yday
  961. && lt->tm_wday == tm.tm_wday
  962. && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
  963. == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
  964. return 0;
  965. }
  966. return 1;
  967. }
  968. static int
  969. year_2050_test ()
  970. {
  971. /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
  972. ignoring leap seconds. */
  973. unsigned long int answer = 2527315200UL;
  974. struct tm tm;
  975. time_t t;
  976. tm.tm_year = 2050 - 1900;
  977. tm.tm_mon = 2 - 1;
  978. tm.tm_mday = 1;
  979. tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
  980. tm.tm_isdst = -1;
  981. /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
  982. instead of "TZ=America/Vancouver" in order to detect the bug even
  983. on systems that don't support the Olson extension, or don't have the
  984. full zoneinfo tables installed. */
  985. putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
  986. t = mktime (&tm);
  987. /* Check that the result is either a failure, or close enough
  988. to the correct answer that we can assume the discrepancy is
  989. due to leap seconds. */
  990. return (t == (time_t) -1
  991. || (0 < t && answer - 120 <= t && t <= answer + 120));
  992. }
  993. int
  994. main ()
  995. {
  996. time_t t, delta;
  997. int i, j;
  998. /* This test makes some buggy mktime implementations loop.
  999. Give up after 60 seconds; a mktime slower than that
  1000. isn't worth using anyway. */
  1001. alarm (60);
  1002. for (;;)
  1003. {
  1004. t = (time_t_max << 1) + 1;
  1005. if (t <= time_t_max)
  1006. break;
  1007. time_t_max = t;
  1008. }
  1009. time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
  1010. delta = time_t_max / 997; /* a suitable prime number */
  1011. for (i = 0; i < N_STRINGS; i++)
  1012. {
  1013. if (tz_strings[i])
  1014. putenv ((char*) tz_strings[i]);
  1015. for (t = 0; t <= time_t_max - delta; t += delta)
  1016. if (! mktime_test (t))
  1017. return 1;
  1018. if (! (mktime_test ((time_t) 1)
  1019. && mktime_test ((time_t) (60 * 60))
  1020. && mktime_test ((time_t) (60 * 60 * 24))))
  1021. return 1;
  1022. for (j = 1; ; j <<= 1)
  1023. if (! bigtime_test (j))
  1024. return 1;
  1025. else if (INT_MAX / 2 < j)
  1026. break;
  1027. if (! bigtime_test (INT_MAX))
  1028. return 1;
  1029. }
  1030. return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
  1031. }]])],
  1032. [ac_cv_func_working_mktime=yes],
  1033. [ac_cv_func_working_mktime=no],
  1034. [ac_cv_func_working_mktime=no])])
  1035. if test $ac_cv_func_working_mktime = no; then
  1036. AC_LIBOBJ([mktime])
  1037. fi
  1038. ])# AC_FUNC_MKTIME
  1039. # AU::AM_FUNC_MKTIME
  1040. # ------------------
  1041. AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
  1042. # AC_FUNC_MMAP
  1043. # ------------
  1044. AN_FUNCTION([mmap], [AC_FUNC_MMAP])
  1045. AC_DEFUN([AC_FUNC_MMAP],
  1046. [AC_CHECK_HEADERS_ONCE([stdlib.h unistd.h sys/param.h])
  1047. AC_CHECK_FUNCS([getpagesize])
  1048. AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
  1049. [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
  1050. [[/* malloc might have been renamed as rpl_malloc. */
  1051. #undef malloc
  1052. /* Thanks to Mike Haertel and Jim Avera for this test.
  1053. Here is a matrix of mmap possibilities:
  1054. mmap private not fixed
  1055. mmap private fixed at somewhere currently unmapped
  1056. mmap private fixed at somewhere already mapped
  1057. mmap shared not fixed
  1058. mmap shared fixed at somewhere currently unmapped
  1059. mmap shared fixed at somewhere already mapped
  1060. For private mappings, we should verify that changes cannot be read()
  1061. back from the file, nor mmap's back from the file at a different
  1062. address. (There have been systems where private was not correctly
  1063. implemented like the infamous i386 svr4.0, and systems where the
  1064. VM page cache was not coherent with the file system buffer cache
  1065. like early versions of FreeBSD and possibly contemporary NetBSD.)
  1066. For shared mappings, we should conversely verify that changes get
  1067. propagated back to all the places they're supposed to be.
  1068. Grep wants private fixed already mapped.
  1069. The main things grep needs to know about mmap are:
  1070. * does it exist and is it safe to write into the mmap'd area
  1071. * how to use it (BSD variants) */
  1072. #include <fcntl.h>
  1073. #include <sys/mman.h>
  1074. #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
  1075. char *malloc ();
  1076. #endif
  1077. /* This mess was copied from the GNU getpagesize.h. */
  1078. #ifndef HAVE_GETPAGESIZE
  1079. # ifdef _SC_PAGESIZE
  1080. # define getpagesize() sysconf(_SC_PAGESIZE)
  1081. # else /* no _SC_PAGESIZE */
  1082. # ifdef HAVE_SYS_PARAM_H
  1083. # include <sys/param.h>
  1084. # ifdef EXEC_PAGESIZE
  1085. # define getpagesize() EXEC_PAGESIZE
  1086. # else /* no EXEC_PAGESIZE */
  1087. # ifdef NBPG
  1088. # define getpagesize() NBPG * CLSIZE
  1089. # ifndef CLSIZE
  1090. # define CLSIZE 1
  1091. # endif /* no CLSIZE */
  1092. # else /* no NBPG */
  1093. # ifdef NBPC
  1094. # define getpagesize() NBPC
  1095. # else /* no NBPC */
  1096. # ifdef PAGESIZE
  1097. # define getpagesize() PAGESIZE
  1098. # endif /* PAGESIZE */
  1099. # endif /* no NBPC */
  1100. # endif /* no NBPG */
  1101. # endif /* no EXEC_PAGESIZE */
  1102. # else /* no HAVE_SYS_PARAM_H */
  1103. # define getpagesize() 8192 /* punt totally */
  1104. # endif /* no HAVE_SYS_PARAM_H */
  1105. # endif /* no _SC_PAGESIZE */
  1106. #endif /* no HAVE_GETPAGESIZE */
  1107. int
  1108. main ()
  1109. {
  1110. char *data, *data2, *data3;
  1111. const char *cdata2;
  1112. int i, pagesize;
  1113. int fd, fd2;
  1114. pagesize = getpagesize ();
  1115. /* First, make a file with some known garbage in it. */
  1116. data = (char *) malloc (pagesize);
  1117. if (!data)
  1118. return 1;
  1119. for (i = 0; i < pagesize; ++i)
  1120. *(data + i) = rand ();
  1121. umask (0);
  1122. fd = creat ("conftest.mmap", 0600);
  1123. if (fd < 0)
  1124. return 2;
  1125. if (write (fd, data, pagesize) != pagesize)
  1126. return 3;
  1127. close (fd);
  1128. /* Next, check that the tail of a page is zero-filled. File must have
  1129. non-zero length, otherwise we risk SIGBUS for entire page. */
  1130. fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
  1131. if (fd2 < 0)
  1132. return 4;
  1133. cdata2 = "";
  1134. if (write (fd2, cdata2, 1) != 1)
  1135. return 5;
  1136. data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
  1137. if (data2 == MAP_FAILED)
  1138. return 6;
  1139. for (i = 0; i < pagesize; ++i)
  1140. if (*(data2 + i))
  1141. return 7;
  1142. close (fd2);
  1143. if (munmap (data2, pagesize))
  1144. return 8;
  1145. /* Next, try to mmap the file at a fixed address which already has
  1146. something else allocated at it. If we can, also make sure that
  1147. we see the same garbage. */
  1148. fd = open ("conftest.mmap", O_RDWR);
  1149. if (fd < 0)
  1150. return 9;
  1151. if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
  1152. MAP_PRIVATE | MAP_FIXED, fd, 0L))
  1153. return 10;
  1154. for (i = 0; i < pagesize; ++i)
  1155. if (*(data + i) != *(data2 + i))
  1156. return 11;
  1157. /* Finally, make sure that changes to the mapped area do not
  1158. percolate back to the file as seen by read(). (This is a bug on
  1159. some variants of i386 svr4.0.) */
  1160. for (i = 0; i < pagesize; ++i)
  1161. *(data2 + i) = *(data2 + i) + 1;
  1162. data3 = (char *) malloc (pagesize);
  1163. if (!data3)
  1164. return 12;
  1165. if (read (fd, data3, pagesize) != pagesize)
  1166. return 13;
  1167. for (i = 0; i < pagesize; ++i)
  1168. if (*(data + i) != *(data3 + i))
  1169. return 14;
  1170. close (fd);
  1171. return 0;
  1172. }]])],
  1173. [ac_cv_func_mmap_fixed_mapped=yes],
  1174. [ac_cv_func_mmap_fixed_mapped=no],
  1175. [ac_cv_func_mmap_fixed_mapped=no])])
  1176. if test $ac_cv_func_mmap_fixed_mapped = yes; then
  1177. AC_DEFINE([HAVE_MMAP], [1],
  1178. [Define to 1 if you have a working `mmap' system call.])
  1179. fi
  1180. rm -f conftest.mmap conftest.txt
  1181. ])# AC_FUNC_MMAP
  1182. # AU::AC_MMAP
  1183. # -----------
  1184. AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
  1185. # AC_FUNC_OBSTACK
  1186. # ---------------
  1187. # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
  1188. AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])
  1189. AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])
  1190. AC_DEFUN([AC_FUNC_OBSTACK],
  1191. [AC_LIBSOURCES([obstack.h, obstack.c])dnl
  1192. AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
  1193. [AC_LINK_IFELSE(
  1194. [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
  1195. [@%:@include "obstack.h"]],
  1196. [[struct obstack mem;
  1197. @%:@define obstack_chunk_alloc malloc
  1198. @%:@define obstack_chunk_free free
  1199. obstack_init (&mem);
  1200. obstack_free (&mem, 0);]])],
  1201. [ac_cv_func_obstack=yes],
  1202. [ac_cv_func_obstack=no])])
  1203. if test $ac_cv_func_obstack = yes; then
  1204. AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
  1205. else
  1206. AC_LIBOBJ(obstack)
  1207. fi
  1208. ])# AC_FUNC_OBSTACK
  1209. # AU::AM_FUNC_OBSTACK
  1210. # -------------------
  1211. AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
  1212. # _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
  1213. # -------------------------------------
  1214. # If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
  1215. AC_DEFUN([_AC_FUNC_REALLOC_IF],
  1216. [AC_REQUIRE([AC_HEADER_STDC])dnl
  1217. AC_CHECK_HEADERS(stdlib.h)
  1218. AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
  1219. [AC_RUN_IFELSE(
  1220. [AC_LANG_PROGRAM(
  1221. [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
  1222. # include <stdlib.h>
  1223. #else
  1224. char *realloc ();
  1225. #endif
  1226. ]],
  1227. [return ! realloc (0, 0);])],
  1228. [ac_cv_func_realloc_0_nonnull=yes],
  1229. [ac_cv_func_realloc_0_nonnull=no],
  1230. [ac_cv_func_realloc_0_nonnull=no])])
  1231. AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
  1232. ])# AC_FUNC_REALLOC
  1233. # AC_FUNC_REALLOC
  1234. # ---------------
  1235. # Report whether `realloc (0, 0)' is properly handled, and replace realloc if
  1236. # needed.
  1237. AN_FUNCTION([realloc], [AC_FUNC_REALLOC])
  1238. AC_DEFUN([AC_FUNC_REALLOC],
  1239. [_AC_FUNC_REALLOC_IF(
  1240. [AC_DEFINE([HAVE_REALLOC], 1,
  1241. [Define to 1 if your system has a GNU libc compatible `realloc'
  1242. function, and to 0 otherwise.])],
  1243. [AC_DEFINE([HAVE_REALLOC], 0)
  1244. AC_LIBOBJ([realloc])
  1245. AC_DEFINE([realloc], [rpl_realloc],
  1246. [Define to rpl_realloc if the replacement function should be used.])])
  1247. ])# AC_FUNC_REALLOC
  1248. # AC_FUNC_SELECT_ARGTYPES
  1249. # -----------------------
  1250. # Determine the correct type to be passed to each of the `select'
  1251. # function's arguments, and define those types in `SELECT_TYPE_ARG1',
  1252. # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
  1253. AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
  1254. [AC_CHECK_HEADERS(sys/select.h sys/socket.h)
  1255. AC_CACHE_CHECK([types of arguments for select],
  1256. [ac_cv_func_select_args],
  1257. [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
  1258. for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
  1259. for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
  1260. AC_COMPILE_IFELSE(
  1261. [AC_LANG_PROGRAM(
  1262. [AC_INCLUDES_DEFAULT
  1263. #ifdef HAVE_SYS_SELECT_H
  1264. # include <sys/select.h>
  1265. #endif
  1266. #ifdef HAVE_SYS_SOCKET_H
  1267. # include <sys/socket.h>
  1268. #endif
  1269. ],
  1270. [extern int select ($ac_arg1,
  1271. $ac_arg234, $ac_arg234, $ac_arg234,
  1272. $ac_arg5);])],
  1273. [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
  1274. done
  1275. done
  1276. done
  1277. # Provide a safe default value.
  1278. : "${ac_cv_func_select_args=int,int *,struct timeval *}"
  1279. ])
  1280. ac_save_IFS=$IFS; IFS=','
  1281. set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
  1282. IFS=$ac_save_IFS
  1283. shift
  1284. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
  1285. [Define to the type of arg 1 for `select'.])
  1286. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
  1287. [Define to the type of args 2, 3 and 4 for `select'.])
  1288. AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
  1289. [Define to the type of arg 5 for `select'.])
  1290. rm -f conftest*
  1291. ])# AC_FUNC_SELECT_ARGTYPES
  1292. # AC_FUNC_SETPGRP
  1293. # ---------------
  1294. AC_DEFUN([AC_FUNC_SETPGRP],
  1295. [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
  1296. [AC_RUN_IFELSE(
  1297. [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  1298. [/* If this system has a BSD-style setpgrp which takes arguments,
  1299. setpgrp(1, 1) will fail with ESRCH and return -1, in that case
  1300. exit successfully. */
  1301. return setpgrp (1,1) != -1;])],
  1302. [ac_cv_func_setpgrp_void=no],
  1303. [ac_cv_func_setpgrp_void=yes],
  1304. [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])
  1305. if test $ac_cv_func_setpgrp_void = yes; then
  1306. AC_DEFINE(SETPGRP_VOID, 1,
  1307. [Define to 1 if the `setpgrp' function takes no argument.])
  1308. fi
  1309. ])# AC_FUNC_SETPGRP
  1310. # _AC_FUNC_STAT(STAT | LSTAT)
  1311. # ---------------------------
  1312. # Determine whether stat or lstat have the bug that it succeeds when
  1313. # given the zero-length file name argument. The stat and lstat from
  1314. # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
  1315. #
  1316. # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
  1317. # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
  1318. # function.
  1319. m4_define([_AC_FUNC_STAT],
  1320. [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
  1321. AC_CACHE_CHECK([whether $1 accepts an empty string],
  1322. [ac_cv_func_$1_empty_string_bug],
  1323. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  1324. [[struct stat sbuf;
  1325. return $1 ("", &sbuf) == 0;]])],
  1326. [ac_cv_func_$1_empty_string_bug=no],
  1327. [ac_cv_func_$1_empty_string_bug=yes],
  1328. [ac_cv_func_$1_empty_string_bug=yes])])
  1329. if test $ac_cv_func_$1_empty_string_bug = yes; then
  1330. AC_LIBOBJ([$1])
  1331. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
  1332. [Define to 1 if `$1' has the bug that it succeeds when
  1333. given the zero-length file name argument.])
  1334. fi
  1335. ])# _AC_FUNC_STAT
  1336. # AC_FUNC_STAT & AC_FUNC_LSTAT
  1337. # ----------------------------
  1338. AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
  1339. AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
  1340. # _AC_LIBOBJ_STRTOD
  1341. # -----------------
  1342. m4_define([_AC_LIBOBJ_STRTOD],
  1343. [AC_LIBOBJ(strtod)
  1344. AC_CHECK_FUNC(pow)
  1345. if test $ac_cv_func_pow = no; then
  1346. AC_CHECK_LIB(m, pow,
  1347. [POW_LIB=-lm],
  1348. [AC_MSG_WARN([cannot find library containing definition of pow])])
  1349. fi
  1350. ])# _AC_LIBOBJ_STRTOD
  1351. # AC_FUNC_STRTOD
  1352. # --------------
  1353. AN_FUNCTION([strtod], [AC_FUNC_STRTOD])
  1354. AC_DEFUN([AC_FUNC_STRTOD],
  1355. [AC_SUBST(POW_LIB)dnl
  1356. AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
  1357. [AC_RUN_IFELSE([AC_LANG_SOURCE([[
  1358. ]AC_INCLUDES_DEFAULT[
  1359. #ifndef strtod
  1360. double strtod ();
  1361. #endif
  1362. int
  1363. main()
  1364. {
  1365. {
  1366. /* Some versions of Linux strtod mis-parse strings with leading '+'. */
  1367. char *string = " +69";
  1368. char *term;
  1369. double value;
  1370. value = strtod (string, &term);
  1371. if (value != 69 || term != (string + 4))
  1372. return 1;
  1373. }
  1374. {
  1375. /* Under Solaris 2.4, strtod returns the wrong value for the
  1376. terminating character under some conditions. */
  1377. char *string = "NaN";
  1378. char *term;
  1379. strtod (string, &term);
  1380. if (term != string && *(term - 1) == 0)
  1381. return 1;
  1382. }
  1383. return 0;
  1384. }
  1385. ]])],
  1386. ac_cv_func_strtod=yes,
  1387. ac_cv_func_strtod=no,
  1388. ac_cv_func_strtod=no)])
  1389. if test $ac_cv_func_strtod = no; then
  1390. _AC_LIBOBJ_STRTOD
  1391. fi
  1392. ])
  1393. # AC_FUNC_STRTOLD
  1394. # ---------------
  1395. AC_DEFUN([AC_FUNC_STRTOLD],
  1396. [
  1397. AC_CACHE_CHECK([whether strtold conforms to C99],
  1398. [ac_cv_func_strtold],
  1399. [AC_COMPILE_IFELSE(
  1400. [AC_LANG_PROGRAM(
  1401. [[/* On HP-UX before 11.23, strtold returns a struct instead of
  1402. long double. Reject implementations like that, by requiring
  1403. compatibility with the C99 prototype. */
  1404. # include <stdlib.h>
  1405. static long double (*p) (char const *, char **) = strtold;
  1406. static long double
  1407. test (char const *nptr, char **endptr)
  1408. {
  1409. long double r;
  1410. r = strtold (nptr, endptr);
  1411. return r;
  1412. }]],
  1413. [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
  1414. [ac_cv_func_strtold=yes],
  1415. [ac_cv_func_strtold=no])])
  1416. if test $ac_cv_func_strtold = yes; then
  1417. AC_DEFINE([HAVE_STRTOLD], 1,
  1418. [Define to 1 if strtold exists and conforms to C99.])
  1419. fi
  1420. ])# AC_FUNC_STRTOLD
  1421. # AU::AM_FUNC_STRTOD
  1422. # ------------------
  1423. AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
  1424. # AC_FUNC_STRERROR_R
  1425. # ------------------
  1426. AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])
  1427. AC_DEFUN([AC_FUNC_STRERROR_R],
  1428. [AC_CHECK_DECLS([strerror_r])
  1429. AC_CHECK_FUNCS([strerror_r])
  1430. AC_CACHE_CHECK([whether strerror_r returns char *],
  1431. ac_cv_func_strerror_r_char_p,
  1432. [
  1433. ac_cv_func_strerror_r_char_p=no
  1434. if test $ac_cv_have_decl_strerror_r = yes; then
  1435. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  1436. [[
  1437. char buf[100];
  1438. char x = *strerror_r (0, buf, sizeof buf);
  1439. char *p = strerror_r (0, buf, sizeof buf);
  1440. return !p || x;
  1441. ]])],
  1442. ac_cv_func_strerror_r_char_p=yes)
  1443. else
  1444. # strerror_r is not declared. Choose between
  1445. # systems that have relatively inaccessible declarations for the
  1446. # function. BeOS and DEC UNIX 4.0 fall in this category, but the
  1447. # former has a strerror_r that returns char*, while the latter
  1448. # has a strerror_r that returns `int'.
  1449. # This test should segfault on the DEC system.
  1450. AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
  1451. extern char *strerror_r ();],
  1452. [[char buf[100];
  1453. char x = *strerror_r (0, buf, sizeof buf);
  1454. return ! isalpha (x);]])],
  1455. ac_cv_func_strerror_r_char_p=yes, , :)
  1456. fi
  1457. ])
  1458. if test $ac_cv_func_strerror_r_char_p = yes; then
  1459. AC_DEFINE([STRERROR_R_CHAR_P], 1,
  1460. [Define to 1 if strerror_r returns char *.])
  1461. fi
  1462. ])# AC_FUNC_STRERROR_R
  1463. # AC_FUNC_STRFTIME
  1464. # ----------------
  1465. AC_DEFUN([AC_FUNC_STRFTIME],
  1466. [AC_CHECK_FUNCS(strftime, [],
  1467. [# strftime is in -lintl on SCO UNIX.
  1468. AC_CHECK_LIB(intl, strftime,
  1469. [AC_DEFINE(HAVE_STRFTIME)
  1470. LIBS="-lintl $LIBS"])])dnl
  1471. ])# AC_FUNC_STRFTIME
  1472. # AC_FUNC_STRNLEN
  1473. # ---------------
  1474. AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
  1475. AC_DEFUN([AC_FUNC_STRNLEN],
  1476. [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
  1477. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  1478. AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
  1479. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
  1480. #define S "foobar"
  1481. #define S_LEN (sizeof S - 1)
  1482. /* At least one implementation is buggy: that of AIX 4.3 would
  1483. give strnlen (S, 1) == 3. */
  1484. int i;
  1485. for (i = 0; i < S_LEN + 1; ++i)
  1486. {
  1487. int expected = i <= S_LEN ? i : S_LEN;
  1488. if (strnlen (S, i) != expected)
  1489. return 1;
  1490. }
  1491. return 0;
  1492. ]])],
  1493. [ac_cv_func_strnlen_working=yes],
  1494. [ac_cv_func_strnlen_working=no],
  1495. [# Guess no on AIX systems, yes otherwise.
  1496. case "$host_os" in
  1497. aix*) ac_cv_func_strnlen_working=no;;
  1498. *) ac_cv_func_strnlen_working=yes;;
  1499. esac])])
  1500. test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
  1501. ])# AC_FUNC_STRNLEN
  1502. # AC_FUNC_SETVBUF_REVERSED
  1503. # ------------------------
  1504. AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
  1505. [AC_DIAGNOSE([obsolete],
  1506. [The macro `$0' is obsolete. Remove it and all references to SETVBUF_REVERSED.])dnl
  1507. AC_CACHE_VAL([ac_cv_func_setvbuf_reversed], [ac_cv_func_setvbuf_reversed=no])
  1508. ])# AC_FUNC_SETVBUF_REVERSED
  1509. # AU::AC_SETVBUF_REVERSED
  1510. # -----------------------
  1511. AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
  1512. # AC_FUNC_STRCOLL
  1513. # ---------------
  1514. AN_FUNCTION([strcoll], [AC_FUNC_STRCOLL])
  1515. AC_DEFUN([AC_FUNC_STRCOLL],
  1516. [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
  1517. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  1518. [[return (strcoll ("abc", "def") >= 0 ||
  1519. strcoll ("ABC", "DEF") >= 0 ||
  1520. strcoll ("123", "456") >= 0)]])],
  1521. ac_cv_func_strcoll_works=yes,
  1522. ac_cv_func_strcoll_works=no,
  1523. ac_cv_func_strcoll_works=no)])
  1524. if test $ac_cv_func_strcoll_works = yes; then
  1525. AC_DEFINE(HAVE_STRCOLL, 1,
  1526. [Define to 1 if you have the `strcoll' function and it is properly
  1527. defined.])
  1528. fi
  1529. ])# AC_FUNC_STRCOLL
  1530. # AU::AC_STRCOLL
  1531. # --------------
  1532. AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
  1533. # AC_FUNC_UTIME_NULL
  1534. # ------------------
  1535. AC_DEFUN([AC_FUNC_UTIME_NULL],
  1536. [AC_CHECK_HEADERS_ONCE(utime.h)
  1537. AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
  1538. [rm -f conftest.data; >conftest.data
  1539. # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
  1540. AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
  1541. #ifdef HAVE_UTIME_H
  1542. # include <utime.h>
  1543. #endif],
  1544. [[struct stat s, t;
  1545. return ! (stat ("conftest.data", &s) == 0
  1546. && utime ("conftest.data", 0) == 0
  1547. && stat ("conftest.data", &t) == 0
  1548. && t.st_mtime >= s.st_mtime
  1549. && t.st_mtime - s.st_mtime < 120);]])],
  1550. ac_cv_func_utime_null=yes,
  1551. ac_cv_func_utime_null=no,
  1552. ac_cv_func_utime_null='guessing yes')])
  1553. if test "x$ac_cv_func_utime_null" != xno; then
  1554. ac_cv_func_utime_null=yes
  1555. AC_DEFINE(HAVE_UTIME_NULL, 1,
  1556. [Define to 1 if `utime(file, NULL)' sets file's timestamp to the
  1557. present.])
  1558. fi
  1559. rm -f conftest.data
  1560. ])# AC_FUNC_UTIME_NULL
  1561. # AU::AC_UTIME_NULL
  1562. # -----------------
  1563. AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
  1564. # AC_FUNC_FORK
  1565. # ------------
  1566. AN_FUNCTION([fork], [AC_FUNC_FORK])
  1567. AN_FUNCTION([vfork], [AC_FUNC_FORK])
  1568. AC_DEFUN([AC_FUNC_FORK],
  1569. [AC_REQUIRE([AC_TYPE_PID_T])dnl
  1570. AC_CHECK_HEADERS(vfork.h)
  1571. AC_CHECK_FUNCS(fork vfork)
  1572. if test "x$ac_cv_func_fork" = xyes; then
  1573. _AC_FUNC_FORK
  1574. else
  1575. ac_cv_func_fork_works=$ac_cv_func_fork
  1576. fi
  1577. if test "x$ac_cv_func_fork_works" = xcross; then
  1578. case $host in
  1579. *-*-amigaos* | *-*-msdosdjgpp*)
  1580. # Override, as these systems have only a dummy fork() stub
  1581. ac_cv_func_fork_works=no
  1582. ;;
  1583. *)
  1584. ac_cv_func_fork_works=yes
  1585. ;;
  1586. esac
  1587. AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
  1588. fi
  1589. ac_cv_func_vfork_works=$ac_cv_func_vfork
  1590. if test "x$ac_cv_func_vfork" = xyes; then
  1591. _AC_FUNC_VFORK
  1592. fi;
  1593. if test "x$ac_cv_func_fork_works" = xcross; then
  1594. ac_cv_func_vfork_works=$ac_cv_func_vfork
  1595. AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
  1596. fi
  1597. if test "x$ac_cv_func_vfork_works" = xyes; then
  1598. AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
  1599. else
  1600. AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
  1601. fi
  1602. if test "x$ac_cv_func_fork_works" = xyes; then
  1603. AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
  1604. fi
  1605. ])# AC_FUNC_FORK
  1606. # _AC_FUNC_FORK
  1607. # -------------
  1608. AC_DEFUN([_AC_FUNC_FORK],
  1609. [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
  1610. [AC_RUN_IFELSE(
  1611. [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  1612. [
  1613. /* By Ruediger Kuhlmann. */
  1614. return fork () < 0;
  1615. ])],
  1616. [ac_cv_func_fork_works=yes],
  1617. [ac_cv_func_fork_works=no],
  1618. [ac_cv_func_fork_works=cross])])]
  1619. )# _AC_FUNC_FORK
  1620. # _AC_FUNC_VFORK
  1621. # --------------
  1622. AC_DEFUN([_AC_FUNC_VFORK],
  1623. [AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
  1624. [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
  1625. ]AC_INCLUDES_DEFAULT[
  1626. #include <sys/wait.h>
  1627. #ifdef HAVE_VFORK_H
  1628. # include <vfork.h>
  1629. #endif
  1630. /* On some sparc systems, changes by the child to local and incoming
  1631. argument registers are propagated back to the parent. The compiler
  1632. is told about this with #include <vfork.h>, but some compilers
  1633. (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
  1634. static variable whose address is put into a register that is
  1635. clobbered by the vfork. */
  1636. static void
  1637. #ifdef __cplusplus
  1638. sparc_address_test (int arg)
  1639. # else
  1640. sparc_address_test (arg) int arg;
  1641. #endif
  1642. {
  1643. static pid_t child;
  1644. if (!child) {
  1645. child = vfork ();
  1646. if (child < 0) {
  1647. perror ("vfork");
  1648. _exit(2);
  1649. }
  1650. if (!child) {
  1651. arg = getpid();
  1652. write(-1, "", 0);
  1653. _exit (arg);
  1654. }
  1655. }
  1656. }
  1657. int
  1658. main ()
  1659. {
  1660. pid_t parent = getpid ();
  1661. pid_t child;
  1662. sparc_address_test (0);
  1663. child = vfork ();
  1664. if (child == 0) {
  1665. /* Here is another test for sparc vfork register problems. This
  1666. test uses lots of local variables, at least as many local
  1667. variables as main has allocated so far including compiler
  1668. temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
  1669. 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
  1670. reuse the register of parent for one of the local variables,
  1671. since it will think that parent can't possibly be used any more
  1672. in this routine. Assigning to the local variable will thus
  1673. munge parent in the parent process. */
  1674. pid_t
  1675. p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
  1676. p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
  1677. /* Convince the compiler that p..p7 are live; otherwise, it might
  1678. use the same hardware register for all 8 local variables. */
  1679. if (p != p1 || p != p2 || p != p3 || p != p4
  1680. || p != p5 || p != p6 || p != p7)
  1681. _exit(1);
  1682. /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
  1683. from child file descriptors. If the child closes a descriptor
  1684. before it execs or exits, this munges the parent's descriptor
  1685. as well. Test for this by closing stdout in the child. */
  1686. _exit(close(fileno(stdout)) != 0);
  1687. } else {
  1688. int status;
  1689. struct stat st;
  1690. while (wait(&status) != child)
  1691. ;
  1692. return (
  1693. /* Was there some problem with vforking? */
  1694. child < 0
  1695. /* Did the child fail? (This shouldn't happen.) */
  1696. || status
  1697. /* Did the vfork/compiler bug occur? */
  1698. || parent != getpid()
  1699. /* Did the file descriptor bug occur? */
  1700. || fstat(fileno(stdout), &st) != 0
  1701. );
  1702. }
  1703. }]])],
  1704. [ac_cv_func_vfork_works=yes],
  1705. [ac_cv_func_vfork_works=no],
  1706. [ac_cv_func_vfork_works=cross])])
  1707. ])# _AC_FUNC_VFORK
  1708. # AU::AC_FUNC_VFORK
  1709. # -----------------
  1710. AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
  1711. # AU::AC_VFORK
  1712. # ------------
  1713. AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
  1714. # AC_FUNC_VPRINTF
  1715. # ---------------
  1716. # Why the heck is that _doprnt does not define HAVE__DOPRNT???
  1717. # That the logical name!
  1718. AC_DEFUN([AC_FUNC_VPRINTF],
  1719. [AC_CHECK_FUNCS(vprintf, []
  1720. [AC_CHECK_FUNC(_doprnt,
  1721. [AC_DEFINE(HAVE_DOPRNT, 1,
  1722. [Define to 1 if you don't have `vprintf' but do have
  1723. `_doprnt.'])])])
  1724. ])
  1725. # AU::AC_VPRINTF
  1726. # --------------
  1727. AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
  1728. # AC_FUNC_WAIT3
  1729. # -------------
  1730. # Don't bother too hard maintaining this macro, as it's obsoleted.
  1731. # We don't AU define it, since we don't have any alternative to propose,
  1732. # any invocation should be removed, and the code adjusted.
  1733. AN_FUNCTION([wait3], [AC_FUNC_WAIT3])
  1734. AC_DEFUN([AC_FUNC_WAIT3],
  1735. [AC_DIAGNOSE([obsolete],
  1736. [$0: `wait3' has been removed from POSIX.
  1737. Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
  1738. AC_CACHE_CHECK([for wait3 that fills in rusage],
  1739. [ac_cv_func_wait3_rusage],
  1740. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  1741. [AC_INCLUDES_DEFAULT[
  1742. #include <sys/time.h>
  1743. #include <sys/resource.h>
  1744. #include <sys/wait.h>
  1745. /* HP-UX has wait3 but does not fill in rusage at all. */
  1746. int
  1747. main ()
  1748. {
  1749. struct rusage r;
  1750. int i;
  1751. /* Use a field that we can force nonzero --
  1752. voluntary context switches.
  1753. For systems like NeXT and OSF/1 that don't set it,
  1754. also use the system CPU time. And page faults (I/O) for Linux. */
  1755. r.ru_nvcsw = 0;
  1756. r.ru_stime.tv_sec = 0;
  1757. r.ru_stime.tv_usec = 0;
  1758. r.ru_majflt = r.ru_minflt = 0;
  1759. switch (fork ())
  1760. {
  1761. case 0: /* Child. */
  1762. sleep(1); /* Give up the CPU. */
  1763. _exit(0);
  1764. break;
  1765. case -1: /* What can we do? */
  1766. _exit(0);
  1767. break;
  1768. default: /* Parent. */
  1769. wait3(&i, 0, &r);
  1770. /* Avoid "text file busy" from rm on fast HP-UX machines. */
  1771. sleep(2);
  1772. return (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
  1773. && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
  1774. }
  1775. }]])],
  1776. [ac_cv_func_wait3_rusage=yes],
  1777. [ac_cv_func_wait3_rusage=no],
  1778. [ac_cv_func_wait3_rusage=no])])
  1779. if test $ac_cv_func_wait3_rusage = yes; then
  1780. AC_DEFINE(HAVE_WAIT3, 1,
  1781. [Define to 1 if you have the `wait3' system call.
  1782. Deprecated, you should no longer depend upon `wait3'.])
  1783. fi
  1784. ])# AC_FUNC_WAIT3
  1785. # AU::AC_WAIT3
  1786. # ------------
  1787. AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])