14a1767b4Smrgdnl GMP specific autoconf macros 24a1767b4Smrg 34a1767b4Smrg 4*274b3bceSmrgdnl Copyright 2000-2006, 2009, 2011, 2013-2018 Free Software Foundation, Inc. 54a1767b4Smrgdnl 64a1767b4Smrgdnl This file is part of the GNU MP Library. 74a1767b4Smrgdnl 84a1767b4Smrgdnl The GNU MP Library is free software; you can redistribute it and/or modify 921c03f4cSmrgdnl it under the terms of either: 1021c03f4cSmrgdnl 1121c03f4cSmrgdnl * the GNU Lesser General Public License as published by the Free 1221c03f4cSmrgdnl Software Foundation; either version 3 of the License, or (at your 1321c03f4cSmrgdnl option) any later version. 1421c03f4cSmrgdnl 1521c03f4cSmrgdnl or 1621c03f4cSmrgdnl 1721c03f4cSmrgdnl * the GNU General Public License as published by the Free Software 1821c03f4cSmrgdnl Foundation; either version 2 of the License, or (at your option) any 1921c03f4cSmrgdnl later version. 2021c03f4cSmrgdnl 2121c03f4cSmrgdnl or both in parallel, as here. 224a1767b4Smrgdnl 234a1767b4Smrgdnl The GNU MP Library is distributed in the hope that it will be useful, but 244a1767b4Smrgdnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 2521c03f4cSmrgdnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2621c03f4cSmrgdnl for more details. 274a1767b4Smrgdnl 2821c03f4cSmrgdnl You should have received copies of the GNU General Public License and the 2921c03f4cSmrgdnl GNU Lesser General Public License along with the GNU MP Library. If not, 3021c03f4cSmrgdnl see https://www.gnu.org/licenses/. 314a1767b4Smrg 324a1767b4Smrg 334a1767b4Smrgdnl Some tests use, or must delete, the default compiler output. The 344a1767b4Smrgdnl possible filenames are based on what autoconf looks for, namely 354a1767b4Smrgdnl 364a1767b4Smrgdnl a.out - normal unix style 374a1767b4Smrgdnl b.out - i960 systems, including gcc there 384a1767b4Smrgdnl a.exe - djgpp 394a1767b4Smrgdnl a_out.exe - OpenVMS DEC C called via GNV wrapper (gnv.sourceforge.net) 404a1767b4Smrgdnl conftest.exe - various DOS compilers 414a1767b4Smrg 424a1767b4Smrg 434a1767b4Smrgdefine(IA64_PATTERN, 444a1767b4Smrg[[ia64*-*-* | itanium-*-* | itanium2-*-*]]) 454a1767b4Smrg 4650ee1fa7Smattdefine(M5407_PATTERN, 4750ee1fa7Smatt[[m5407-*-*]]) 4850ee1fa7Smatt 494a1767b4Smrgdnl Need to be careful not to match m6811, m6812, m68hc11 and m68hc12, all 504a1767b4Smrgdnl of which config.sub accepts. (Though none of which are likely to work 514a1767b4Smrgdnl with GMP.) 524a1767b4Smrgdnl 534a1767b4Smrgdefine(M68K_PATTERN, 544a1767b4Smrg[[m68k-*-* | m68[0-9][0-9][0-9]-*-*]]) 554a1767b4Smrg 564a1767b4Smrgdefine(POWERPC64_PATTERN, 574a1767b4Smrg[[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-* | powerpc970-*-* | power[3-9]-*-*]]) 584a1767b4Smrg 59b6659776Smrgdefine(S390_PATTERN, 60b6659776Smrg[[s390-*-* | z900esa-*-* | z990esa-*-* | z9esa-*-* | z10esa-*-* | z196esa-*-*]]) 61b6659776Smrg 62b6659776Smrgdefine(S390X_PATTERN, 63b6659776Smrg[[s390x-*-* | z900-*-* | z990-*-* | z9-*-* | z10-*-* | z196-*-*]]) 64b6659776Smrg 654a1767b4Smrgdefine(X86_PATTERN, 664a1767b4Smrg[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]]) 674a1767b4Smrg 684a1767b4Smrgdefine(X86_64_PATTERN, 69*274b3bceSmrg[[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | jaguar*-*-* | bulldozer*-*-* | piledriver*-*-* | steamroller*-*-* | excavator*-*-* | zen*-*-* | pentium4-*-* | atom-*-* | silvermont-*-* | goldmont-*-* | core2-*-* | corei*-*-* | x86_64-*-* | nano-*-* | nehalem*-*-* | westmere*-*-* | sandybridge*-*-* | ivybridge*-*-* | haswell*-*-* | broadwell*-*-* | skylake*-*-* | kabylake*-*-*]]) 704a1767b4Smrg 714a1767b4Smrgdnl GMP_FAT_SUFFIX(DSTVAR, DIRECTORY) 724a1767b4Smrgdnl --------------------------------- 734a1767b4Smrgdnl Emit code to set shell variable DSTVAR to the suffix for a fat binary 744a1767b4Smrgdnl routine from DIRECTORY. DIRECTORY can be a shell expression like $foo 754a1767b4Smrgdnl etc. 764a1767b4Smrgdnl 774a1767b4Smrgdnl The suffix is directory separators / or \ changed to underscores, and 784a1767b4Smrgdnl if there's more than one directory part, then the first is dropped. 794a1767b4Smrgdnl 804a1767b4Smrgdnl For instance, 814a1767b4Smrgdnl 824a1767b4Smrgdnl x86 -> x86 834a1767b4Smrgdnl x86/k6 -> k6 844a1767b4Smrgdnl x86/k6/mmx -> k6_mmx 854a1767b4Smrg 864a1767b4Smrgdefine(GMP_FAT_SUFFIX, 874a1767b4Smrg[[$1=`echo $2 | sed -e '/\//s:^[^/]*/::' -e 's:[\\/]:_:g'`]]) 884a1767b4Smrg 894a1767b4Smrg 904a1767b4Smrgdnl GMP_REMOVE_FROM_LIST(listvar,item) 914a1767b4Smrgdnl ---------------------------------- 924a1767b4Smrgdnl Emit code to remove any occurrence of ITEM from $LISTVAR. ITEM can be a 934a1767b4Smrgdnl shell expression like $foo if desired. 944a1767b4Smrg 954a1767b4Smrgdefine(GMP_REMOVE_FROM_LIST, 964a1767b4Smrg[remove_from_list_tmp= 974a1767b4Smrgfor remove_from_list_i in $[][$1]; do 984a1767b4Smrg if test $remove_from_list_i = [$2]; then :; 994a1767b4Smrg else 1004a1767b4Smrg remove_from_list_tmp="$remove_from_list_tmp $remove_from_list_i" 1014a1767b4Smrg fi 1024a1767b4Smrgdone 1034a1767b4Smrg[$1]=$remove_from_list_tmp 1044a1767b4Smrg]) 1054a1767b4Smrg 1064a1767b4Smrg 1074a1767b4Smrgdnl GMP_STRIP_PATH(subdir) 1084a1767b4Smrgdnl ---------------------- 1094a1767b4Smrgdnl Strip entries */subdir from $path and $fat_path. 1104a1767b4Smrg 1114a1767b4Smrgdefine(GMP_STRIP_PATH, 1124a1767b4Smrg[GMP_STRIP_PATH_VAR(path, [$1]) 1134a1767b4SmrgGMP_STRIP_PATH_VAR(fat_path, [$1]) 1144a1767b4Smrg]) 1154a1767b4Smrg 1164a1767b4Smrgdefine(GMP_STRIP_PATH_VAR, 1174a1767b4Smrg[tmp_path= 1184a1767b4Smrgfor i in $[][$1]; do 1194a1767b4Smrg case $i in 1204a1767b4Smrg */[$2]) ;; 1214a1767b4Smrg *) tmp_path="$tmp_path $i" ;; 1224a1767b4Smrg esac 1234a1767b4Smrgdone 1244a1767b4Smrg[$1]="$tmp_path" 1254a1767b4Smrg]) 1264a1767b4Smrg 1274a1767b4Smrg 1284a1767b4Smrgdnl GMP_INCLUDE_GMP_H 1294a1767b4Smrgdnl ----------------- 1304a1767b4Smrgdnl Expand to the right way to #include gmp-h.in. This must be used 1314a1767b4Smrgdnl instead of gmp.h, since that file isn't generated until the end of the 1324a1767b4Smrgdnl configure. 1334a1767b4Smrgdnl 1344a1767b4Smrgdnl Dummy value for GMP_LIMB_BITS is enough 1354a1767b4Smrgdnl for all current configure-time uses of gmp.h. 1364a1767b4Smrg 1374a1767b4Smrgdefine(GMP_INCLUDE_GMP_H, 1384a1767b4Smrg[[#define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ 1394a1767b4Smrg#define GMP_NAIL_BITS $GMP_NAIL_BITS 1404a1767b4Smrg#define GMP_LIMB_BITS 123 1414a1767b4Smrg$DEFN_LONG_LONG_LIMB 1424a1767b4Smrg#include "$srcdir/gmp-h.in"] 1434a1767b4Smrg]) 1444a1767b4Smrg 1454a1767b4Smrg 1464a1767b4Smrgdnl GMP_HEADER_GETVAL(NAME,FILE) 1474a1767b4Smrgdnl ---------------------------- 1484a1767b4Smrgdnl Expand at autoconf time to the value of a "#define NAME" from the given 1494a1767b4Smrgdnl FILE. The regexps here aren't very rugged, but are enough for gmp. 1504a1767b4Smrgdnl /dev/null as a parameter prevents a hang if $2 is accidentally omitted. 1514a1767b4Smrg 1524a1767b4Smrgdefine(GMP_HEADER_GETVAL, 1534a1767b4Smrg[patsubst(patsubst( 1544a1767b4Smrgesyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]), 1554a1767b4Smrg[^.*$1[ ]+],[]), 1564a1767b4Smrg[[ 1574a1767b4Smrg ]*$],[])]) 1584a1767b4Smrg 1594a1767b4Smrg 1604a1767b4Smrgdnl GMP_VERSION 1614a1767b4Smrgdnl ----------- 1624a1767b4Smrgdnl The gmp version number, extracted from the #defines in gmp-h.in at 1634a1767b4Smrgdnl autoconf time. Two digits like 3.0 if patchlevel <= 0, or three digits 1644a1767b4Smrgdnl like 3.0.1 if patchlevel > 0. 1654a1767b4Smrg 1664a1767b4Smrgdefine(GMP_VERSION, 1674a1767b4Smrg[GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp-h.in)[]dnl 1684a1767b4Smrg.GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp-h.in)[]dnl 1694a1767b4Smrg.GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in)]) 1704a1767b4Smrg 1714a1767b4Smrg 1724a1767b4Smrgdnl GMP_SUBST_CHECK_FUNCS(func,...) 1734a1767b4Smrgdnl ------------------------------ 1744a1767b4Smrgdnl Setup an AC_SUBST of HAVE_FUNC_01 for each argument. 1754a1767b4Smrg 1764a1767b4SmrgAC_DEFUN([GMP_SUBST_CHECK_FUNCS], 1774a1767b4Smrg[m4_if([$1],,, 1784a1767b4Smrg[_GMP_SUBST_CHECK_FUNCS(ac_cv_func_[$1],HAVE_[]m4_translit([$1],[a-z],[A-Z])_01) 1794a1767b4SmrgGMP_SUBST_CHECK_FUNCS(m4_shift($@))])]) 1804a1767b4Smrg 1814a1767b4Smrgdnl Called: _GMP_SUBST_CHECK_FUNCS(cachevar,substvar) 1824a1767b4SmrgAC_DEFUN([_GMP_SUBST_CHECK_FUNCS], 1834a1767b4Smrg[case $[$1] in 1844a1767b4Smrgyes) AC_SUBST([$2],1) ;; 1854a1767b4Smrgno) [$2]=0 ;; 1864a1767b4Smrgesac 1874a1767b4Smrg]) 1884a1767b4Smrg 1894a1767b4Smrg 1904a1767b4Smrgdnl GMP_SUBST_CHECK_HEADERS(foo.h,...) 1914a1767b4Smrgdnl ---------------------------------- 1924a1767b4Smrgdnl Setup an AC_SUBST of HAVE_FOO_H_01 for each argument. 1934a1767b4Smrg 1944a1767b4SmrgAC_DEFUN([GMP_SUBST_CHECK_HEADERS], 1954a1767b4Smrg[m4_if([$1],,, 1964a1767b4Smrg[_GMP_SUBST_CHECK_HEADERS(ac_cv_header_[]m4_translit([$1],[./],[__]), 1974a1767b4SmrgHAVE_[]m4_translit([$1],[a-z./],[A-Z__])_01) 1984a1767b4SmrgGMP_SUBST_CHECK_HEADERS(m4_shift($@))])]) 1994a1767b4Smrg 2004a1767b4Smrgdnl Called: _GMP_SUBST_CHECK_HEADERS(cachevar,substvar) 2014a1767b4SmrgAC_DEFUN([_GMP_SUBST_CHECK_HEADERS], 2024a1767b4Smrg[case $[$1] in 2034a1767b4Smrgyes) AC_SUBST([$2],1) ;; 2044a1767b4Smrgno) [$2]=0 ;; 2054a1767b4Smrgesac 2064a1767b4Smrg]) 2074a1767b4Smrg 2084a1767b4Smrg 2094a1767b4Smrgdnl GMP_COMPARE_GE(A1,B1, A2,B2, ...) 2104a1767b4Smrgdnl --------------------------------- 2114a1767b4Smrgdnl Compare two version numbers A1.A2.etc and B1.B2.etc. Set 2124a1767b4Smrgdnl $gmp_compare_ge to yes or no according to the result. The A parts 2134a1767b4Smrgdnl should be variables, the B parts fixed numbers. As many parts as 2144a1767b4Smrgdnl desired can be included. An empty string in an A part is taken to be 2154a1767b4Smrgdnl zero, the B parts should be non-empty and non-zero. 2164a1767b4Smrgdnl 2174a1767b4Smrgdnl For example, 2184a1767b4Smrgdnl 2194a1767b4Smrgdnl GMP_COMPARE($major,10, $minor,3, $subminor,1) 2204a1767b4Smrgdnl 2214a1767b4Smrgdnl would test whether $major.$minor.$subminor is greater than or equal to 2224a1767b4Smrgdnl 10.3.1. 2234a1767b4Smrg 2244a1767b4SmrgAC_DEFUN([GMP_COMPARE_GE], 2254a1767b4Smrg[gmp_compare_ge=no 2264a1767b4SmrgGMP_COMPARE_GE_INTERNAL($@) 2274a1767b4Smrg]) 2284a1767b4Smrg 2294a1767b4SmrgAC_DEFUN([GMP_COMPARE_GE_INTERNAL], 2304a1767b4Smrg[ifelse(len([$3]),0, 2314a1767b4Smrg[if test -n "$1" && test "$1" -ge $2; then 2324a1767b4Smrg gmp_compare_ge=yes 2334a1767b4Smrgfi], 2344a1767b4Smrg[if test -n "$1"; then 2354a1767b4Smrg if test "$1" -gt $2; then 2364a1767b4Smrg gmp_compare_ge=yes 2374a1767b4Smrg else 2384a1767b4Smrg if test "$1" -eq $2; then 2394a1767b4Smrg GMP_COMPARE_GE_INTERNAL(m4_shift(m4_shift($@))) 2404a1767b4Smrg fi 2414a1767b4Smrg fi 2424a1767b4Smrgfi]) 2434a1767b4Smrg]) 2444a1767b4Smrg 2454a1767b4Smrg 2464a1767b4Smrgdnl GMP_PROG_AR 2474a1767b4Smrgdnl ----------- 2484a1767b4Smrgdnl GMP additions to $AR. 2494a1767b4Smrgdnl 2504a1767b4Smrgdnl A cross-"ar" may be necessary when cross-compiling since the build 2514a1767b4Smrgdnl system "ar" might try to interpret the object files to build a symbol 2524a1767b4Smrgdnl table index, hence the use of AC_CHECK_TOOL. 2534a1767b4Smrgdnl 2544a1767b4Smrgdnl A user-selected $AR is always left unchanged. AC_CHECK_TOOL is still 2554a1767b4Smrgdnl run to get the "checking" message printed though. 2564a1767b4Smrgdnl 2574a1767b4Smrgdnl If extra flags are added to AR, then ac_cv_prog_AR and 2584a1767b4Smrgdnl ac_cv_prog_ac_ct_AR are set too, since libtool (cvs 2003-03-31 at 2594a1767b4Smrgdnl least) will do an AC_CHECK_TOOL and that will AR from one of those two 2604a1767b4Smrgdnl cached variables. (ac_cv_prog_AR is used if there's an ac_tool_prefix, 2614a1767b4Smrgdnl or ac_cv_prog_ac_ct_AR is used otherwise.) FIXME: This is highly 2624a1767b4Smrgdnl dependent on autoconf internals, perhaps it'd work to put our extra 2634a1767b4Smrgdnl flags into AR_FLAGS instead. 2644a1767b4Smrgdnl 2654a1767b4Smrgdnl $AR_FLAGS is set to "cq" rather than leaving it to libtool "cru". The 2664a1767b4Smrgdnl latter fails when libtool goes into piecewise mode and is unlucky 2674a1767b4Smrgdnl enough to have two same-named objects in separate pieces, as happens 2684a1767b4Smrgdnl for instance to random.o (and others) on vax-dec-ultrix4.5. Naturally 2694a1767b4Smrgdnl a user-selected $AR_FLAGS is left unchanged. 2704a1767b4Smrgdnl 2714a1767b4Smrgdnl For reference, $ARFLAGS is used by automake (1.8) for its ".a" archive 2724a1767b4Smrgdnl file rules. This doesn't get used by the piecewise linking, so we 2734a1767b4Smrgdnl leave it at the default "cru". 2744a1767b4Smrgdnl 2754a1767b4Smrgdnl FIXME: Libtool 1.5.2 has its own arrangements for "cq", but that version 2764a1767b4Smrgdnl is broken in other ways. When we can upgrade, remove the forcible 2774a1767b4Smrgdnl AR_FLAGS=cq. 2784a1767b4Smrg 2794a1767b4SmrgAC_DEFUN([GMP_PROG_AR], 2804a1767b4Smrg[dnl Want to establish $AR before libtool initialization. 2814a1767b4SmrgAC_BEFORE([$0],[AC_PROG_LIBTOOL]) 2824a1767b4Smrggmp_user_AR=$AR 2834a1767b4SmrgAC_CHECK_TOOL(AR, ar, ar) 2844a1767b4Smrgif test -z "$gmp_user_AR"; then 2854a1767b4Smrg eval arflags=\"\$ar${abi1}_flags\" 2864a1767b4Smrg test -n "$arflags" || eval arflags=\"\$ar${abi2}_flags\" 2874a1767b4Smrg if test -n "$arflags"; then 2884a1767b4Smrg AC_MSG_CHECKING([for extra ar flags]) 2894a1767b4Smrg AR="$AR $arflags" 2904a1767b4Smrg ac_cv_prog_AR="$AR $arflags" 2914a1767b4Smrg ac_cv_prog_ac_ct_AR="$AR $arflags" 2924a1767b4Smrg AC_MSG_RESULT([$arflags]) 2934a1767b4Smrg fi 2944a1767b4Smrgfi 2954a1767b4Smrgif test -z "$AR_FLAGS"; then 2964a1767b4Smrg AR_FLAGS=cq 2974a1767b4Smrgfi 2984a1767b4Smrg]) 2994a1767b4Smrg 3004a1767b4Smrg 3014a1767b4Smrgdnl GMP_PROG_M4 3024a1767b4Smrgdnl ----------- 3034a1767b4Smrgdnl Find a working m4, either in $PATH or likely locations, and setup $M4 3044a1767b4Smrgdnl and an AC_SUBST accordingly. If $M4 is already set then it's a user 3054a1767b4Smrgdnl choice and is accepted with no checks. GMP_PROG_M4 is like 3064a1767b4Smrgdnl AC_PATH_PROG or AC_CHECK_PROG, but tests each m4 found to see if it's 3074a1767b4Smrgdnl good enough. 3084a1767b4Smrgdnl 3094a1767b4Smrgdnl See mpn/asm-defs.m4 for details on the known bad m4s. 3104a1767b4Smrg 3114a1767b4SmrgAC_DEFUN([GMP_PROG_M4], 3124a1767b4Smrg[AC_ARG_VAR(M4,[m4 macro processor]) 3134a1767b4SmrgAC_CACHE_CHECK([for suitable m4], 3144a1767b4Smrg gmp_cv_prog_m4, 3154a1767b4Smrg[if test -n "$M4"; then 3164a1767b4Smrg gmp_cv_prog_m4="$M4" 3174a1767b4Smrgelse 3184a1767b4Smrg cat >conftest.m4 <<\EOF 3194a1767b4Smrgdnl Must protect this against being expanded during autoconf m4! 3204a1767b4Smrgdnl Dont put "dnl"s in this as autoconf will flag an error for unexpanded 3214a1767b4Smrgdnl macros. 3224a1767b4Smrg[define(dollarhash,``$][#'')ifelse(dollarhash(x),1,`define(t1,Y)', 3234a1767b4Smrg``bad: $][# not supported (SunOS /usr/bin/m4) 3244a1767b4Smrg'')ifelse(eval(89),89,`define(t2,Y)', 3254a1767b4Smrg`bad: eval() doesnt support 8 or 9 in a constant (OpenBSD 2.6 m4) 32621c03f4cSmrg')ifelse(eval(9,9),10,`define(t3,Y)', 32721c03f4cSmrg`bad: eval() doesnt support radix in eval (FreeBSD 8.x,9.0,9.1,9.2 m4) 32821c03f4cSmrg')ifelse(t1`'t2`'t3,YYY,`good 3294a1767b4Smrg')] 3304a1767b4SmrgEOF 3314a1767b4Smrgdnl ' <- balance the quotes for emacs sh-mode 3324a1767b4Smrg echo "trying m4" >&AC_FD_CC 3334a1767b4Smrg gmp_tmp_val=`(m4 conftest.m4) 2>&AC_FD_CC` 3344a1767b4Smrg echo "$gmp_tmp_val" >&AC_FD_CC 3354a1767b4Smrg if test "$gmp_tmp_val" = good; then 3364a1767b4Smrg gmp_cv_prog_m4="m4" 3374a1767b4Smrg else 3384a1767b4Smrg IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" 3394a1767b4Smrgdnl $ac_dummy forces splitting on constant user-supplied paths. 3404a1767b4Smrgdnl POSIX.2 word splitting is done only on the output of word expansions, 3414a1767b4Smrgdnl not every word. This closes a longstanding sh security hole. 3424a1767b4Smrg ac_dummy="$PATH:/usr/5bin" 3434a1767b4Smrg for ac_dir in $ac_dummy; do 3444a1767b4Smrg test -z "$ac_dir" && ac_dir=. 3454a1767b4Smrg echo "trying $ac_dir/m4" >&AC_FD_CC 3464a1767b4Smrg gmp_tmp_val=`($ac_dir/m4 conftest.m4) 2>&AC_FD_CC` 3474a1767b4Smrg echo "$gmp_tmp_val" >&AC_FD_CC 3484a1767b4Smrg if test "$gmp_tmp_val" = good; then 3494a1767b4Smrg gmp_cv_prog_m4="$ac_dir/m4" 3504a1767b4Smrg break 3514a1767b4Smrg fi 3524a1767b4Smrg done 3534a1767b4Smrg IFS="$ac_save_ifs" 3544a1767b4Smrg if test -z "$gmp_cv_prog_m4"; then 3554a1767b4Smrg AC_MSG_ERROR([No usable m4 in \$PATH or /usr/5bin (see config.log for reasons).]) 3564a1767b4Smrg fi 3574a1767b4Smrg fi 3584a1767b4Smrg rm -f conftest.m4 3594a1767b4Smrgfi]) 3604a1767b4SmrgM4="$gmp_cv_prog_m4" 3614a1767b4SmrgAC_SUBST(M4) 3624a1767b4Smrg]) 3634a1767b4Smrg 3644a1767b4Smrg 3654a1767b4Smrgdnl GMP_M4_M4WRAP_SPURIOUS 3664a1767b4Smrgdnl ---------------------- 3674a1767b4Smrgdnl Check for spurious output from m4wrap(), as described in mpn/asm-defs.m4. 3684a1767b4Smrgdnl 3694a1767b4Smrgdnl The following systems have been seen with the problem. 3704a1767b4Smrgdnl 3714a1767b4Smrgdnl - Unicos alpha, but its assembler doesn't seem to mind. 3724a1767b4Smrgdnl - MacOS X Darwin, its assembler fails. 3734a1767b4Smrgdnl - NetBSD 1.4.1 m68k, and gas 1.92.3 there gives a warning and ignores 3744a1767b4Smrgdnl the bad last line since it doesn't have a newline. 3754a1767b4Smrgdnl - NetBSD 1.4.2 alpha, but its assembler doesn't seem to mind. 3764a1767b4Smrgdnl - HP-UX ia64. 3774a1767b4Smrgdnl 3784a1767b4Smrgdnl Enhancement: Maybe this could be in GMP_PROG_M4, and attempt to prefer 3794a1767b4Smrgdnl an m4 with a working m4wrap, if it can be found. 3804a1767b4Smrg 3814a1767b4SmrgAC_DEFUN([GMP_M4_M4WRAP_SPURIOUS], 3824a1767b4Smrg[AC_REQUIRE([GMP_PROG_M4]) 3834a1767b4SmrgAC_CACHE_CHECK([if m4wrap produces spurious output], 3844a1767b4Smrg gmp_cv_m4_m4wrap_spurious, 3854a1767b4Smrg[# hide the d-n-l from autoconf's error checking 3864a1767b4Smrgtmp_d_n_l=d""nl 3874a1767b4Smrgcat >conftest.m4 <<EOF 3884a1767b4Smrg[changequote({,})define(x,)m4wrap({x})$tmp_d_n_l] 3894a1767b4SmrgEOF 3904a1767b4Smrgecho test input is >&AC_FD_CC 3914a1767b4Smrgcat conftest.m4 >&AC_FD_CC 3924a1767b4Smrgtmp_chars=`$M4 conftest.m4 | wc -c` 3934a1767b4Smrgecho produces $tmp_chars chars output >&AC_FD_CC 3944a1767b4Smrgrm -f conftest.m4 3954a1767b4Smrgif test $tmp_chars = 0; then 3964a1767b4Smrg gmp_cv_m4_m4wrap_spurious=no 3974a1767b4Smrgelse 3984a1767b4Smrg gmp_cv_m4_m4wrap_spurious=yes 3994a1767b4Smrgfi 4004a1767b4Smrg]) 4014a1767b4SmrgGMP_DEFINE_RAW(["define(<M4WRAP_SPURIOUS>,<$gmp_cv_m4_m4wrap_spurious>)"]) 4024a1767b4Smrg]) 4034a1767b4Smrg 4044a1767b4Smrg 4054a1767b4Smrgdnl GMP_PROG_NM 4064a1767b4Smrgdnl ----------- 4074a1767b4Smrgdnl GMP additions to libtool AC_PROG_NM. 4084a1767b4Smrgdnl 4094a1767b4Smrgdnl Note that if AC_PROG_NM can't find a working nm it still leaves 4104a1767b4Smrgdnl $NM set to "nm", so $NM can't be assumed to actually work. 4114a1767b4Smrgdnl 4124a1767b4Smrgdnl A user-selected $NM is always left unchanged. AC_PROG_NM is still run 4134a1767b4Smrgdnl to get the "checking" message printed though. 4144a1767b4Smrgdnl 4154a1767b4Smrgdnl Perhaps it'd be worthwhile checking that nm works, by running it on an 4164a1767b4Smrgdnl actual object file. For instance on sparcv9 solaris old versions of 4174a1767b4Smrgdnl GNU nm don't recognise 64-bit objects. Checking would give a better 4184a1767b4Smrgdnl error message than just a failure in later tests like GMP_ASM_W32 etc. 4194a1767b4Smrgdnl 4204a1767b4Smrgdnl On the other hand it's not really normal autoconf practice to take too 4214a1767b4Smrgdnl much trouble over detecting a broken set of tools. And libtool doesn't 4224a1767b4Smrgdnl do anything at all for say ranlib or strip. So for now we're inclined 4234a1767b4Smrgdnl to just demand that the user provides a coherent environment. 4244a1767b4Smrg 4254a1767b4SmrgAC_DEFUN([GMP_PROG_NM], 4264a1767b4Smrg[dnl Make sure we're the first to call AC_PROG_NM, so our extra flags are 4274a1767b4Smrgdnl used by everyone. 4284a1767b4SmrgAC_BEFORE([$0],[AC_PROG_NM]) 4294a1767b4Smrggmp_user_NM=$NM 4304a1767b4SmrgAC_PROG_NM 4314a1767b4Smrg 4324a1767b4Smrg# FIXME: When cross compiling (ie. $ac_tool_prefix not empty), libtool 4334a1767b4Smrg# defaults to plain "nm" if a "${ac_tool_prefix}nm" is not found. In this 4344a1767b4Smrg# case run it again to try the native "nm", firstly so that likely locations 4354a1767b4Smrg# are searched, secondly so that -B or -p are added if necessary for BSD 4364a1767b4Smrg# format. This is necessary for instance on OSF with "./configure 4374a1767b4Smrg# --build=alphaev5-dec-osf --host=alphaev6-dec-osf". 4384a1767b4Smrg# 4394a1767b4Smrgif test -z "$gmp_user_NM" && test -n "$ac_tool_prefix" && test "$NM" = nm; then 4404a1767b4Smrg $as_unset lt_cv_path_NM 4414a1767b4Smrg gmp_save_ac_tool_prefix=$ac_tool_prefix 4424a1767b4Smrg ac_tool_prefix= 4434a1767b4Smrg NM= 4444a1767b4Smrg AC_PROG_NM 4454a1767b4Smrg ac_tool_prefix=$gmp_save_ac_tool_prefix 4464a1767b4Smrgfi 4474a1767b4Smrg 4484a1767b4Smrgif test -z "$gmp_user_NM"; then 4494a1767b4Smrg eval nmflags=\"\$nm${abi1}_flags\" 4504a1767b4Smrg test -n "$nmflags" || eval nmflags=\"\$nm${abi2}_flags\" 4514a1767b4Smrg if test -n "$nmflags"; then 4524a1767b4Smrg AC_MSG_CHECKING([for extra nm flags]) 4534a1767b4Smrg NM="$NM $nmflags" 4544a1767b4Smrg AC_MSG_RESULT([$nmflags]) 4554a1767b4Smrg fi 4564a1767b4Smrgfi 4574a1767b4Smrg]) 4584a1767b4Smrg 4594a1767b4Smrg 4604a1767b4Smrgdnl GMP_PROG_CC_WORKS(cc+cflags,[ACTION-IF-WORKS][,ACTION-IF-NOT-WORKS]) 4614a1767b4Smrgdnl -------------------------------------------------------------------- 4624a1767b4Smrgdnl Check if cc+cflags can compile and link. 4634a1767b4Smrgdnl 4644a1767b4Smrgdnl This test is designed to be run repeatedly with different cc+cflags 4654a1767b4Smrgdnl selections, so the result is not cached. 4664a1767b4Smrgdnl 4674a1767b4Smrgdnl For a native build, meaning $cross_compiling == no, we require that the 4684a1767b4Smrgdnl generated program will run. This is the same as AC_PROG_CC does in 4694a1767b4Smrgdnl _AC_COMPILER_EXEEXT_WORKS, and checking here will ensure we don't pass 4704a1767b4Smrgdnl a CC/CFLAGS combination that it rejects. 4714a1767b4Smrgdnl 4724a1767b4Smrgdnl sparc-*-solaris2.7 can compile ABI=64 but won't run it if the kernel 4734a1767b4Smrgdnl was booted in 32-bit mode. The effect of requiring the compiler output 4744a1767b4Smrgdnl will run is that a plain native "./configure" falls back on ABI=32, but 4754a1767b4Smrgdnl ABI=64 is still available as a cross-compile. 4764a1767b4Smrgdnl 4774a1767b4Smrgdnl The various specific problems we try to detect are done in separate 4784a1767b4Smrgdnl compiles. Although this is probably a bit slower than one test 4794a1767b4Smrgdnl program, it makes it easy to indicate the problem in AC_MSG_RESULT, 4804a1767b4Smrgdnl hence giving the user a clue about why we rejected the compiler. 4814a1767b4Smrg 4824a1767b4SmrgAC_DEFUN([GMP_PROG_CC_WORKS], 4834a1767b4Smrg[AC_MSG_CHECKING([compiler $1]) 4844a1767b4Smrggmp_prog_cc_works=yes 4854a1767b4Smrg 4864a1767b4Smrg# first see a simple "main()" works, then go on to other checks 4874a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], []) 4884a1767b4Smrg 4894a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [function pointer return], 4904a1767b4Smrg[/* The following provokes an internal error from gcc 2.95.2 -mpowerpc64 4914a1767b4Smrg (without -maix64), hence detecting an unusable compiler */ 4924a1767b4Smrgvoid *g() { return (void *) 0; } 4934a1767b4Smrgvoid *f() { return g(); } 4944a1767b4Smrg]) 4954a1767b4Smrg 4964a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [cmov instruction], 4974a1767b4Smrg[/* The following provokes an invalid instruction syntax from i386 gcc 4984a1767b4Smrg -march=pentiumpro on Solaris 2.8. The native sun assembler 4994a1767b4Smrg requires a non-standard syntax for cmov which gcc (as of 2.95.2 at 5004a1767b4Smrg least) doesn't know. */ 5014a1767b4Smrgint n; 5024a1767b4Smrgint cmov () { return (n >= 0 ? n : 0); } 5034a1767b4Smrg]) 5044a1767b4Smrg 5054a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [double -> ulong conversion], 5064a1767b4Smrg[/* The following provokes a linker invocation problem with gcc 3.0.3 5074a1767b4Smrg on AIX 4.3 under "-maix64 -mpowerpc64 -mcpu=630". The -mcpu=630 5084a1767b4Smrg option causes gcc to incorrectly select the 32-bit libgcc.a, not 5094a1767b4Smrg the 64-bit one, and consequently it misses out on the __fixunsdfdi 5104a1767b4Smrg helper (double -> uint64 conversion). */ 5114a1767b4Smrgdouble d; 5124a1767b4Smrgunsigned long gcc303 () { return (unsigned long) d; } 5134a1767b4Smrg]) 5144a1767b4Smrg 5154a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [double negation], 5164a1767b4Smrg[/* The following provokes an error from hppa gcc 2.95 under -mpa-risc-2-0 if 5174a1767b4Smrg the assembler doesn't know hppa 2.0 instructions. fneg is a 2.0 5184a1767b4Smrg instruction, and a negation like this comes out using it. */ 5194a1767b4Smrgdouble fneg_data; 5204a1767b4Smrgunsigned long fneg () { return -fneg_data; } 5214a1767b4Smrg]) 5224a1767b4Smrg 5234a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [double -> float conversion], 5244a1767b4Smrg[/* The following makes gcc 3.3 -march=pentium4 generate an SSE2 xmm insn 5254a1767b4Smrg (cvtsd2ss) which will provoke an error if the assembler doesn't recognise 5264a1767b4Smrg those instructions. Not sure how much of the gmp code will come out 5274a1767b4Smrg wanting sse2, but it's easiest to reject an option we know is bad. */ 5284a1767b4Smrgdouble ftod_data; 5294a1767b4Smrgfloat ftod () { return (float) ftod_data; } 5304a1767b4Smrg]) 5314a1767b4Smrg 5324a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [gnupro alpha ev6 char spilling], 5334a1767b4Smrg[/* The following provokes an internal compiler error from gcc version 5344a1767b4Smrg "2.9-gnupro-99r1" under "-O2 -mcpu=ev6", apparently relating to char 5354a1767b4Smrg values being spilled into floating point registers. The problem doesn't 5364a1767b4Smrg show up all the time, but has occurred enough in GMP for us to reject 5374a1767b4Smrg this compiler+flags. */ 5384a1767b4Smrg#include <string.h> /* for memcpy */ 5394a1767b4Smrgstruct try_t 5404a1767b4Smrg{ 5414a1767b4Smrg char dst[2]; 5424a1767b4Smrg char size; 5434a1767b4Smrg long d0, d1, d2, d3, d4, d5, d6; 5444a1767b4Smrg char overlap; 5454a1767b4Smrg}; 5464a1767b4Smrgstruct try_t param[6]; 5474a1767b4Smrgint 5484a1767b4Smrgparam_init () 5494a1767b4Smrg{ 5504a1767b4Smrg struct try_t *p; 5514a1767b4Smrg memcpy (p, ¶m[ 2 ], sizeof (*p)); 5524a1767b4Smrg memcpy (p, ¶m[ 2 ], sizeof (*p)); 5534a1767b4Smrg p->size = 2; 5544a1767b4Smrg memcpy (p, ¶m[ 1 ], sizeof (*p)); 5554a1767b4Smrg p->dst[0] = 1; 5564a1767b4Smrg p->overlap = 2; 5574a1767b4Smrg memcpy (p, ¶m[ 3 ], sizeof (*p)); 5584a1767b4Smrg p->dst[0] = 1; 5594a1767b4Smrg p->overlap = 8; 5604a1767b4Smrg memcpy (p, ¶m[ 4 ], sizeof (*p)); 5614a1767b4Smrg memcpy (p, ¶m[ 4 ], sizeof (*p)); 5624a1767b4Smrg p->overlap = 8; 5634a1767b4Smrg memcpy (p, ¶m[ 5 ], sizeof (*p)); 5644a1767b4Smrg memcpy (p, ¶m[ 5 ], sizeof (*p)); 5654a1767b4Smrg memcpy (p, ¶m[ 5 ], sizeof (*p)); 5664a1767b4Smrg return 0; 5674a1767b4Smrg} 5684a1767b4Smrg]) 5694a1767b4Smrg 5704a1767b4Smrg# __builtin_alloca is not available everywhere, check it exists before 5714a1767b4Smrg# seeing that it works 5724a1767b4SmrgGMP_PROG_CC_WORKS_PART_TEST([$1],[__builtin_alloca availability], 5734a1767b4Smrg[int k; int foo () { __builtin_alloca (k); }], 5744a1767b4Smrg [GMP_PROG_CC_WORKS_PART([$1], [alloca array], 5754a1767b4Smrg[/* The following provokes an internal compiler error from Itanium HP-UX cc 5764a1767b4Smrg under +O2 or higher. We use this sort of code in mpn/generic/mul_fft.c. */ 5774a1767b4Smrgint k; 5784a1767b4Smrgint foo () 5794a1767b4Smrg{ 5804a1767b4Smrg int i, **a; 5814a1767b4Smrg a = __builtin_alloca (k); 5824a1767b4Smrg for (i = 0; i <= k; i++) 5834a1767b4Smrg a[i] = __builtin_alloca (1 << i); 5844a1767b4Smrg} 5854a1767b4Smrg])]) 5864a1767b4Smrg 5874a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [abs int -> double conversion], 5884a1767b4Smrg[/* The following provokes an internal error from the assembler on 5894a1767b4Smrg power2-ibm-aix4.3.1.0. gcc -mrios2 compiles to nabs+fcirz, and this 5904a1767b4Smrg results in "Internal error related to the source program domain". 5914a1767b4Smrg 5924a1767b4Smrg For reference it seems to be the combination of nabs+fcirz which is bad, 5934a1767b4Smrg not either alone. This sort of thing occurs in mpz/get_str.c with the 5944a1767b4Smrg way double chars_per_bit_exactly is applied in MPN_SIZEINBASE. Perhaps 5954a1767b4Smrg if that code changes to a scaled-integer style then we won't need this 5964a1767b4Smrg test. */ 5974a1767b4Smrg 5984a1767b4Smrgdouble fp[1]; 5994a1767b4Smrgint x; 6004a1767b4Smrgint f () 6014a1767b4Smrg{ 6024a1767b4Smrg int a; 6034a1767b4Smrg a = (x >= 0 ? x : -x); 6044a1767b4Smrg return a * fp[0]; 6054a1767b4Smrg} 6064a1767b4Smrg]) 6074a1767b4Smrg 6084a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [long long reliability test 1], 6094a1767b4Smrg[/* The following provokes a segfault in the compiler on powerpc-apple-darwin. 6104a1767b4Smrg Extracted from tests/mpn/t-iord_u.c. Causes Apple's gcc 3.3 build 1640 and 6114a1767b4Smrg 1666 to segfault with e.g., -O2 -mpowerpc64. */ 6124a1767b4Smrg 6134a1767b4Smrg#if defined (__GNUC__) && ! defined (__cplusplus) 6144a1767b4Smrgtypedef unsigned long long t1;typedef t1*t2; 61521c03f4cSmrgvoid g(){} 61621c03f4cSmrgvoid h(){} 6174a1767b4Smrgstatic __inline__ t1 e(t2 rp,t2 up,int n,t1 v0) 6184a1767b4Smrg{t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;} 61921c03f4cSmrgvoid f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i; 6204a1767b4Smrgfor(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}} 6214a1767b4Smrg#else 6224a1767b4Smrgint dummy; 6234a1767b4Smrg#endif 6244a1767b4Smrg]) 6254a1767b4Smrg 6264a1767b4SmrgGMP_PROG_CC_WORKS_PART([$1], [long long reliability test 2], 6274a1767b4Smrg[/* The following provokes an internal compiler error on powerpc-apple-darwin. 6284a1767b4Smrg Extracted from mpz/cfdiv_q_2exp.c. Causes Apple's gcc 3.3 build 1640 and 6294a1767b4Smrg 1666 to get an ICE with -O1 -mpowerpc64. */ 6304a1767b4Smrg 6314a1767b4Smrg#if defined (__GNUC__) && ! defined (__cplusplus) 63221c03f4cSmrgint g(); 63321c03f4cSmrgvoid f(int u){int i;long long x;x=u?~0:0;if(x)for(i=0;i<9;i++);x&=g();if(x)g();} 63421c03f4cSmrgint g(){return 0;} 63521c03f4cSmrg#else 63621c03f4cSmrgint dummy; 63721c03f4cSmrg#endif 63821c03f4cSmrg]) 63921c03f4cSmrg 64021c03f4cSmrgGMP_PROG_CC_WORKS_PART([$1], [freebsd hacked gcc], 64121c03f4cSmrg[/* Provokes an ICE on i386-freebsd with the FreeBSD-hacked gcc, under 64221c03f4cSmrg -O2 -march=amdfam10. We call helper functions here "open" and "close" in 64321c03f4cSmrg order for linking to succeed. */ 64421c03f4cSmrg 64521c03f4cSmrg#if defined (__GNUC__) && ! defined (__cplusplus) 64621c03f4cSmrgint open(int*,int*,int);void*close(int);void g(int*rp,int*up,int un){ 64721c03f4cSmrg__builtin_expect(un<=0x7f00,1)?__builtin_alloca(un):close(un);if(__builtin_clzl 64821c03f4cSmrg(up[un])){open(rp,up,un);while(1){if(rp[un-1]!=0)break;un--;}}} 6494a1767b4Smrg#else 6504a1767b4Smrgint dummy; 6514a1767b4Smrg#endif 6524a1767b4Smrg]) 6534a1767b4Smrg 6544a1767b4SmrgGMP_PROG_CC_WORKS_PART_MAIN([$1], [mpn_lshift_com optimization], 6554a1767b4Smrg[/* The following is mis-compiled by HP ia-64 cc version 6564a1767b4Smrg cc: HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003] 6574a1767b4Smrg under "cc +O3", both in +DD32 and +DD64 modes. The mpn_lshift_com gets 6584a1767b4Smrg inlined and its return value somehow botched to be 0 instead of 1. This 6594a1767b4Smrg arises in the real mpn_lshift_com in mul_fft.c. A lower optimization 6604a1767b4Smrg level, like +O2 seems ok. This code needs to be run to show the problem, 6614a1767b4Smrg but that's fine, the offending cc is a native-only compiler so we don't 6624a1767b4Smrg have to worry about cross compiling. */ 6634a1767b4Smrg 6644a1767b4Smrg#if ! defined (__cplusplus) 6654a1767b4Smrgunsigned long 6664a1767b4Smrglshift_com (rp, up, n, cnt) 6674a1767b4Smrg unsigned long *rp; 6684a1767b4Smrg unsigned long *up; 6694a1767b4Smrg long n; 6704a1767b4Smrg unsigned cnt; 6714a1767b4Smrg{ 6724a1767b4Smrg unsigned long retval, high_limb, low_limb; 6734a1767b4Smrg unsigned tnc; 6744a1767b4Smrg long i; 6754a1767b4Smrg tnc = 8 * sizeof (unsigned long) - cnt; 6764a1767b4Smrg low_limb = *up++; 6774a1767b4Smrg retval = low_limb >> tnc; 6784a1767b4Smrg high_limb = low_limb << cnt; 6794a1767b4Smrg for (i = n - 1; i != 0; i--) 6804a1767b4Smrg { 6814a1767b4Smrg low_limb = *up++; 6824a1767b4Smrg *rp++ = ~(high_limb | (low_limb >> tnc)); 6834a1767b4Smrg high_limb = low_limb << cnt; 6844a1767b4Smrg } 6854a1767b4Smrg return retval; 6864a1767b4Smrg} 6874a1767b4Smrgint 6884a1767b4Smrgmain () 6894a1767b4Smrg{ 6904a1767b4Smrg unsigned long cy, rp[2], up[2]; 6914a1767b4Smrg up[0] = ~ 0L; 6924a1767b4Smrg up[1] = 0; 6934a1767b4Smrg cy = lshift_com (rp, up, 2L, 1); 6944a1767b4Smrg if (cy != 1L) 6954a1767b4Smrg return 1; 6964a1767b4Smrg return 0; 6974a1767b4Smrg} 6984a1767b4Smrg#else 6994a1767b4Smrgint 7004a1767b4Smrgmain () 7014a1767b4Smrg{ 7024a1767b4Smrg return 0; 7034a1767b4Smrg} 7044a1767b4Smrg#endif 7054a1767b4Smrg]) 7064a1767b4Smrg 7074a1767b4SmrgGMP_PROG_CC_WORKS_PART_MAIN([$1], [mpn_lshift_com optimization 2], 7084a1767b4Smrg[/* The following is mis-compiled by Intel ia-64 icc version 1.8 under 70921c03f4cSmrg "icc -O3", After several calls, the function writes partial garbage to 7104a1767b4Smrg the result vector. Perhaps relates to the chk.a.nc insn. This code needs 7114a1767b4Smrg to be run to show the problem, but that's fine, the offending cc is a 7124a1767b4Smrg native-only compiler so we don't have to worry about cross compiling. */ 7134a1767b4Smrg 7144a1767b4Smrg#if ! defined (__cplusplus) 7154a1767b4Smrg#include <stdlib.h> 7164a1767b4Smrgvoid 7174a1767b4Smrglshift_com (rp, up, n, cnt) 7184a1767b4Smrg unsigned long *rp; 7194a1767b4Smrg unsigned long *up; 7204a1767b4Smrg long n; 7214a1767b4Smrg unsigned cnt; 7224a1767b4Smrg{ 7234a1767b4Smrg unsigned long high_limb, low_limb; 7244a1767b4Smrg unsigned tnc; 7254a1767b4Smrg long i; 7264a1767b4Smrg up += n; 7274a1767b4Smrg rp += n; 7284a1767b4Smrg tnc = 8 * sizeof (unsigned long) - cnt; 7294a1767b4Smrg low_limb = *--up; 7304a1767b4Smrg high_limb = low_limb << cnt; 7314a1767b4Smrg for (i = n - 1; i != 0; i--) 7324a1767b4Smrg { 7334a1767b4Smrg low_limb = *--up; 7344a1767b4Smrg *--rp = ~(high_limb | (low_limb >> tnc)); 7354a1767b4Smrg high_limb = low_limb << cnt; 7364a1767b4Smrg } 7374a1767b4Smrg *--rp = ~high_limb; 7384a1767b4Smrg} 7394a1767b4Smrgint 7404a1767b4Smrgmain () 7414a1767b4Smrg{ 7424a1767b4Smrg unsigned long *r, *r2; 7434a1767b4Smrg unsigned long a[88 + 1]; 7444a1767b4Smrg long i; 7454a1767b4Smrg for (i = 0; i < 88 + 1; i++) 7464a1767b4Smrg a[i] = ~0L; 74706796c14Snonaka r = calloc (10000, sizeof (unsigned long)); 7484a1767b4Smrg r2 = r; 74921c03f4cSmrg for (i = 0; i < 528; i += 23) 7504a1767b4Smrg { 7514a1767b4Smrg lshift_com (r2, a, 7524a1767b4Smrg i / (8 * sizeof (unsigned long)) + 1, 7534a1767b4Smrg i % (8 * sizeof (unsigned long))); 7544a1767b4Smrg r2 += 88 + 1; 7554a1767b4Smrg } 7564a1767b4Smrg if (r[2048] != 0 || r[2049] != 0 || r[2050] != 0 || r[2051] != 0 || 7574a1767b4Smrg r[2052] != 0 || r[2053] != 0 || r[2054] != 0) 7584a1767b4Smrg abort (); 75921c03f4cSmrg free (r); 7604a1767b4Smrg return 0; 7614a1767b4Smrg} 7624a1767b4Smrg#else 7634a1767b4Smrgint 7644a1767b4Smrgmain () 7654a1767b4Smrg{ 7664a1767b4Smrg return 0; 7674a1767b4Smrg} 7684a1767b4Smrg#endif 7694a1767b4Smrg]) 7704a1767b4Smrg 7714a1767b4Smrg 7724a1767b4Smrg# A certain _GLOBAL_OFFSET_TABLE_ problem in past versions of gas, tickled 7734a1767b4Smrg# by recent versions of gcc. 7744a1767b4Smrg# 7754a1767b4Smrgif test "$gmp_prog_cc_works" = yes; then 7764a1767b4Smrg case $host in 7774a1767b4Smrg X86_PATTERN) 7784a1767b4Smrg # this problem only arises in PIC code, so don't need to test when 7794a1767b4Smrg # --disable-shared. We don't necessarily have $enable_shared set to 7804a1767b4Smrg # yes at this point, it will still be unset for the default (which is 7814a1767b4Smrg # yes); hence the use of "!= no". 7824a1767b4Smrg if test "$enable_shared" != no; then 7834a1767b4Smrg GMP_PROG_CC_X86_GOT_EAX_EMITTED([$1], 7844a1767b4Smrg [GMP_ASM_X86_GOT_EAX_OK([$1],, 7854a1767b4Smrg [gmp_prog_cc_works="no, bad gas GOT with eax"])]) 7864a1767b4Smrg fi 7874a1767b4Smrg ;; 7884a1767b4Smrg esac 7894a1767b4Smrgfi 7904a1767b4Smrg 7914a1767b4SmrgAC_MSG_RESULT($gmp_prog_cc_works) 7924a1767b4Smrgcase $gmp_prog_cc_works in 7934a1767b4Smrg yes) 7944a1767b4Smrg [$2] 7954a1767b4Smrg ;; 7964a1767b4Smrg *) 7974a1767b4Smrg [$3] 7984a1767b4Smrg ;; 7994a1767b4Smrgesac 8004a1767b4Smrg]) 8014a1767b4Smrg 8024a1767b4Smrgdnl Called: GMP_PROG_CC_WORKS_PART(CC+CFLAGS,FAIL-MESSAGE [,CODE]) 8034a1767b4Smrgdnl A dummy main() is appended to the CODE given. 8044a1767b4Smrgdnl 8054a1767b4SmrgAC_DEFUN([GMP_PROG_CC_WORKS_PART], 8064a1767b4Smrg[GMP_PROG_CC_WORKS_PART_MAIN([$1],[$2], 8074a1767b4Smrg[$3] 8084a1767b4Smrg[int main () { return 0; }]) 8094a1767b4Smrg]) 8104a1767b4Smrg 8114a1767b4Smrgdnl Called: GMP_PROG_CC_WORKS_PART_MAIN(CC+CFLAGS,FAIL-MESSAGE,CODE) 8124a1767b4Smrgdnl CODE must include a main(). 8134a1767b4Smrgdnl 8144a1767b4SmrgAC_DEFUN([GMP_PROG_CC_WORKS_PART_MAIN], 8154a1767b4Smrg[GMP_PROG_CC_WORKS_PART_TEST([$1],[$2],[$3], 8164a1767b4Smrg [], 8174a1767b4Smrg gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2]", 8184a1767b4Smrg gmp_prog_cc_works="no[]m4_if([$2],,,[[, ]])[$2][[, program does not run]]") 8194a1767b4Smrg]) 8204a1767b4Smrg 8214a1767b4Smrgdnl Called: GMP_PROG_CC_WORKS_PART_TEST(CC+CFLAGS,TITLE,[CODE], 8224a1767b4Smrgdnl [ACTION-GOOD],[ACTION-BAD][ACTION-NORUN]) 8234a1767b4Smrgdnl 8244a1767b4SmrgAC_DEFUN([GMP_PROG_CC_WORKS_PART_TEST], 8254a1767b4Smrg[if test "$gmp_prog_cc_works" = yes; then 8264a1767b4Smrg # remove anything that might look like compiler output to our "||" expression 8274a1767b4Smrg rm -f conftest* a.out b.out a.exe a_out.exe 8284a1767b4Smrg cat >conftest.c <<EOF 8294a1767b4Smrg[$3] 8304a1767b4SmrgEOF 8314a1767b4Smrg echo "Test compile: [$2]" >&AC_FD_CC 8324a1767b4Smrg gmp_compile="$1 conftest.c >&AC_FD_CC" 8334a1767b4Smrg if AC_TRY_EVAL(gmp_compile); then 8344a1767b4Smrg cc_works_part=yes 8354a1767b4Smrg if test "$cross_compiling" = no; then 8364a1767b4Smrg if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :; 8374a1767b4Smrg else 8384a1767b4Smrg cc_works_part=norun 8394a1767b4Smrg fi 8404a1767b4Smrg fi 8414a1767b4Smrg else 8424a1767b4Smrg cc_works_part=no 8434a1767b4Smrg fi 8444a1767b4Smrg if test "$cc_works_part" != yes; then 8454a1767b4Smrg echo "failed program was:" >&AC_FD_CC 8464a1767b4Smrg cat conftest.c >&AC_FD_CC 8474a1767b4Smrg fi 8484a1767b4Smrg rm -f conftest* a.out b.out a.exe a_out.exe 8494a1767b4Smrg case $cc_works_part in 8504a1767b4Smrg yes) 8514a1767b4Smrg $4 8524a1767b4Smrg ;; 8534a1767b4Smrg no) 8544a1767b4Smrg $5 8554a1767b4Smrg ;; 8564a1767b4Smrg norun) 8574a1767b4Smrg $6 8584a1767b4Smrg ;; 8594a1767b4Smrg esac 8604a1767b4Smrgfi 8614a1767b4Smrg]) 8624a1767b4Smrg 8634a1767b4Smrg 8644a1767b4Smrgdnl GMP_PROG_CC_WORKS_LONGLONG(cc+cflags,[ACTION-YES][,ACTION-NO]) 8654a1767b4Smrgdnl -------------------------------------------------------------- 8664a1767b4Smrgdnl Check that cc+cflags accepts "long long". 8674a1767b4Smrgdnl 8684a1767b4Smrgdnl This test is designed to be run repeatedly with different cc+cflags 8694a1767b4Smrgdnl selections, so the result is not cached. 8704a1767b4Smrg 8714a1767b4SmrgAC_DEFUN([GMP_PROG_CC_WORKS_LONGLONG], 8724a1767b4Smrg[AC_MSG_CHECKING([compiler $1 has long long]) 8734a1767b4Smrgcat >conftest.c <<EOF 8744a1767b4Smrglong long foo; 8754a1767b4Smrglong long bar () { return foo; } 8764a1767b4Smrgint main () { return 0; } 8774a1767b4SmrgEOF 8784a1767b4Smrggmp_prog_cc_works=no 8794a1767b4Smrggmp_compile="$1 -c conftest.c >&AC_FD_CC" 8804a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 8814a1767b4Smrg gmp_prog_cc_works=yes 8824a1767b4Smrgelse 8834a1767b4Smrg echo "failed program was:" >&AC_FD_CC 8844a1767b4Smrg cat conftest.c >&AC_FD_CC 8854a1767b4Smrgfi 8864a1767b4Smrgrm -f conftest* a.out b.out a.exe a_out.exe 8874a1767b4SmrgAC_MSG_RESULT($gmp_prog_cc_works) 8884a1767b4Smrgif test $gmp_prog_cc_works = yes; then 8894a1767b4Smrg ifelse([$2],,:,[$2]) 8904a1767b4Smrgelse 8914a1767b4Smrg ifelse([$3],,:,[$3]) 8924a1767b4Smrgfi 8934a1767b4Smrg]) 8944a1767b4Smrg 8954a1767b4Smrg 8964a1767b4Smrgdnl GMP_C_TEST_SIZEOF(cc/cflags,test,[ACTION-GOOD][,ACTION-BAD]) 8974a1767b4Smrgdnl ------------------------------------------------------------ 8984a1767b4Smrgdnl The given cc/cflags compiler is run to check the size of a type 8994a1767b4Smrgdnl specified by the "test" argument. "test" can either be a string, or a 9004a1767b4Smrgdnl variable like $foo. The value should be for instance "sizeof-long-4", 9014a1767b4Smrgdnl to test that sizeof(long)==4. 9024a1767b4Smrgdnl 9034a1767b4Smrgdnl This test is designed to be run for different compiler and/or flags 9044a1767b4Smrgdnl combinations, so the result is not cached. 9054a1767b4Smrgdnl 9064a1767b4Smrgdnl The idea for making an array that has a negative size if the desired 9074a1767b4Smrgdnl condition test is false comes from autoconf AC_CHECK_SIZEOF. The cast 9084a1767b4Smrgdnl to "long" in the array dimension also follows autoconf, apparently it's 9094a1767b4Smrgdnl a workaround for a HP compiler bug. 9104a1767b4Smrg 9114a1767b4SmrgAC_DEFUN([GMP_C_TEST_SIZEOF], 9124a1767b4Smrg[echo "configure: testlist $2" >&AC_FD_CC 913*274b3bceSmrg[gmp_sizeof_type=`echo "$2" | sed 's/sizeof-\([a-z\*]*\).*/\1/'`] 914*274b3bceSmrg[gmp_sizeof_want=`echo "$2" | sed 's/sizeof-[a-z\*]*-\([0-9]*\).*/\1/'`] 9154a1767b4SmrgAC_MSG_CHECKING([compiler $1 has sizeof($gmp_sizeof_type)==$gmp_sizeof_want]) 9164a1767b4Smrgcat >conftest.c <<EOF 9174a1767b4Smrg[int 9184a1767b4Smrgmain () 9194a1767b4Smrg{ 9204a1767b4Smrg static int test_array [1 - 2 * (long) (sizeof ($gmp_sizeof_type) != $gmp_sizeof_want)]; 9214a1767b4Smrg test_array[0] = 0; 9224a1767b4Smrg return 0; 9234a1767b4Smrg}] 9244a1767b4SmrgEOF 9254a1767b4Smrggmp_c_testlist_sizeof=no 9264a1767b4Smrggmp_compile="$1 -c conftest.c >&AC_FD_CC" 9274a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 9284a1767b4Smrg gmp_c_testlist_sizeof=yes 9294a1767b4Smrgfi 9304a1767b4Smrgrm -f conftest* 9314a1767b4SmrgAC_MSG_RESULT($gmp_c_testlist_sizeof) 9324a1767b4Smrgif test $gmp_c_testlist_sizeof = yes; then 9334a1767b4Smrg ifelse([$3],,:,[$3]) 9344a1767b4Smrgelse 9354a1767b4Smrg ifelse([$4],,:,[$4]) 9364a1767b4Smrgfi 9374a1767b4Smrg]) 9384a1767b4Smrg 9394a1767b4Smrg 9404a1767b4Smrgdnl GMP_PROG_CC_IS_GNU(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO]) 9414a1767b4Smrgdnl ------------------------------------------------------- 9424a1767b4Smrgdnl Determine whether the given compiler is GNU C. 9434a1767b4Smrgdnl 9444a1767b4Smrgdnl This test is the same as autoconf _AC_LANG_COMPILER_GNU, but doesn't 9454a1767b4Smrgdnl cache the result. The same "ifndef" style test is used, to avoid 9464a1767b4Smrgdnl problems with syntax checking cpp's used on NeXT and Apple systems. 9474a1767b4Smrg 9484a1767b4SmrgAC_DEFUN([GMP_PROG_CC_IS_GNU], 9494a1767b4Smrg[cat >conftest.c <<EOF 9504a1767b4Smrg#if ! defined (__GNUC__) || defined (__INTEL_COMPILER) 9514a1767b4Smrg choke me 9524a1767b4Smrg#endif 9534a1767b4SmrgEOF 9544a1767b4Smrggmp_compile="$1 -c conftest.c >&AC_FD_CC" 9554a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 9564a1767b4Smrg rm -f conftest* 9574a1767b4Smrg AC_MSG_CHECKING([whether $1 is gcc]) 9584a1767b4Smrg AC_MSG_RESULT(yes) 9594a1767b4Smrg ifelse([$2],,:,[$2]) 9604a1767b4Smrgelse 9614a1767b4Smrg rm -f conftest* 9624a1767b4Smrg ifelse([$3],,:,[$3]) 9634a1767b4Smrgfi 9644a1767b4Smrg]) 9654a1767b4Smrg 9664a1767b4Smrg 9674a1767b4Smrgdnl GMP_PROG_CC_IS_XLC(CC,[ACTIONS-IF-YES][,ACTIONS-IF-NO]) 9684a1767b4Smrgdnl ------------------------------------------------------- 9694a1767b4Smrgdnl Determine whether the given compiler is IBM xlc (on AIX). 9704a1767b4Smrgdnl 9714a1767b4Smrgdnl There doesn't seem to be a preprocessor symbol to test for this, or if 9724a1767b4Smrgdnl there is one then it's well hidden in xlc 3.1 on AIX 4.3, so just grep 9734a1767b4Smrgdnl the man page printed when xlc is invoked with no arguments. 9744a1767b4Smrg 9754a1767b4SmrgAC_DEFUN([GMP_PROG_CC_IS_XLC], 9764a1767b4Smrg[gmp_command="$1 2>&1 | grep xlc >/dev/null" 9774a1767b4Smrgif AC_TRY_EVAL(gmp_command); then 9784a1767b4Smrg AC_MSG_CHECKING([whether $1 is xlc]) 9794a1767b4Smrg AC_MSG_RESULT(yes) 9804a1767b4Smrg ifelse([$2],,:,[$2]) 9814a1767b4Smrgelse 9824a1767b4Smrg ifelse([$3],,:,[$3]) 9834a1767b4Smrgfi 9844a1767b4Smrg]) 9854a1767b4Smrg 9864a1767b4Smrg 9874a1767b4Smrgdnl GMP_PROG_CC_X86_GOT_EAX_EMITTED(CC+CFLAGS, [ACTION-YES] [, ACTION-NO]) 9884a1767b4Smrgdnl ---------------------------------------------------------------------- 9894a1767b4Smrgdnl Determine whether CC+CFLAGS emits instructions using %eax with 9904a1767b4Smrgdnl _GLOBAL_OFFSET_TABLE_. This test is for use on x86 systems. 9914a1767b4Smrgdnl 9924a1767b4Smrgdnl Recent versions of gcc will use %eax for the GOT in leaf functions, for 9934a1767b4Smrgdnl instance gcc 3.3.3 with -O3. This avoids having to save and restore 9944a1767b4Smrgdnl %ebx which otherwise usually holds the GOT, and is what gcc used in the 9954a1767b4Smrgdnl past. 9964a1767b4Smrgdnl 9974a1767b4Smrgdnl %ecx and %edx are also candidates for this sort of optimization, and 9984a1767b4Smrgdnl are used under lesser optimization levels, like -O2 in 3.3.3. FIXME: 9994a1767b4Smrgdnl It's not quite clear what the conditions for using %eax are, we might 10004a1767b4Smrgdnl need more test code to provoke it. 10014a1767b4Smrgdnl 10024a1767b4Smrgdnl The motivation for this test is that past versions of gas have bugs 10034a1767b4Smrgdnl affecting this usage, see GMP_ASM_X86_GOT_EAX_OK. 10044a1767b4Smrgdnl 10054a1767b4Smrgdnl This test is not specific to gcc, other compilers might emit %eax GOT 10064a1767b4Smrgdnl insns like this, though we've not investigated that. 10074a1767b4Smrgdnl 10084a1767b4Smrgdnl This is for use by compiler probing in GMP_PROG_CC_WORKS, so we doesn't 10094a1767b4Smrgdnl cache the result. 10104a1767b4Smrgdnl 10114a1767b4Smrgdnl -fPIC is hard coded here, because this test is for use before libtool 10124a1767b4Smrgdnl has established the pic options. It's right for gcc, but perhaps not 10134a1767b4Smrgdnl other compilers. 10144a1767b4Smrg 10154a1767b4SmrgAC_DEFUN([GMP_PROG_CC_X86_GOT_EAX_EMITTED], 10164a1767b4Smrg[echo "Testing gcc GOT with eax emitted" >&AC_FD_CC 10174a1767b4Smrgcat >conftest.c <<\EOF 10184a1767b4Smrg[int foo; 10194a1767b4Smrgint bar () { return foo; } 10204a1767b4Smrg]EOF 10214a1767b4Smrgtmp_got_emitted=no 10224a1767b4Smrggmp_compile="$1 -fPIC -S conftest.c >&AC_FD_CC 2>&1" 10234a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 10244a1767b4Smrg if grep "addl.*_GLOBAL_OFFSET_TABLE_.*eax" conftest.s >/dev/null; then 10254a1767b4Smrg tmp_got_emitted=yes 10264a1767b4Smrg fi 10274a1767b4Smrgfi 10284a1767b4Smrgrm -f conftest.* 10294a1767b4Smrgecho "Result: $tmp_got_emitted" >&AC_FD_CC 10304a1767b4Smrgif test "$tmp_got_emitted" = yes; then 10314a1767b4Smrg ifelse([$2],,:,[$2]) 10324a1767b4Smrgelse 10334a1767b4Smrg ifelse([$3],,:,[$3]) 10344a1767b4Smrgfi 10354a1767b4Smrg]) 10364a1767b4Smrg 10374a1767b4Smrg 10384a1767b4Smrgdnl GMP_HPC_HPPA_2_0(cc,[ACTION-IF-GOOD][,ACTION-IF-BAD]) 10394a1767b4Smrgdnl --------------------------------------------------------- 10404a1767b4Smrgdnl Find out whether a HP compiler is good enough to generate hppa 2.0. 10414a1767b4Smrgdnl 10424a1767b4Smrgdnl This test might be repeated for different compilers, so the result is 10434a1767b4Smrgdnl not cached. 10444a1767b4Smrg 10454a1767b4SmrgAC_DEFUN([GMP_HPC_HPPA_2_0], 10464a1767b4Smrg[AC_MSG_CHECKING([whether HP compiler $1 is good for 64-bits]) 10474a1767b4Smrg# Bad compiler output: 10484a1767b4Smrg# ccom: HP92453-01 G.10.32.05 HP C Compiler 10494a1767b4Smrg# Good compiler output: 10504a1767b4Smrg# ccom: HP92453-01 A.10.32.30 HP C Compiler 10514a1767b4Smrg# Let A.10.32.30 or higher be ok. 10524a1767b4Smrgecho >conftest.c 10534a1767b4Smrggmp_tmp_vs=`$1 $2 -V -c -o conftest.$OBJEXT conftest.c 2>&1 | grep "^ccom:"` 10544a1767b4Smrgecho "Version string: $gmp_tmp_vs" >&AC_FD_CC 10554a1767b4Smrgrm conftest* 10564a1767b4Smrggmp_tmp_v1=`echo $gmp_tmp_vs | sed 's/.* .\.\([[0-9]]*\).*/\1/'` 10574a1767b4Smrggmp_tmp_v2=`echo $gmp_tmp_vs | sed 's/.* .\..*\.\(.*\)\..* HP C.*/\1/'` 10584a1767b4Smrggmp_tmp_v3=`echo $gmp_tmp_vs | sed 's/.* .\..*\..*\.\(.*\) HP C.*/\1/'` 10594a1767b4Smrgecho "Version number: $gmp_tmp_v1.$gmp_tmp_v2.$gmp_tmp_v3" >&AC_FD_CC 10604a1767b4Smrgif test -z "$gmp_tmp_v1"; then 10614a1767b4Smrg gmp_hpc_64bit=not-applicable 10624a1767b4Smrgelse 10634a1767b4Smrg GMP_COMPARE_GE($gmp_tmp_v1, 10, $gmp_tmp_v2, 32, $gmp_tmp_v3, 30) 10644a1767b4Smrg gmp_hpc_64bit=$gmp_compare_ge 10654a1767b4Smrgfi 10664a1767b4SmrgAC_MSG_RESULT($gmp_hpc_64bit) 10674a1767b4Smrgif test $gmp_hpc_64bit = yes; then 10684a1767b4Smrg ifelse([$2],,:,[$2]) 10694a1767b4Smrgelse 10704a1767b4Smrg ifelse([$3],,:,[$3]) 10714a1767b4Smrgfi 10724a1767b4Smrg]) 10734a1767b4Smrg 10744a1767b4Smrg 10754a1767b4Smrgdnl GMP_GCC_ARM_UMODSI(CC,[ACTIONS-IF-GOOD][,ACTIONS-IF-BAD]) 10764a1767b4Smrgdnl --------------------------------------------------------- 10774a1767b4Smrgdnl gcc 2.95.3 and earlier on arm has a bug in the libgcc __umodsi routine 10784a1767b4Smrgdnl making "%" give wrong results for some operands, eg. "0x90000000 % 3". 10794a1767b4Smrgdnl We're hoping it'll be fixed in 2.95.4, and we know it'll be fixed in 10804a1767b4Smrgdnl gcc 3. 10814a1767b4Smrgdnl 10824a1767b4Smrgdnl There's only a couple of places gmp cares about this, one is the 10834a1767b4Smrgdnl size==1 case in mpn/generic/mode1o.c, and this shows up in 10844a1767b4Smrgdnl tests/mpz/t-jac.c as a wrong result from mpz_kronecker_ui. 10854a1767b4Smrg 10864a1767b4SmrgAC_DEFUN([GMP_GCC_ARM_UMODSI], 10874a1767b4Smrg[AC_MSG_CHECKING([whether ARM gcc unsigned division works]) 10884a1767b4Smrgtmp_version=`$1 --version` 10894a1767b4Smrgecho "$tmp_version" >&AC_FD_CC 10904a1767b4Smrgcase $tmp_version in 10914a1767b4Smrg [2.95 | 2.95.[123]]) 10924a1767b4Smrg ifelse([$3],,:,[$3]) 10934a1767b4Smrg gmp_gcc_arm_umodsi_result=["no, gcc 2.95.[0123]"] ;; 10944a1767b4Smrg *) 10954a1767b4Smrg ifelse([$2],,:,[$2]) 10964a1767b4Smrg gmp_gcc_arm_umodsi_result=yes ;; 10974a1767b4Smrgesac 10984a1767b4SmrgAC_MSG_RESULT([$gmp_gcc_arm_umodsi_result]) 10994a1767b4Smrg]) 11004a1767b4Smrg 11014a1767b4Smrg 11024a1767b4Smrgdnl GMP_GCC_MIPS_O32(gcc,[actions-yes][,[actions-no]]) 11034a1767b4Smrgdnl ------------------------------------------------- 11044a1767b4Smrgdnl Test whether gcc supports o32. 11054a1767b4Smrgdnl 11064a1767b4Smrgdnl gcc 2.7.2.2 only does o32, and doesn't accept -mabi=32. 11074a1767b4Smrgdnl 11084a1767b4Smrgdnl gcc 2.95 accepts -mabi=32 but it only works on irix5, on irix6 it gives 11094a1767b4Smrgdnl "cc1: The -mabi=32 support does not work yet". 11104a1767b4Smrg 11114a1767b4SmrgAC_DEFUN([GMP_GCC_MIPS_O32], 11124a1767b4Smrg[AC_MSG_CHECKING([whether gcc supports o32]) 11134a1767b4Smrgecho 'int x;' >conftest.c 11144a1767b4Smrgecho "$1 -mabi=32 -c conftest.c" >&AC_FD_CC 11154a1767b4Smrgif $1 -mabi=32 -c conftest.c >conftest.out 2>&1; then 11164a1767b4Smrg result=yes 11174a1767b4Smrgelse 11184a1767b4Smrg cat conftest.out >&AC_FD_CC 11194a1767b4Smrg if grep "cc1: Invalid option \`abi=32'" conftest.out >/dev/null; then 11204a1767b4Smrg result=yes 11214a1767b4Smrg else 11224a1767b4Smrg result=no 11234a1767b4Smrg fi 11244a1767b4Smrgfi 11254a1767b4Smrgrm -f conftest.* 11264a1767b4SmrgAC_MSG_RESULT($result) 11274a1767b4Smrgif test $result = yes; then 11284a1767b4Smrg ifelse([$2],,:,[$2]) 11294a1767b4Smrgelse 11304a1767b4Smrg ifelse([$3],,:,[$3]) 11314a1767b4Smrgfi 11324a1767b4Smrg]) 11334a1767b4Smrg 11344a1767b4Smrg 11354a1767b4Smrgdnl GMP_GCC_NO_CPP_PRECOMP(CCBASE,CC,CFLAGS,[ACTIONS-YES][,ACTIONS-NO]) 11364a1767b4Smrgdnl ------------------------------------------------------------------- 11374a1767b4Smrgdnl Check whether -no-cpp-precomp should be used on this compiler, and 11384a1767b4Smrgdnl execute the corresponding ACTIONS-YES or ACTIONS-NO. 11394a1767b4Smrgdnl 11404a1767b4Smrgdnl -no-cpp-precomp is only meant for Apple's hacked version of gcc found 11414a1767b4Smrgdnl on powerpc*-*-darwin*, but we can give it a try on any gcc. Normal gcc 11424a1767b4Smrgdnl (as of 3.0 at least) only gives a warning, not an actual error, and we 11434a1767b4Smrgdnl watch for that and decide against the option in that case, to avoid 11444a1767b4Smrgdnl confusing the user. 11454a1767b4Smrg 11464a1767b4SmrgAC_DEFUN([GMP_GCC_NO_CPP_PRECOMP], 11474a1767b4Smrg[if test "$ccbase" = gcc; then 11484a1767b4Smrg AC_MSG_CHECKING([compiler $2 $3 -no-cpp-precomp]) 11494a1767b4Smrg result=no 11504a1767b4Smrg cat >conftest.c <<EOF 11514a1767b4Smrgint main () { return 0; } 11524a1767b4SmrgEOF 11534a1767b4Smrg gmp_compile="$2 $3 -no-cpp-precomp conftest.c >conftest.out 2>&1" 11544a1767b4Smrg if AC_TRY_EVAL(gmp_compile); then 11554a1767b4Smrg if grep "unrecognized option.*-no-cpp-precomp" conftest.out >/dev/null; then : ; 11564a1767b4Smrg else 11574a1767b4Smrg result=yes 11584a1767b4Smrg fi 11594a1767b4Smrg fi 11604a1767b4Smrg cat conftest.out >&AC_FD_CC 11614a1767b4Smrg rm -f conftest* a.out b.out a.exe a_out.exe 11624a1767b4Smrg AC_MSG_RESULT($result) 11634a1767b4Smrg if test "$result" = yes; then 11644a1767b4Smrg ifelse([$4],,:,[$4]) 11654a1767b4Smrg else 11664a1767b4Smrg ifelse([$5],,:,[$5]) 11674a1767b4Smrg fi 11684a1767b4Smrgfi 11694a1767b4Smrg]) 11704a1767b4Smrg 11714a1767b4Smrg 11724a1767b4Smrgdnl GMP_GCC_PENTIUM4_SSE2(CC+CFLAGS,[ACTION-IF-YES][,ACTION-IF-NO]) 11734a1767b4Smrgdnl --------------------------------------------------------------- 11744a1767b4Smrgdnl Determine whether gcc CC+CFLAGS is a good enough version for 11754a1767b4Smrgdnl -march=pentium4 with sse2. 11764a1767b4Smrgdnl 11774a1767b4Smrgdnl Gcc 3.2.1 was seen generating incorrect code for raw double -> int 11784a1767b4Smrgdnl conversions through a union. We believe the problem is in all 3.1 and 11794a1767b4Smrgdnl 3.2 versions, but that it's fixed in 3.3. 11804a1767b4Smrg 11814a1767b4SmrgAC_DEFUN([GMP_GCC_PENTIUM4_SSE2], 11824a1767b4Smrg[AC_MSG_CHECKING([whether gcc is good for sse2]) 11834a1767b4Smrgcase `$1 -dumpversion` in 11844a1767b4Smrg [3.[012] | 3.[012].*]) result=no ;; 11854a1767b4Smrg *) result=yes ;; 11864a1767b4Smrgesac 11874a1767b4SmrgAC_MSG_RESULT($result) 11884a1767b4Smrgif test "$result" = yes; then 11894a1767b4Smrg ifelse([$2],,:,[$2]) 11904a1767b4Smrgelse 11914a1767b4Smrg ifelse([$3],,:,[$3]) 11924a1767b4Smrgfi 11934a1767b4Smrg]) 11944a1767b4Smrg 11954a1767b4Smrg 11964a1767b4Smrgdnl GMP_GCC_WA_MCPU(CC+CFLAGS, NEWFLAG [,ACTION-YES [,ACTION-NO]]) 11974a1767b4Smrgdnl -------------------------------------------------------------- 11984a1767b4Smrgdnl Check whether gcc (or gas rather) accepts a flag like "-Wa,-mev67". 11994a1767b4Smrgdnl 12004a1767b4Smrgdnl Gas doesn't give an error for an unknown cpu, it only prints a warning 12014a1767b4Smrgdnl like "Warning: Unknown CPU identifier `ev78'". 12024a1767b4Smrgdnl 12034a1767b4Smrgdnl This is intended for use on alpha, since only recent versions of gas 12044a1767b4Smrgdnl accept -mev67, but there's nothing here that's alpha specific. 12054a1767b4Smrg 12064a1767b4SmrgAC_DEFUN([GMP_GCC_WA_MCPU], 12074a1767b4Smrg[AC_MSG_CHECKING([assembler $1 $2]) 12084a1767b4Smrgresult=no 12094a1767b4Smrgcat >conftest.c <<EOF 12104a1767b4Smrgint main () {} 12114a1767b4SmrgEOF 12124a1767b4Smrggmp_compile="$1 $2 -c conftest.c >conftest.out 2>&1" 12134a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 12144a1767b4Smrg if grep "Unknown CPU identifier" conftest.out >/dev/null; then : ; 12154a1767b4Smrg else 12164a1767b4Smrg result=yes 12174a1767b4Smrg fi 12184a1767b4Smrgfi 12194a1767b4Smrgcat conftest.out >&AC_FD_CC 12204a1767b4Smrgrm -f conftest* 12214a1767b4SmrgAC_MSG_RESULT($result) 12224a1767b4Smrgif test "$result" = yes; then 12234a1767b4Smrg ifelse([$3],,:,[$3]) 12244a1767b4Smrgelse 12254a1767b4Smrg ifelse([$4],,:,[$4]) 12264a1767b4Smrgfi 12274a1767b4Smrg]) 12284a1767b4Smrg 12294a1767b4Smrg 12304a1767b4Smrgdnl GMP_GCC_WA_OLDAS(CC+CFLAGS [,ACTION-YES [,ACTION-NO]]) 12314a1767b4Smrgdnl ------------------------------------------------------ 12324a1767b4Smrgdnl Check whether gcc should be run with "-Wa,-oldas". 12334a1767b4Smrgdnl 12344a1767b4Smrgdnl On systems alpha*-*-osf* (or maybe just osf5), apparently there's a 12354a1767b4Smrgdnl newish Compaq "as" which doesn't work with the gcc mips-tfile. 12364a1767b4Smrgdnl Compiling an empty file with "gcc -c foo.c" produces for instance 12374a1767b4Smrgdnl 12384a1767b4Smrgdnl mips-tfile, /tmp/ccaqUNnF.s:7 Segmentation fault 12394a1767b4Smrgdnl 12404a1767b4Smrgdnl The fix is to pass "-oldas" to that assembler, as noted by 12414a1767b4Smrgdnl 12424a1767b4Smrgdnl http://gcc.gnu.org/install/specific.html#alpha*-dec-osf* 12434a1767b4Smrgdnl 12444a1767b4Smrgdnl The test here tries to compile an empty file, and if that fails but 12454a1767b4Smrgdnl adding -Wa,-oldas makes it succeed, then that flag is considered 12464a1767b4Smrgdnl necessary. 12474a1767b4Smrgdnl 12484a1767b4Smrgdnl We look for the failing case specifically, since it may not be a good 12494a1767b4Smrgdnl idea to use -Wa,-oldas in other circumstances. For instance gas takes 12504a1767b4Smrgdnl "-oldas" to mean the "-o" option and will write a file called "ldas" as 12514a1767b4Smrgdnl its output. Normally gcc puts its own "-o" after any -Wa options, so 12524a1767b4Smrgdnl -oldas ends up being harmless, but clearly that's only through good 12534a1767b4Smrgdnl luck. 12544a1767b4Smrgdnl 12554a1767b4Smrgdnl This macro is designed for use while probing for a good compiler, and 12564a1767b4Smrgdnl so doesn't cache it's result. 12574a1767b4Smrg 12584a1767b4SmrgAC_DEFUN([GMP_GCC_WA_OLDAS], 12594a1767b4Smrg[AC_MSG_CHECKING([for $1 -Wa,-oldas]) 12604a1767b4Smrgresult=no 12614a1767b4Smrgcat >conftest.c <<EOF 12624a1767b4SmrgEOF 12634a1767b4Smrgecho "with empty conftest.c" >&AC_FD_CC 12644a1767b4Smrggmp_compile="$1 -c conftest.c >&AC_FD_CC 2>&1" 12654a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then : ; 12664a1767b4Smrgelse 12674a1767b4Smrg # empty fails 12684a1767b4Smrg gmp_compile="$1 -Wa,-oldas -c conftest.c >&AC_FD_CC 2>&1" 12694a1767b4Smrg if AC_TRY_EVAL(gmp_compile); then 12704a1767b4Smrg # but with -Wa,-oldas it works 12714a1767b4Smrg result=yes 12724a1767b4Smrg fi 12734a1767b4Smrgfi 12744a1767b4Smrgrm -f conftest* 12754a1767b4SmrgAC_MSG_RESULT($result) 12764a1767b4Smrgif test "$result" = yes; then 12774a1767b4Smrg ifelse([$2],,:,[$2]) 12784a1767b4Smrgelse 12794a1767b4Smrg ifelse([$3],,:,[$3]) 12804a1767b4Smrgfi 12814a1767b4Smrg]) 12824a1767b4Smrg 12834a1767b4Smrg 12844a1767b4Smrgdnl GMP_OS_X86_XMM(CC+CFLAGS,[ACTION-IF-YES][,ACTION-IF-NO]) 12854a1767b4Smrgdnl -------------------------------------------------------- 12864a1767b4Smrgdnl Determine whether the operating system supports XMM registers. 12874a1767b4Smrgdnl 12884a1767b4Smrgdnl If build==host then a test program is run, executing an SSE2 12894a1767b4Smrgdnl instruction using an XMM register. This will give a SIGILL if the 12904a1767b4Smrgdnl system hasn't set the OSFXSR bit in CR4 to say it knows it must use 12914a1767b4Smrgdnl fxsave/fxrestor in a context switch (to save xmm registers). 12924a1767b4Smrgdnl 12934a1767b4Smrgdnl If build!=host, we can fallback on: 12944a1767b4Smrgdnl 12954a1767b4Smrgdnl - FreeBSD version 4 is the first supporting xmm. 12964a1767b4Smrgdnl 12974a1767b4Smrgdnl - Linux kernel 2.4 might be the first stable series supporting xmm 12984a1767b4Smrgdnl (not sure). But there's no version number in the GNU/Linux 12994a1767b4Smrgdnl config tuple to test anyway. 13004a1767b4Smrgdnl 13014a1767b4Smrgdnl The default is to allow xmm. This might seem rash, but it's likely 13024a1767b4Smrgdnl most systems know xmm by now, so this will normally be what's wanted. 13034a1767b4Smrgdnl And cross compiling is a bit hairy anyway, so hopefully anyone doing it 13044a1767b4Smrgdnl will be smart enough to know what to do. 13054a1767b4Smrgdnl 13064a1767b4Smrgdnl In the test program, .text and .globl are hard coded because this macro 13074a1767b4Smrgdnl is wanted before GMP_ASM_TEXT and GMP_ASM_GLOBL are run. A .byte 13084a1767b4Smrgdnl sequence is used (for xorps %xmm0, %xmm0) to make us independent of 13094a1767b4Smrgdnl tests for whether the assembler supports sse2/xmm. Obviously we need 13104a1767b4Smrgdnl both assembler and OS support, but this means we don't force the order 13114a1767b4Smrgdnl in which we test. 13124a1767b4Smrgdnl 13134a1767b4Smrgdnl FIXME: Maybe we should use $CCAS to assemble, if it's set. (Would 13144a1767b4Smrgdnl still want $CC/$CFLAGS for the link.) But this test is used before 13154a1767b4Smrgdnl AC_PROG_CC sets $OBJEXT, so we'd need to check for various object file 13164a1767b4Smrgdnl suffixes ourselves. 13174a1767b4Smrg 13184a1767b4SmrgAC_DEFUN([GMP_OS_X86_XMM], 13194a1767b4Smrg[AC_CACHE_CHECK([whether the operating system supports XMM registers], 13204a1767b4Smrg gmp_cv_os_x86_xmm, 13214a1767b4Smrg[if test "$build" = "$host"; then 13224a1767b4Smrg # remove anything that might look like compiler output to our "||" expression 13234a1767b4Smrg rm -f conftest* a.out b.out a.exe a_out.exe 13244a1767b4Smrg cat >conftest.s <<EOF 13254a1767b4Smrg .text 13264a1767b4Smrgmain: 13274a1767b4Smrg_main: 13284a1767b4Smrg .globl main 13294a1767b4Smrg .globl _main 13304a1767b4Smrg .byte 0x0f, 0x57, 0xc0 13314a1767b4Smrg xorl %eax, %eax 13324a1767b4Smrg ret 13334a1767b4SmrgEOF 13344a1767b4Smrg gmp_compile="$1 conftest.s -o conftest >&AC_FD_CC" 13354a1767b4Smrg if AC_TRY_EVAL(gmp_compile); then 13364a1767b4Smrg if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then 13374a1767b4Smrg gmp_cv_os_x86_xmm=yes 13384a1767b4Smrg else 13394a1767b4Smrg gmp_cv_os_x86_xmm=no 13404a1767b4Smrg fi 13414a1767b4Smrg else 13424a1767b4Smrg AC_MSG_WARN([Oops, cannot compile test program]) 13434a1767b4Smrg fi 13444a1767b4Smrg rm -f conftest* 13454a1767b4Smrgfi 13464a1767b4Smrg 13474a1767b4Smrgif test -z "$gmp_cv_os_x86_xmm"; then 13484a1767b4Smrg case $host_os in 13494a1767b4Smrg [freebsd[123] | freebsd[123].*]) 13504a1767b4Smrg gmp_cv_os_x86_xmm=no ;; 13514a1767b4Smrg freebsd*) 13524a1767b4Smrg gmp_cv_os_x86_xmm=yes ;; 13534a1767b4Smrg *) 13544a1767b4Smrg gmp_cv_os_x86_xmm=probably ;; 13554a1767b4Smrg esac 13564a1767b4Smrgfi 13574a1767b4Smrg]) 13584a1767b4Smrg 13594a1767b4Smrgif test "$gmp_cv_os_x86_xmm" = probably; then 13604a1767b4Smrg AC_MSG_WARN([Not certain of OS support for xmm when cross compiling.]) 13614a1767b4Smrg AC_MSG_WARN([Will assume it's ok, expect a SIGILL if this is wrong.]) 13624a1767b4Smrgfi 13634a1767b4Smrg 13644a1767b4Smrgcase $gmp_cv_os_x86_xmm in 13654a1767b4Smrgno) 13664a1767b4Smrg $3 13674a1767b4Smrg ;; 13684a1767b4Smrg*) 13694a1767b4Smrg $2 13704a1767b4Smrg ;; 13714a1767b4Smrgesac 13724a1767b4Smrg]) 13734a1767b4Smrg 13744a1767b4Smrg 13754a1767b4Smrgdnl GMP_CRAY_HOST_TYPES(C90/T90-IEEE, C90/T90-CFP, J90/SV1) 13764a1767b4Smrgdnl ------------------------------------------------------- 13774a1767b4Smrgdnl Execute the actions in the arguments on the respective Cray vector 13784a1767b4Smrgdnl systems. For other hosts, do nothing. 13794a1767b4Smrgdnl 13804a1767b4Smrgdnl This macro should be used after the C compiler has been chosen, since 13814a1767b4Smrgdnl on c90 and t90 we ask the compiler whether we're in IEEE or CFP float 13824a1767b4Smrgdnl mode. 13834a1767b4Smrgdnl 13844a1767b4Smrgdnl This code is in a macro so that any AC_REQUIRE pre-requisites of 13854a1767b4Smrgdnl AC_EGREP_CPP will be expanded at the top-level, ie. for all hosts not 13864a1767b4Smrgdnl merely c90 and t90. In autoconf 2.57 for instance this means 13874a1767b4Smrgdnl AC_PROG_EGREP, which is needed by various other macros. 13884a1767b4Smrg 13894a1767b4SmrgAC_DEFUN([GMP_CRAY_OPTIONS], 13904a1767b4Smrg[case $host_cpu in 13914a1767b4Smrg c90 | t90) 13924a1767b4Smrg AC_EGREP_CPP(yes, 13934a1767b4Smrg[#ifdef _CRAYIEEE 13944a1767b4Smrgyes 13954a1767b4Smrg#endif], 13964a1767b4Smrg [$1], 13974a1767b4Smrg [$2]) 13984a1767b4Smrg ;; 13994a1767b4Smrg j90 | sv1) 14004a1767b4Smrg [$3] 14014a1767b4Smrg ;; 14024a1767b4Smrgesac 14034a1767b4Smrg]) 14044a1767b4Smrg 14054a1767b4Smrg 14064a1767b4Smrgdnl GMP_HPPA_LEVEL_20(cc/cflags [, ACTION-GOOD [,ACTION-BAD]]) 14074a1767b4Smrgdnl ---------------------------------------------------------- 14084a1767b4Smrgdnl Check that the given cc/cflags accepts HPPA 2.0n assembler code. 14094a1767b4Smrgdnl 14104a1767b4Smrgdnl Old versions of gas don't know 2.0 instructions. It rejects ".level 14114a1767b4Smrgdnl 2.0" for a start, so just test that. 14124a1767b4Smrgdnl 14134a1767b4Smrgdnl This test is designed to be run for various different compiler and 14144a1767b4Smrgdnl flags combinations, and hence doesn't cache its result. 14154a1767b4Smrg 14164a1767b4SmrgAC_DEFUN([GMP_HPPA_LEVEL_20], 14174a1767b4Smrg[AC_MSG_CHECKING([$1 assembler knows hppa 2.0]) 14184a1767b4Smrgresult=no 14194a1767b4Smrgcat >conftest.s <<EOF 14204a1767b4Smrg .level 2.0 14214a1767b4SmrgEOF 14224a1767b4Smrggmp_compile="$1 -c conftest.s >&AC_FD_CC 2>&1" 14234a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 14244a1767b4Smrg result=yes 14254a1767b4Smrgelse 14264a1767b4Smrg echo "failed program was" >&AC_FD_CC 14274a1767b4Smrg cat conftest.s >&AC_FD_CC 14284a1767b4Smrgfi 14294a1767b4Smrgrm -f conftest* 14304a1767b4SmrgAC_MSG_RESULT($result) 14314a1767b4Smrgif test "$result" = yes; then 14324a1767b4Smrg ifelse([$2],,:,[$2]) 14334a1767b4Smrgelse 14344a1767b4Smrg ifelse([$3],,:,[$3]) 14354a1767b4Smrgfi 14364a1767b4Smrg]) 14374a1767b4Smrg 14384a1767b4Smrg 14394a1767b4Smrgdnl GMP_PROG_CXX_WORKS(cxx/cxxflags [, ACTION-YES [,ACTION-NO]]) 14404a1767b4Smrgdnl ------------------------------------------------------------ 14414a1767b4Smrgdnl Check whether cxx/cxxflags can compile and link. 14424a1767b4Smrgdnl 14434a1767b4Smrgdnl This test is designed to be run repeatedly with different cxx/cxxflags 14444a1767b4Smrgdnl selections, so the result is not cached. 14454a1767b4Smrgdnl 14464a1767b4Smrgdnl For a native build, we insist on being able to run the program, so as 14474a1767b4Smrgdnl to detect any problems with the standard C++ library. During 14484a1767b4Smrgdnl development various systems with broken or incomplete C++ installations 14494a1767b4Smrgdnl were seen. 14504a1767b4Smrgdnl 14514a1767b4Smrgdnl The various features and problems we try to detect are done in separate 14524a1767b4Smrgdnl compiles. Although this is probably a bit slower than one test 14534a1767b4Smrgdnl program, it makes it easy to indicate the problem in AC_MSG_RESULT, 14544a1767b4Smrgdnl hence giving the user a clue about why we rejected the compiler. 14554a1767b4Smrg 14564a1767b4SmrgAC_DEFUN([GMP_PROG_CXX_WORKS], 14574a1767b4Smrg[AC_MSG_CHECKING([C++ compiler $1]) 14584a1767b4Smrggmp_prog_cxx_works=yes 14594a1767b4Smrg 14604a1767b4Smrg# start with a plain "main()", then go on to further checks 14614a1767b4SmrgGMP_PROG_CXX_WORKS_PART([$1], []) 14624a1767b4Smrg 14634a1767b4SmrgGMP_PROG_CXX_WORKS_PART([$1], [namespace], 14644a1767b4Smrg[namespace foo { } 14654a1767b4Smrgusing namespace foo; 14664a1767b4Smrg]) 14674a1767b4Smrg 14684a1767b4Smrg# GMP requires the standard C++ iostream classes 14694a1767b4SmrgGMP_PROG_CXX_WORKS_PART([$1], [std iostream], 14704a1767b4Smrg[/* This test rejects g++ 2.7.2 which doesn't have <iostream>, only a 14714a1767b4Smrg pre-standard iostream.h. */ 14724a1767b4Smrg#include <iostream> 14734a1767b4Smrg 14744a1767b4Smrg/* This test rejects OSF 5.1 Compaq C++ in its default pre-standard iostream 14754a1767b4Smrg mode, since that mode puts cout in the global namespace, not "std". */ 14764a1767b4Smrgvoid someoutput (void) { std::cout << 123; } 14774a1767b4Smrg]) 14784a1767b4Smrg 14794a1767b4SmrgAC_MSG_RESULT($gmp_prog_cxx_works) 14804a1767b4Smrgcase $gmp_prog_cxx_works in 14814a1767b4Smrg yes) 14824a1767b4Smrg [$2] 14834a1767b4Smrg ;; 14844a1767b4Smrg *) 14854a1767b4Smrg [$3] 14864a1767b4Smrg ;; 14874a1767b4Smrgesac 14884a1767b4Smrg]) 14894a1767b4Smrg 14904a1767b4Smrgdnl Called: GMP_PROG_CXX_WORKS_PART(CXX+CXXFLAGS, FAIL-MESSAGE [,CODE]) 14914a1767b4Smrgdnl 14924a1767b4SmrgAC_DEFUN([GMP_PROG_CXX_WORKS_PART], 14934a1767b4Smrg[if test "$gmp_prog_cxx_works" = yes; then 14944a1767b4Smrg # remove anything that might look like compiler output to our "||" expression 14954a1767b4Smrg rm -f conftest* a.out b.out a.exe a_out.exe 14964a1767b4Smrg cat >conftest.cc <<EOF 14974a1767b4Smrg[$3] 14984a1767b4Smrgint main (void) { return 0; } 14994a1767b4SmrgEOF 15004a1767b4Smrg echo "Test compile: [$2]" >&AC_FD_CC 15014a1767b4Smrg gmp_cxxcompile="$1 conftest.cc >&AC_FD_CC" 15024a1767b4Smrg if AC_TRY_EVAL(gmp_cxxcompile); then 15034a1767b4Smrg if test "$cross_compiling" = no; then 15044a1767b4Smrg if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :; 15054a1767b4Smrg else 15064a1767b4Smrg gmp_prog_cxx_works="no[]m4_if([$2],,,[, ])[$2], program does not run" 15074a1767b4Smrg fi 15084a1767b4Smrg fi 15094a1767b4Smrg else 15104a1767b4Smrg gmp_prog_cxx_works="no[]m4_if([$2],,,[, ])[$2]" 15114a1767b4Smrg fi 15124a1767b4Smrg case $gmp_prog_cxx_works in 15134a1767b4Smrg no*) 15144a1767b4Smrg echo "failed program was:" >&AC_FD_CC 15154a1767b4Smrg cat conftest.cc >&AC_FD_CC 15164a1767b4Smrg ;; 15174a1767b4Smrg esac 15184a1767b4Smrg rm -f conftest* a.out b.out a.exe a_out.exe 15194a1767b4Smrgfi 15204a1767b4Smrg]) 15214a1767b4Smrg 15224a1767b4Smrg 15234a1767b4Smrgdnl GMP_INIT([M4-DEF-FILE]) 15244a1767b4Smrgdnl ----------------------- 15254a1767b4Smrgdnl Initializations for GMP config.m4 generation. 15264a1767b4Smrgdnl 15274a1767b4Smrgdnl FIXME: The generated config.m4 doesn't get recreated by config.status. 15284a1767b4Smrgdnl Maybe the relevant "echo"s should go through AC_CONFIG_COMMANDS. 15294a1767b4Smrg 15304a1767b4SmrgAC_DEFUN([GMP_INIT], 15314a1767b4Smrg[ifelse([$1], , gmp_configm4=config.m4, gmp_configm4="[$1]") 15324a1767b4Smrggmp_tmpconfigm4=cnfm4.tmp 15334a1767b4Smrggmp_tmpconfigm4i=cnfm4i.tmp 15344a1767b4Smrggmp_tmpconfigm4p=cnfm4p.tmp 15354a1767b4Smrgrm -f $gmp_tmpconfigm4 $gmp_tmpconfigm4i $gmp_tmpconfigm4p 15364a1767b4Smrg 15374a1767b4Smrg# CONFIG_TOP_SRCDIR is a path from the mpn builddir to the top srcdir. 15384a1767b4Smrg# The pattern here tests for an absolute path the same way as 15394a1767b4Smrg# _AC_OUTPUT_FILES in autoconf acgeneral.m4. 15404a1767b4Smrgcase $srcdir in 15414a1767b4Smrg[[\\/]]* | ?:[[\\/]]* ) tmp="$srcdir" ;; 15424a1767b4Smrg*) tmp="../$srcdir" ;; 15434a1767b4Smrgesac 15444a1767b4Smrgecho ["define(<CONFIG_TOP_SRCDIR>,<\`$tmp'>)"] >>$gmp_tmpconfigm4 15454a1767b4Smrg 15464a1767b4Smrg# All CPUs use asm-defs.m4 15474a1767b4Smrgecho ["include][(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"] >>$gmp_tmpconfigm4i 15484a1767b4Smrg]) 15494a1767b4Smrg 15504a1767b4Smrg 15514a1767b4Smrgdnl GMP_FINISH 15524a1767b4Smrgdnl ---------- 15534a1767b4Smrgdnl Create config.m4 from its accumulated parts. 15544a1767b4Smrgdnl 15554a1767b4Smrgdnl __CONFIG_M4_INCLUDED__ is used so that a second or subsequent include 15564a1767b4Smrgdnl of config.m4 is harmless. 15574a1767b4Smrgdnl 15584a1767b4Smrgdnl A separate ifdef on the angle bracket quoted part ensures the quoting 15594a1767b4Smrgdnl style there is respected. The basic defines from gmp_tmpconfigm4 are 15604a1767b4Smrgdnl fully quoted but are still put under an ifdef in case any have been 15614a1767b4Smrgdnl redefined by one of the m4 include files. 15624a1767b4Smrgdnl 15634a1767b4Smrgdnl Doing a big ifdef within asm-defs.m4 and/or other macro files wouldn't 15644a1767b4Smrgdnl work, since it'd interpret parentheses and quotes in dnl comments, and 15654a1767b4Smrgdnl having a whole file as a macro argument would overflow the string space 15664a1767b4Smrgdnl on BSD m4. 15674a1767b4Smrg 15684a1767b4SmrgAC_DEFUN([GMP_FINISH], 15694a1767b4Smrg[AC_REQUIRE([GMP_INIT]) 15704a1767b4Smrgecho "creating $gmp_configm4" 15714a1767b4Smrgecho ["d""nl $gmp_configm4. Generated automatically by configure."] > $gmp_configm4 15724a1767b4Smrgif test -f $gmp_tmpconfigm4; then 15734a1767b4Smrg echo ["changequote(<,>)"] >> $gmp_configm4 15744a1767b4Smrg echo ["ifdef(<__CONFIG_M4_INCLUDED__>,,<"] >> $gmp_configm4 15754a1767b4Smrg cat $gmp_tmpconfigm4 >> $gmp_configm4 15764a1767b4Smrg echo [">)"] >> $gmp_configm4 15774a1767b4Smrg echo ["changequote(\`,')"] >> $gmp_configm4 15784a1767b4Smrg rm $gmp_tmpconfigm4 15794a1767b4Smrgfi 15804a1767b4Smrgecho ["ifdef(\`__CONFIG_M4_INCLUDED__',,\`"] >> $gmp_configm4 15814a1767b4Smrgif test -f $gmp_tmpconfigm4i; then 15824a1767b4Smrg cat $gmp_tmpconfigm4i >> $gmp_configm4 15834a1767b4Smrg rm $gmp_tmpconfigm4i 15844a1767b4Smrgfi 15854a1767b4Smrgif test -f $gmp_tmpconfigm4p; then 15864a1767b4Smrg cat $gmp_tmpconfigm4p >> $gmp_configm4 15874a1767b4Smrg rm $gmp_tmpconfigm4p 15884a1767b4Smrgfi 15894a1767b4Smrgecho ["')"] >> $gmp_configm4 15904a1767b4Smrgecho ["define(\`__CONFIG_M4_INCLUDED__')"] >> $gmp_configm4 15914a1767b4Smrg]) 15924a1767b4Smrg 15934a1767b4Smrg 15944a1767b4Smrgdnl GMP_INCLUDE_MPN(FILE) 15954a1767b4Smrgdnl --------------------- 15964a1767b4Smrgdnl Add an include_mpn(`FILE') to config.m4. FILE should be a path 15974a1767b4Smrgdnl relative to the mpn source directory, for example 15984a1767b4Smrgdnl 15994a1767b4Smrgdnl GMP_INCLUDE_MPN(`x86/x86-defs.m4') 16004a1767b4Smrgdnl 16014a1767b4Smrg 16024a1767b4SmrgAC_DEFUN([GMP_INCLUDE_MPN], 16034a1767b4Smrg[AC_REQUIRE([GMP_INIT]) 16044a1767b4Smrgecho ["include_mpn(\`$1')"] >> $gmp_tmpconfigm4i 16054a1767b4Smrg]) 16064a1767b4Smrg 16074a1767b4Smrg 16084a1767b4Smrgdnl GMP_DEFINE(MACRO, DEFINITION [, LOCATION]) 16094a1767b4Smrgdnl ------------------------------------------ 16104a1767b4Smrgdnl Define M4 macro MACRO as DEFINITION in temporary file. 16114a1767b4Smrgdnl 16124a1767b4Smrgdnl If LOCATION is `POST', the definition will appear after any include() 16134a1767b4Smrgdnl directives inserted by GMP_INCLUDE. Mind the quoting! No shell 16144a1767b4Smrgdnl variables will get expanded. Don't forget to invoke GMP_FINISH to 16154a1767b4Smrgdnl create file config.m4. config.m4 uses `<' and '>' as quote characters 16164a1767b4Smrgdnl for all defines. 16174a1767b4Smrg 16184a1767b4SmrgAC_DEFUN([GMP_DEFINE], 16194a1767b4Smrg[AC_REQUIRE([GMP_INIT]) 16204a1767b4Smrgecho ['define(<$1>, <$2>)'] >>ifelse([$3], [POST], 16214a1767b4Smrg $gmp_tmpconfigm4p, $gmp_tmpconfigm4) 16224a1767b4Smrg]) 16234a1767b4Smrg 16244a1767b4Smrg 16254a1767b4Smrgdnl GMP_DEFINE_RAW(STRING [, LOCATION]) 16264a1767b4Smrgdnl ------------------------------------ 16274a1767b4Smrgdnl Put STRING into config.m4 file. 16284a1767b4Smrgdnl 16294a1767b4Smrgdnl If LOCATION is `POST', the definition will appear after any include() 16304a1767b4Smrgdnl directives inserted by GMP_INCLUDE. Don't forget to invoke GMP_FINISH 16314a1767b4Smrgdnl to create file config.m4. 16324a1767b4Smrg 16334a1767b4SmrgAC_DEFUN([GMP_DEFINE_RAW], 16344a1767b4Smrg[AC_REQUIRE([GMP_INIT]) 16354a1767b4Smrgecho [$1] >> ifelse([$2], [POST], $gmp_tmpconfigm4p, $gmp_tmpconfigm4) 16364a1767b4Smrg]) 16374a1767b4Smrg 16384a1767b4Smrg 16394a1767b4Smrgdnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail]) 16404a1767b4Smrgdnl ---------------------------------------------------------- 16414a1767b4Smrgdnl Attempt to assemble the given code. 16424a1767b4Smrgdnl Do "action-success" if this succeeds, "action-fail" if not. 16434a1767b4Smrgdnl 16444a1767b4Smrgdnl conftest.o and conftest.out are available for inspection in 16454a1767b4Smrgdnl "action-success". If either action does a "break" out of a loop then 16464a1767b4Smrgdnl an explicit "rm -f conftest*" will be necessary. 16474a1767b4Smrgdnl 16484a1767b4Smrgdnl This is not unlike AC_TRY_COMPILE, but there's no default includes or 16494a1767b4Smrgdnl anything in "asm-code", everything wanted must be given explicitly. 16504a1767b4Smrg 16514a1767b4SmrgAC_DEFUN([GMP_TRY_ASSEMBLE], 16524a1767b4Smrg[cat >conftest.s <<EOF 16534a1767b4Smrg[$1] 16544a1767b4SmrgEOF 16554a1767b4Smrggmp_assemble="$CCAS $CFLAGS $CPPFLAGS conftest.s >conftest.out 2>&1" 16564a1767b4Smrgif AC_TRY_EVAL(gmp_assemble); then 16574a1767b4Smrg cat conftest.out >&AC_FD_CC 16584a1767b4Smrg ifelse([$2],,:,[$2]) 16594a1767b4Smrgelse 16604a1767b4Smrg cat conftest.out >&AC_FD_CC 16614a1767b4Smrg echo "configure: failed program was:" >&AC_FD_CC 16624a1767b4Smrg cat conftest.s >&AC_FD_CC 16634a1767b4Smrg ifelse([$3],,:,[$3]) 16644a1767b4Smrgfi 16654a1767b4Smrgrm -f conftest* 16664a1767b4Smrg]) 16674a1767b4Smrg 16684a1767b4Smrg 16694a1767b4Smrgdnl Checks whether the stack can be marked nonexecutable by passing an option 167021c03f4cSmrgdnl to the C-compiler when acting on .s files. Appends that option to ASMFLAGS. 16714a1767b4Smrgdnl This macro is adapted from one found in GLIBC-2.3.5. 167221c03f4cSmrgdnl FIXME: This test looks broken. It tests that a file with .note.GNU-stack... 167321c03f4cSmrgdnl can be compiled/assembled with -Wa,--noexecstack. It does not determine 167421c03f4cSmrgdnl if that command-line option has any effect on general asm code. 16754a1767b4SmrgAC_DEFUN([CL_AS_NOEXECSTACK],[ 16764a1767b4Smrgdnl AC_REQUIRE([AC_PROG_CC]) GMP uses something else 16774a1767b4SmrgAC_CACHE_CHECK([whether assembler supports --noexecstack option], 16784a1767b4Smrgcl_cv_as_noexecstack, [dnl 16794a1767b4Smrg cat > conftest.c <<EOF 16804a1767b4Smrgvoid foo() {} 16814a1767b4SmrgEOF 16824a1767b4Smrg if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS 16834a1767b4Smrg -S -o conftest.s conftest.c >/dev/null]) \ 16844a1767b4Smrg && grep .note.GNU-stack conftest.s >/dev/null \ 16854a1767b4Smrg && AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -Wa,--noexecstack 16864a1767b4Smrg -c -o conftest.o conftest.s >/dev/null]) 16874a1767b4Smrg then 16884a1767b4Smrg cl_cv_as_noexecstack=yes 16894a1767b4Smrg else 16904a1767b4Smrg cl_cv_as_noexecstack=no 16914a1767b4Smrg fi 16924a1767b4Smrg rm -f conftest*]) 16934a1767b4Smrg if test "$cl_cv_as_noexecstack" = yes; then 16944a1767b4Smrg ASMFLAGS="$ASMFLAGS -Wa,--noexecstack" 16954a1767b4Smrg fi 16964a1767b4Smrg AC_SUBST(ASMFLAGS) 16974a1767b4Smrg]) 16984a1767b4Smrg 16994a1767b4Smrg 17004a1767b4Smrgdnl GMP_ASM_LABEL_SUFFIX 17014a1767b4Smrgdnl -------------------- 17024a1767b4Smrgdnl : - is usual. 17034a1767b4Smrgdnl empty - hppa on HP-UX doesn't use a :, just the label name 17044a1767b4Smrgdnl 17054a1767b4Smrgdnl Note that it's necessary to test the empty case first, since HP "as" 17064a1767b4Smrgdnl will accept "somelabel:", and take it to mean a label with a name that 17074a1767b4Smrgdnl happens to end in a colon. 17084a1767b4Smrg 17094a1767b4SmrgAC_DEFUN([GMP_ASM_LABEL_SUFFIX], 17104a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 17114a1767b4SmrgAC_CACHE_CHECK([for assembler label suffix], 17124a1767b4Smrg gmp_cv_asm_label_suffix, 17134a1767b4Smrg[gmp_cv_asm_label_suffix=unknown 17144a1767b4Smrgfor i in "" ":"; do 17154a1767b4Smrg echo "trying $i" >&AC_FD_CC 17164a1767b4Smrg GMP_TRY_ASSEMBLE( 17174a1767b4Smrg[ $gmp_cv_asm_text 17184a1767b4Smrgsomelabel$i], 17194a1767b4Smrg [gmp_cv_asm_label_suffix=$i 17204a1767b4Smrg rm -f conftest* 17214a1767b4Smrg break], 17224a1767b4Smrg [cat conftest.out >&AC_FD_CC]) 17234a1767b4Smrgdone 17244a1767b4Smrgif test "$gmp_cv_asm_label_suffix" = "unknown"; then 17254a1767b4Smrg AC_MSG_ERROR([Cannot determine label suffix]) 17264a1767b4Smrgfi 17274a1767b4Smrg]) 17284a1767b4Smrgecho ["define(<LABEL_SUFFIX>, <$gmp_cv_asm_label_suffix>)"] >> $gmp_tmpconfigm4 17294a1767b4Smrg]) 17304a1767b4Smrg 17314a1767b4Smrg 17324a1767b4Smrgdnl GMP_ASM_UNDERSCORE 17334a1767b4Smrgdnl ------------------ 17344a1767b4Smrgdnl Determine whether global symbols need to be prefixed with an underscore. 17354a1767b4Smrgdnl The output from "nm" is grepped to see what a typical symbol looks like. 17364a1767b4Smrgdnl 17374a1767b4Smrgdnl This test used to grep the .o file directly, but that failed with greps 17384a1767b4Smrgdnl that don't like binary files (eg. SunOS 4). 17394a1767b4Smrgdnl 17404a1767b4Smrgdnl This test also used to construct an assembler file with and without an 17414a1767b4Smrgdnl underscore and try to link that to a C file, to see which worked. 17424a1767b4Smrgdnl Although that's what will happen in the real build we don't really want 17434a1767b4Smrgdnl to depend on creating asm files within configure for every possible CPU 17444a1767b4Smrgdnl (or at least we don't want to do that more than we have to). 17454a1767b4Smrgdnl 17464a1767b4Smrgdnl The fallback on no underscore is based on the assumption that the world 17474a1767b4Smrgdnl is moving towards non-underscore systems. There should actually be no 17484a1767b4Smrgdnl good reason for nm to fail though. 17494a1767b4Smrg 17504a1767b4SmrgAC_DEFUN([GMP_ASM_UNDERSCORE], 17514a1767b4Smrg[AC_REQUIRE([GMP_PROG_NM]) 17524a1767b4SmrgAC_CACHE_CHECK([if globals are prefixed by underscore], 17534a1767b4Smrg gmp_cv_asm_underscore, 17544a1767b4Smrg[gmp_cv_asm_underscore="unknown" 17554a1767b4Smrgcat >conftest.c <<EOF 17564a1767b4Smrgint gurkmacka; 17574a1767b4SmrgEOF 17584a1767b4Smrggmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC" 17594a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 17604a1767b4Smrg $NM conftest.$OBJEXT >conftest.out 176121c03f4cSmrg if grep "[[ ]]_gurkmacka" conftest.out >/dev/null; then 17624a1767b4Smrg gmp_cv_asm_underscore=yes 176321c03f4cSmrg elif grep "[[ ]]gurkmacka" conftest.out >/dev/null; then 17644a1767b4Smrg gmp_cv_asm_underscore=no 17654a1767b4Smrg else 17664a1767b4Smrg echo "configure: $NM doesn't have gurkmacka:" >&AC_FD_CC 17674a1767b4Smrg cat conftest.out >&AC_FD_CC 17684a1767b4Smrg fi 17694a1767b4Smrgelse 17704a1767b4Smrg echo "configure: failed program was:" >&AC_FD_CC 17714a1767b4Smrg cat conftest.c >&AC_FD_CC 17724a1767b4Smrgfi 17734a1767b4Smrgrm -f conftest* 17744a1767b4Smrg]) 17754a1767b4Smrgcase $gmp_cv_asm_underscore in 17764a1767b4Smrg yes) 17774a1767b4Smrg GMP_DEFINE(GSYM_PREFIX, [_]) ;; 17784a1767b4Smrg no) 17794a1767b4Smrg GMP_DEFINE(GSYM_PREFIX, []) ;; 17804a1767b4Smrg *) 17814a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 17824a1767b4Smrg AC_MSG_WARN([| Cannot determine global symbol prefix.]) 17834a1767b4Smrg AC_MSG_WARN([| $NM output doesn't contain a global data symbol.]) 17844a1767b4Smrg AC_MSG_WARN([| Will proceed with no underscore.]) 17854a1767b4Smrg AC_MSG_WARN([| If this is wrong then you'll get link errors referring]) 17864a1767b4Smrg AC_MSG_WARN([| to ___gmpn_add_n (note three underscores).]) 17874a1767b4Smrg AC_MSG_WARN([| In this case do a fresh build with an override,]) 17884a1767b4Smrg AC_MSG_WARN([| ./configure gmp_cv_asm_underscore=yes]) 17894a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 17904a1767b4Smrg GMP_DEFINE(GSYM_PREFIX, []) 17914a1767b4Smrg ;; 17924a1767b4Smrgesac 17934a1767b4Smrg]) 17944a1767b4Smrg 17954a1767b4Smrg 17964a1767b4Smrgdnl GMP_ASM_ALIGN_LOG 17974a1767b4Smrgdnl ----------------- 17984a1767b4Smrgdnl Is parameter to `.align' logarithmic? 17994a1767b4Smrg 18004a1767b4SmrgAC_DEFUN([GMP_ASM_ALIGN_LOG], 18014a1767b4Smrg[AC_REQUIRE([GMP_ASM_GLOBL]) 18024a1767b4SmrgAC_REQUIRE([GMP_ASM_BYTE]) 18034a1767b4SmrgAC_REQUIRE([GMP_ASM_DATA]) 18044a1767b4SmrgAC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) 18054a1767b4SmrgAC_REQUIRE([GMP_PROG_NM]) 18064a1767b4SmrgAC_CACHE_CHECK([if .align assembly directive is logarithmic], 18074a1767b4Smrg gmp_cv_asm_align_log, 18084a1767b4Smrg[GMP_TRY_ASSEMBLE( 18094a1767b4Smrg[ $gmp_cv_asm_data 18104a1767b4Smrg .align 4 18114a1767b4Smrg $gmp_cv_asm_globl foo 18124a1767b4Smrg $gmp_cv_asm_byte 1 18134a1767b4Smrg .align 4 18144a1767b4Smrgfoo$gmp_cv_asm_label_suffix 18154a1767b4Smrg $gmp_cv_asm_byte 2], 18164a1767b4Smrg [gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \ 18174a1767b4Smrg sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`] 18184a1767b4Smrg if test "$gmp_tmp_val" = "10" || test "$gmp_tmp_val" = "16"; then 18194a1767b4Smrg gmp_cv_asm_align_log=yes 18204a1767b4Smrg else 18214a1767b4Smrg gmp_cv_asm_align_log=no 18224a1767b4Smrg fi], 18234a1767b4Smrg [AC_MSG_ERROR([cannot assemble alignment test])])]) 18244a1767b4Smrg 18254a1767b4SmrgGMP_DEFINE_RAW(["define(<ALIGN_LOGARITHMIC>,<$gmp_cv_asm_align_log>)"]) 18264a1767b4Smrg]) 18274a1767b4Smrg 18284a1767b4Smrg 18294a1767b4Smrgdnl GMP_ASM_ALIGN_FILL_0x90 18304a1767b4Smrgdnl ----------------------- 18314a1767b4Smrgdnl Determine whether a ",0x90" suffix works on a .align directive. 18324a1767b4Smrgdnl This is only meant for use on x86, 0x90 being a "nop". 18334a1767b4Smrgdnl 18344a1767b4Smrgdnl Old gas, eg. 1.92.3 18354a1767b4Smrgdnl Needs ",0x90" or else the fill is 0x00, which can't be executed 18364a1767b4Smrgdnl across. 18374a1767b4Smrgdnl 18384a1767b4Smrgdnl New gas, eg. 2.91 18394a1767b4Smrgdnl Generates multi-byte nop fills even when ",0x90" is given. 18404a1767b4Smrgdnl 18414a1767b4Smrgdnl Solaris 2.6 as 18424a1767b4Smrgdnl ",0x90" is not allowed, causes a fatal error. 18434a1767b4Smrgdnl 18444a1767b4Smrgdnl Solaris 2.8 as 18454a1767b4Smrgdnl ",0x90" does nothing, generates a warning that it's being ignored. 18464a1767b4Smrgdnl 18474a1767b4Smrgdnl SCO OpenServer 5 as 18484a1767b4Smrgdnl Second parameter is max bytes to fill, not a fill pattern. 18494a1767b4Smrgdnl ",0x90" is an error due to being bigger than the first parameter. 18504a1767b4Smrgdnl Multi-byte nop fills are generated in text segments. 18514a1767b4Smrgdnl 18524a1767b4Smrgdnl Note that both solaris "as"s only care about ",0x90" if they actually 18534a1767b4Smrgdnl have to use it to fill something, hence the .byte in the test. It's 18544a1767b4Smrgdnl the second .align which provokes the error or warning. 18554a1767b4Smrgdnl 18564a1767b4Smrgdnl The warning from solaris 2.8 is suppressed to stop anyone worrying that 18574a1767b4Smrgdnl something might be wrong. 18584a1767b4Smrg 18594a1767b4SmrgAC_DEFUN([GMP_ASM_ALIGN_FILL_0x90], 18604a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 18614a1767b4SmrgAC_CACHE_CHECK([if the .align directive accepts an 0x90 fill in .text], 18624a1767b4Smrg gmp_cv_asm_align_fill_0x90, 18634a1767b4Smrg[GMP_TRY_ASSEMBLE( 18644a1767b4Smrg[ $gmp_cv_asm_text 18654a1767b4Smrg .align 4, 0x90 18664a1767b4Smrg .byte 0 18674a1767b4Smrg .align 4, 0x90], 18684a1767b4Smrg[if grep "Warning: Fill parameter ignored for executable section" conftest.out >/dev/null; then 186921c03f4cSmrg echo "Suppressing this warning by omitting 0x90" 1>&AC_FD_CC 18704a1767b4Smrg gmp_cv_asm_align_fill_0x90=no 18714a1767b4Smrgelse 18724a1767b4Smrg gmp_cv_asm_align_fill_0x90=yes 18734a1767b4Smrgfi], 18744a1767b4Smrg[gmp_cv_asm_align_fill_0x90=no])]) 18754a1767b4Smrg 18764a1767b4SmrgGMP_DEFINE_RAW(["define(<ALIGN_FILL_0x90>,<$gmp_cv_asm_align_fill_0x90>)"]) 18774a1767b4Smrg]) 18784a1767b4Smrg 18794a1767b4Smrg 18804a1767b4Smrgdnl GMP_ASM_BYTE 18814a1767b4Smrgdnl ------------ 18824a1767b4Smrgdnl .byte - is usual. 18834a1767b4Smrgdnl data1 - required by ia64 (on hpux at least). 18844a1767b4Smrgdnl 18854a1767b4Smrgdnl This macro is just to support other configure tests, not any actual asm 18864a1767b4Smrgdnl code. 18874a1767b4Smrg 18884a1767b4SmrgAC_DEFUN([GMP_ASM_BYTE], 18894a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 18904a1767b4SmrgAC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) 18914a1767b4SmrgAC_CACHE_CHECK([for assembler byte directive], 18924a1767b4Smrg gmp_cv_asm_byte, 18934a1767b4Smrg[for i in .byte data1; do 18944a1767b4Smrg echo "trying $i" >&AC_FD_CC 18954a1767b4Smrg GMP_TRY_ASSEMBLE( 18964a1767b4Smrg[ $gmp_cv_asm_data 18974a1767b4Smrg $i 0 18984a1767b4Smrg], 18994a1767b4Smrg [gmp_cv_asm_byte=$i 19004a1767b4Smrg rm -f conftest* 19014a1767b4Smrg break], 19024a1767b4Smrg [cat conftest.out >&AC_FD_CC]) 19034a1767b4Smrgdone 19044a1767b4Smrgif test -z "$gmp_cv_asm_byte"; then 19054a1767b4Smrg AC_MSG_ERROR([Cannot determine how to emit a data byte]) 19064a1767b4Smrgfi 19074a1767b4Smrg]) 19084a1767b4Smrg]) 19094a1767b4Smrg 19104a1767b4Smrg 19114a1767b4Smrgdnl GMP_ASM_TEXT 19124a1767b4Smrgdnl ------------ 19134a1767b4Smrgdnl .text - is usual. 19144a1767b4Smrgdnl .code - is needed by the hppa on HP-UX (but ia64 HP-UX uses .text) 19154a1767b4Smrgdnl .csect .text[PR] - is for AIX. 19164a1767b4Smrg 19174a1767b4SmrgAC_DEFUN([GMP_ASM_TEXT], 19184a1767b4Smrg[AC_CACHE_CHECK([how to switch to text section], 19194a1767b4Smrg gmp_cv_asm_text, 19204a1767b4Smrg[for i in ".text" ".code" [".csect .text[PR]"]; do 19214a1767b4Smrg echo "trying $i" >&AC_FD_CC 19224a1767b4Smrg GMP_TRY_ASSEMBLE([ $i], 19234a1767b4Smrg [gmp_cv_asm_text=$i 19244a1767b4Smrg rm -f conftest* 19254a1767b4Smrg break]) 19264a1767b4Smrgdone 19274a1767b4Smrgif test -z "$gmp_cv_asm_text"; then 19284a1767b4Smrg AC_MSG_ERROR([Cannot determine text section directive]) 19294a1767b4Smrgfi 19304a1767b4Smrg]) 19314a1767b4Smrgecho ["define(<TEXT>, <$gmp_cv_asm_text>)"] >> $gmp_tmpconfigm4 19324a1767b4Smrg]) 19334a1767b4Smrg 19344a1767b4Smrg 19354a1767b4Smrgdnl GMP_ASM_DATA 19364a1767b4Smrgdnl ------------ 19374a1767b4Smrgdnl Can we say `.data'? 19384a1767b4Smrg 19394a1767b4SmrgAC_DEFUN([GMP_ASM_DATA], 19404a1767b4Smrg[AC_CACHE_CHECK([how to switch to data section], 19414a1767b4Smrg gmp_cv_asm_data, 19424a1767b4Smrg[case $host in 19434a1767b4Smrg *-*-aix*) gmp_cv_asm_data=[".csect .data[RW]"] ;; 19444a1767b4Smrg *) gmp_cv_asm_data=".data" ;; 19454a1767b4Smrgesac 19464a1767b4Smrg]) 19474a1767b4Smrgecho ["define(<DATA>, <$gmp_cv_asm_data>)"] >> $gmp_tmpconfigm4 19484a1767b4Smrg]) 19494a1767b4Smrg 19504a1767b4Smrg 19514a1767b4Smrgdnl GMP_ASM_RODATA 19524a1767b4Smrgdnl -------------- 19534a1767b4Smrgdnl Find out how to switch to the read-only data section. 19544a1767b4Smrgdnl 19554a1767b4Smrgdnl The compiler output is grepped for the right directive. It's not 19564a1767b4Smrgdnl considered wise to just probe for ".section .rodata" or whatever works, 19574a1767b4Smrgdnl since arbitrary section names might be accepted, but not necessarily do 19584a1767b4Smrgdnl the right thing when they get to the linker. 19594a1767b4Smrgdnl 19604a1767b4Smrgdnl Only a few asm files use RODATA, so this code is perhaps a bit 19614a1767b4Smrgdnl excessive right now, but should find more uses in the future. 19624a1767b4Smrgdnl 19634a1767b4Smrgdnl FIXME: gcc on aix generates something like ".csect _foo.ro_c[RO],3" 19644a1767b4Smrgdnl where foo is the object file. Might need to check for that if we use 19654a1767b4Smrgdnl RODATA there. 19664a1767b4Smrg 19674a1767b4SmrgAC_DEFUN([GMP_ASM_RODATA], 19684a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 19694a1767b4SmrgAC_REQUIRE([GMP_ASM_DATA]) 19704a1767b4SmrgAC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) 19714a1767b4SmrgAC_REQUIRE([GMP_ASM_UNDERSCORE]) 19724a1767b4SmrgAC_CACHE_CHECK([how to switch to read-only data section], 19734a1767b4Smrg gmp_cv_asm_rodata, 19744a1767b4Smrg[ 19754a1767b4Smrgdnl Default to DATA on CPUs with split code/data caching, and TEXT 19764a1767b4Smrgdnl elsewhere. i386 means generic x86, so use DATA on it. 19774a1767b4Smrgcase $host in 19784a1767b4SmrgX86_PATTERN | x86_64-*-*) 19794a1767b4Smrg gmp_cv_asm_rodata="$gmp_cv_asm_data" ;; 19804a1767b4Smrg*) 19814a1767b4Smrg gmp_cv_asm_rodata="$gmp_cv_asm_text" ;; 19824a1767b4Smrgesac 19834a1767b4Smrg 19844a1767b4Smrgcat >conftest.c <<EOF 1985b6659776Smrgextern const int foo[[]]; /* Suppresses C++'s suppression of foo */ 1986b6659776Smrgconst int foo[[]] = {1,2,3}; 19874a1767b4SmrgEOF 19884a1767b4Smrgecho "Test program:" >&AC_FD_CC 19894a1767b4Smrgcat conftest.c >&AC_FD_CC 19904a1767b4Smrggmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC" 19914a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 19924a1767b4Smrg echo "Compiler output:" >&AC_FD_CC 19934a1767b4Smrg cat conftest.s >&AC_FD_CC 19944a1767b4Smrg if test $gmp_cv_asm_underscore = yes; then 19954a1767b4Smrg tmp_gsym_prefix=_ 19964a1767b4Smrg else 19974a1767b4Smrg tmp_gsym_prefix= 19984a1767b4Smrg fi 19994a1767b4Smrg # must see our label 20004a1767b4Smrg if grep "^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" conftest.s >/dev/null 2>&AC_FD_CC; then 20014a1767b4Smrg # take the last directive before our label (hence skipping segments 20024a1767b4Smrg # getting debugging info etc) 20034a1767b4Smrg tmp_match=`sed -n ["/^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix/q 20044a1767b4Smrg /^[. ]*data/p 20054a1767b4Smrg /^[. ]*rdata/p 20064a1767b4Smrg /^[. ]*text/p 20074a1767b4Smrg /^[. ]*section/p 20084a1767b4Smrg /^[. ]*csect/p 20094a1767b4Smrg /^[. ]*CSECT/p"] conftest.s | sed -n '$p'` 20104a1767b4Smrg echo "Match: $tmp_match" >&AC_FD_CC 20114a1767b4Smrg if test -n "$tmp_match"; then 20124a1767b4Smrg gmp_cv_asm_rodata=$tmp_match 20134a1767b4Smrg fi 20144a1767b4Smrg else 20154a1767b4Smrg echo "Couldn't find label: ^${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix" >&AC_FD_CC 20164a1767b4Smrg fi 20174a1767b4Smrgfi 20184a1767b4Smrgrm -f conftest* 20194a1767b4Smrg]) 20204a1767b4Smrgecho ["define(<RODATA>, <$gmp_cv_asm_rodata>)"] >> $gmp_tmpconfigm4 20214a1767b4Smrg]) 20224a1767b4Smrg 20234a1767b4Smrg 20244a1767b4Smrgdnl GMP_ASM_GLOBL 20254a1767b4Smrgdnl ------------- 20264a1767b4Smrgdnl The assembler directive to mark a label as a global symbol. 20274a1767b4Smrgdnl 20284a1767b4Smrgdnl ia64 - .global is standard, according to the Intel documentation. 20294a1767b4Smrgdnl 20304a1767b4Smrgdnl hppa - ".export foo,entry" is demanded by HP hppa "as". ".global" is a 20314a1767b4Smrgdnl kind of import. 20324a1767b4Smrgdnl 20334a1767b4Smrgdnl other - .globl is usual. 20344a1767b4Smrgdnl 20354a1767b4Smrgdnl "gas" tends to accept .globl everywhere, in addition to .export or 20364a1767b4Smrgdnl .global or whatever the system assembler demands. 20374a1767b4Smrg 20384a1767b4SmrgAC_DEFUN([GMP_ASM_GLOBL], 20394a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 20404a1767b4SmrgAC_CACHE_CHECK([for assembler global directive], 20414a1767b4Smrg gmp_cv_asm_globl, 20424a1767b4Smrg[case $host in 20434a1767b4Smrg hppa*-*-*) gmp_cv_asm_globl=.export ;; 20444a1767b4Smrg IA64_PATTERN) gmp_cv_asm_globl=.global ;; 20454a1767b4Smrg *) gmp_cv_asm_globl=.globl ;; 20464a1767b4Smrgesac 20474a1767b4Smrg]) 20484a1767b4Smrgecho ["define(<GLOBL>, <$gmp_cv_asm_globl>)"] >> $gmp_tmpconfigm4 20494a1767b4Smrg]) 20504a1767b4Smrg 20514a1767b4Smrg 20524a1767b4Smrgdnl GMP_ASM_GLOBL_ATTR 20534a1767b4Smrgdnl ------------------ 20544a1767b4Smrgdnl Do we need something after `GLOBL symbol'? 20554a1767b4Smrg 20564a1767b4SmrgAC_DEFUN([GMP_ASM_GLOBL_ATTR], 20574a1767b4Smrg[AC_REQUIRE([GMP_ASM_GLOBL]) 20584a1767b4SmrgAC_CACHE_CHECK([for assembler global directive attribute], 20594a1767b4Smrg gmp_cv_asm_globl_attr, 20604a1767b4Smrg[case $gmp_cv_asm_globl in 20614a1767b4Smrg .export) gmp_cv_asm_globl_attr=",entry" ;; 20624a1767b4Smrg *) gmp_cv_asm_globl_attr="" ;; 20634a1767b4Smrgesac 20644a1767b4Smrg]) 20654a1767b4Smrgecho ["define(<GLOBL_ATTR>, <$gmp_cv_asm_globl_attr>)"] >> $gmp_tmpconfigm4 20664a1767b4Smrg]) 20674a1767b4Smrg 20684a1767b4Smrg 20694a1767b4Smrgdnl GMP_ASM_TYPE 20704a1767b4Smrgdnl ------------ 20714a1767b4Smrgdnl Can we say ".type", and how? 20724a1767b4Smrgdnl 20734a1767b4Smrgdnl For i386 GNU/Linux ELF systems, and very likely other ELF systems, 20744a1767b4Smrgdnl .type and .size are important on functions in shared libraries. If 20754a1767b4Smrgdnl .type is omitted and the mainline program references that function then 20764a1767b4Smrgdnl the code will be copied down to the mainline at load time like a piece 20774a1767b4Smrgdnl of data. If .size is wrong or missing (it defaults to 4 bytes or some 20784a1767b4Smrgdnl such) then incorrect bytes will be copied and a segv is the most likely 20794a1767b4Smrgdnl result. In any case such copying is not what's wanted, a .type 20804a1767b4Smrgdnl directive will ensure a PLT entry is used. 20814a1767b4Smrgdnl 20824a1767b4Smrgdnl In GMP the assembler functions are normally only used from within the 20834a1767b4Smrgdnl library (since most programs are not interested in the low level 20844a1767b4Smrgdnl routines), and in those circumstances a missing .type isn't fatal, 20854a1767b4Smrgdnl letting the problem go unnoticed. tests/mpn/t-asmtype.c aims to check 20864a1767b4Smrgdnl for it. 20874a1767b4Smrg 20884a1767b4SmrgAC_DEFUN([GMP_ASM_TYPE], 20894a1767b4Smrg[AC_CACHE_CHECK([for assembler .type directive], 20904a1767b4Smrg gmp_cv_asm_type, 20914a1767b4Smrg[gmp_cv_asm_type= 20924a1767b4Smrgfor gmp_tmp_prefix in @ \# %; do 20934a1767b4Smrg GMP_TRY_ASSEMBLE([ .type sym,${gmp_tmp_prefix}function], 20944a1767b4Smrg [if grep "\.type pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ; 20954a1767b4Smrg else 20964a1767b4Smrg gmp_cv_asm_type=".type \$][1,${gmp_tmp_prefix}\$][2" 20974a1767b4Smrg break 20984a1767b4Smrg fi]) 20994a1767b4Smrgdone 21004a1767b4Smrgrm -f conftest* 21014a1767b4Smrg]) 21024a1767b4Smrgecho ["define(<TYPE>, <$gmp_cv_asm_type>)"] >> $gmp_tmpconfigm4 21034a1767b4Smrg]) 21044a1767b4Smrg 21054a1767b4Smrg 21064a1767b4Smrgdnl GMP_ASM_SIZE 21074a1767b4Smrgdnl ------------ 21084a1767b4Smrgdnl Can we say `.size'? 21094a1767b4Smrg 21104a1767b4SmrgAC_DEFUN([GMP_ASM_SIZE], 21114a1767b4Smrg[AC_CACHE_CHECK([for assembler .size directive], 21124a1767b4Smrg gmp_cv_asm_size, 21134a1767b4Smrg[gmp_cv_asm_size= 21144a1767b4SmrgGMP_TRY_ASSEMBLE([ .size sym,1], 21154a1767b4Smrg [if grep "\.size pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ; 21164a1767b4Smrg else 21174a1767b4Smrg gmp_cv_asm_size=".size \$][1,\$][2" 21184a1767b4Smrg fi]) 21194a1767b4Smrg]) 21204a1767b4Smrgecho ["define(<SIZE>, <$gmp_cv_asm_size>)"] >> $gmp_tmpconfigm4 21214a1767b4Smrg]) 21224a1767b4Smrg 21234a1767b4Smrg 21244a1767b4Smrgdnl GMP_ASM_COFF_TYPE 21254a1767b4Smrgdnl ----------------- 21264a1767b4Smrgdnl Determine whether the assembler supports COFF type information. 21274a1767b4Smrgdnl 21284a1767b4Smrgdnl Currently this is only needed for mingw (and cygwin perhaps) and so is 21294a1767b4Smrgdnl run only on the x86s, but it ought to work anywhere. 21304a1767b4Smrgdnl 21314a1767b4Smrgdnl On MINGW, recent versions of the linker have an automatic import scheme 21324a1767b4Smrgdnl for data in a DLL which is referenced by a mainline but without 21334a1767b4Smrgdnl __declspec (__dllimport__) on the prototype. It seems functions 21344a1767b4Smrgdnl without type information are treated as data, or something, and calls 21354a1767b4Smrgdnl to them from the mainline will crash. gcc puts type information on the 21364a1767b4Smrgdnl C functions it generates, we need to do the same for assembler 21374a1767b4Smrgdnl functions. 21384a1767b4Smrgdnl 21394a1767b4Smrgdnl This applies only to functions without __declspec(__dllimport__), 21404a1767b4Smrgdnl ie. without __GMP_DECLSPEC in the case of libgmp, so it also works just 21414a1767b4Smrgdnl to ensure all assembler functions used from outside libgmp have 21424a1767b4Smrgdnl __GMP_DECLSPEC on their prototypes. But this isn't an ideal situation, 21434a1767b4Smrgdnl since we don't want perfectly valid calls going wrong just because 21444a1767b4Smrgdnl there wasn't a prototype in scope. 21454a1767b4Smrgdnl 21464a1767b4Smrgdnl When an auto-import takes place, the following warning is given by the 21474a1767b4Smrgdnl linker. This shouldn't be seen for any functions. 21484a1767b4Smrgdnl 21494a1767b4Smrgdnl Info: resolving _foo by linking to __imp__foo (auto-import) 21504a1767b4Smrgdnl 21514a1767b4Smrgdnl 21524a1767b4Smrgdnl COFF type directives look like the following 21534a1767b4Smrgdnl 21544a1767b4Smrgdnl .def _foo 21554a1767b4Smrgdnl .scl 2 21564a1767b4Smrgdnl .type 32 21574a1767b4Smrgdnl .endef 21584a1767b4Smrgdnl 21594a1767b4Smrgdnl _foo is the symbol with GSYM_PREFIX (_). .scl is the storage class, 2 21604a1767b4Smrgdnl for external, 3 for static. .type is the object type, 32 for a 21614a1767b4Smrgdnl function. 21624a1767b4Smrgdnl 21634a1767b4Smrgdnl On an ELF system, this is (correctly) rejected due to .def, .endef and 21644a1767b4Smrgdnl .scl being invalid, and .type not having enough arguments. 21654a1767b4Smrg 21664a1767b4SmrgAC_DEFUN([GMP_ASM_COFF_TYPE], 21674a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 21684a1767b4SmrgAC_REQUIRE([GMP_ASM_GLOBL]) 21694a1767b4SmrgAC_REQUIRE([GMP_ASM_GLOBL_ATTR]) 21704a1767b4SmrgAC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) 21714a1767b4SmrgAC_REQUIRE([GMP_ASM_UNDERSCORE]) 21724a1767b4SmrgAC_CACHE_CHECK([for assembler COFF type directives], 21734a1767b4Smrg gmp_cv_asm_x86_coff_type, 21744a1767b4Smrg[GMP_TRY_ASSEMBLE( 21754a1767b4Smrg[ $gmp_cv_asm_text 21764a1767b4Smrg $gmp_cv_asm_globl ${tmp_gsym_prefix}foo$gmp_cv_asm_globl_attr 21774a1767b4Smrg .def ${tmp_gsym_prefix}foo 21784a1767b4Smrg .scl 2 21794a1767b4Smrg .type 32 21804a1767b4Smrg .endef 21814a1767b4Smrg${tmp_gsym_prefix}foo$gmp_cv_asm_label_suffix 21824a1767b4Smrg], 21834a1767b4Smrg [gmp_cv_asm_x86_coff_type=yes], 21844a1767b4Smrg [gmp_cv_asm_x86_coff_type=no]) 21854a1767b4Smrg]) 21864a1767b4Smrgecho ["define(<HAVE_COFF_TYPE>, <$gmp_cv_asm_x86_coff_type>)"] >> $gmp_tmpconfigm4 21874a1767b4Smrg]) 21884a1767b4Smrg 21894a1767b4Smrg 21904a1767b4Smrgdnl GMP_ASM_LSYM_PREFIX 21914a1767b4Smrgdnl ------------------- 21924a1767b4Smrgdnl What is the prefix for a local label? 21934a1767b4Smrgdnl 21944a1767b4Smrgdnl The prefixes tested are, 21954a1767b4Smrgdnl 21964a1767b4Smrgdnl L - usual for underscore systems 21974a1767b4Smrgdnl .L - usual for non-underscore systems 21984a1767b4Smrgdnl $ - alpha (gas and OSF system assembler) 21994a1767b4Smrgdnl L$ - hppa (gas and HP-UX system assembler) 22004a1767b4Smrgdnl 22014a1767b4Smrgdnl The default is "L" if the tests fail for any reason. There's a good 22024a1767b4Smrgdnl chance this will be adequate, since on most systems labels are local 22034a1767b4Smrgdnl anyway unless given a ".globl", and an "L" will avoid clashes with 22044a1767b4Smrgdnl other identifers. 22054a1767b4Smrgdnl 22064a1767b4Smrgdnl For gas, ".L" is normally purely local to the assembler, it doesn't get 22074a1767b4Smrgdnl put into the object file at all. This style is preferred, to keep the 22084a1767b4Smrgdnl object files nice and clean. 22094a1767b4Smrgdnl 22104a1767b4Smrgdnl BSD format nm produces a line like 22114a1767b4Smrgdnl 22124a1767b4Smrgdnl 00000000 t Lgurkmacka 22134a1767b4Smrgdnl 22144a1767b4Smrgdnl The symbol code is normally "t" for text, but any lower case letter 22154a1767b4Smrgdnl indicates a local definition. 22164a1767b4Smrgdnl 22174a1767b4Smrgdnl Code "n" is for a debugging symbol, OSF "nm -B" gives that as an upper 22184a1767b4Smrgdnl case "N" for a local. 22194a1767b4Smrgdnl 22204a1767b4Smrgdnl HP-UX nm prints an error message (though seems to give a 0 exit) if 22214a1767b4Smrgdnl there's no symbols at all in an object file, hence the use of "dummy". 22224a1767b4Smrg 22234a1767b4SmrgAC_DEFUN([GMP_ASM_LSYM_PREFIX], 22244a1767b4Smrg[AC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) 22254a1767b4SmrgAC_REQUIRE([GMP_ASM_TEXT]) 22264a1767b4SmrgAC_REQUIRE([GMP_PROG_NM]) 22274a1767b4SmrgAC_CACHE_CHECK([for assembler local label prefix], 22284a1767b4Smrg gmp_cv_asm_lsym_prefix, 22294a1767b4Smrg[gmp_tmp_pre_appears=yes 22304a1767b4Smrgfor gmp_tmp_pre in L .L $L $ L$; do 22314a1767b4Smrg echo "Trying $gmp_tmp_pre" >&AC_FD_CC 22324a1767b4Smrg GMP_TRY_ASSEMBLE( 22334a1767b4Smrg[ $gmp_cv_asm_text 22344a1767b4Smrgdummy${gmp_cv_asm_label_suffix} 22354a1767b4Smrg${gmp_tmp_pre}gurkmacka${gmp_cv_asm_label_suffix}], 22364a1767b4Smrg [if $NM conftest.$OBJEXT >conftest.nm 2>&AC_FD_CC; then : ; else 22374a1767b4Smrg cat conftest.nm >&AC_FD_CC 22384a1767b4Smrg AC_MSG_WARN(["$NM" failure]) 22394a1767b4Smrg break 22404a1767b4Smrg fi 22414a1767b4Smrg cat conftest.nm >&AC_FD_CC 22424a1767b4Smrg if grep gurkmacka conftest.nm >/dev/null; then : ; else 22434a1767b4Smrg # no mention of the symbol, this is good 22444a1767b4Smrg echo "$gmp_tmp_pre label doesn't appear in object file at all (good)" >&AC_FD_CC 22454a1767b4Smrg gmp_cv_asm_lsym_prefix="$gmp_tmp_pre" 22464a1767b4Smrg gmp_tmp_pre_appears=no 22474a1767b4Smrg break 22484a1767b4Smrg fi 22494a1767b4Smrg if grep [' [a-zN] .*gurkmacka'] conftest.nm >/dev/null; then 22504a1767b4Smrg # symbol mentioned as a local, use this if nothing better 22514a1767b4Smrg echo "$gmp_tmp_pre label is local but still in object file" >&AC_FD_CC 22524a1767b4Smrg if test -z "$gmp_cv_asm_lsym_prefix"; then 22534a1767b4Smrg gmp_cv_asm_lsym_prefix="$gmp_tmp_pre" 22544a1767b4Smrg fi 22554a1767b4Smrg else 22564a1767b4Smrg echo "$gmp_tmp_pre label is something unknown" >&AC_FD_CC 22574a1767b4Smrg fi 22584a1767b4Smrg ]) 22594a1767b4Smrgdone 22604a1767b4Smrgrm -f conftest* 22614a1767b4Smrgif test -z "$gmp_cv_asm_lsym_prefix"; then 22624a1767b4Smrg gmp_cv_asm_lsym_prefix=L 22634a1767b4Smrg AC_MSG_WARN([cannot determine local label, using default $gmp_cv_asm_lsym_prefix]) 22644a1767b4Smrgfi 22654a1767b4Smrg# for development purposes, note whether we got a purely temporary local label 22664a1767b4Smrgecho "Local label appears in object files: $gmp_tmp_pre_appears" >&AC_FD_CC 22674a1767b4Smrg]) 22684a1767b4Smrgecho ["define(<LSYM_PREFIX>, <${gmp_cv_asm_lsym_prefix}>)"] >> $gmp_tmpconfigm4 22694a1767b4SmrgAC_DEFINE_UNQUOTED(LSYM_PREFIX, "$gmp_cv_asm_lsym_prefix", 22704a1767b4Smrg [Assembler local label prefix]) 22714a1767b4Smrg]) 22724a1767b4Smrg 22734a1767b4Smrg 22744a1767b4Smrgdnl GMP_ASM_W32 22754a1767b4Smrgdnl ----------- 22764a1767b4Smrgdnl How to define a 32-bit word. 22774a1767b4Smrgdnl 22784a1767b4Smrgdnl FIXME: This test is not right for ia64-*-hpux*. The directive should 22794a1767b4Smrgdnl be "data4", but the W32 macro is not currently used by the mpn/ia64 asm 22804a1767b4Smrgdnl files. 22814a1767b4Smrg 22824a1767b4SmrgAC_DEFUN([GMP_ASM_W32], 22834a1767b4Smrg[AC_REQUIRE([GMP_ASM_DATA]) 22844a1767b4SmrgAC_REQUIRE([GMP_ASM_BYTE]) 22854a1767b4SmrgAC_REQUIRE([GMP_ASM_GLOBL]) 22864a1767b4SmrgAC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) 22874a1767b4SmrgAC_REQUIRE([GMP_PROG_NM]) 22884a1767b4SmrgAC_CACHE_CHECK([how to define a 32-bit word], 22894a1767b4Smrg gmp_cv_asm_w32, 22904a1767b4Smrg[case $host in 22914a1767b4Smrg *-*-hpux*) 22924a1767b4Smrg # FIXME: HPUX puts first symbol at 0x40000000, breaking our assumption 22934a1767b4Smrg # that it's at 0x0. We'll have to declare another symbol before the 22944a1767b4Smrg # .long/.word and look at the distance between the two symbols. The 22954a1767b4Smrg # only problem is that the sed expression(s) barfs (on Solaris, for 22964a1767b4Smrg # example) for the symbol with value 0. For now, HPUX uses .word. 22974a1767b4Smrg gmp_cv_asm_w32=".word" 22984a1767b4Smrg ;; 22994a1767b4Smrg *-*-*) 23004a1767b4Smrg gmp_tmp_val= 23014a1767b4Smrg for gmp_tmp_op in .long .word data4; do 23024a1767b4Smrg GMP_TRY_ASSEMBLE( 23034a1767b4Smrg[ $gmp_cv_asm_data 23044a1767b4Smrg $gmp_cv_asm_globl foo 23054a1767b4Smrg $gmp_tmp_op 0 23064a1767b4Smrgfoo$gmp_cv_asm_label_suffix 23074a1767b4Smrg $gmp_cv_asm_byte 0], 23084a1767b4Smrg [gmp_tmp_val=[`$NM conftest.$OBJEXT | grep foo | \ 23094a1767b4Smrg sed -e 's;[[][0-9][]]\(.*\);\1;' -e 's;[^1-9]*\([0-9]*\).*;\1;'`] 23104a1767b4Smrg if test "$gmp_tmp_val" = 4; then 23114a1767b4Smrg gmp_cv_asm_w32="$gmp_tmp_op" 23124a1767b4Smrg break 23134a1767b4Smrg fi]) 23144a1767b4Smrg done 23154a1767b4Smrg rm -f conftest* 23164a1767b4Smrg ;; 23174a1767b4Smrgesac 23184a1767b4Smrgif test -z "$gmp_cv_asm_w32"; then 23194a1767b4Smrg AC_MSG_ERROR([cannot determine how to define a 32-bit word]) 23204a1767b4Smrgfi 23214a1767b4Smrg]) 23224a1767b4Smrgecho ["define(<W32>, <$gmp_cv_asm_w32>)"] >> $gmp_tmpconfigm4 23234a1767b4Smrg]) 23244a1767b4Smrg 23254a1767b4Smrg 23264a1767b4Smrgdnl GMP_X86_ASM_GOT_UNDERSCORE 23274a1767b4Smrgdnl -------------------------- 23284a1767b4Smrgdnl Determine whether i386 _GLOBAL_OFFSET_TABLE_ needs an additional 23294a1767b4Smrgdnl underscore prefix. 23304a1767b4Smrgdnl 23314a1767b4Smrgdnl SVR4 - the standard is _GLOBAL_OFFSET_TABLE_ 23324a1767b4Smrgdnl GNU/Linux - follows SVR4 23334a1767b4Smrgdnl OpenBSD - an a.out underscore system, uses __GLOBAL_OFFSET_TABLE_ 23344a1767b4Smrgdnl NetBSD - also an a.out underscore system, but _GLOBAL_OFFSET_TABLE_ 23354a1767b4Smrgdnl 23364a1767b4Smrgdnl The test attempts to link a program using _GLOBAL_OFFSET_TABLE_ or 23374a1767b4Smrgdnl __GLOBAL_OFFSET_TABLE_ to see which works. 23384a1767b4Smrgdnl 23394a1767b4Smrgdnl $lt_prog_compiler_pic is included in the compile because old versions 23404a1767b4Smrgdnl of gas wouldn't accept PIC idioms without the right option (-K). This 23414a1767b4Smrgdnl is the same as what libtool and mpn/Makeasm.am will do. 23424a1767b4Smrgdnl 23434a1767b4Smrgdnl $lt_prog_compiler_pic is also included in the link because OpenBSD ld 23444a1767b4Smrgdnl won't accept an R_386_GOTPC relocation without the right options. This 23454a1767b4Smrgdnl is not what's done by the Makefiles when building executables, but 23464a1767b4Smrgdnl let's hope it's ok (it works fine with gcc). 23474a1767b4Smrgdnl 23484a1767b4Smrgdnl The fallback is no additional underscore, on the basis that this will 23494a1767b4Smrgdnl suit SVR4/ELF style systems, which should be much more common than 23504a1767b4Smrgdnl a.out systems with shared libraries. 23514a1767b4Smrgdnl 23524a1767b4Smrgdnl Note that it's not an error for the tests to fail, since for instance 23534a1767b4Smrgdnl cygwin, mingw and djgpp don't have a _GLOBAL_OFFSET_TABLE_ scheme at 23544a1767b4Smrgdnl all. 23554a1767b4Smrgdnl 23564a1767b4Smrgdnl Perhaps $CCAS could be asked to do the linking as well as the 23574a1767b4Smrgdnl assembling, but in the Makefiles it's only used for assembling, so lets 23584a1767b4Smrgdnl keep it that way. 23594a1767b4Smrgdnl 23604a1767b4Smrgdnl The test here is run even under --disable-shared, so that PIC objects 23614a1767b4Smrgdnl can be built and tested by the tune/many.pl development scheme. The 23624a1767b4Smrgdnl tests will be reasonably quick and won't give a fatal error, so this 23634a1767b4Smrgdnl arrangement is ok. AC_LIBTOOL_PROG_COMPILER_PIC does its 23644a1767b4Smrgdnl $lt_prog_compiler_pic setups even for --disable-shared too. 23654a1767b4Smrg 23664a1767b4SmrgAC_DEFUN([GMP_ASM_X86_GOT_UNDERSCORE], 23674a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 23684a1767b4SmrgAC_REQUIRE([GMP_ASM_GLOBL]) 23694a1767b4SmrgAC_REQUIRE([GMP_ASM_GLOBL_ATTR]) 23704a1767b4SmrgAC_REQUIRE([GMP_ASM_LABEL_SUFFIX]) 23714a1767b4SmrgAC_REQUIRE([GMP_ASM_UNDERSCORE]) 23724a1767b4SmrgAC_REQUIRE([AC_LIBTOOL_PROG_COMPILER_PIC]) 23734a1767b4SmrgAC_CACHE_CHECK([if _GLOBAL_OFFSET_TABLE_ is prefixed by underscore], 23744a1767b4Smrg gmp_cv_asm_x86_got_underscore, 23754a1767b4Smrg[gmp_cv_asm_x86_got_underscore="not applicable" 23764a1767b4Smrgif test $gmp_cv_asm_underscore = yes; then 23774a1767b4Smrg tmp_gsym_prefix=_ 23784a1767b4Smrgelse 23794a1767b4Smrg tmp_gsym_prefix= 23804a1767b4Smrgfi 23814a1767b4Smrgfor tmp_underscore in "" "_"; do 23824a1767b4Smrg cat >conftest.s <<EOF 23834a1767b4Smrg $gmp_cv_asm_text 23844a1767b4Smrg $gmp_cv_asm_globl ${tmp_gsym_prefix}main$gmp_cv_asm_globl_attr 23854a1767b4Smrg${tmp_gsym_prefix}main$gmp_cv_asm_label_suffix 23864a1767b4Smrg addl $ ${tmp_underscore}_GLOBAL_OFFSET_TABLE_, %ebx 23874a1767b4SmrgEOF 23884a1767b4Smrg gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&AC_FD_CC && $CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&AC_FD_CC" 23894a1767b4Smrg if AC_TRY_EVAL(gmp_compile); then 23904a1767b4Smrg if test "$tmp_underscore" = "_"; then 23914a1767b4Smrg gmp_cv_asm_x86_got_underscore=yes 23924a1767b4Smrg else 23934a1767b4Smrg gmp_cv_asm_x86_got_underscore=no 23944a1767b4Smrg fi 23954a1767b4Smrg break 23964a1767b4Smrg fi 23974a1767b4Smrgdone 23984a1767b4Smrgrm -f conftest* a.out b.out a.exe a_out.exe 23994a1767b4Smrg]) 24004a1767b4Smrgif test "$gmp_cv_asm_x86_got_underscore" = "yes"; then 24014a1767b4Smrg GMP_DEFINE(GOT_GSYM_PREFIX, [_]) 24024a1767b4Smrgelse 24034a1767b4Smrg GMP_DEFINE(GOT_GSYM_PREFIX, []) 24044a1767b4Smrgfi 24054a1767b4Smrg]) 24064a1767b4Smrg 24074a1767b4Smrg 24084a1767b4Smrgdnl GMP_ASM_X86_GOT_EAX_OK(CC+CFLAGS, [ACTION-YES] [, ACTION-NO]) 24094a1767b4Smrgdnl ------------------------------------------------------------- 24104a1767b4Smrgdnl Determine whether _GLOBAL_OFFSET_TABLE_ used with %eax is ok. 24114a1767b4Smrgdnl 24124a1767b4Smrgdnl An instruction 24134a1767b4Smrgdnl 24144a1767b4Smrgdnl addl $_GLOBAL_OFFSET_TABLE_, %eax 24154a1767b4Smrgdnl 24164a1767b4Smrgdnl is incorrectly assembled by gas 2.12 (or thereabouts) and earlier. It 24174a1767b4Smrgdnl puts an addend 2 into the R_386_GOTPC relocation, but it should be 1 24184a1767b4Smrgdnl for this %eax form being a 1 byte opcode (with other registers it's 2 24194a1767b4Smrgdnl opcode bytes). See note about this in mpn/x86/README too. 24204a1767b4Smrgdnl 24214a1767b4Smrgdnl We assemble this, surrounded by some unlikely byte sequences as 24224a1767b4Smrgdnl delimiters, and check for the bad output. 24234a1767b4Smrgdnl 24244a1767b4Smrgdnl This is for use by compiler probing in GMP_PROG_CC_WORKS, so the result 24254a1767b4Smrgdnl is not cached. 24264a1767b4Smrgdnl 24274a1767b4Smrgdnl This test is not specific to gas, but old gas is the only assembler we 24284a1767b4Smrgdnl know of with this problem. The Solaris has been seen coming out ok. 24294a1767b4Smrgdnl 24304a1767b4Smrgdnl ".text" is hard coded because this macro is wanted before GMP_ASM_TEXT. 24314a1767b4Smrgdnl This should be fine, ".text" is normal on x86 systems, and certainly 24324a1767b4Smrgdnl will be fine with the offending gas. 24334a1767b4Smrgdnl 24344a1767b4Smrgdnl If an error occurs when assembling, we consider the assembler ok, since 24354a1767b4Smrgdnl the bad output does not occur. This happens for instance on mingw, 24364a1767b4Smrgdnl where _GLOBAL_OFFSET_TABLE_ results in a bfd error, since there's no 24374a1767b4Smrgdnl GOT etc in PE object files. 24384a1767b4Smrgdnl 24394a1767b4Smrgdnl This test is used before the object file extension has been determined, 24404a1767b4Smrgdnl so we force output to conftest.o. Using -o with -c is not portable, 24414a1767b4Smrgdnl but we think all x86 compilers will accept -o with -c, certainly gcc 24424a1767b4Smrgdnl does. 24434a1767b4Smrgdnl 24444a1767b4Smrgdnl -fPIC is hard coded here, because this test is for use before libtool 24454a1767b4Smrgdnl has established the pic options. It's right for gcc, but perhaps not 24464a1767b4Smrgdnl other compilers. 24474a1767b4Smrg 24484a1767b4SmrgAC_DEFUN([GMP_ASM_X86_GOT_EAX_OK], 24494a1767b4Smrg[echo "Testing gas GOT with eax good" >&AC_FD_CC 24504a1767b4Smrgcat >conftest.awk <<\EOF 24514a1767b4Smrg[BEGIN { 24524a1767b4Smrg want[0] = "001" 24534a1767b4Smrg want[1] = "043" 24544a1767b4Smrg want[2] = "105" 24554a1767b4Smrg want[3] = "147" 24564a1767b4Smrg want[4] = "211" 24574a1767b4Smrg want[5] = "253" 24584a1767b4Smrg want[6] = "315" 24594a1767b4Smrg want[7] = "357" 24604a1767b4Smrg 24614a1767b4Smrg want[8] = "005" 24624a1767b4Smrg want[9] = "002" 24634a1767b4Smrg want[10] = "000" 24644a1767b4Smrg want[11] = "000" 24654a1767b4Smrg want[12] = "000" 24664a1767b4Smrg 24674a1767b4Smrg want[13] = "376" 24684a1767b4Smrg want[14] = "334" 24694a1767b4Smrg want[15] = "272" 24704a1767b4Smrg want[16] = "230" 24714a1767b4Smrg want[17] = "166" 24724a1767b4Smrg want[18] = "124" 24734a1767b4Smrg want[19] = "062" 24744a1767b4Smrg want[20] = "020" 24754a1767b4Smrg 24764a1767b4Smrg result = "yes" 24774a1767b4Smrg} 24784a1767b4Smrg{ 24794a1767b4Smrg for (f = 2; f <= NF; f++) 24804a1767b4Smrg { 24814a1767b4Smrg for (i = 0; i < 20; i++) 24824a1767b4Smrg got[i] = got[i+1]; 24834a1767b4Smrg got[20] = $f; 24844a1767b4Smrg 24854a1767b4Smrg found = 1 24864a1767b4Smrg for (i = 0; i < 21; i++) 24874a1767b4Smrg if (got[i] != want[i]) 24884a1767b4Smrg { 24894a1767b4Smrg found = 0 24904a1767b4Smrg break 24914a1767b4Smrg } 24924a1767b4Smrg if (found) 24934a1767b4Smrg { 24944a1767b4Smrg result = "no" 24954a1767b4Smrg exit 24964a1767b4Smrg } 24974a1767b4Smrg } 24984a1767b4Smrg} 24994a1767b4SmrgEND { 25004a1767b4Smrg print result 25014a1767b4Smrg} 25024a1767b4Smrg]EOF 25034a1767b4Smrgcat >conftest.s <<\EOF 25044a1767b4Smrg[ .text 25054a1767b4Smrg .byte 1, 35, 69, 103, 137, 171, 205, 239 25064a1767b4Smrg addl $_GLOBAL_OFFSET_TABLE_, %eax 25074a1767b4Smrg .byte 254, 220, 186, 152, 118, 84, 50, 16 25084a1767b4Smrg]EOF 25094a1767b4Smrgtmp_got_good=yes 25104a1767b4Smrggmp_compile="$1 -fPIC -o conftest.o -c conftest.s >&AC_FD_CC 2>&1" 25114a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 25124a1767b4Smrg tmp_got_good=`od -b conftest.o | $AWK -f conftest.awk` 25134a1767b4Smrgfi 25144a1767b4Smrgrm -f conftest.* 25154a1767b4Smrgecho "Result: $tmp_got_good" >&AC_FD_CC 25164a1767b4Smrgif test "$tmp_got_good" = no; then 25174a1767b4Smrg ifelse([$3],,:,[$3]) 25184a1767b4Smrgelse 25194a1767b4Smrg ifelse([$2],,:,[$2]) 25204a1767b4Smrgfi 25214a1767b4Smrg]) 25224a1767b4Smrg 25234a1767b4Smrg 25244a1767b4Smrgdnl GMP_ASM_X86_MMX([ACTION-IF-YES][,ACTION-IF-NO]) 25254a1767b4Smrgdnl ----------------------------------------------- 25264a1767b4Smrgdnl Determine whether the assembler supports MMX instructions. 25274a1767b4Smrgdnl 25284a1767b4Smrgdnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded 25294a1767b4Smrgdnl here. ".text" is believed to be correct on all x86 systems. Actually 25304a1767b4Smrgdnl ".text" probably isn't needed at all, at least for just checking 25314a1767b4Smrgdnl instruction syntax. 25324a1767b4Smrgdnl 25334a1767b4Smrgdnl "movq %mm0, %mm1" should assemble to "0f 6f c8", but Solaris 2.6 and 25344a1767b4Smrgdnl 2.7 wrongly assemble it to "0f 6f c1" (that being the reverse "movq 25354a1767b4Smrgdnl %mm1, %mm0"). It seems more trouble than it's worth to work around 25364a1767b4Smrgdnl this in the code, so just detect and reject. 25374a1767b4Smrg 25384a1767b4SmrgAC_DEFUN([GMP_ASM_X86_MMX], 25394a1767b4Smrg[AC_CACHE_CHECK([if the assembler knows about MMX instructions], 25404a1767b4Smrg gmp_cv_asm_x86_mmx, 25414a1767b4Smrg[GMP_TRY_ASSEMBLE( 25424a1767b4Smrg[ .text 25434a1767b4Smrg movq %mm0, %mm1], 25444a1767b4Smrg[gmp_cv_asm_x86_mmx=yes 25454a1767b4Smrgcase $host in 25464a1767b4Smrg*-*-solaris*) 25474a1767b4Smrg if (dis conftest.$OBJEXT >conftest.out) 2>/dev/null; then 25484a1767b4Smrg if grep "0f 6f c1" conftest.out >/dev/null; then 25494a1767b4Smrg gmp_cv_asm_x86_mmx=movq-bug 25504a1767b4Smrg fi 25514a1767b4Smrg else 25524a1767b4Smrg AC_MSG_WARN(["dis" not available to check for "as" movq bug]) 25534a1767b4Smrg fi 25544a1767b4Smrgesac], 25554a1767b4Smrg[gmp_cv_asm_x86_mmx=no])]) 25564a1767b4Smrg 25574a1767b4Smrgcase $gmp_cv_asm_x86_mmx in 25584a1767b4Smrgmovq-bug) 25594a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 25604a1767b4Smrg AC_MSG_WARN([| WARNING WARNING WARNING]) 25614a1767b4Smrg AC_MSG_WARN([| Host CPU has MMX code, but the assembler]) 25624a1767b4Smrg AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) 25634a1767b4Smrg AC_MSG_WARN([| has the Solaris 2.6 and 2.7 bug where register to register]) 25644a1767b4Smrg AC_MSG_WARN([| movq operands are reversed.]) 25654a1767b4Smrg AC_MSG_WARN([| Non-MMX replacements will be used.]) 25664a1767b4Smrg AC_MSG_WARN([| This will be an inferior build.]) 25674a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 25684a1767b4Smrg ;; 25694a1767b4Smrgno) 25704a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 25714a1767b4Smrg AC_MSG_WARN([| WARNING WARNING WARNING]) 25724a1767b4Smrg AC_MSG_WARN([| Host CPU has MMX code, but it can't be assembled by]) 25734a1767b4Smrg AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) 25744a1767b4Smrg AC_MSG_WARN([| Non-MMX replacements will be used.]) 25754a1767b4Smrg AC_MSG_WARN([| This will be an inferior build.]) 25764a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 25774a1767b4Smrg ;; 25784a1767b4Smrgesac 25794a1767b4Smrgif test "$gmp_cv_asm_x86_mmx" = yes; then 25804a1767b4Smrg ifelse([$1],,:,[$1]) 25814a1767b4Smrgelse 25824a1767b4Smrg ifelse([$2],,:,[$2]) 25834a1767b4Smrgfi 25844a1767b4Smrg]) 25854a1767b4Smrg 25864a1767b4Smrg 25874a1767b4Smrgdnl GMP_ASM_X86_SHLDL_CL 25884a1767b4Smrgdnl -------------------- 25894a1767b4Smrg 25904a1767b4SmrgAC_DEFUN([GMP_ASM_X86_SHLDL_CL], 25914a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 25924a1767b4SmrgAC_CACHE_CHECK([if the assembler takes cl with shldl], 25934a1767b4Smrg gmp_cv_asm_x86_shldl_cl, 25944a1767b4Smrg[GMP_TRY_ASSEMBLE( 25954a1767b4Smrg[ $gmp_cv_asm_text 25964a1767b4Smrg shldl %cl, %eax, %ebx], 25974a1767b4Smrg gmp_cv_asm_x86_shldl_cl=yes, 25984a1767b4Smrg gmp_cv_asm_x86_shldl_cl=no) 25994a1767b4Smrg]) 26004a1767b4Smrgif test "$gmp_cv_asm_x86_shldl_cl" = "yes"; then 26014a1767b4Smrg GMP_DEFINE(WANT_SHLDL_CL,1) 26024a1767b4Smrgelse 26034a1767b4Smrg GMP_DEFINE(WANT_SHLDL_CL,0) 26044a1767b4Smrgfi 26054a1767b4Smrg]) 26064a1767b4Smrg 26074a1767b4Smrg 26084a1767b4Smrgdnl GMP_ASM_X86_SSE2([ACTION-IF-YES][,ACTION-IF-NO]) 26094a1767b4Smrgdnl ------------------------------------------------ 26104a1767b4Smrgdnl Determine whether the assembler supports SSE2 instructions. 26114a1767b4Smrgdnl 26124a1767b4Smrgdnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded 26134a1767b4Smrgdnl here. ".text" is believed to be correct on all x86 systems, certainly 26144a1767b4Smrgdnl it's all GMP_ASM_TEXT gives currently. Actually ".text" probably isn't 26154a1767b4Smrgdnl needed at all, at least for just checking instruction syntax. 26164a1767b4Smrg 26174a1767b4SmrgAC_DEFUN([GMP_ASM_X86_SSE2], 26184a1767b4Smrg[AC_CACHE_CHECK([if the assembler knows about SSE2 instructions], 26194a1767b4Smrg gmp_cv_asm_x86_sse2, 26204a1767b4Smrg[GMP_TRY_ASSEMBLE( 26214a1767b4Smrg[ .text 26224a1767b4Smrg paddq %mm0, %mm1], 26234a1767b4Smrg [gmp_cv_asm_x86_sse2=yes], 26244a1767b4Smrg [gmp_cv_asm_x86_sse2=no]) 26254a1767b4Smrg]) 26264a1767b4Smrgcase $gmp_cv_asm_x86_sse2 in 26274a1767b4Smrgyes) 26284a1767b4Smrg ifelse([$1],,:,[$1]) 26294a1767b4Smrg ;; 26304a1767b4Smrg*) 26314a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 26324a1767b4Smrg AC_MSG_WARN([| WARNING WARNING WARNING]) 26334a1767b4Smrg AC_MSG_WARN([| Host CPU has SSE2 code, but it can't be assembled by]) 26344a1767b4Smrg AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) 26354a1767b4Smrg AC_MSG_WARN([| Non-SSE2 replacements will be used.]) 26364a1767b4Smrg AC_MSG_WARN([| This will be an inferior build.]) 26374a1767b4Smrg AC_MSG_WARN([+----------------------------------------------------------]) 26384a1767b4Smrg ifelse([$2],,:,[$2]) 26394a1767b4Smrg ;; 26404a1767b4Smrgesac 26414a1767b4Smrg]) 26424a1767b4Smrg 26434a1767b4Smrg 264421c03f4cSmrgdnl GMP_ASM_X86_MULX([ACTION-IF-YES][,ACTION-IF-NO]) 264521c03f4cSmrgdnl ------------------------------------------------ 264621c03f4cSmrgdnl Determine whether the assembler supports the mulx instruction which debut 264721c03f4cSmrgdnl with Haswell. 264821c03f4cSmrgdnl 264921c03f4cSmrgdnl This macro is wanted before GMP_ASM_TEXT, so ".text" is hard coded 265021c03f4cSmrgdnl here. ".text" is believed to be correct on all x86 systems, certainly 265121c03f4cSmrgdnl it's all GMP_ASM_TEXT gives currently. Actually ".text" probably isn't 265221c03f4cSmrgdnl needed at all, at least for just checking instruction syntax. 265321c03f4cSmrg 265421c03f4cSmrgAC_DEFUN([GMP_ASM_X86_MULX], 265521c03f4cSmrg[AC_CACHE_CHECK([if the assembler knows about the mulx instruction], 265621c03f4cSmrg gmp_cv_asm_x86_mulx, 265721c03f4cSmrg[GMP_TRY_ASSEMBLE( 265821c03f4cSmrg[ .text 265921c03f4cSmrg mulx %r8, %r9, %r10], 266021c03f4cSmrg [gmp_cv_asm_x86_mulx=yes], 266121c03f4cSmrg [gmp_cv_asm_x86_mulx=no]) 266221c03f4cSmrg]) 266321c03f4cSmrgcase $gmp_cv_asm_x86_mulx in 266421c03f4cSmrgyes) 2665*274b3bceSmrg AC_DEFINE(X86_ASM_MULX, 1, 2666*274b3bceSmrg [Define to 1 if the assembler understands the mulx instruction]) 266721c03f4cSmrg ifelse([$1],,:,[$1]) 266821c03f4cSmrg ;; 266921c03f4cSmrg*) 267021c03f4cSmrg AC_MSG_WARN([+----------------------------------------------------------]) 267121c03f4cSmrg AC_MSG_WARN([| WARNING WARNING WARNING]) 267221c03f4cSmrg AC_MSG_WARN([| Host CPU has the mulx instruction, but it can't be]) 267321c03f4cSmrg AC_MSG_WARN([| assembled by]) 267421c03f4cSmrg AC_MSG_WARN([| $CCAS $CFLAGS $CPPFLAGS]) 267521c03f4cSmrg AC_MSG_WARN([| Older x86 instructions will be used.]) 267621c03f4cSmrg AC_MSG_WARN([| This will be an inferior build.]) 267721c03f4cSmrg AC_MSG_WARN([+----------------------------------------------------------]) 267821c03f4cSmrg ifelse([$2],,:,[$2]) 267921c03f4cSmrg ;; 268021c03f4cSmrgesac 268121c03f4cSmrg]) 268221c03f4cSmrg 268321c03f4cSmrg 26844a1767b4Smrgdnl GMP_ASM_X86_MCOUNT 26854a1767b4Smrgdnl ------------------ 26864a1767b4Smrgdnl Find out how to call mcount for profiling on an x86 system. 26874a1767b4Smrgdnl 26884a1767b4Smrgdnl A dummy function is compiled and the ".s" output examined. The pattern 26894a1767b4Smrgdnl matching might be a bit fragile, but should work at least with gcc on 26904a1767b4Smrgdnl sensible systems. Certainly it's better than hard coding a table of 26914a1767b4Smrgdnl conventions. 26924a1767b4Smrgdnl 26934a1767b4Smrgdnl For non-PIC, any ".data" is taken to mean a counter might be passed. 26944a1767b4Smrgdnl It's assumed a movl will set it up, and the right register is taken 26954a1767b4Smrgdnl from that movl. Any movl involving %esp is ignored (a frame pointer 26964a1767b4Smrgdnl setup normally). 26974a1767b4Smrgdnl 26984a1767b4Smrgdnl For PIC, any ".data" is similarly interpreted, but a GOTOFF identifies 26994a1767b4Smrgdnl the line setting up the right register. 27004a1767b4Smrgdnl 27014a1767b4Smrgdnl In both cases a line with "mcount" identifies the call and that line is 27024a1767b4Smrgdnl used literally. 27034a1767b4Smrgdnl 27044a1767b4Smrgdnl On some systems (eg. FreeBSD 3.5) gcc emits ".data" but doesn't use it, 27054a1767b4Smrgdnl so it's not an error to have .data but then not find a register. 27064a1767b4Smrgdnl 27074a1767b4Smrgdnl Variations in mcount conventions on different x86 systems can be found 27084a1767b4Smrgdnl in gcc config/i386. mcount can have a "_" prefix or be .mcount or 27094a1767b4Smrgdnl _mcount_ptr, and for PIC it can be called through a GOT entry, or via 27104a1767b4Smrgdnl the PLT. If a pointer to a counter is required it's passed in %eax or 27114a1767b4Smrgdnl %edx. 27124a1767b4Smrgdnl 27134a1767b4Smrgdnl Flags to specify PIC are taken from $lt_prog_compiler_pic set by 27144a1767b4Smrgdnl AC_PROG_LIBTOOL. 27154a1767b4Smrgdnl 27164a1767b4Smrgdnl Enhancement: Cache the values determined here. But what's the right way 27174a1767b4Smrgdnl to get two variables (mcount_nonpic_reg and mcount_nonpic_call say) set 27184a1767b4Smrgdnl from one block of commands? 27194a1767b4Smrg 27204a1767b4SmrgAC_DEFUN([GMP_ASM_X86_MCOUNT], 27214a1767b4Smrg[AC_REQUIRE([AC_ENABLE_SHARED]) 27224a1767b4SmrgAC_REQUIRE([AC_PROG_LIBTOOL]) 27234a1767b4SmrgAC_MSG_CHECKING([how to call x86 mcount]) 27244a1767b4Smrgcat >conftest.c <<EOF 27254a1767b4Smrgfoo(){bar();} 27264a1767b4SmrgEOF 27274a1767b4Smrg 27284a1767b4Smrgif test "$enable_static" = yes; then 27294a1767b4Smrg gmp_asmout_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c 1>&AC_FD_CC" 27304a1767b4Smrg if AC_TRY_EVAL(gmp_asmout_compile); then 27314a1767b4Smrg if grep '\.data' conftest.s >/dev/null; then 27324a1767b4Smrg mcount_nonpic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s` 27334a1767b4Smrg else 27344a1767b4Smrg mcount_nonpic_reg= 27354a1767b4Smrg fi 27364a1767b4Smrg mcount_nonpic_call=`grep 'call.*mcount' conftest.s` 27374a1767b4Smrg if test -z "$mcount_nonpic_call"; then 27384a1767b4Smrg AC_MSG_ERROR([Cannot find mcount call for non-PIC]) 27394a1767b4Smrg fi 27404a1767b4Smrg else 27414a1767b4Smrg AC_MSG_ERROR([Cannot compile test program for non-PIC]) 27424a1767b4Smrg fi 27434a1767b4Smrgfi 27444a1767b4Smrg 27454a1767b4Smrgif test "$enable_shared" = yes; then 27464a1767b4Smrg gmp_asmout_compile="$CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic -S conftest.c 1>&AC_FD_CC" 27474a1767b4Smrg if AC_TRY_EVAL(gmp_asmout_compile); then 27484a1767b4Smrg if grep '\.data' conftest.s >/dev/null; then 27494a1767b4Smrg case $lt_prog_compiler_pic in 27504a1767b4Smrg *-DDLL_EXPORT*) 27514a1767b4Smrg # Windows DLLs have non-PIC style mcount 27524a1767b4Smrg mcount_pic_reg=`sed -n ['/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p'] conftest.s` 27534a1767b4Smrg ;; 27544a1767b4Smrg *) 27554a1767b4Smrg mcount_pic_reg=`sed -n ['s/.*GOTOFF.*,\(%[a-z]*\).*$/\1/p'] conftest.s` 27564a1767b4Smrg ;; 27574a1767b4Smrg esac 27584a1767b4Smrg else 27594a1767b4Smrg mcount_pic_reg= 27604a1767b4Smrg fi 27614a1767b4Smrg mcount_pic_call=`grep 'call.*mcount' conftest.s` 27624a1767b4Smrg if test -z "$mcount_pic_call"; then 27634a1767b4Smrg AC_MSG_ERROR([Cannot find mcount call for PIC]) 27644a1767b4Smrg fi 27654a1767b4Smrg else 27664a1767b4Smrg AC_MSG_ERROR([Cannot compile test program for PIC]) 27674a1767b4Smrg fi 27684a1767b4Smrgfi 27694a1767b4Smrg 27704a1767b4SmrgGMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_REG>, <\`$mcount_nonpic_reg'>)"]) 27714a1767b4SmrgGMP_DEFINE_RAW(["define(<MCOUNT_NONPIC_CALL>,<\`$mcount_nonpic_call'>)"]) 27724a1767b4SmrgGMP_DEFINE_RAW(["define(<MCOUNT_PIC_REG>, <\`$mcount_pic_reg'>)"]) 27734a1767b4SmrgGMP_DEFINE_RAW(["define(<MCOUNT_PIC_CALL>, <\`$mcount_pic_call'>)"]) 27744a1767b4Smrg 27754a1767b4Smrgrm -f conftest.* 27764a1767b4SmrgAC_MSG_RESULT([determined]) 27774a1767b4Smrg]) 27784a1767b4Smrg 27794a1767b4Smrg 27804a1767b4Smrgdnl GMP_ASM_IA64_ALIGN_OK 27814a1767b4Smrgdnl --------------------- 27824a1767b4Smrgdnl Determine whether .align correctly pads with nop instructions in a text 27834a1767b4Smrgdnl segment. 27844a1767b4Smrgdnl 27854a1767b4Smrgdnl gas 2.14 and earlier byte swaps its padding bundle on big endian 27864a1767b4Smrgdnl systems, which is incorrect (endianness only changes data). What 27874a1767b4Smrgdnl should be "nop.m / nop.f / nop.i" comes out as "break" instructions. 27884a1767b4Smrgdnl 27894a1767b4Smrgdnl The test here detects the bad case, and assumes anything else is ok 27904a1767b4Smrgdnl (there are many sensible nop bundles, so it'd be impractical to try to 27914a1767b4Smrgdnl match everything good). 27924a1767b4Smrg 27934a1767b4SmrgAC_DEFUN([GMP_ASM_IA64_ALIGN_OK], 27944a1767b4Smrg[AC_CACHE_CHECK([whether assembler .align padding is good], 27954a1767b4Smrg gmp_cv_asm_ia64_align_ok, 27964a1767b4Smrg[cat >conftest.awk <<\EOF 27974a1767b4Smrg[BEGIN { 27984a1767b4Smrg want[0] = "011" 27994a1767b4Smrg want[1] = "160" 28004a1767b4Smrg want[2] = "074" 28014a1767b4Smrg want[3] = "040" 28024a1767b4Smrg want[4] = "000" 28034a1767b4Smrg want[5] = "040" 28044a1767b4Smrg want[6] = "020" 28054a1767b4Smrg want[7] = "221" 28064a1767b4Smrg want[8] = "114" 28074a1767b4Smrg want[9] = "000" 28084a1767b4Smrg want[10] = "100" 28094a1767b4Smrg want[11] = "200" 28104a1767b4Smrg want[12] = "122" 28114a1767b4Smrg want[13] = "261" 28124a1767b4Smrg want[14] = "000" 28134a1767b4Smrg want[15] = "200" 28144a1767b4Smrg 28154a1767b4Smrg want[16] = "000" 28164a1767b4Smrg want[17] = "004" 28174a1767b4Smrg want[18] = "000" 28184a1767b4Smrg want[19] = "000" 28194a1767b4Smrg want[20] = "000" 28204a1767b4Smrg want[21] = "000" 28214a1767b4Smrg want[22] = "002" 28224a1767b4Smrg want[23] = "000" 28234a1767b4Smrg want[24] = "000" 28244a1767b4Smrg want[25] = "000" 28254a1767b4Smrg want[26] = "000" 28264a1767b4Smrg want[27] = "001" 28274a1767b4Smrg want[28] = "000" 28284a1767b4Smrg want[29] = "000" 28294a1767b4Smrg want[30] = "000" 28304a1767b4Smrg want[31] = "014" 28314a1767b4Smrg 28324a1767b4Smrg want[32] = "011" 28334a1767b4Smrg want[33] = "270" 28344a1767b4Smrg want[34] = "140" 28354a1767b4Smrg want[35] = "062" 28364a1767b4Smrg want[36] = "000" 28374a1767b4Smrg want[37] = "040" 28384a1767b4Smrg want[38] = "240" 28394a1767b4Smrg want[39] = "331" 28404a1767b4Smrg want[40] = "160" 28414a1767b4Smrg want[41] = "000" 28424a1767b4Smrg want[42] = "100" 28434a1767b4Smrg want[43] = "240" 28444a1767b4Smrg want[44] = "343" 28454a1767b4Smrg want[45] = "371" 28464a1767b4Smrg want[46] = "000" 28474a1767b4Smrg want[47] = "200" 28484a1767b4Smrg 28494a1767b4Smrg result = "yes" 28504a1767b4Smrg} 28514a1767b4Smrg{ 28524a1767b4Smrg for (f = 2; f <= NF; f++) 28534a1767b4Smrg { 28544a1767b4Smrg for (i = 0; i < 47; i++) 28554a1767b4Smrg got[i] = got[i+1]; 28564a1767b4Smrg got[47] = $f; 28574a1767b4Smrg 28584a1767b4Smrg found = 1 28594a1767b4Smrg for (i = 0; i < 48; i++) 28604a1767b4Smrg if (got[i] != want[i]) 28614a1767b4Smrg { 28624a1767b4Smrg found = 0 28634a1767b4Smrg break 28644a1767b4Smrg } 28654a1767b4Smrg if (found) 28664a1767b4Smrg { 28674a1767b4Smrg result = "no" 28684a1767b4Smrg exit 28694a1767b4Smrg } 28704a1767b4Smrg } 28714a1767b4Smrg} 28724a1767b4SmrgEND { 28734a1767b4Smrg print result 28744a1767b4Smrg} 28754a1767b4Smrg]EOF 28764a1767b4SmrgGMP_TRY_ASSEMBLE( 28774a1767b4Smrg[ .text 28784a1767b4Smrg .align 32 28794a1767b4Smrg{ .mmi; add r14 = r15, r16 28804a1767b4Smrg add r17 = r18, r19 28814a1767b4Smrg add r20 = r21, r22 ;; } 28824a1767b4Smrg .align 32 28834a1767b4Smrg{ .mmi; add r23 = r24, r25 28844a1767b4Smrg add r26 = r27, r28 28854a1767b4Smrg add r29 = r30, r31 ;; } 28864a1767b4Smrg], 28874a1767b4Smrg [gmp_cv_asm_ia64_align_ok=`od -b conftest.$OBJEXT | $AWK -f conftest.awk`], 28884a1767b4Smrg [AC_MSG_WARN([oops, cannot compile test program]) 28894a1767b4Smrg gmp_cv_asm_ia64_align_ok=yes]) 28904a1767b4Smrg]) 28914a1767b4SmrgGMP_DEFINE_RAW(["define(<IA64_ALIGN_OK>, <\`$gmp_cv_asm_ia64_align_ok'>)"]) 28924a1767b4Smrg]) 28934a1767b4Smrg 28944a1767b4Smrg 28954a1767b4Smrg 28964a1767b4Smrg 28974a1767b4Smrgdnl GMP_ASM_M68K_INSTRUCTION 28984a1767b4Smrgdnl ------------------------ 28994a1767b4Smrgdnl Not sure if ".l" and "%" are independent settings, but it doesn't hurt 29004a1767b4Smrgdnl to try all four possibilities. Note that the % ones must be first, so 29014a1767b4Smrgdnl "d0" won't be interpreted as a label. 29024a1767b4Smrgdnl 29034a1767b4Smrgdnl gas 1.92.3 on NetBSD 1.4 needs to be tested with a two operand 29044a1767b4Smrgdnl instruction. It takes registers without "%", but a single operand 29054a1767b4Smrgdnl "clrl %d0" only gives a warning, not an error. 29064a1767b4Smrg 29074a1767b4SmrgAC_DEFUN([GMP_ASM_M68K_INSTRUCTION], 29084a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 29094a1767b4SmrgAC_CACHE_CHECK([assembler instruction and register style], 29104a1767b4Smrg gmp_cv_asm_m68k_instruction, 29114a1767b4Smrg[for i in "addl %d0,%d1" "add.l %d0,%d1" "addl d0,d1" "add.l d0,d1"; do 29124a1767b4Smrg GMP_TRY_ASSEMBLE( 29134a1767b4Smrg [ $gmp_cv_asm_text 29144a1767b4Smrg $i], 29154a1767b4Smrg [gmp_cv_asm_m68k_instruction=$i 29164a1767b4Smrg rm -f conftest* 29174a1767b4Smrg break]) 29184a1767b4Smrgdone 29194a1767b4Smrgif test -z "$gmp_cv_asm_m68k_instruction"; then 29204a1767b4Smrg AC_MSG_ERROR([cannot determine assembler instruction and register style]) 29214a1767b4Smrgfi 29224a1767b4Smrg]) 29234a1767b4Smrgcase $gmp_cv_asm_m68k_instruction in 29244a1767b4Smrg"addl d0,d1") want_dot_size=no; want_register_percent=no ;; 29254a1767b4Smrg"addl %d0,%d1") want_dot_size=no; want_register_percent=yes ;; 29264a1767b4Smrg"add.l d0,d1") want_dot_size=yes; want_register_percent=no ;; 29274a1767b4Smrg"add.l %d0,%d1") want_dot_size=yes; want_register_percent=yes ;; 29284a1767b4Smrg*) AC_MSG_ERROR([oops, unrecognised instruction and register style]) ;; 29294a1767b4Smrgesac 29304a1767b4SmrgGMP_DEFINE_RAW(["define(<WANT_REGISTER_PERCENT>, <\`$want_register_percent'>)"]) 29314a1767b4SmrgGMP_DEFINE_RAW(["define(<WANT_DOT_SIZE>, <\`$want_dot_size'>)"]) 29324a1767b4Smrg]) 29334a1767b4Smrg 29344a1767b4Smrg 29354a1767b4Smrgdnl GMP_ASM_M68K_ADDRESSING 29364a1767b4Smrgdnl ----------------------- 29374a1767b4Smrg 29384a1767b4SmrgAC_DEFUN([GMP_ASM_M68K_ADDRESSING], 29394a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 29404a1767b4SmrgAC_REQUIRE([GMP_ASM_M68K_INSTRUCTION]) 29414a1767b4SmrgAC_CACHE_CHECK([assembler addressing style], 29424a1767b4Smrg gmp_cv_asm_m68k_addressing, 29434a1767b4Smrg[case $gmp_cv_asm_m68k_instruction in 29444a1767b4Smrgaddl*) movel=movel ;; 29454a1767b4Smrgadd.l*) movel=move.l ;; 29464a1767b4Smrg*) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;; 29474a1767b4Smrgesac 29484a1767b4Smrgcase $gmp_cv_asm_m68k_instruction in 29494a1767b4Smrg*"%d0,%d1") dreg=%d0; areg=%a0 ;; 29504a1767b4Smrg*"d0,d1") dreg=d0; areg=a0 ;; 29514a1767b4Smrg*) AC_MSG_ERROR([oops, unrecognised gmp_cv_asm_m68k_instruction]) ;; 29524a1767b4Smrgesac 29534a1767b4SmrgGMP_TRY_ASSEMBLE( 29544a1767b4Smrg[ $gmp_cv_asm_text 29554a1767b4Smrg $movel $dreg, $areg@-], 29564a1767b4Smrg [gmp_cv_asm_m68k_addressing=mit], 29574a1767b4Smrg[GMP_TRY_ASSEMBLE( 29584a1767b4Smrg[ $gmp_cv_asm_text 29594a1767b4Smrg $movel $dreg, -($areg)], 29604a1767b4Smrg [gmp_cv_asm_m68k_addressing=motorola], 29614a1767b4Smrg[AC_MSG_ERROR([cannot determine assembler addressing style])])]) 29624a1767b4Smrg]) 29634a1767b4SmrgGMP_DEFINE_RAW(["define(<WANT_ADDRESSING>, <\`$gmp_cv_asm_m68k_addressing'>)"]) 29644a1767b4Smrg]) 29654a1767b4Smrg 29664a1767b4Smrg 29674a1767b4Smrgdnl GMP_ASM_M68K_BRANCHES 29684a1767b4Smrgdnl --------------------- 29694a1767b4Smrgdnl "bra" is the standard branch instruction. "jra" or "jbra" are 29704a1767b4Smrgdnl preferred where available, since on gas for instance they give a 29714a1767b4Smrgdnl displacement only as big as it needs to be, whereas "bra" is always 29724a1767b4Smrgdnl 16-bits. This applies to the conditional branches "bcc" etc too. 29734a1767b4Smrgdnl However "dbcc" etc on gas are already only as big as they need to be. 29744a1767b4Smrg 29754a1767b4SmrgAC_DEFUN([GMP_ASM_M68K_BRANCHES], 29764a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 29774a1767b4SmrgAC_CACHE_CHECK([assembler shortest branches], 29784a1767b4Smrg gmp_cv_asm_m68k_branches, 29794a1767b4Smrg[for i in jra jbra bra; do 29804a1767b4Smrg GMP_TRY_ASSEMBLE( 29814a1767b4Smrg[ $gmp_cv_asm_text 29824a1767b4Smrgfoo$gmp_cv_asm_label_suffix 29834a1767b4Smrg $i foo], 29844a1767b4Smrg [gmp_cv_asm_m68k_branches=$i 29854a1767b4Smrg rm -f conftest* 29864a1767b4Smrg break]) 29874a1767b4Smrgdone 29884a1767b4Smrgif test -z "$gmp_cv_asm_m68k_branches"; then 29894a1767b4Smrg AC_MSG_ERROR([cannot determine assembler branching style]) 29904a1767b4Smrgfi 29914a1767b4Smrg]) 29924a1767b4SmrgGMP_DEFINE_RAW(["define(<WANT_BRANCHES>, <\`$gmp_cv_asm_m68k_branches'>)"]) 29934a1767b4Smrg]) 29944a1767b4Smrg 29954a1767b4Smrg 29964a1767b4Smrgdnl GMP_ASM_POWERPC_PIC_ALWAYS 29974a1767b4Smrgdnl -------------------------- 29984a1767b4Smrgdnl Determine whether PIC is the default compiler output. 29994a1767b4Smrgdnl 30004a1767b4Smrgdnl SVR4 style "foo@ha" addressing is interpreted as non-PIC, and anything 30014a1767b4Smrgdnl else is assumed to require PIC always (Darwin or AIX). SVR4 is the 30024a1767b4Smrgdnl only non-PIC addressing syntax the asm files have at the moment anyway. 30034a1767b4Smrgdnl 30044a1767b4Smrgdnl Libtool does this by taking "*-*-aix* | *-*-darwin* | *-*-rhapsody*" to 30054a1767b4Smrgdnl mean PIC always, but it seems more reliable to grep the compiler 30064a1767b4Smrgdnl output. 30074a1767b4Smrgdnl 30084a1767b4Smrgdnl The next paragraph is untrue for Tiger. Was it ever true? For tiger, 30094a1767b4Smrgdnl "cc -fast" makes non-PIC the default (and the binaries do run). 30104a1767b4Smrgdnl On Darwin "cc -static" is non-PIC with syntax "ha16(_foo)", but that's 30114a1767b4Smrgdnl apparently only for use in the kernel, which we're not attempting to 30124a1767b4Smrgdnl target at the moment, so don't look for that. 30134a1767b4Smrg 30144a1767b4SmrgAC_DEFUN([GMP_ASM_POWERPC_PIC_ALWAYS], 30154a1767b4Smrg[AC_REQUIRE([AC_PROG_CC]) 30164a1767b4SmrgAC_CACHE_CHECK([whether compiler output is PIC by default], 30174a1767b4Smrg gmp_cv_asm_powerpc_pic, 30184a1767b4Smrg[gmp_cv_asm_powerpc_pic=yes 30194a1767b4Smrgcat >conftest.c <<EOF 30204a1767b4Smrgint foo; 30214a1767b4Smrgint *bar() { return &foo; } 30224a1767b4SmrgEOF 30234a1767b4Smrgecho "Test program:" >&AC_FD_CC 30244a1767b4Smrgcat conftest.c >&AC_FD_CC 30254a1767b4Smrggmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&AC_FD_CC" 30264a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 30274a1767b4Smrg echo "Compiler output:" >&AC_FD_CC 30284a1767b4Smrg cat conftest.s >&AC_FD_CC 30294a1767b4Smrg if grep 'foo@ha' conftest.s >/dev/null 2>&AC_FD_CC; then 30304a1767b4Smrg gmp_cv_asm_powerpc_pic=no 30314a1767b4Smrg fi 30324a1767b4Smrg if grep 'ha16(_foo)' conftest.s >/dev/null 2>&AC_FD_CC; then 30334a1767b4Smrg gmp_cv_asm_powerpc_pic=no 30344a1767b4Smrg fi 30354a1767b4Smrgfi 30364a1767b4Smrgrm -f conftest* 30374a1767b4Smrg]) 30384a1767b4SmrgGMP_DEFINE_RAW(["define(<PIC_ALWAYS>,<$gmp_cv_asm_powerpc_pic>)"]) 30394a1767b4Smrg]) 30404a1767b4Smrg 30414a1767b4Smrg 30424a1767b4Smrgdnl GMP_ASM_POWERPC_R_REGISTERS 30434a1767b4Smrgdnl --------------------------- 30444a1767b4Smrgdnl Determine whether the assembler takes powerpc registers with an "r" as 30454a1767b4Smrgdnl in "r6", or as plain "6". The latter is standard, but NeXT, Rhapsody, 30464a1767b4Smrgdnl and MacOS-X require the "r" forms. 30474a1767b4Smrgdnl 30484a1767b4Smrgdnl See also mpn/powerpc32/powerpc-defs.m4 which uses the result of this 30494a1767b4Smrgdnl test. 30504a1767b4Smrg 30514a1767b4SmrgAC_DEFUN([GMP_ASM_POWERPC_R_REGISTERS], 30524a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 30534a1767b4SmrgAC_CACHE_CHECK([if the assembler needs r on registers], 30544a1767b4Smrg gmp_cv_asm_powerpc_r_registers, 30554a1767b4Smrg[GMP_TRY_ASSEMBLE( 30564a1767b4Smrg[ $gmp_cv_asm_text 30574a1767b4Smrg mtctr 6], 30584a1767b4Smrg[gmp_cv_asm_powerpc_r_registers=no], 30594a1767b4Smrg[GMP_TRY_ASSEMBLE( 30604a1767b4Smrg[ $gmp_cv_asm_text 30614a1767b4Smrg mtctr r6], 30624a1767b4Smrg[gmp_cv_asm_powerpc_r_registers=yes], 30634a1767b4Smrg[AC_MSG_ERROR([neither "mtctr 6" nor "mtctr r6" works])])])]) 30644a1767b4Smrg 30654a1767b4SmrgGMP_DEFINE_RAW(["define(<WANT_R_REGISTERS>,<$gmp_cv_asm_powerpc_r_registers>)"]) 30664a1767b4Smrg]) 30674a1767b4Smrg 30684a1767b4Smrg 30694a1767b4Smrgdnl GMP_ASM_SPARC_REGISTER 30704a1767b4Smrgdnl ---------------------- 30714a1767b4Smrgdnl Determine whether the assembler accepts the ".register" directive. 30724a1767b4Smrgdnl Old versions of solaris "as" don't. 30734a1767b4Smrgdnl 30744a1767b4Smrgdnl See also mpn/sparc32/sparc-defs.m4 which uses the result of this test. 30754a1767b4Smrg 30764a1767b4SmrgAC_DEFUN([GMP_ASM_SPARC_REGISTER], 30774a1767b4Smrg[AC_REQUIRE([GMP_ASM_TEXT]) 30784a1767b4SmrgAC_CACHE_CHECK([if the assembler accepts ".register"], 30794a1767b4Smrg gmp_cv_asm_sparc_register, 30804a1767b4Smrg[GMP_TRY_ASSEMBLE( 30814a1767b4Smrg[ $gmp_cv_asm_text 30824a1767b4Smrg .register %g2,#scratch 30834a1767b4Smrg], 30844a1767b4Smrg[gmp_cv_asm_sparc_register=yes], 30854a1767b4Smrg[gmp_cv_asm_sparc_register=no])]) 30864a1767b4Smrg 30874a1767b4SmrgGMP_DEFINE_RAW(["define(<HAVE_REGISTER>,<$gmp_cv_asm_sparc_register>)"]) 30884a1767b4Smrg]) 30894a1767b4Smrg 30904a1767b4Smrg 309121c03f4cSmrgdnl GMP_ASM_SPARC_GOTDATA 309221c03f4cSmrgdnl ---------------------- 309321c03f4cSmrgdnl Determine whether the assembler accepts gotdata relocations. 309421c03f4cSmrgdnl 309521c03f4cSmrgdnl See also mpn/sparc32/sparc-defs.m4 which uses the result of this test. 309621c03f4cSmrg 309721c03f4cSmrgAC_DEFUN([GMP_ASM_SPARC_GOTDATA], 309821c03f4cSmrg[AC_REQUIRE([GMP_ASM_TEXT]) 309921c03f4cSmrgAC_CACHE_CHECK([if the assembler accepts gotdata relocations], 310021c03f4cSmrg gmp_cv_asm_sparc_gotdata, 310121c03f4cSmrg[GMP_TRY_ASSEMBLE( 310221c03f4cSmrg[ $gmp_cv_asm_text 310321c03f4cSmrg .text 310421c03f4cSmrg sethi %gdop_hix22(symbol), %g1 310521c03f4cSmrg or %g1, %gdop_lox10(symbol), %g1 310621c03f4cSmrg], 310721c03f4cSmrg[gmp_cv_asm_sparc_gotdata=yes], 310821c03f4cSmrg[gmp_cv_asm_sparc_gotdata=no])]) 310921c03f4cSmrg 311021c03f4cSmrgGMP_DEFINE_RAW(["define(<HAVE_GOTDATA>,<$gmp_cv_asm_sparc_gotdata>)"]) 311121c03f4cSmrg]) 311221c03f4cSmrg 311321c03f4cSmrg 311421c03f4cSmrgdnl GMP_ASM_SPARC_SHARED_THUNKS 311521c03f4cSmrgdnl ---------------------- 311621c03f4cSmrgdnl Determine whether the assembler supports all of the features 311721c03f4cSmrgdnl necessary in order to emit shared PIC thunks on sparc. 311821c03f4cSmrgdnl 311921c03f4cSmrgdnl See also mpn/sparc32/sparc-defs.m4 which uses the result of this test. 312021c03f4cSmrg 312121c03f4cSmrgAC_DEFUN([GMP_ASM_SPARC_SHARED_THUNKS], 312221c03f4cSmrg[AC_REQUIRE([GMP_ASM_TEXT]) 312321c03f4cSmrgAC_CACHE_CHECK([if the assembler can support shared PIC thunks], 312421c03f4cSmrg gmp_cv_asm_sparc_shared_thunks, 312521c03f4cSmrg[GMP_TRY_ASSEMBLE( 312621c03f4cSmrg[ $gmp_cv_asm_text 312721c03f4cSmrg .section .text.__sparc_get_pc_thunk.l7,"axG",@progbits,__sparc_get_pc_thunk.l7,comdat 312821c03f4cSmrg .weak __sparc_get_pc_thunk.l7 312921c03f4cSmrg .hidden __sparc_get_pc_thunk.l7 313021c03f4cSmrg .type __sparc_get_pc_thunk.l7, #function 313121c03f4cSmrg__sparc_get_pc_thunk.l7: 313221c03f4cSmrg jmp %o7+8 313321c03f4cSmrg add %o7, %l7, %l7 313421c03f4cSmrg], 313521c03f4cSmrg[gmp_cv_asm_sparc_shared_thunks=yes], 313621c03f4cSmrg[gmp_cv_asm_sparc_shared_thunks=no])]) 313721c03f4cSmrg 313821c03f4cSmrgGMP_DEFINE_RAW(["define(<HAVE_SHARED_THUNKS>,<$gmp_cv_asm_sparc_shared_thunks>)"]) 313921c03f4cSmrg]) 314021c03f4cSmrg 314121c03f4cSmrg 31424a1767b4Smrgdnl GMP_C_ATTRIBUTE_CONST 31434a1767b4Smrgdnl --------------------- 31444a1767b4Smrg 31454a1767b4SmrgAC_DEFUN([GMP_C_ATTRIBUTE_CONST], 31464a1767b4Smrg[AC_CACHE_CHECK([whether gcc __attribute__ ((const)) works], 31474a1767b4Smrg gmp_cv_c_attribute_const, 31484a1767b4Smrg[AC_TRY_COMPILE([int foo (int x) __attribute__ ((const));], , 31494a1767b4Smrg gmp_cv_c_attribute_const=yes, gmp_cv_c_attribute_const=no) 31504a1767b4Smrg]) 31514a1767b4Smrgif test $gmp_cv_c_attribute_const = yes; then 31524a1767b4Smrg AC_DEFINE(HAVE_ATTRIBUTE_CONST, 1, 31534a1767b4Smrg [Define to 1 if the compiler accepts gcc style __attribute__ ((const))]) 31544a1767b4Smrgfi 31554a1767b4Smrg]) 31564a1767b4Smrg 31574a1767b4Smrg 31584a1767b4Smrgdnl GMP_C_ATTRIBUTE_MALLOC 31594a1767b4Smrgdnl ---------------------- 31604a1767b4Smrgdnl gcc 2.95.x accepts __attribute__ ((malloc)) but with a warning that 31614a1767b4Smrgdnl it's ignored. Pretend it doesn't exist in this case, to avoid that 31624a1767b4Smrgdnl warning. 31634a1767b4Smrg 31644a1767b4SmrgAC_DEFUN([GMP_C_ATTRIBUTE_MALLOC], 31654a1767b4Smrg[AC_CACHE_CHECK([whether gcc __attribute__ ((malloc)) works], 31664a1767b4Smrg gmp_cv_c_attribute_malloc, 31674a1767b4Smrg[cat >conftest.c <<EOF 31684a1767b4Smrgvoid *foo (int x) __attribute__ ((malloc)); 31694a1767b4SmrgEOF 31704a1767b4Smrggmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1" 31714a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 31724a1767b4Smrg if grep "attribute directive ignored" conftest.out >/dev/null; then 31734a1767b4Smrg gmp_cv_c_attribute_malloc=no 31744a1767b4Smrg else 31754a1767b4Smrg gmp_cv_c_attribute_malloc=yes 31764a1767b4Smrg fi 31774a1767b4Smrgelse 31784a1767b4Smrg gmp_cv_c_attribute_malloc=no 31794a1767b4Smrgfi 31804a1767b4Smrgcat conftest.out >&AC_FD_CC 31814a1767b4Smrgrm -f conftest* 31824a1767b4Smrg]) 31834a1767b4Smrgif test $gmp_cv_c_attribute_malloc = yes; then 31844a1767b4Smrg AC_DEFINE(HAVE_ATTRIBUTE_MALLOC, 1, 31854a1767b4Smrg [Define to 1 if the compiler accepts gcc style __attribute__ ((malloc))]) 31864a1767b4Smrgfi 31874a1767b4Smrg]) 31884a1767b4Smrg 31894a1767b4Smrg 31904a1767b4Smrgdnl GMP_C_ATTRIBUTE_MODE 31914a1767b4Smrgdnl -------------------- 31924a1767b4Smrgdnl Introduced in gcc 2.2, but perhaps not in all Apple derived versions. 31934a1767b4Smrg 31944a1767b4SmrgAC_DEFUN([GMP_C_ATTRIBUTE_MODE], 31954a1767b4Smrg[AC_CACHE_CHECK([whether gcc __attribute__ ((mode (XX))) works], 31964a1767b4Smrg gmp_cv_c_attribute_mode, 31974a1767b4Smrg[AC_TRY_COMPILE([typedef int SItype __attribute__ ((mode (SI)));], , 31984a1767b4Smrg gmp_cv_c_attribute_mode=yes, gmp_cv_c_attribute_mode=no) 31994a1767b4Smrg]) 32004a1767b4Smrgif test $gmp_cv_c_attribute_mode = yes; then 32014a1767b4Smrg AC_DEFINE(HAVE_ATTRIBUTE_MODE, 1, 32024a1767b4Smrg [Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))]) 32034a1767b4Smrgfi 32044a1767b4Smrg]) 32054a1767b4Smrg 32064a1767b4Smrg 32074a1767b4Smrgdnl GMP_C_ATTRIBUTE_NORETURN 32084a1767b4Smrgdnl ------------------------ 32094a1767b4Smrg 32104a1767b4SmrgAC_DEFUN([GMP_C_ATTRIBUTE_NORETURN], 32114a1767b4Smrg[AC_CACHE_CHECK([whether gcc __attribute__ ((noreturn)) works], 32124a1767b4Smrg gmp_cv_c_attribute_noreturn, 32134a1767b4Smrg[AC_TRY_COMPILE([void foo (int x) __attribute__ ((noreturn));], , 32144a1767b4Smrg gmp_cv_c_attribute_noreturn=yes, gmp_cv_c_attribute_noreturn=no) 32154a1767b4Smrg]) 32164a1767b4Smrgif test $gmp_cv_c_attribute_noreturn = yes; then 32174a1767b4Smrg AC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1, 32184a1767b4Smrg [Define to 1 if the compiler accepts gcc style __attribute__ ((noreturn))]) 32194a1767b4Smrgfi 32204a1767b4Smrg]) 32214a1767b4Smrg 322221c03f4cSmrgdnl GMP_C_HIDDEN_ALIAS 322321c03f4cSmrgdnl ------------------------ 322421c03f4cSmrg 322521c03f4cSmrgAC_DEFUN([GMP_C_HIDDEN_ALIAS], 322621c03f4cSmrg[AC_CACHE_CHECK([whether gcc hidden aliases work], 322721c03f4cSmrg gmp_cv_c_hidden_alias, 322821c03f4cSmrg[AC_TRY_COMPILE( 322921c03f4cSmrg[void hid() __attribute__ ((visibility("hidden"))); 323021c03f4cSmrgvoid hid() {} 323121c03f4cSmrgvoid pub() __attribute__ ((alias("hid")));], 323221c03f4cSmrg, gmp_cv_c_hidden_alias=yes, gmp_cv_c_hidden_alias=no) 323321c03f4cSmrg]) 323421c03f4cSmrgif test $gmp_cv_c_hidden_alias = yes; then 323521c03f4cSmrg AC_DEFINE(HAVE_HIDDEN_ALIAS, 1, 323621c03f4cSmrg [Define to 1 if the compiler accepts gcc style __attribute__ ((visibility)) 323721c03f4cSmrgand __attribute__ ((alias))]) 323821c03f4cSmrgfi 323921c03f4cSmrg]) 32404a1767b4Smrg 32414a1767b4Smrgdnl GMP_C_DOUBLE_FORMAT 32424a1767b4Smrgdnl ------------------- 32434a1767b4Smrgdnl Determine the floating point format. 32444a1767b4Smrgdnl 32454a1767b4Smrgdnl The object file is grepped, in order to work when cross compiling. A 3246b6659776Smrgdnl start and end sequence is included to avoid false matches, and allowance 3247b6659776Smrgdnl is made for the desired data crossing an "od -b" line boundary. The test 3248b6659776Smrgdnl number is a small integer so it should appear exactly, no rounding or 3249b6659776Smrgdnl truncation etc. 32504a1767b4Smrgdnl 32514a1767b4Smrgdnl "od -b", incidentally, is supported even by Unix V7, and the awk script 32524a1767b4Smrgdnl used doesn't have functions or anything, so even an "old" awk should 32534a1767b4Smrgdnl suffice. 3254b6659776Smrgdnl 3255b6659776Smrgdnl The C code here declares the variable foo as extern; without that, some 3256b6659776Smrgdnl C++ compilers will not put foo in the object file. 32574a1767b4Smrg 32584a1767b4SmrgAC_DEFUN([GMP_C_DOUBLE_FORMAT], 32594a1767b4Smrg[AC_REQUIRE([AC_PROG_CC]) 32604a1767b4SmrgAC_REQUIRE([AC_PROG_AWK]) 32614a1767b4SmrgAC_CACHE_CHECK([format of `double' floating point], 32624a1767b4Smrg gmp_cv_c_double_format, 32634a1767b4Smrg[gmp_cv_c_double_format=unknown 32644a1767b4Smrgcat >conftest.c <<\EOF 3265*274b3bceSmrg[#include <stdio.h> 3266*274b3bceSmrgstruct foo { 32674a1767b4Smrg char before[8]; 32684a1767b4Smrg double x; 32694a1767b4Smrg char after[8]; 3270b6659776Smrg}; 3271b6659776Smrgextern struct foo foo; 3272b6659776Smrgstruct foo foo = { 32734a1767b4Smrg { '\001', '\043', '\105', '\147', '\211', '\253', '\315', '\357' }, 32744a1767b4Smrg -123456789.0, 32754a1767b4Smrg { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' }, 3276*274b3bceSmrg}; 3277*274b3bceSmrgint main(){ 3278*274b3bceSmrg int i; 3279*274b3bceSmrg for (i = 0; i < 8; i++) { 3280*274b3bceSmrg printf ("%d %f\n", foo.before[i] + foo.after[i], foo.x); 3281*274b3bceSmrg } 3282*274b3bceSmrg return 0; 3283*274b3bceSmrg}] 32844a1767b4SmrgEOF 3285*274b3bceSmrggmp_compile="$CC $CFLAGS $CPPFLAGS conftest.c -o conftest$EXEEXT >&AC_FD_CC 2>&1" 32864a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 32874a1767b4Smrgcat >conftest.awk <<\EOF 32884a1767b4Smrg[ 32894a1767b4SmrgBEGIN { 32904a1767b4Smrg found = 0 32914a1767b4Smrg} 32924a1767b4Smrg 32934a1767b4Smrg{ 32944a1767b4Smrg for (f = 2; f <= NF; f++) 32954a1767b4Smrg { 32964a1767b4Smrg for (i = 0; i < 23; i++) 32974a1767b4Smrg got[i] = got[i+1]; 32984a1767b4Smrg got[23] = $f; 32994a1767b4Smrg 33004a1767b4Smrg # match the special begin and end sequences 33014a1767b4Smrg if (got[0] != "001") continue 33024a1767b4Smrg if (got[1] != "043") continue 33034a1767b4Smrg if (got[2] != "105") continue 33044a1767b4Smrg if (got[3] != "147") continue 33054a1767b4Smrg if (got[4] != "211") continue 33064a1767b4Smrg if (got[5] != "253") continue 33074a1767b4Smrg if (got[6] != "315") continue 33084a1767b4Smrg if (got[7] != "357") continue 33094a1767b4Smrg if (got[16] != "376") continue 33104a1767b4Smrg if (got[17] != "334") continue 33114a1767b4Smrg if (got[18] != "272") continue 33124a1767b4Smrg if (got[19] != "230") continue 33134a1767b4Smrg if (got[20] != "166") continue 33144a1767b4Smrg if (got[21] != "124") continue 33154a1767b4Smrg if (got[22] != "062") continue 33164a1767b4Smrg if (got[23] != "020") continue 33174a1767b4Smrg 33184a1767b4Smrg saw = " (" got[8] " " got[9] " " got[10] " " got[11] " " got[12] " " got[13] " " got[14] " " got[15] ")" 33194a1767b4Smrg 33204a1767b4Smrg if (got[8] == "000" && \ 33214a1767b4Smrg got[9] == "000" && \ 33224a1767b4Smrg got[10] == "000" && \ 33234a1767b4Smrg got[11] == "124" && \ 33244a1767b4Smrg got[12] == "064" && \ 33254a1767b4Smrg got[13] == "157" && \ 33264a1767b4Smrg got[14] == "235" && \ 33274a1767b4Smrg got[15] == "301") 33284a1767b4Smrg { 33294a1767b4Smrg print "IEEE little endian" 33304a1767b4Smrg found = 1 33314a1767b4Smrg exit 33324a1767b4Smrg } 33334a1767b4Smrg 33344a1767b4Smrg # Little endian with the two 4-byte halves swapped, as used by ARM 33354a1767b4Smrg # when the chip is in little endian mode. 33364a1767b4Smrg # 33374a1767b4Smrg if (got[8] == "064" && \ 33384a1767b4Smrg got[9] == "157" && \ 33394a1767b4Smrg got[10] == "235" && \ 33404a1767b4Smrg got[11] == "301" && \ 33414a1767b4Smrg got[12] == "000" && \ 33424a1767b4Smrg got[13] == "000" && \ 33434a1767b4Smrg got[14] == "000" && \ 33444a1767b4Smrg got[15] == "124") 33454a1767b4Smrg { 33464a1767b4Smrg print "IEEE little endian, swapped halves" 33474a1767b4Smrg found = 1 33484a1767b4Smrg exit 33494a1767b4Smrg } 33504a1767b4Smrg 33514a1767b4Smrg # gcc 2.95.4 on one GNU/Linux ARM system was seen generating 000 in 33524a1767b4Smrg # the last byte, whereas 124 is correct. Not sure where the bug 33534a1767b4Smrg # actually lies, but a running program didn't seem to get a full 33544a1767b4Smrg # mantissa worth of working bits. 33554a1767b4Smrg # 33564a1767b4Smrg # We match this case explicitly so we can give a nice result message, 33574a1767b4Smrg # but we deliberately exclude it from the normal IEEE double setups 33584a1767b4Smrg # since it's too broken. 33594a1767b4Smrg # 33604a1767b4Smrg if (got[8] == "064" && \ 33614a1767b4Smrg got[9] == "157" && \ 33624a1767b4Smrg got[10] == "235" && \ 33634a1767b4Smrg got[11] == "301" && \ 33644a1767b4Smrg got[12] == "000" && \ 33654a1767b4Smrg got[13] == "000" && \ 33664a1767b4Smrg got[14] == "000" && \ 33674a1767b4Smrg got[15] == "000") 33684a1767b4Smrg { 33694a1767b4Smrg print "bad ARM software floats" 33704a1767b4Smrg found = 1 33714a1767b4Smrg exit 33724a1767b4Smrg } 33734a1767b4Smrg 33744a1767b4Smrg if (got[8] == "301" && \ 33754a1767b4Smrg got[9] == "235" && \ 33764a1767b4Smrg got[10] == "157" && \ 33774a1767b4Smrg got[11] == "064" && \ 33784a1767b4Smrg got[12] == "124" && \ 33794a1767b4Smrg got[13] == "000" && \ 33804a1767b4Smrg got[14] == "000" && \ 33814a1767b4Smrg got[15] == "000") 33824a1767b4Smrg { 33834a1767b4Smrg print "IEEE big endian" 33844a1767b4Smrg found = 1 33854a1767b4Smrg exit 33864a1767b4Smrg } 33874a1767b4Smrg 33884a1767b4Smrg if (got[8] == "353" && \ 33894a1767b4Smrg got[9] == "315" && \ 33904a1767b4Smrg got[10] == "242" && \ 33914a1767b4Smrg got[11] == "171" && \ 33924a1767b4Smrg got[12] == "000" && \ 33934a1767b4Smrg got[13] == "240" && \ 33944a1767b4Smrg got[14] == "000" && \ 33954a1767b4Smrg got[15] == "000") 33964a1767b4Smrg { 33974a1767b4Smrg print "VAX D" 33984a1767b4Smrg found = 1 33994a1767b4Smrg exit 34004a1767b4Smrg } 34014a1767b4Smrg 34024a1767b4Smrg if (got[8] == "275" && \ 34034a1767b4Smrg got[9] == "301" && \ 34044a1767b4Smrg got[10] == "064" && \ 34054a1767b4Smrg got[11] == "157" && \ 34064a1767b4Smrg got[12] == "000" && \ 34074a1767b4Smrg got[13] == "124" && \ 34084a1767b4Smrg got[14] == "000" && \ 34094a1767b4Smrg got[15] == "000") 34104a1767b4Smrg { 34114a1767b4Smrg print "VAX G" 34124a1767b4Smrg found = 1 34134a1767b4Smrg exit 34144a1767b4Smrg } 34154a1767b4Smrg 34164a1767b4Smrg if (got[8] == "300" && \ 34174a1767b4Smrg got[9] == "033" && \ 34184a1767b4Smrg got[10] == "353" && \ 34194a1767b4Smrg got[11] == "171" && \ 34204a1767b4Smrg got[12] == "242" && \ 34214a1767b4Smrg got[13] == "240" && \ 34224a1767b4Smrg got[14] == "000" && \ 34234a1767b4Smrg got[15] == "000") 34244a1767b4Smrg { 34254a1767b4Smrg print "Cray CFP" 34264a1767b4Smrg found = 1 34274a1767b4Smrg exit 34284a1767b4Smrg } 34294a1767b4Smrg } 34304a1767b4Smrg} 34314a1767b4Smrg 34324a1767b4SmrgEND { 34334a1767b4Smrg if (! found) 34344a1767b4Smrg print "unknown", saw 34354a1767b4Smrg} 34364a1767b4Smrg] 34374a1767b4SmrgEOF 3438*274b3bceSmrg gmp_cv_c_double_format=`od -b conftest$EXEEXT | $AWK -f conftest.awk` 34394a1767b4Smrg case $gmp_cv_c_double_format in 34404a1767b4Smrg unknown*) 3441*274b3bceSmrg echo "cannot match anything, conftest$EXEEXT contains" >&AC_FD_CC 3442*274b3bceSmrg od -b conftest$EXEEXT >&AC_FD_CC 34434a1767b4Smrg ;; 34444a1767b4Smrg esac 34454a1767b4Smrgelse 34464a1767b4Smrg AC_MSG_WARN([oops, cannot compile test program]) 34474a1767b4Smrgfi 34484a1767b4Smrgrm -f conftest* 34494a1767b4Smrg]) 34504a1767b4Smrg 34514a1767b4SmrgAH_VERBATIM([HAVE_DOUBLE], 34524a1767b4Smrg[/* Define one of the following to 1 for the format of a `double'. 34534a1767b4Smrg If your format is not among these choices, or you don't know what it is, 34544a1767b4Smrg then leave all undefined. 34554a1767b4Smrg IEEE_LITTLE_SWAPPED means little endian, but with the two 4-byte halves 34564a1767b4Smrg swapped, as used by ARM CPUs in little endian mode. */ 34574a1767b4Smrg#undef HAVE_DOUBLE_IEEE_BIG_ENDIAN 34584a1767b4Smrg#undef HAVE_DOUBLE_IEEE_LITTLE_ENDIAN 34594a1767b4Smrg#undef HAVE_DOUBLE_IEEE_LITTLE_SWAPPED 34604a1767b4Smrg#undef HAVE_DOUBLE_VAX_D 34614a1767b4Smrg#undef HAVE_DOUBLE_VAX_G 34624a1767b4Smrg#undef HAVE_DOUBLE_CRAY_CFP]) 34634a1767b4Smrg 34644a1767b4Smrgcase $gmp_cv_c_double_format in 34654a1767b4Smrg "IEEE big endian") 34664a1767b4Smrg AC_DEFINE(HAVE_DOUBLE_IEEE_BIG_ENDIAN, 1) 34674a1767b4Smrg GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_DOUBLE_IEEE_BIG_ENDIAN')", POST) 34684a1767b4Smrg ;; 34694a1767b4Smrg "IEEE little endian") 34704a1767b4Smrg AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_ENDIAN, 1) 34714a1767b4Smrg GMP_DEFINE_RAW("define_not_for_expansion(\`HAVE_DOUBLE_IEEE_LITTLE_ENDIAN')", POST) 34724a1767b4Smrg ;; 34734a1767b4Smrg "IEEE little endian, swapped halves") 34744a1767b4Smrg AC_DEFINE(HAVE_DOUBLE_IEEE_LITTLE_SWAPPED, 1) ;; 34754a1767b4Smrg "VAX D") 34764a1767b4Smrg AC_DEFINE(HAVE_DOUBLE_VAX_D, 1) ;; 34774a1767b4Smrg "VAX G") 34784a1767b4Smrg AC_DEFINE(HAVE_DOUBLE_VAX_G, 1) ;; 34794a1767b4Smrg "Cray CFP") 34804a1767b4Smrg AC_DEFINE(HAVE_DOUBLE_CRAY_CFP, 1) ;; 34814a1767b4Smrg "bad ARM software floats") 34824a1767b4Smrg ;; 34834a1767b4Smrg unknown*) 34844a1767b4Smrg AC_MSG_WARN([Could not determine float format.]) 34854a1767b4Smrg AC_MSG_WARN([Conversions to and from "double" may be slow.]) 34864a1767b4Smrg ;; 34874a1767b4Smrg *) 34884a1767b4Smrg AC_MSG_WARN([oops, unrecognised float format: $gmp_cv_c_double_format]) 34894a1767b4Smrg ;; 34904a1767b4Smrgesac 34914a1767b4Smrg]) 34924a1767b4Smrg 34934a1767b4Smrg 34944a1767b4Smrgdnl GMP_C_STDARG 34954a1767b4Smrgdnl ------------ 349621c03f4cSmrgdnl Test whether to use <stdarg.h>. 34974a1767b4Smrgdnl 34984a1767b4Smrgdnl Notice the AC_DEFINE here is HAVE_STDARG to avoid clashing with 34994a1767b4Smrgdnl HAVE_STDARG_H which could arise from AC_CHECK_HEADERS. 35004a1767b4Smrgdnl 35014a1767b4Smrgdnl This test might be slight overkill, after all there's really only going 35024a1767b4Smrgdnl to be ANSI or K&R and the two can be differentiated by AC_PROG_CC_STDC 35034a1767b4Smrgdnl or very likely by the setups for _PROTO in gmp.h. On the other hand 35044a1767b4Smrgdnl this test is nice and direct, being what we're going to actually use. 35054a1767b4Smrg 350621c03f4cSmrgdnl AC_DEFUN([GMP_C_STDARG], 350721c03f4cSmrgdnl [AC_CACHE_CHECK([whether <stdarg.h> exists and works], 350821c03f4cSmrgdnl gmp_cv_c_stdarg, 350921c03f4cSmrgdnl [AC_TRY_COMPILE( 351021c03f4cSmrgdnl [#include <stdarg.h> 351121c03f4cSmrgdnl int foo (int x, ...) 351221c03f4cSmrgdnl { 351321c03f4cSmrgdnl va_list ap; 351421c03f4cSmrgdnl int y; 351521c03f4cSmrgdnl va_start (ap, x); 351621c03f4cSmrgdnl y = va_arg (ap, int); 351721c03f4cSmrgdnl va_end (ap); 351821c03f4cSmrgdnl return y; 351921c03f4cSmrgdnl }],, 352021c03f4cSmrgdnl gmp_cv_c_stdarg=yes, gmp_cv_c_stdarg=no) 352121c03f4cSmrgdnl ]) 352221c03f4cSmrgdnl if test $gmp_cv_c_stdarg = yes; then 352321c03f4cSmrgdnl AC_DEFINE(HAVE_STDARG, 1, [Define to 1 if <stdarg.h> exists and works]) 352421c03f4cSmrgdnl fi 352521c03f4cSmrgdnl ]) 35264a1767b4Smrg 35274a1767b4Smrg 35284a1767b4Smrgdnl GMP_FUNC_ALLOCA 35294a1767b4Smrgdnl --------------- 35304a1767b4Smrgdnl Determine whether "alloca" is available. This is AC_FUNC_ALLOCA from 35314a1767b4Smrgdnl autoconf, but changed so it doesn't use alloca.c if alloca() isn't 35324a1767b4Smrgdnl available, and also to use gmp-impl.h for the conditionals detecting 35334a1767b4Smrgdnl compiler builtin alloca's. 35344a1767b4Smrg 35354a1767b4SmrgAC_DEFUN([GMP_FUNC_ALLOCA], 35364a1767b4Smrg[AC_REQUIRE([GMP_HEADER_ALLOCA]) 35374a1767b4SmrgAC_CACHE_CHECK([for alloca (via gmp-impl.h)], 35384a1767b4Smrg gmp_cv_func_alloca, 35394a1767b4Smrg[AC_TRY_LINK( 35404a1767b4SmrgGMP_INCLUDE_GMP_H 35414a1767b4Smrg[#include "$srcdir/gmp-impl.h" 35424a1767b4Smrg], 35434a1767b4Smrg [char *p = (char *) alloca (1);], 35444a1767b4Smrg gmp_cv_func_alloca=yes, 35454a1767b4Smrg gmp_cv_func_alloca=no)]) 35464a1767b4Smrgif test $gmp_cv_func_alloca = yes; then 35474a1767b4Smrg AC_DEFINE(HAVE_ALLOCA, 1, [Define to 1 if alloca() works (via gmp-impl.h).]) 35484a1767b4Smrgfi 35494a1767b4Smrg]) 35504a1767b4Smrg 35514a1767b4SmrgAC_DEFUN([GMP_HEADER_ALLOCA], 35524a1767b4Smrg[# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works 35534a1767b4Smrg# for constant arguments. Useless! 35544a1767b4SmrgAC_CACHE_CHECK([for working alloca.h], 35554a1767b4Smrg gmp_cv_header_alloca, 35564a1767b4Smrg[AC_TRY_LINK([#include <alloca.h>], 35574a1767b4Smrg [char *p = (char *) alloca (2 * sizeof (int));], 35584a1767b4Smrg gmp_cv_header_alloca=yes, 35594a1767b4Smrg gmp_cv_header_alloca=no)]) 35604a1767b4Smrgif test $gmp_cv_header_alloca = yes; then 35614a1767b4Smrg AC_DEFINE(HAVE_ALLOCA_H, 1, 35624a1767b4Smrg [Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).]) 35634a1767b4Smrgfi 35644a1767b4Smrg]) 35654a1767b4Smrg 35664a1767b4Smrg 35674a1767b4Smrgdnl GMP_OPTION_ALLOCA 35684a1767b4Smrgdnl ----------------- 35694a1767b4Smrgdnl Decide what to do about --enable-alloca from the user. 35704a1767b4Smrgdnl This is a macro so it can require GMP_FUNC_ALLOCA. 35714a1767b4Smrg 35724a1767b4SmrgAC_DEFUN([GMP_OPTION_ALLOCA], 35734a1767b4Smrg[AC_REQUIRE([GMP_FUNC_ALLOCA]) 35744a1767b4SmrgAC_CACHE_CHECK([how to allocate temporary memory], 35754a1767b4Smrg gmp_cv_option_alloca, 35764a1767b4Smrg[case $enable_alloca in 35774a1767b4Smrg yes) 35784a1767b4Smrg gmp_cv_option_alloca=alloca 35794a1767b4Smrg ;; 35804a1767b4Smrg no) 35814a1767b4Smrg gmp_cv_option_alloca=malloc-reentrant 35824a1767b4Smrg ;; 35834a1767b4Smrg reentrant | notreentrant) 35844a1767b4Smrg case $gmp_cv_func_alloca in 35854a1767b4Smrg yes) gmp_cv_option_alloca=alloca ;; 35864a1767b4Smrg *) gmp_cv_option_alloca=malloc-$enable_alloca ;; 35874a1767b4Smrg esac 35884a1767b4Smrg ;; 35894a1767b4Smrg *) 35904a1767b4Smrg gmp_cv_option_alloca=$enable_alloca 35914a1767b4Smrg ;; 35924a1767b4Smrgesac 35934a1767b4Smrg]) 35944a1767b4Smrg 35954a1767b4SmrgAH_VERBATIM([WANT_TMP], 35964a1767b4Smrg[/* Define one of these to 1 for the desired temporary memory allocation 35974a1767b4Smrg method, per --enable-alloca. */ 35984a1767b4Smrg#undef WANT_TMP_ALLOCA 35994a1767b4Smrg#undef WANT_TMP_REENTRANT 36004a1767b4Smrg#undef WANT_TMP_NOTREENTRANT 36014a1767b4Smrg#undef WANT_TMP_DEBUG]) 36024a1767b4Smrg 36034a1767b4Smrgcase $gmp_cv_option_alloca in 36044a1767b4Smrg alloca) 36054a1767b4Smrg if test $gmp_cv_func_alloca = no; then 36064a1767b4Smrg AC_MSG_ERROR([--enable-alloca=alloca specified, but alloca not available]) 36074a1767b4Smrg fi 36084a1767b4Smrg AC_DEFINE(WANT_TMP_ALLOCA) 36094a1767b4Smrg TAL_OBJECT=tal-reent$U.lo 36104a1767b4Smrg ;; 36114a1767b4Smrg malloc-reentrant) 36124a1767b4Smrg AC_DEFINE(WANT_TMP_REENTRANT) 36134a1767b4Smrg TAL_OBJECT=tal-reent$U.lo 36144a1767b4Smrg ;; 36154a1767b4Smrg malloc-notreentrant) 36164a1767b4Smrg AC_DEFINE(WANT_TMP_NOTREENTRANT) 36174a1767b4Smrg TAL_OBJECT=tal-notreent$U.lo 36184a1767b4Smrg ;; 36194a1767b4Smrg debug) 36204a1767b4Smrg AC_DEFINE(WANT_TMP_DEBUG) 36214a1767b4Smrg TAL_OBJECT=tal-debug$U.lo 36224a1767b4Smrg ;; 36234a1767b4Smrg *) 36244a1767b4Smrg # checks at the start of configure.in should protect us 36254a1767b4Smrg AC_MSG_ERROR([unrecognised --enable-alloca=$gmp_cv_option_alloca]) 36264a1767b4Smrg ;; 36274a1767b4Smrgesac 36284a1767b4SmrgAC_SUBST(TAL_OBJECT) 36294a1767b4Smrg]) 36304a1767b4Smrg 36314a1767b4Smrg 36324a1767b4Smrgdnl GMP_FUNC_SSCANF_WRITABLE_INPUT 36334a1767b4Smrgdnl ------------------------------ 36344a1767b4Smrgdnl Determine whether sscanf requires a writable input string. 36354a1767b4Smrgdnl 36364a1767b4Smrgdnl It might be nicer to run a program to determine this when doing a 36374a1767b4Smrgdnl native build, but the systems afflicted are few and far between these 36384a1767b4Smrgdnl days, so it seems good enough just to list them. 36394a1767b4Smrg 36404a1767b4SmrgAC_DEFUN([GMP_FUNC_SSCANF_WRITABLE_INPUT], 36414a1767b4Smrg[AC_CACHE_CHECK([whether sscanf needs writable input], 36424a1767b4Smrg gmp_cv_func_sscanf_writable_input, 36434a1767b4Smrg[case $host in 36444a1767b4Smrg *-*-hpux9 | *-*-hpux9.*) 36454a1767b4Smrg gmp_cv_func_sscanf_writable_input=yes ;; 36464a1767b4Smrg *) gmp_cv_func_sscanf_writable_input=no ;; 36474a1767b4Smrgesac 36484a1767b4Smrg]) 36494a1767b4Smrgcase $gmp_cv_func_sscanf_writable_input in 36504a1767b4Smrg yes) AC_DEFINE(SSCANF_WRITABLE_INPUT, 1, 36514a1767b4Smrg [Define to 1 if sscanf requires writable inputs]) ;; 36524a1767b4Smrg no) ;; 36534a1767b4Smrg *) AC_MSG_ERROR([unrecognised \$gmp_cv_func_sscanf_writable_input]) ;; 36544a1767b4Smrgesac 36554a1767b4Smrg]) 36564a1767b4Smrg 36574a1767b4Smrg 36584a1767b4Smrgdnl GMP_FUNC_VSNPRINTF 36594a1767b4Smrgdnl ------------------ 36604a1767b4Smrgdnl Check whether vsnprintf exists, and works properly. 36614a1767b4Smrgdnl 36624a1767b4Smrgdnl Systems without vsnprintf include mingw32, OSF 4. 36634a1767b4Smrgdnl 36644a1767b4Smrgdnl Sparc Solaris 2.7 in 64-bit mode doesn't always truncate, making 36654a1767b4Smrgdnl vsnprintf like vsprintf, and hence completely useless. On one system a 36664a1767b4Smrgdnl literal string is enough to provoke the problem, on another a "%n" was 36674a1767b4Smrgdnl needed. There seems to be something weird going on with the optimizer 36684a1767b4Smrgdnl or something, since on the first system adding a second check with 36694a1767b4Smrgdnl "%n", or even just an initialized local variable, makes it work. In 36704a1767b4Smrgdnl any case, without bothering to get to the bottom of this, the two 36714a1767b4Smrgdnl program runs in the code below end up successfully detecting the 36724a1767b4Smrgdnl problem. 36734a1767b4Smrgdnl 36744a1767b4Smrgdnl glibc 2.0.x returns either -1 or bufsize-1 for an overflow (both seen, 36754a1767b4Smrgdnl not sure which 2.0.x does which), but still puts the correct null 36764a1767b4Smrgdnl terminated result into the buffer. 36774a1767b4Smrg 36784a1767b4SmrgAC_DEFUN([GMP_FUNC_VSNPRINTF], 367921c03f4cSmrg[AC_CHECK_FUNC(vsnprintf, 36804a1767b4Smrg [gmp_vsnprintf_exists=yes], 36814a1767b4Smrg [gmp_vsnprintf_exists=no]) 36824a1767b4Smrgif test "$gmp_vsnprintf_exists" = no; then 36834a1767b4Smrg gmp_cv_func_vsnprintf=no 36844a1767b4Smrgelse 36854a1767b4Smrg AC_CACHE_CHECK([whether vsnprintf works], 36864a1767b4Smrg gmp_cv_func_vsnprintf, 36874a1767b4Smrg [gmp_cv_func_vsnprintf=yes 3688b6659776Smrg for i in 'return check ("hello world");' 'int n; return check ("%nhello world", &n);'; do 36894a1767b4Smrg AC_TRY_RUN([ 36904a1767b4Smrg#include <string.h> /* for strcmp */ 36914a1767b4Smrg#include <stdio.h> /* for vsnprintf */ 36924a1767b4Smrg 36934a1767b4Smrg#include <stdarg.h> 36944a1767b4Smrg 36954a1767b4Smrgint 36964a1767b4Smrgcheck (const char *fmt, ...) 36974a1767b4Smrg{ 36984a1767b4Smrg static char buf[128]; 36994a1767b4Smrg va_list ap; 37004a1767b4Smrg int ret; 37014a1767b4Smrg 37024a1767b4Smrg va_start (ap, fmt); 37034a1767b4Smrg 37044a1767b4Smrg ret = vsnprintf (buf, 4, fmt, ap); 37054a1767b4Smrg 3706*274b3bceSmrg if (ret == -1 || strcmp (buf, "hel") != 0) 3707b6659776Smrg return 1; 37084a1767b4Smrg 37094a1767b4Smrg /* allowed return values */ 3710*274b3bceSmrg if (ret != 3 && ret != 11) 3711b6659776Smrg return 2; 37124a1767b4Smrg 37134a1767b4Smrg return 0; 37144a1767b4Smrg} 37154a1767b4Smrg 37164a1767b4Smrgint 37174a1767b4Smrgmain () 37184a1767b4Smrg{ 37194a1767b4Smrg$i 37204a1767b4Smrg} 37214a1767b4Smrg], 37224a1767b4Smrg [:], 37234a1767b4Smrg [gmp_cv_func_vsnprintf=no; break], 37244a1767b4Smrg [gmp_cv_func_vsnprintf=probably; break]) 37254a1767b4Smrg done 37264a1767b4Smrg ]) 37274a1767b4Smrg if test "$gmp_cv_func_vsnprintf" = probably; then 37284a1767b4Smrg AC_MSG_WARN([cannot check for properly working vsnprintf when cross compiling, will assume it's ok]) 37294a1767b4Smrg fi 37304a1767b4Smrg if test "$gmp_cv_func_vsnprintf" != no; then 37314a1767b4Smrg AC_DEFINE(HAVE_VSNPRINTF,1, 37324a1767b4Smrg [Define to 1 if you have the `vsnprintf' function and it works properly.]) 37334a1767b4Smrg fi 37344a1767b4Smrgfi 37354a1767b4Smrg]) 37364a1767b4Smrg 37374a1767b4Smrg 37384a1767b4Smrgdnl GMP_H_EXTERN_INLINE 37394a1767b4Smrgdnl ------------------- 37404a1767b4Smrgdnl If the compiler has an "inline" of some sort, check whether the 37414a1767b4Smrgdnl #ifdef's in gmp.h recognise it. 37424a1767b4Smrg 37434a1767b4SmrgAC_DEFUN([GMP_H_EXTERN_INLINE], 37444a1767b4Smrg[AC_REQUIRE([AC_C_INLINE]) 37454a1767b4Smrgcase $ac_cv_c_inline in 37464a1767b4Smrgno) ;; 37474a1767b4Smrg*) 37484a1767b4Smrg AC_TRY_COMPILE( 37494a1767b4Smrg[#define __GMP_WITHIN_CONFIGURE_INLINE 1 37504a1767b4Smrg]GMP_INCLUDE_GMP_H[ 37514a1767b4Smrg#ifndef __GMP_EXTERN_INLINE 37524a1767b4Smrgdie die die 37534a1767b4Smrg#endif 37544a1767b4Smrg],,, 37554a1767b4Smrg [case $ac_cv_c_inline in 37564a1767b4Smrg yes) tmp_inline=inline ;; 37574a1767b4Smrg *) tmp_inline=$ac_cv_c_inline ;; 37584a1767b4Smrg esac 37594a1767b4Smrg AC_MSG_WARN([gmp.h doesnt recognise compiler "$tmp_inline", inlines will be unavailable])]) 37604a1767b4Smrg ;; 37614a1767b4Smrgesac 37624a1767b4Smrg]) 37634a1767b4Smrg 37644a1767b4Smrg 37654a1767b4Smrgdnl GMP_H_HAVE_FILE 37664a1767b4Smrgdnl --------------- 37674a1767b4Smrgdnl Check whether the #ifdef's in gmp.h recognise when stdio.h has been 37684a1767b4Smrgdnl included to get FILE. 37694a1767b4Smrg 37704a1767b4SmrgAC_DEFUN([GMP_H_HAVE_FILE], 37714a1767b4Smrg[AC_TRY_COMPILE( 37724a1767b4Smrg[#include <stdio.h>] 37734a1767b4SmrgGMP_INCLUDE_GMP_H 37744a1767b4Smrg[#if ! _GMP_H_HAVE_FILE 37754a1767b4Smrgdie die die 37764a1767b4Smrg#endif 37774a1767b4Smrg],,, 37784a1767b4Smrg [AC_MSG_WARN([gmp.h doesnt recognise <stdio.h>, FILE prototypes will be unavailable])]) 37794a1767b4Smrg]) 37804a1767b4Smrg 37814a1767b4Smrg 37824a1767b4Smrgdnl GMP_PROG_CC_FOR_BUILD 37834a1767b4Smrgdnl --------------------- 37844a1767b4Smrgdnl Establish CC_FOR_BUILD, a C compiler for the build system. 37854a1767b4Smrgdnl 37864a1767b4Smrgdnl If CC_FOR_BUILD is set then it's expected to work, likewise the old 37874a1767b4Smrgdnl style HOST_CC, otherwise some likely candidates are tried, the same as 37884a1767b4Smrgdnl configfsf.guess. 37894a1767b4Smrg 37904a1767b4SmrgAC_DEFUN([GMP_PROG_CC_FOR_BUILD], 37914a1767b4Smrg[AC_REQUIRE([AC_PROG_CC]) 37924a1767b4Smrgif test -n "$CC_FOR_BUILD"; then 37934a1767b4Smrg GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,, 37944a1767b4Smrg [AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])]) 37954a1767b4Smrgelif test -n "$HOST_CC"; then 37964a1767b4Smrg GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC, 37974a1767b4Smrg [CC_FOR_BUILD=$HOST_CC], 37984a1767b4Smrg [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])]) 37994a1767b4Smrgelse 38004a1767b4Smrg for i in "$CC" "$CC $CFLAGS $CPPFLAGS" cc gcc c89 c99; do 38014a1767b4Smrg GMP_PROG_CC_FOR_BUILD_WORKS($i, 38024a1767b4Smrg [CC_FOR_BUILD=$i 38034a1767b4Smrg break]) 38044a1767b4Smrg done 38054a1767b4Smrg if test -z "$CC_FOR_BUILD"; then 38064a1767b4Smrg AC_MSG_ERROR([Cannot find a build system compiler]) 38074a1767b4Smrg fi 38084a1767b4Smrgfi 38094a1767b4Smrg 38104a1767b4SmrgAC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) 38114a1767b4SmrgAC_SUBST(CC_FOR_BUILD) 38124a1767b4Smrg]) 38134a1767b4Smrg 38144a1767b4Smrg 38154a1767b4Smrgdnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]]) 38164a1767b4Smrgdnl ------------------------------------------------------------------------- 38174a1767b4Smrgdnl See if the given cc/cflags works on the build system. 38184a1767b4Smrgdnl 38194a1767b4Smrgdnl It seems easiest to just use the default compiler output, rather than 38204a1767b4Smrgdnl figuring out the .exe or whatever at this stage. 38214a1767b4Smrg 38224a1767b4SmrgAC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS], 38234a1767b4Smrg[AC_MSG_CHECKING([build system compiler $1]) 38244a1767b4Smrg# remove anything that might look like compiler output to our "||" expression 38254a1767b4Smrgrm -f conftest* a.out b.out a.exe a_out.exe 38264a1767b4Smrgcat >conftest.c <<EOF 38274a1767b4Smrgint 38284a1767b4Smrgmain () 38294a1767b4Smrg{ 383021c03f4cSmrg return 0; 38314a1767b4Smrg} 38324a1767b4SmrgEOF 38334a1767b4Smrggmp_compile="$1 conftest.c" 38344a1767b4Smrgcc_for_build_works=no 38354a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 38364a1767b4Smrg if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then 38374a1767b4Smrg cc_for_build_works=yes 38384a1767b4Smrg fi 38394a1767b4Smrgfi 38404a1767b4Smrgrm -f conftest* a.out b.out a.exe a_out.exe 38414a1767b4SmrgAC_MSG_RESULT($cc_for_build_works) 38424a1767b4Smrgif test "$cc_for_build_works" = yes; then 38434a1767b4Smrg ifelse([$2],,:,[$2]) 38444a1767b4Smrgelse 38454a1767b4Smrg ifelse([$3],,:,[$3]) 38464a1767b4Smrgfi 38474a1767b4Smrg]) 38484a1767b4Smrg 38494a1767b4Smrg 38504a1767b4Smrgdnl GMP_PROG_CPP_FOR_BUILD 38514a1767b4Smrgdnl --------------------- 38524a1767b4Smrgdnl Establish CPP_FOR_BUILD, the build system C preprocessor. 38534a1767b4Smrgdnl The choices tried here are the same as AC_PROG_CPP, but with 38544a1767b4Smrgdnl CC_FOR_BUILD. 38554a1767b4Smrg 38564a1767b4SmrgAC_DEFUN([GMP_PROG_CPP_FOR_BUILD], 38574a1767b4Smrg[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) 38584a1767b4SmrgAC_MSG_CHECKING([for build system preprocessor]) 38594a1767b4Smrgif test -z "$CPP_FOR_BUILD"; then 38604a1767b4Smrg AC_CACHE_VAL(gmp_cv_prog_cpp_for_build, 38614a1767b4Smrg [cat >conftest.c <<EOF 38624a1767b4Smrg#define FOO BAR 38634a1767b4SmrgEOF 38644a1767b4Smrg for i in "$CC_FOR_BUILD -E" "$CC_FOR_BUILD -E -traditional-cpp" "/lib/cpp"; do 38654a1767b4Smrg gmp_compile="$i conftest.c" 38664a1767b4Smrg if AC_TRY_EVAL(gmp_compile) >&AC_FD_CC 2>&1; then 38674a1767b4Smrg gmp_cv_prog_cpp_for_build=$i 38684a1767b4Smrg break 38694a1767b4Smrg fi 38704a1767b4Smrg done 38714a1767b4Smrg rm -f conftest* a.out b.out a.exe a_out.exe 38724a1767b4Smrg if test -z "$gmp_cv_prog_cpp_for_build"; then 38734a1767b4Smrg AC_MSG_ERROR([Cannot find build system C preprocessor.]) 38744a1767b4Smrg fi 38754a1767b4Smrg ]) 38764a1767b4Smrg CPP_FOR_BUILD=$gmp_cv_prog_cpp_for_build 38774a1767b4Smrgfi 38784a1767b4SmrgAC_MSG_RESULT([$CPP_FOR_BUILD]) 38794a1767b4Smrg 38804a1767b4SmrgAC_ARG_VAR(CPP_FOR_BUILD,[build system C preprocessor]) 38814a1767b4SmrgAC_SUBST(CPP_FOR_BUILD) 38824a1767b4Smrg]) 38834a1767b4Smrg 38844a1767b4Smrg 38854a1767b4Smrgdnl GMP_PROG_EXEEXT_FOR_BUILD 38864a1767b4Smrgdnl ------------------------- 38874a1767b4Smrgdnl Determine EXEEXT_FOR_BUILD, the build system executable suffix. 38884a1767b4Smrgdnl 38894a1767b4Smrgdnl The idea is to find what "-o conftest$foo" will make it possible to run 38904a1767b4Smrgdnl the program with ./conftest. On Unix-like systems this is of course 38914a1767b4Smrgdnl nothing, for DOS it's ".exe", or for a strange RISC OS foreign file 38924a1767b4Smrgdnl system cross compile it can be ",ff8" apparently. Not sure if the 38934a1767b4Smrgdnl latter actually applies to a build-system executable, maybe it doesn't, 38944a1767b4Smrgdnl but it won't hurt to try. 38954a1767b4Smrg 38964a1767b4SmrgAC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD], 38974a1767b4Smrg[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) 38984a1767b4SmrgAC_CACHE_CHECK([for build system executable suffix], 38994a1767b4Smrg gmp_cv_prog_exeext_for_build, 39004a1767b4Smrg[cat >conftest.c <<EOF 39014a1767b4Smrgint 39024a1767b4Smrgmain () 39034a1767b4Smrg{ 390421c03f4cSmrg return 0; 39054a1767b4Smrg} 39064a1767b4SmrgEOF 39074a1767b4Smrgfor i in .exe ,ff8 ""; do 39084a1767b4Smrg gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i" 39094a1767b4Smrg if AC_TRY_EVAL(gmp_compile); then 39104a1767b4Smrg if (./conftest) 2>&AC_FD_CC; then 39114a1767b4Smrg gmp_cv_prog_exeext_for_build=$i 39124a1767b4Smrg break 39134a1767b4Smrg fi 39144a1767b4Smrg fi 39154a1767b4Smrgdone 39164a1767b4Smrgrm -f conftest* 39174a1767b4Smrgif test "${gmp_cv_prog_exeext_for_build+set}" != set; then 39184a1767b4Smrg AC_MSG_ERROR([Cannot determine executable suffix]) 39194a1767b4Smrgfi 39204a1767b4Smrg]) 39214a1767b4SmrgAC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build) 39224a1767b4Smrg]) 39234a1767b4Smrg 39244a1767b4Smrg 39254a1767b4Smrgdnl GMP_C_FOR_BUILD_ANSI 39264a1767b4Smrgdnl -------------------- 39274a1767b4Smrgdnl Determine whether CC_FOR_BUILD is ANSI, and establish U_FOR_BUILD 39284a1767b4Smrgdnl accordingly. 39294a1767b4Smrgdnl 39304a1767b4Smrgdnl FIXME: Use AC_PROG_CC sets ac_cv_prog_cc_c89 which could be used instead 39314a1767b4Smrg 39324a1767b4SmrgAC_DEFUN([GMP_C_FOR_BUILD_ANSI], 39334a1767b4Smrg[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) 39344a1767b4SmrgAC_CACHE_CHECK([whether build system compiler is ANSI], 39354a1767b4Smrg gmp_cv_c_for_build_ansi, 39364a1767b4Smrg[cat >conftest.c <<EOF 39374a1767b4Smrgint 39384a1767b4Smrgmain (int argc, char **argv) 39394a1767b4Smrg{ 394021c03f4cSmrg return 0; 39414a1767b4Smrg} 39424a1767b4SmrgEOF 39434a1767b4Smrggmp_compile="$CC_FOR_BUILD conftest.c" 39444a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 39454a1767b4Smrg gmp_cv_c_for_build_ansi=yes 39464a1767b4Smrgelse 39474a1767b4Smrg gmp_cv_c_for_build_ansi=no 39484a1767b4Smrgfi 39494a1767b4Smrgrm -f conftest* a.out b.out a.exe a_out.exe 39504a1767b4Smrg]) 39514a1767b4Smrgif test "$gmp_cv_c_for_build_ansi" = yes; then 39524a1767b4Smrg U_FOR_BUILD= 39534a1767b4Smrgelse 39544a1767b4Smrg AC_SUBST(U_FOR_BUILD,_) 39554a1767b4Smrgfi 39564a1767b4Smrg]) 39574a1767b4Smrg 39584a1767b4Smrg 39594a1767b4Smrgdnl GMP_CHECK_LIBM_FOR_BUILD 39604a1767b4Smrgdnl ------------------------ 39614a1767b4Smrgdnl Establish LIBM_FOR_BUILD as -lm, if that seems to work. 39624a1767b4Smrgdnl 39634a1767b4Smrgdnl Libtool AC_CHECK_LIBM also uses -lmw on *-ncr-sysv4.3*, if it works. 39644a1767b4Smrgdnl Don't know what that does, lets assume it's not needed just for log(). 39654a1767b4Smrg 39664a1767b4SmrgAC_DEFUN([GMP_CHECK_LIBM_FOR_BUILD], 39674a1767b4Smrg[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD]) 39684a1767b4SmrgAC_CACHE_CHECK([for build system compiler math library], 39694a1767b4Smrg gmp_cv_check_libm_for_build, 39704a1767b4Smrg[cat >conftest.c <<EOF 397121c03f4cSmrg#include <math.h> 39724a1767b4Smrgint 39734a1767b4Smrgmain () 39744a1767b4Smrg{ 397521c03f4cSmrg return 0; 39764a1767b4Smrg} 39774a1767b4Smrgdouble d; 39784a1767b4Smrgdouble 39794a1767b4Smrgfoo () 39804a1767b4Smrg{ 39814a1767b4Smrg return log (d); 39824a1767b4Smrg} 39834a1767b4SmrgEOF 39844a1767b4Smrggmp_compile="$CC_FOR_BUILD conftest.c -lm" 39854a1767b4Smrgif AC_TRY_EVAL(gmp_compile); then 39864a1767b4Smrg gmp_cv_check_libm_for_build=-lm 39874a1767b4Smrgelse 39884a1767b4Smrg gmp_cv_check_libm_for_build=no 39894a1767b4Smrgfi 39904a1767b4Smrgrm -f conftest* a.out b.out a.exe a_out.exe 39914a1767b4Smrg]) 39924a1767b4Smrgcase $gmp_cv_check_libm_for_build in 39934a1767b4Smrg yes) AC_SUBST(LIBM_FOR_BUILD,-lm) ;; 39944a1767b4Smrg no) LIBM_FOR_BUILD= ;; 39954a1767b4Smrg *) LIBM_FOR_BUILD=$gmp_cv_check_libm_for_build ;; 39964a1767b4Smrgesac 39974a1767b4Smrg]) 3998