Blame common/m4/gst-arch.m4

Packit Service 4387a0
dnl AG_GST_ARCH
Packit Service 4387a0
dnl sets up defines and automake conditionals for host architecture
Packit Service 4387a0
dnl checks endianness
Packit Service 4387a0
dnl defines HOST_CPU
Packit Service 4387a0
Packit Service 4387a0
AC_DEFUN([AG_GST_ARCH],
Packit Service 4387a0
[
Packit Service 4387a0
  dnl Determine CPU
Packit Service 4387a0
  case "x${target_cpu}" in
Packit Service 4387a0
    xi?86 | xk? | xi?86_64)
Packit Service 4387a0
      case $target_os in
Packit Service 4387a0
         solaris*)
Packit Service 4387a0
            AC_CHECK_DECL([__i386],	[I386_ABI="yes"], [I386_ABI="no"])
Packit Service 4387a0
            AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
Packit Service 4387a0
Packit Service 4387a0
            if test "x$I386_ABI" = "xyes" ; then
Packit Service 4387a0
               HAVE_CPU_I386=yes
Packit Service 4387a0
               AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
Packit Service 4387a0
            fi
Packit Service 4387a0
            if test "x$AMD64_ABI" = "xyes" ; then
Packit Service 4387a0
                HAVE_CPU_X86_64=yes
Packit Service 4387a0
                AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64])
Packit Service 4387a0
            fi
Packit Service 4387a0
            ;;
Packit Service 4387a0
         *)
Packit Service 4387a0
            HAVE_CPU_I386=yes
Packit Service 4387a0
            AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
Packit Service 4387a0
Packit Service 4387a0
            dnl FIXME could use some better detection
Packit Service 4387a0
            dnl (ie CPUID)
Packit Service 4387a0
            case "x${target_cpu}" in
Packit Service 4387a0
              xi386 | xi486) ;;
Packit Service 4387a0
            *)
Packit Service 4387a0
              AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;;
Packit Service 4387a0
            esac
Packit Service 4387a0
            ;;
Packit Service 4387a0
      esac
Packit Service 4387a0
      ;;
Packit Service 4387a0
    xpowerpc)
Packit Service 4387a0
      HAVE_CPU_PPC=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the target CPU is a PowerPC]) ;;
Packit Service 4387a0
    xpowerpc64)
Packit Service 4387a0
      HAVE_CPU_PPC64=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the target CPU is a 64 bit PowerPC]) ;;
Packit Service 4387a0
    xalpha*)
Packit Service 4387a0
      HAVE_CPU_ALPHA=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the target CPU is an Alpha]) ;;
Packit Service 4387a0
    xarc*)
Packit Service 4387a0
      HAVE_CPU_ARC=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_ARC, 1, [Define if the target CPU is an ARC]) ;;
Packit Service 4387a0
    xarm*)
Packit Service 4387a0
      HAVE_CPU_ARM=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the target CPU is an ARM]) ;;
Packit Service 4387a0
    xaarch64*)
Packit Service 4387a0
      HAVE_CPU_AARCH64=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_AARCH64, 1, [Define if the target CPU is AARCH64]) ;;
Packit Service 4387a0
    xsparc*)
Packit Service 4387a0
      HAVE_CPU_SPARC=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the target CPU is a SPARC]) ;;
Packit Service 4387a0
    xmips*)
Packit Service 4387a0
      HAVE_CPU_MIPS=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the target CPU is a MIPS]) ;;
Packit Service 4387a0
    xhppa*)
Packit Service 4387a0
      HAVE_CPU_HPPA=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the target CPU is a HPPA]) ;;
Packit Service 4387a0
    xs390*)
Packit Service 4387a0
      HAVE_CPU_S390=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_S390, 1, [Define if the target CPU is a S390]) ;;
Packit Service 4387a0
    xia64*)
Packit Service 4387a0
      HAVE_CPU_IA64=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the target CPU is a IA64]) ;;
Packit Service 4387a0
    xm68k*)
Packit Service 4387a0
      HAVE_CPU_M68K=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the target CPU is a M68K]) ;;
Packit Service 4387a0
    xx86_64)
Packit Service 4387a0
      HAVE_CPU_X86_64=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64]) ;;
Packit Service 4387a0
    xcris)
Packit Service 4387a0
      HAVE_CPU_CRIS=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the target CPU is a CRIS]) ;;
Packit Service 4387a0
    xcrisv32)
Packit Service 4387a0
      HAVE_CPU_CRISV32=yes
Packit Service 4387a0
      AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the target CPU is a CRISv32]) ;;
Packit Service 4387a0
  esac
Packit Service 4387a0
Packit Service 4387a0
  dnl Determine endianness
Packit Service 4387a0
  AC_C_BIGENDIAN
Packit Service 4387a0
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_I386,       test "x$HAVE_CPU_I386" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_PPC,        test "x$HAVE_CPU_PPC" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_PPC64,      test "x$HAVE_CPU_PPC64" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_ALPHA,      test "x$HAVE_CPU_ALPHA" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_ARC,        test "x$HAVE_CPU_ARC" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_ARM,        test "x$HAVE_CPU_ARM" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_SPARC,      test "x$HAVE_CPU_SPARC" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_HPPA,       test "x$HAVE_CPU_HPPA" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_MIPS,       test "x$HAVE_CPU_MIPS" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_S390,       test "x$HAVE_CPU_S390" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_IA64,       test "x$HAVE_CPU_IA64" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_M68K,       test "x$HAVE_CPU_M68K" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_X86_64,     test "x$HAVE_CPU_X86_64" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_CRIS,       test "x$HAVE_CPU_CRIS" = "xyes")
Packit Service 4387a0
  AM_CONDITIONAL(HAVE_CPU_CRISV32,    test "x$HAVE_CPU_CRISV32" = "xyes")
Packit Service 4387a0
Packit Service 4387a0
  AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
Packit Service 4387a0
  AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu", [the target CPU])
Packit Service 4387a0
])
Packit Service 4387a0
Packit Service 4387a0
dnl check if unaligned memory access works correctly
Packit Service 4387a0
AC_DEFUN([AG_GST_UNALIGNED_ACCESS], [
Packit Service 4387a0
  AC_MSG_CHECKING([if unaligned memory access works correctly])
Packit Service 4387a0
  if test x"$as_cv_unaligned_access" = x ; then
Packit Service 4387a0
    case $host in
Packit Service 4387a0
      alpha*|arc*|arm*|aarch64*|hp*|mips*|sh*|sparc*|ia64*)
Packit Service 4387a0
        _AS_ECHO_N([(blacklisted) ])
Packit Service 4387a0
        as_cv_unaligned_access=no
Packit Service 4387a0
	;;
Packit Service 4387a0
      i?86*|x86_64*|amd64*|powerpc*|m68k*|cris*)
Packit Service 4387a0
        _AS_ECHO_N([(whitelisted) ])
Packit Service 4387a0
        as_cv_unaligned_access=yes
Packit Service 4387a0
	;;
Packit Service 4387a0
    esac
Packit Service 4387a0
  else
Packit Service 4387a0
    _AS_ECHO_N([(cached) ])
Packit Service 4387a0
  fi
Packit Service 4387a0
  if test x"$as_cv_unaligned_access" = x ; then
Packit Service 4387a0
    AC_TRY_RUN([
Packit Service 4387a0
int main(int argc, char **argv)
Packit Service 4387a0
{
Packit Service 4387a0
  char array[] = "ABCDEFGH";
Packit Service 4387a0
  unsigned int iarray[2];
Packit Service 4387a0
  memcpy(iarray,array,8);
Packit Service 4387a0
#define GET(x) (*(unsigned int *)((char *)iarray + (x)))
Packit Service 4387a0
  if(GET(0) != 0x41424344 && GET(0) != 0x44434241) return 1;
Packit Service 4387a0
  if(GET(1) != 0x42434445 && GET(1) != 0x45444342) return 1;
Packit Service 4387a0
  if(GET(2) != 0x43444546 && GET(2) != 0x46454443) return 1;
Packit Service 4387a0
  if(GET(3) != 0x44454647 && GET(3) != 0x47464544) return 1;
Packit Service 4387a0
  return 0;
Packit Service 4387a0
}
Packit Service 4387a0
    ], as_cv_unaligned_access="yes", as_cv_unaligned_access="no")
Packit Service 4387a0
  fi
Packit Service 4387a0
  AC_MSG_RESULT($as_cv_unaligned_access)
Packit Service 4387a0
  if test "$as_cv_unaligned_access" = "yes"; then
Packit Service 4387a0
    AC_DEFINE_UNQUOTED(HAVE_UNALIGNED_ACCESS, 1,
Packit Service 4387a0
      [defined if unaligned memory access works correctly])
Packit Service 4387a0
  fi
Packit Service 4387a0
])