2 dnl sets up defines and automake conditionals for host architecture
6 AC_DEFUN([AG_GST_ARCH],
9 case "x${target_cpu}" in
10 xi?86 | xk? | xi?86_64)
13 AC_CHECK_DECL([__i386], [I386_ABI="yes"], [I386_ABI="no"])
14 AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
16 if test "x$I386_ABI" = "xyes" ; then
18 AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
20 if test "x$AMD64_ABI" = "xyes" ; then
22 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64])
27 AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
29 dnl FIXME could use some better detection
31 case "x${target_cpu}" in
34 AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;;
41 AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the target CPU is a PowerPC]) ;;
44 AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the target CPU is a 64 bit PowerPC]) ;;
47 AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the target CPU is an Alpha]) ;;
50 AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the target CPU is an ARM]) ;;
53 AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the target CPU is a SPARC]) ;;
56 AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the target CPU is a MIPS]) ;;
59 AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the target CPU is a HPPA]) ;;
62 AC_DEFINE(HAVE_CPU_S390, 1, [Define if the target CPU is a S390]) ;;
65 AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the target CPU is a IA64]) ;;
68 AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the target CPU is a M68K]) ;;
71 AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64]) ;;
74 AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the target CPU is a CRIS]) ;;
77 AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the target CPU is a CRISv32]) ;;
80 dnl Determine endianness
83 AM_CONDITIONAL(HAVE_CPU_I386, test "x$HAVE_CPU_I386" = "xyes")
84 AM_CONDITIONAL(HAVE_CPU_PPC, test "x$HAVE_CPU_PPC" = "xyes")
85 AM_CONDITIONAL(HAVE_CPU_PPC64, test "x$HAVE_CPU_PPC64" = "xyes")
86 AM_CONDITIONAL(HAVE_CPU_ALPHA, test "x$HAVE_CPU_ALPHA" = "xyes")
87 AM_CONDITIONAL(HAVE_CPU_ARM, test "x$HAVE_CPU_ARM" = "xyes")
88 AM_CONDITIONAL(HAVE_CPU_SPARC, test "x$HAVE_CPU_SPARC" = "xyes")
89 AM_CONDITIONAL(HAVE_CPU_HPPA, test "x$HAVE_CPU_HPPA" = "xyes")
90 AM_CONDITIONAL(HAVE_CPU_MIPS, test "x$HAVE_CPU_MIPS" = "xyes")
91 AM_CONDITIONAL(HAVE_CPU_S390, test "x$HAVE_CPU_S390" = "xyes")
92 AM_CONDITIONAL(HAVE_CPU_IA64, test "x$HAVE_CPU_IA64" = "xyes")
93 AM_CONDITIONAL(HAVE_CPU_M68K, test "x$HAVE_CPU_M68K" = "xyes")
94 AM_CONDITIONAL(HAVE_CPU_X86_64, test "x$HAVE_CPU_X86_64" = "xyes")
95 AM_CONDITIONAL(HAVE_CPU_CRIS, test "x$HAVE_CPU_CRIS" = "xyes")
96 AM_CONDITIONAL(HAVE_CPU_CRISV32, test "x$HAVE_CPU_CRISV32" = "xyes")
98 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
99 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu", [the target CPU])
102 dnl check if unaligned memory access works correctly
103 AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [
104 AC_MSG_CHECKING([if unaligned memory access works correctly])
105 if test x"$as_cv_unaligned_access" = x ; then
107 alpha*|arm*|hp*|mips*|sh*|sparc*|ia64*)
108 _AS_ECHO_N([(blacklisted) ])
109 as_cv_unaligned_access=no
111 i?86*|x86_64*|amd64*|powerpc*|m68k*|cris*)
112 _AS_ECHO_N([(whitelisted) ])
113 as_cv_unaligned_access=yes
117 _AS_ECHO_N([(cached) ])
119 if test x"$as_cv_unaligned_access" = x ; then
121 int main(int argc, char **argv)
123 char array[] = "ABCDEFGH";
124 unsigned int iarray[2];
125 memcpy(iarray,array,8);
126 #define GET(x) (*(unsigned int *)((char *)iarray + (x)))
127 if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1;
128 if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1;
129 if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1;
130 if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1;
133 ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no")
135 AC_MSG_RESULT($as_cv_unaligned_access)
136 if test "$as_cv_unaligned_access" = "yes"; then
137 AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1,
138 [defined if unaligned memory access works correctly])