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)
14 AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86])
16 dnl FIXME could use some better detection
18 case "x${host_cpu}" in
21 AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;;
25 AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the host CPU is a PowerPC]) ;;
28 AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the host CPU is a 64 bit PowerPC]) ;;
31 AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the host CPU is an Alpha]) ;;
34 AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the host CPU is an ARM]) ;;
37 AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the host CPU is a SPARC]) ;;
40 AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the host CPU is a MIPS]) ;;
43 AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the host CPU is a HPPA]) ;;
46 AC_DEFINE(HAVE_CPU_S390, 1, [Define if the host CPU is a S390]) ;;
49 AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the host CPU is a IA64]) ;;
52 AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the host CPU is a M68K]) ;;
55 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64]) ;;
58 AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the host CPU is a CRIS]) ;;
61 AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the host CPU is a CRISv32]) ;;
64 dnl Determine endianness
67 AM_CONDITIONAL(HAVE_CPU_I386, test "x$HAVE_CPU_I386" = "xyes")
68 AM_CONDITIONAL(HAVE_CPU_PPC, test "x$HAVE_CPU_PPC" = "xyes")
69 AM_CONDITIONAL(HAVE_CPU_PPC64, test "x$HAVE_CPU_PPC64" = "xyes")
70 AM_CONDITIONAL(HAVE_CPU_ALPHA, test "x$HAVE_CPU_ALPHA" = "xyes")
71 AM_CONDITIONAL(HAVE_CPU_ARM, test "x$HAVE_CPU_ARM" = "xyes")
72 AM_CONDITIONAL(HAVE_CPU_SPARC, test "x$HAVE_CPU_SPARC" = "xyes")
73 AM_CONDITIONAL(HAVE_CPU_HPPA, test "x$HAVE_CPU_HPPA" = "xyes")
74 AM_CONDITIONAL(HAVE_CPU_MIPS, test "x$HAVE_CPU_MIPS" = "xyes")
75 AM_CONDITIONAL(HAVE_CPU_S390, test "x$HAVE_CPU_S390" = "xyes")
76 AM_CONDITIONAL(HAVE_CPU_IA64, test "x$HAVE_CPU_IA64" = "xyes")
77 AM_CONDITIONAL(HAVE_CPU_M68K, test "x$HAVE_CPU_M68K" = "xyes")
78 AM_CONDITIONAL(HAVE_CPU_X86_64, test "x$HAVE_CPU_X86_64" = "xyes")
79 AM_CONDITIONAL(HAVE_CPU_CRIS, test "x$HAVE_CPU_CRIS" = "xyes")
80 AM_CONDITIONAL(HAVE_CPU_CRISV32, test "x$HAVE_CPU_CRISV32" = "xyes")
82 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
85 dnl check if unaligned memory access works correctly
86 AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [
87 AC_MSG_CHECKING([if unaligned memory access works correctly])
88 if test x"$as_cv_unaligned_access" = x ; then
90 alpha*|arm*|hp*|mips*|sh*|sparc*|ia64*)
91 _AS_ECHO_N([(blacklisted) ])
92 as_cv_unaligned_access=no
94 i?86*|powerpc*|m68k*|cris*)
95 _AS_ECHO_N([(whitelisted) ])
96 as_cv_unaligned_access=yes
100 _AS_ECHO_N([(cached) ])
102 if test x"$as_cv_unaligned_access" = x ; then
104 int main(int argc, char **argv)
106 char array[] = "ABCDEFGH";
107 unsigned int iarray[2];
108 memcpy(iarray,array,8);
109 #define GET(x) (*(unsigned int *)((char *)iarray + (x)))
110 if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1;
111 if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1;
112 if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1;
113 if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1;
116 ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no")
118 AC_MSG_RESULT($as_cv_unaligned_access)
119 if test "$as_cv_unaligned_access" = "yes"; then
120 AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1,
121 [defined if unaligned memory access works correctly])