2 dnl sets up defines and automake conditionals for host architecture
6 AC_DEFUN([AG_GST_ARCH],
8 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use host_ variables
11 case "x${host_cpu}" in
12 xi?86 | xk? | xi?86_64)
15 AC_CHECK_DECL([__i386], [I386_ABI="yes"], [I386_ABI="no"])
16 AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
18 if test "x$I386_ABI" = "xyes" ; then
20 AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86])
22 if test "x$AMD64_ABI" = "xyes" ; then
24 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64])
29 AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86])
31 dnl FIXME could use some better detection
33 case "x${host_cpu}" in
36 AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;;
43 AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the host CPU is a PowerPC]) ;;
46 AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the host CPU is a 64 bit PowerPC]) ;;
49 AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the host CPU is an Alpha]) ;;
52 AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the host CPU is an ARM]) ;;
55 AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the host CPU is a SPARC]) ;;
58 AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the host CPU is a MIPS]) ;;
61 AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the host CPU is a HPPA]) ;;
64 AC_DEFINE(HAVE_CPU_S390, 1, [Define if the host CPU is a S390]) ;;
67 AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the host CPU is a IA64]) ;;
70 AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the host CPU is a M68K]) ;;
73 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64]) ;;
76 AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the host CPU is a CRIS]) ;;
79 AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the host CPU is a CRISv32]) ;;
82 dnl Determine endianness
85 AM_CONDITIONAL(HAVE_CPU_I386, test "x$HAVE_CPU_I386" = "xyes")
86 AM_CONDITIONAL(HAVE_CPU_PPC, test "x$HAVE_CPU_PPC" = "xyes")
87 AM_CONDITIONAL(HAVE_CPU_PPC64, test "x$HAVE_CPU_PPC64" = "xyes")
88 AM_CONDITIONAL(HAVE_CPU_ALPHA, test "x$HAVE_CPU_ALPHA" = "xyes")
89 AM_CONDITIONAL(HAVE_CPU_ARM, test "x$HAVE_CPU_ARM" = "xyes")
90 AM_CONDITIONAL(HAVE_CPU_SPARC, test "x$HAVE_CPU_SPARC" = "xyes")
91 AM_CONDITIONAL(HAVE_CPU_HPPA, test "x$HAVE_CPU_HPPA" = "xyes")
92 AM_CONDITIONAL(HAVE_CPU_MIPS, test "x$HAVE_CPU_MIPS" = "xyes")
93 AM_CONDITIONAL(HAVE_CPU_S390, test "x$HAVE_CPU_S390" = "xyes")
94 AM_CONDITIONAL(HAVE_CPU_IA64, test "x$HAVE_CPU_IA64" = "xyes")
95 AM_CONDITIONAL(HAVE_CPU_M68K, test "x$HAVE_CPU_M68K" = "xyes")
96 AM_CONDITIONAL(HAVE_CPU_X86_64, test "x$HAVE_CPU_X86_64" = "xyes")
97 AM_CONDITIONAL(HAVE_CPU_CRIS, test "x$HAVE_CPU_CRIS" = "xyes")
98 AM_CONDITIONAL(HAVE_CPU_CRISV32, test "x$HAVE_CPU_CRISV32" = "xyes")
100 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
103 dnl check if unaligned memory access works correctly
104 AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [
105 AC_MSG_CHECKING([if unaligned memory access works correctly])
106 if test x"$as_cv_unaligned_access" = x ; then
108 alpha*|arm*|hp*|mips*|sh*|sparc*|ia64*)
109 _AS_ECHO_N([(blacklisted) ])
110 as_cv_unaligned_access=no
112 i?86*|x86_64*|amd64*|powerpc*|m68k*|cris*)
113 _AS_ECHO_N([(whitelisted) ])
114 as_cv_unaligned_access=yes
118 _AS_ECHO_N([(cached) ])
120 if test x"$as_cv_unaligned_access" = x ; then
122 int main(int argc, char **argv)
124 char array[] = "ABCDEFGH";
125 unsigned int iarray[2];
126 memcpy(iarray,array,8);
127 #define GET(x) (*(unsigned int *)((char *)iarray + (x)))
128 if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1;
129 if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1;
130 if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1;
131 if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1;
134 ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no")
136 AC_MSG_RESULT($as_cv_unaligned_access)
137 if test "$as_cv_unaligned_access" = "yes"; then
138 AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1,
139 [defined if unaligned memory access works correctly])