functions.m4 63 KB

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