1dnl AG_GST_ARCH 2dnl sets up defines and automake conditionals for host architecture 3dnl checks endianness 4dnl defines HOST_CPU 5 6AC_DEFUN([AG_GST_ARCH], 7[ 8 dnl Determine CPU 9 case "x${target_cpu}" in 10 xi?86 | xk? | xi?86_64) 11 case $target_os in 12 solaris*) 13 AC_CHECK_DECL([__i386], [I386_ABI="yes"], [I386_ABI="no"]) 14 AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"]) 15 16 if test "x$I386_ABI" = "xyes" ; then 17 HAVE_CPU_I386=yes 18 AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86]) 19 fi 20 if test "x$AMD64_ABI" = "xyes" ; then 21 HAVE_CPU_X86_64=yes 22 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64]) 23 fi 24 ;; 25 *) 26 HAVE_CPU_I386=yes 27 AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86]) 28 29 dnl FIXME could use some better detection 30 dnl (ie CPUID) 31 case "x${target_cpu}" in 32 xi386 | xi486) ;; 33 *) 34 AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;; 35 esac 36 ;; 37 esac 38 ;; 39 xpowerpc) 40 HAVE_CPU_PPC=yes 41 AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the target CPU is a PowerPC]) ;; 42 xpowerpc64) 43 HAVE_CPU_PPC64=yes 44 AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the target CPU is a 64 bit PowerPC]) ;; 45 xalpha*) 46 HAVE_CPU_ALPHA=yes 47 AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the target CPU is an Alpha]) ;; 48 xarc*) 49 HAVE_CPU_ARC=yes 50 AC_DEFINE(HAVE_CPU_ARC, 1, [Define if the target CPU is an ARC]) ;; 51 xarm*) 52 HAVE_CPU_ARM=yes 53 AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the target CPU is an ARM]) ;; 54 xaarch64*) 55 HAVE_CPU_AARCH64=yes 56 AC_DEFINE(HAVE_CPU_AARCH64, 1, [Define if the target CPU is AARCH64]) ;; 57 xsparc*) 58 HAVE_CPU_SPARC=yes 59 AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the target CPU is a SPARC]) ;; 60 xmips*) 61 HAVE_CPU_MIPS=yes 62 AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the target CPU is a MIPS]) ;; 63 xhppa*) 64 HAVE_CPU_HPPA=yes 65 AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the target CPU is a HPPA]) ;; 66 xs390*) 67 HAVE_CPU_S390=yes 68 AC_DEFINE(HAVE_CPU_S390, 1, [Define if the target CPU is a S390]) ;; 69 xia64*) 70 HAVE_CPU_IA64=yes 71 AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the target CPU is a IA64]) ;; 72 xm68k*) 73 HAVE_CPU_M68K=yes 74 AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the target CPU is a M68K]) ;; 75 xx86_64) 76 HAVE_CPU_X86_64=yes 77 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64]) ;; 78 xcris) 79 HAVE_CPU_CRIS=yes 80 AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the target CPU is a CRIS]) ;; 81 xcrisv32) 82 HAVE_CPU_CRISV32=yes 83 AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the target CPU is a CRISv32]) ;; 84 esac 85 86 dnl Determine endianness 87 AC_C_BIGENDIAN 88 89 AM_CONDITIONAL(HAVE_CPU_I386, test "x$HAVE_CPU_I386" = "xyes") 90 AM_CONDITIONAL(HAVE_CPU_PPC, test "x$HAVE_CPU_PPC" = "xyes") 91 AM_CONDITIONAL(HAVE_CPU_PPC64, test "x$HAVE_CPU_PPC64" = "xyes") 92 AM_CONDITIONAL(HAVE_CPU_ALPHA, test "x$HAVE_CPU_ALPHA" = "xyes") 93 AM_CONDITIONAL(HAVE_CPU_ARC, test "x$HAVE_CPU_ARC" = "xyes") 94 AM_CONDITIONAL(HAVE_CPU_ARM, test "x$HAVE_CPU_ARM" = "xyes") 95 AM_CONDITIONAL(HAVE_CPU_SPARC, test "x$HAVE_CPU_SPARC" = "xyes") 96 AM_CONDITIONAL(HAVE_CPU_HPPA, test "x$HAVE_CPU_HPPA" = "xyes") 97 AM_CONDITIONAL(HAVE_CPU_MIPS, test "x$HAVE_CPU_MIPS" = "xyes") 98 AM_CONDITIONAL(HAVE_CPU_S390, test "x$HAVE_CPU_S390" = "xyes") 99 AM_CONDITIONAL(HAVE_CPU_IA64, test "x$HAVE_CPU_IA64" = "xyes") 100 AM_CONDITIONAL(HAVE_CPU_M68K, test "x$HAVE_CPU_M68K" = "xyes") 101 AM_CONDITIONAL(HAVE_CPU_X86_64, test "x$HAVE_CPU_X86_64" = "xyes") 102 AM_CONDITIONAL(HAVE_CPU_CRIS, test "x$HAVE_CPU_CRIS" = "xyes") 103 AM_CONDITIONAL(HAVE_CPU_CRISV32, test "x$HAVE_CPU_CRISV32" = "xyes") 104 105 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU]) 106 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu", [the target CPU]) 107]) 108 109dnl check if unaligned memory access works correctly 110AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [ 111 AC_MSG_CHECKING([if unaligned memory access works correctly]) 112 if test x"$as_cv_unaligned_access" = x ; then 113 case $host in 114 alpha*|arc*|arm*|aarch64*|hp*|mips*|sh*|sparc*|ia64*) 115 _AS_ECHO_N([(blacklisted) ]) 116 as_cv_unaligned_access=no 117 ;; 118 i?86*|x86_64*|amd64*|powerpc*|m68k*|cris*) 119 _AS_ECHO_N([(whitelisted) ]) 120 as_cv_unaligned_access=yes 121 ;; 122 esac 123 else 124 _AS_ECHO_N([(cached) ]) 125 fi 126 if test x"$as_cv_unaligned_access" = x ; then 127 AC_TRY_RUN([ 128int main(int argc, char **argv) 129{ 130 char array[] = "ABCDEFGH"; 131 unsigned int iarray[2]; 132 memcpy(iarray,array,8); 133#define GET(x) (*(unsigned int *)((char *)iarray + (x))) 134 if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1; 135 if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1; 136 if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1; 137 if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1; 138 return 0; 139} 140 ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no") 141 fi 142 AC_MSG_RESULT($as_cv_unaligned_access) 143 if test "$as_cv_unaligned_access" = "yes"; then 144 AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1, 145 [defined if unaligned memory access works correctly]) 146 fi 147]) 148