Zend.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. dnl
  2. dnl This file contains Zend specific autoconf functions.
  3. dnl
  4. AC_DEFUN([LIBZEND_CHECK_INT_TYPE],[
  5. AC_MSG_CHECKING(for $1)
  6. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  7. #if HAVE_SYS_TYPES_H
  8. #include <sys/types.h>
  9. #endif
  10. #if HAVE_INTTYPES_H
  11. #include <inttypes.h>
  12. #elif HAVE_STDINT_H
  13. #include <stdint.h>
  14. #endif]],
  15. [[if (($1 *) 0)
  16. return 0;
  17. if (sizeof ($1))
  18. return 0;
  19. ]])],[
  20. AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z_-,A-Z__), 1,[Define if $1 type is present. ])
  21. AC_MSG_RESULT(yes)
  22. ], [AC_MSG_RESULT(no)
  23. ])dnl
  24. ])
  25. AC_DEFUN([LIBZEND_BASIC_CHECKS],[
  26. AC_REQUIRE([AC_PROG_YACC])
  27. AC_REQUIRE([AC_PROG_CC])
  28. AC_REQUIRE([AC_PROG_CC_C_O])
  29. AC_REQUIRE([AC_HEADER_STDC])
  30. LIBZEND_BISON_CHECK
  31. dnl Ugly hack to get around a problem with gcc on AIX.
  32. if test "$CC" = "gcc" -a "$ac_cv_prog_cc_g" = "yes" -a \
  33. "`uname -sv`" = "AIX 4"; then
  34. CFLAGS=`echo $CFLAGS | sed -e 's/-g//'`
  35. fi
  36. dnl Hack to work around a Mac OS X cpp problem
  37. dnl Known versions needing this workaround are 5.3 and 5.4
  38. if test "$ac_cv_prog_gcc" = "yes" -a "`uname -s`" = "Rhapsody"; then
  39. CPPFLAGS="$CPPFLAGS -traditional-cpp"
  40. fi
  41. AC_CHECK_HEADERS(
  42. inttypes.h \
  43. stdint.h \
  44. limits.h \
  45. malloc.h \
  46. string.h \
  47. unistd.h \
  48. stdarg.h \
  49. sys/types.h \
  50. sys/time.h \
  51. signal.h \
  52. unix.h \
  53. stdlib.h \
  54. cpuid.h \
  55. dlfcn.h)
  56. AC_TYPE_SIZE_T
  57. AC_DEFUN([LIBZEND_LIBDL_CHECKS],[
  58. AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"])
  59. AC_CHECK_FUNC(dlopen,[AC_DEFINE(HAVE_LIBDL, 1,[ ])])
  60. ])
  61. AC_DEFUN([LIBZEND_DLSYM_CHECK],[
  62. dnl
  63. dnl Ugly hack to check if dlsym() requires a leading underscore in symbol name.
  64. dnl
  65. AC_MSG_CHECKING([whether dlsym() requires a leading underscore in symbol names])
  66. _LT_AC_TRY_DLOPEN_SELF([
  67. AC_MSG_RESULT(no)
  68. ], [
  69. AC_MSG_RESULT(yes)
  70. AC_DEFINE(DLSYM_NEEDS_UNDERSCORE, 1, [Define if dlsym() requires a leading underscore in symbol names. ])
  71. ], [
  72. AC_MSG_RESULT(no)
  73. ], [])
  74. ])
  75. dnl This is required for QNX and may be some BSD derived systems
  76. AC_CHECK_TYPE( uint, unsigned int )
  77. AC_CHECK_TYPE( ulong, unsigned long )
  78. dnl Check if int32_t and uint32_t are defined
  79. LIBZEND_CHECK_INT_TYPE(int32_t)
  80. LIBZEND_CHECK_INT_TYPE(uint32_t)
  81. dnl Checks for library functions.
  82. AC_FUNC_VPRINTF
  83. AC_FUNC_MEMCMP
  84. AC_FUNC_ALLOCA
  85. AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp)
  86. AC_ZEND_BROKEN_SPRINTF
  87. AC_CHECK_DECLS([isfinite, isnan, isinf], [], [], [[#include <math.h>]])
  88. ZEND_FP_EXCEPT
  89. ZEND_CHECK_FLOAT_PRECISION
  90. dnl test whether double cast to long preserves least significant bits
  91. AC_MSG_CHECKING(whether double cast to long preserves least significant bits)
  92. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  93. #include <limits.h>
  94. int main()
  95. {
  96. if (sizeof(long) == 4) {
  97. double d = (double) LONG_MIN * LONG_MIN + 2e9;
  98. if ((long) d == 2e9 && (long) -d == -2e9) {
  99. return 0;
  100. }
  101. } else if (sizeof(long) == 8) {
  102. double correct = 18e18 - ((double) LONG_MIN * -2); /* Subtract ULONG_MAX + 1 */
  103. if ((long) 18e18 == correct) { /* On 64-bit, only check between LONG_MAX and ULONG_MAX */
  104. return 0;
  105. }
  106. }
  107. return 1;
  108. }
  109. ]])], [
  110. AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits])
  111. AC_MSG_RESULT(yes)
  112. ], [
  113. AC_MSG_RESULT(no)
  114. ], [
  115. AC_MSG_RESULT(no)
  116. ])
  117. ])
  118. AC_DEFUN([LIBZEND_ENABLE_DEBUG],[
  119. AC_ARG_ENABLE(debug,
  120. [ --enable-debug Compile with debugging symbols],[
  121. ZEND_DEBUG=$enableval
  122. ],[
  123. ZEND_DEBUG=no
  124. ])
  125. ])
  126. AC_DEFUN([LIBZEND_OTHER_CHECKS],[
  127. AC_ARG_ENABLE(maintainer-zts,
  128. [ --enable-maintainer-zts Enable thread safety - for code maintainers only!!],[
  129. ZEND_MAINTAINER_ZTS=$enableval
  130. ],[
  131. ZEND_MAINTAINER_ZTS=no
  132. ])
  133. AC_ARG_ENABLE(inline-optimization,
  134. [ --disable-inline-optimization
  135. If building zend_execute.lo fails, try this switch],[
  136. ZEND_INLINE_OPTIMIZATION=$enableval
  137. ],[
  138. ZEND_INLINE_OPTIMIZATION=yes
  139. ])
  140. AC_MSG_CHECKING(whether to enable thread-safety)
  141. AC_MSG_RESULT($ZEND_MAINTAINER_ZTS)
  142. AC_MSG_CHECKING(whether to enable inline optimization for GCC)
  143. AC_MSG_RESULT($ZEND_INLINE_OPTIMIZATION)
  144. AC_MSG_CHECKING(whether to enable Zend debugging)
  145. AC_MSG_RESULT($ZEND_DEBUG)
  146. if test "$ZEND_DEBUG" = "yes"; then
  147. AC_DEFINE(ZEND_DEBUG,1,[ ])
  148. echo " $CFLAGS" | grep ' -g' >/dev/null || DEBUG_CFLAGS="-g"
  149. if test "$CFLAGS" = "-g -O2"; then
  150. CFLAGS=-g
  151. fi
  152. test -n "$GCC" && DEBUG_CFLAGS="$DEBUG_CFLAGS -Wall"
  153. test -n "$GCC" && test "$USE_MAINTAINER_MODE" = "yes" && \
  154. DEBUG_CFLAGS="$DEBUG_CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"
  155. else
  156. AC_DEFINE(ZEND_DEBUG,0,[ ])
  157. fi
  158. test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
  159. if test "$ZEND_MAINTAINER_ZTS" = "yes"; then
  160. AC_DEFINE(ZTS,1,[ ])
  161. CFLAGS="$CFLAGS -DZTS"
  162. fi
  163. changequote({,})
  164. if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then
  165. INLINE_CFLAGS=`echo $ac_n "$CFLAGS $ac_c" | sed s/-O[0-9s]*//`
  166. else
  167. INLINE_CFLAGS="$CFLAGS"
  168. fi
  169. changequote([,])
  170. AC_C_INLINE
  171. AC_SUBST(INLINE_CFLAGS)
  172. AC_MSG_CHECKING(target system is Darwin)
  173. if echo "$target" | grep "darwin" > /dev/null; then
  174. AC_DEFINE([DARWIN], 1, [Define if the target system is darwin])
  175. AC_MSG_RESULT(yes)
  176. else
  177. AC_MSG_RESULT(no)
  178. fi
  179. dnl test and set the alignment define for ZEND_MM
  180. dnl this also does the logarithmic test for ZEND_MM.
  181. AC_MSG_CHECKING(for MM alignment and log values)
  182. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  183. #include <stdio.h>
  184. typedef union _mm_align_test {
  185. void *ptr;
  186. double dbl;
  187. long lng;
  188. } mm_align_test;
  189. #if (defined (__GNUC__) && __GNUC__ >= 2)
  190. #define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test))
  191. #else
  192. #define ZEND_MM_ALIGNMENT (sizeof(mm_align_test))
  193. #endif
  194. int main()
  195. {
  196. int i = ZEND_MM_ALIGNMENT;
  197. int zeros = 0;
  198. FILE *fp;
  199. while (i & ~0x1) {
  200. zeros++;
  201. i = i >> 1;
  202. }
  203. fp = fopen("conftest.zend", "w");
  204. fprintf(fp, "%d %d\n", ZEND_MM_ALIGNMENT, zeros);
  205. fclose(fp);
  206. return 0;
  207. }
  208. ]])], [
  209. LIBZEND_MM_ALIGN=`cat conftest.zend | cut -d ' ' -f 1`
  210. LIBZEND_MM_ALIGN_LOG2=`cat conftest.zend | cut -d ' ' -f 2`
  211. AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT, $LIBZEND_MM_ALIGN, [ ])
  212. AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT_LOG2, $LIBZEND_MM_ALIGN_LOG2, [ ])
  213. ], [], [
  214. dnl cross-compile needs something here
  215. LIBZEND_MM_ALIGN=8
  216. ])
  217. AC_MSG_RESULT(done)
  218. dnl test for memory allocation using mmap(MAP_ANON)
  219. AC_MSG_CHECKING(for memory allocation using mmap(MAP_ANON))
  220. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  221. #include <sys/types.h>
  222. #include <sys/stat.h>
  223. #include <fcntl.h>
  224. #include <sys/mman.h>
  225. #include <stdlib.h>
  226. #include <stdio.h>
  227. #ifndef MAP_ANON
  228. # ifdef MAP_ANONYMOUS
  229. # define MAP_ANON MAP_ANONYMOUS
  230. # endif
  231. #endif
  232. #ifndef MREMAP_MAYMOVE
  233. # define MREMAP_MAYMOVE 0
  234. #endif
  235. #ifndef MAP_FAILED
  236. # define MAP_FAILED ((void*)-1)
  237. #endif
  238. #define SEG_SIZE (256*1024)
  239. int main()
  240. {
  241. void *seg = mmap(NULL, SEG_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
  242. if (seg == MAP_FAILED) {
  243. return 1;
  244. }
  245. if (munmap(seg, SEG_SIZE) != 0) {
  246. return 2;
  247. }
  248. return 0;
  249. }
  250. ]])], [
  251. AC_DEFINE([HAVE_MEM_MMAP_ANON], 1, [Define if the target system has support for memory allocation using mmap(MAP_ANON)])
  252. AC_MSG_RESULT(yes)
  253. ], [
  254. AC_MSG_RESULT(no)
  255. ], [
  256. dnl cross-compile needs something here
  257. AC_MSG_RESULT(no)
  258. ])
  259. dnl test for memory allocation using mmap("/dev/zero")
  260. AC_MSG_CHECKING(for memory allocation using mmap("/dev/zero"))
  261. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  262. #include <sys/types.h>
  263. #include <sys/stat.h>
  264. #include <fcntl.h>
  265. #include <sys/mman.h>
  266. #include <stdlib.h>
  267. #include <stdio.h>
  268. #include <unistd.h>
  269. #ifndef MAP_ANON
  270. # ifdef MAP_ANONYMOUS
  271. # define MAP_ANON MAP_ANONYMOUS
  272. # endif
  273. #endif
  274. #ifndef MREMAP_MAYMOVE
  275. # define MREMAP_MAYMOVE 0
  276. #endif
  277. #ifndef MAP_FAILED
  278. # define MAP_FAILED ((void*)-1)
  279. #endif
  280. #define SEG_SIZE (256*1024)
  281. int main()
  282. {
  283. int fd;
  284. void *seg;
  285. fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR);
  286. if (fd < 0) {
  287. return 1;
  288. }
  289. seg = mmap(NULL, SEG_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
  290. if (seg == MAP_FAILED) {
  291. return 2;
  292. }
  293. if (munmap(seg, SEG_SIZE) != 0) {
  294. return 3;
  295. }
  296. if (close(fd) != 0) {
  297. return 4;
  298. }
  299. return 0;
  300. }
  301. ]])], [
  302. AC_DEFINE([HAVE_MEM_MMAP_ZERO], 1, [Define if the target system has support for memory allocation using mmap("/dev/zero")])
  303. AC_MSG_RESULT(yes)
  304. ], [
  305. AC_MSG_RESULT(no)
  306. ], [
  307. dnl cross-compile needs something here
  308. AC_MSG_RESULT(no)
  309. ])
  310. AC_CHECK_FUNCS(mremap)
  311. AC_ARG_ENABLE(zend-signals,
  312. [ --disable-zend-signals whether to enable zend signal handling],[
  313. ZEND_SIGNALS=$enableval
  314. ],[
  315. ZEND_SIGNALS=yes
  316. ])
  317. AC_CHECK_FUNC(sigaction, [
  318. AC_DEFINE(HAVE_SIGACTION, 1, [Whether sigaction() is available])
  319. ], [
  320. ZEND_SIGNALS=no
  321. ])
  322. if test "$ZEND_SIGNALS" = "yes"; then
  323. AC_DEFINE(ZEND_SIGNALS, 1, [Use zend signal handling])
  324. CFLAGS="$CFLAGS -DZEND_SIGNALS"
  325. fi
  326. AC_MSG_CHECKING(whether to enable zend signal handling)
  327. AC_MSG_RESULT($ZEND_SIGNALS)
  328. ])
  329. AC_MSG_CHECKING(whether /dev/urandom exists)
  330. if test -r "/dev/urandom" && test -c "/dev/urandom"; then
  331. AC_DEFINE([HAVE_DEV_URANDOM], 1, [Define if the target system has /dev/urandom device])
  332. AC_MSG_RESULT(yes)
  333. else
  334. AC_MSG_RESULT(no)
  335. fi
  336. AC_MSG_CHECKING(whether /dev/arandom exists)
  337. if test -r "/dev/arandom" && test -c "/dev/arandom"; then
  338. AC_DEFINE([HAVE_DEV_ARANDOM], 1, [Define if the target system has /dev/arandom device])
  339. AC_MSG_RESULT(yes)
  340. else
  341. AC_MSG_RESULT(no)
  342. fi
  343. AC_ARG_ENABLE(gcc-global-regs,
  344. [ --disable-gcc-global-regs
  345. whether to enable GCC global register variables],[
  346. ZEND_GCC_GLOBAL_REGS=$enableval
  347. ],[
  348. ZEND_GCC_GLOBAL_REGS=yes
  349. ])
  350. AC_MSG_CHECKING(for global register variables support)
  351. if test "$ZEND_GCC_GLOBAL_REGS" != "no"; then
  352. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  353. #if defined(__GNUC__)
  354. # define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
  355. #else
  356. # define ZEND_GCC_VERSION 0
  357. #endif
  358. #if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
  359. # define ZEND_VM_FP_GLOBAL_REG "%esi"
  360. # define ZEND_VM_IP_GLOBAL_REG "%edi"
  361. #elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__x86_64__)
  362. # define ZEND_VM_FP_GLOBAL_REG "%r14"
  363. # define ZEND_VM_IP_GLOBAL_REG "%r15"
  364. #elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__powerpc64__)
  365. # define ZEND_VM_FP_GLOBAL_REG "r28"
  366. # define ZEND_VM_IP_GLOBAL_REG "r29"
  367. #elif defined(__IBMC__) && ZEND_GCC_VERSION >= 4002 && defined(__powerpc64__)
  368. # define ZEND_VM_FP_GLOBAL_REG "r28"
  369. # define ZEND_VM_IP_GLOBAL_REG "r29"
  370. #else
  371. # error "global register variables are not supported"
  372. #endif
  373. typedef int (*opcode_handler_t)(void);
  374. register void *FP __asm__(ZEND_VM_FP_GLOBAL_REG);
  375. register const opcode_handler_t *IP __asm__(ZEND_VM_IP_GLOBAL_REG);
  376. int emu(const opcode_handler_t *ip, void *fp) {
  377. const opcode_handler_t *orig_ip = IP;
  378. void *orig_fp = FP;
  379. IP = ip;
  380. FP = fp;
  381. while ((*ip)());
  382. FP = orig_fp;
  383. IP = orig_ip;
  384. }
  385. ]], [[
  386. ]])], [
  387. ZEND_GCC_GLOBAL_REGS=yes
  388. ], [
  389. ZEND_GCC_GLOBAL_REGS=no
  390. ])
  391. fi
  392. if test "$ZEND_GCC_GLOBAL_REGS" = "yes"; then
  393. AC_DEFINE([HAVE_GCC_GLOBAL_REGS], 1, [Define if the target system has support for global register variables])
  394. else
  395. HAVE_GCC_GLOBAL_REGS=no
  396. fi
  397. AC_MSG_RESULT($ZEND_GCC_GLOBAL_REGS)
  398. dnl
  399. dnl Check if atof() accepts NAN
  400. dnl
  401. AC_CACHE_CHECK(whether atof() accepts NAN, ac_cv_atof_accept_nan,[
  402. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  403. #include <math.h>
  404. #include <stdlib.h>
  405. #ifdef HAVE_ISNAN
  406. #define zend_isnan(a) isnan(a)
  407. #elif defined(HAVE_FPCLASS)
  408. #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
  409. #else
  410. #define zend_isnan(a) 0
  411. #endif
  412. int main(int argc, char** argv)
  413. {
  414. return zend_isnan(atof("NAN")) ? 0 : 1;
  415. }
  416. ]])],[
  417. ac_cv_atof_accept_nan=yes
  418. ],[
  419. ac_cv_atof_accept_nan=no
  420. ],[
  421. ac_cv_atof_accept_nan=no
  422. ])])
  423. if test "$ac_cv_atof_accept_nan" = "yes"; then
  424. AC_DEFINE([HAVE_ATOF_ACCEPTS_NAN], 1, [whether atof() accepts NAN])
  425. fi
  426. dnl
  427. dnl Check if atof() accepts INF
  428. dnl
  429. AC_CACHE_CHECK(whether atof() accepts INF, ac_cv_atof_accept_inf,[
  430. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  431. #include <math.h>
  432. #include <stdlib.h>
  433. #ifdef HAVE_ISINF
  434. #define zend_isinf(a) isinf(a)
  435. #elif defined(INFINITY)
  436. /* Might not work, but is required by ISO C99 */
  437. #define zend_isinf(a) (((a)==INFINITY)?1:0)
  438. #elif defined(HAVE_FPCLASS)
  439. #define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
  440. #else
  441. #define zend_isinf(a) 0
  442. #endif
  443. int main(int argc, char** argv)
  444. {
  445. return zend_isinf(atof("INF")) && zend_isinf(atof("-INF")) ? 0 : 1;
  446. }
  447. ]])],[
  448. ac_cv_atof_accept_inf=yes
  449. ],[
  450. ac_cv_atof_accept_inf=no
  451. ],[
  452. ac_cv_atof_accept_inf=no
  453. ])])
  454. if test "$ac_cv_atof_accept_inf" = "yes"; then
  455. AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF])
  456. fi
  457. dnl
  458. dnl Check if HUGE_VAL == INF
  459. dnl
  460. AC_CACHE_CHECK(whether HUGE_VAL == INF, ac_cv_huge_val_inf,[
  461. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  462. #include <math.h>
  463. #include <stdlib.h>
  464. #ifdef HAVE_ISINF
  465. #define zend_isinf(a) isinf(a)
  466. #elif defined(INFINITY)
  467. /* Might not work, but is required by ISO C99 */
  468. #define zend_isinf(a) (((a)==INFINITY)?1:0)
  469. #elif defined(HAVE_FPCLASS)
  470. #define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
  471. #else
  472. #define zend_isinf(a) 0
  473. #endif
  474. int main(int argc, char** argv)
  475. {
  476. return zend_isinf(HUGE_VAL) ? 0 : 1;
  477. }
  478. ]])],[
  479. ac_cv_huge_val_inf=yes
  480. ],[
  481. ac_cv_huge_val_inf=no
  482. ],[
  483. ac_cv_huge_val_inf=yes
  484. ])])
  485. dnl This is the most probable fallback so we assume yes in case of cross compile.
  486. if test "$ac_cv_huge_val_inf" = "yes"; then
  487. AC_DEFINE([HAVE_HUGE_VAL_INF], 1, [whether HUGE_VAL == INF])
  488. fi
  489. dnl
  490. dnl Check if HUGE_VAL + -HUGEVAL == NAN
  491. dnl
  492. AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL == NAN, ac_cv_huge_val_nan,[
  493. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  494. #include <math.h>
  495. #include <stdlib.h>
  496. #ifdef HAVE_ISNAN
  497. #define zend_isnan(a) isnan(a)
  498. #elif defined(HAVE_FPCLASS)
  499. #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
  500. #else
  501. #define zend_isnan(a) 0
  502. #endif
  503. int main(int argc, char** argv)
  504. {
  505. #if defined(__sparc__) && !(__GNUC__ >= 3)
  506. /* prevent bug #27830 */
  507. return 1;
  508. #else
  509. return zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1;
  510. #endif
  511. }
  512. ]])],[
  513. ac_cv_huge_val_nan=yes
  514. ],[
  515. ac_cv_huge_val_nan=no
  516. ],[
  517. ac_cv_huge_val_nan=yes
  518. ])])
  519. dnl This is the most probable fallback so we assume yes in case of cross compile.
  520. if test "$ac_cv_huge_val_nan" = "yes"; then
  521. AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
  522. fi
  523. dnl
  524. dnl Check whether __cpuid_count is available
  525. dnl
  526. AC_CACHE_CHECK(whether __cpuid_count is available, ac_cv_cpuid_count_available, [
  527. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  528. #include <cpuid.h>
  529. ]], [[
  530. unsigned eax, ebx, ecx, edx;
  531. __cpuid_count(0, 0, eax, ebx, ecx, edx);
  532. ]])], [
  533. ac_cv_cpuid_count_available=yes
  534. ], [
  535. ac_cv_cpuid_count_available=no
  536. ])])
  537. if test "$ac_cv_cpuid_count_available" = "yes"; then
  538. AC_DEFINE([HAVE_CPUID_COUNT], 1, [whether __cpuid_count is available])
  539. fi