diff --git a/configure b/configure index dee290d63d..3e4ff75102 100755 --- a/configure +++ b/configure @@ -186,29 +186,22 @@ die () { issystem() { test "$(echo $system_name | tr A-Z a-z)" = "$(echo $1 | tr A-Z a-z)" } -aix() { issystem "AIX"; } -amigaos() { issystem "AmigaOS"; } -beos() { issystem "BEOS"; } -bsdos() { issystem "BSD/OS"; } cygwin() { issystem "CYGWIN"; } darwin() { issystem "Darwin"; } dragonfly() { issystem "DragonFly"; } freebsd() { issystem "FreeBSD" || issystem "GNU/kFreeBSD"; } gnu() { issystem "GNU"; } -hpux() { issystem "HP-UX"; } linux() { issystem "Linux"; } mingw32() { issystem "MINGW32"; } morphos() { issystem "MorphOS"; } netbsd() { issystem "NetBSD"; } openbsd() { issystem "OpenBSD"; } -qnx() { issystem "QNX"; } win32() { cygwin || mingw32; } # arch test boolean functions -# x86/x86pc is used by QNX x86_32() { case "$host_arch" in - i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) return 0 ;; + i[3-9]86|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) return 0 ;; *) return 1 ;; esac } @@ -429,7 +422,6 @@ Available values for --language-man are: all $man_lang_all Available values for --language-msg are: all $msg_lang_all Miscellaneous options: - --enable-runtime-cpudetection enable runtime CPU detection [disable] --enable-cross-compile enable cross-compilation [disable] --cc=COMPILER C compiler to build MPlayer [gcc] --pkg-config=PKGCONFIG pkg-config to find some libraries [pkg-config] @@ -439,22 +431,7 @@ Miscellaneous options: --with-install=PATH path to a custom install program Advanced options: - --enable-mmx enable MMX [autodetect] - --enable-mmxext enable MMX2 (Pentium III, Athlon) [autodetect] - --enable-3dnow enable 3DNow! [autodetect] - --enable-3dnowext enable extended 3DNow! [autodetect] - --enable-sse enable SSE [autodetect] - --enable-sse2 enable SSE2 [autodetect] - --enable-ssse3 enable SSSE3 [autodetect] --enable-shm enable shm [autodetect] - --enable-altivec enable AltiVec (PowerPC) [autodetect] - --enable-armv5te enable DSP extensions (ARM) [autodetect] - --enable-armv6 enable ARMv6 (ARM) [autodetect] - --enable-armv6t2 enable ARMv6t2 (ARM) [autodetect] - --enable-armvfp enable ARM VFP (ARM) [autodetect] - --enable-neon enable NEON (ARM) [autodetect] - --enable-iwmmxt enable iWMMXt (ARM) [autodetect] - --enable-big-endian force byte order to big-endian [autodetect] --enable-debug[=1-3] compile-in debugging information [disable] --enable-profile compile-in profiling information [disable] --disable-sighandler disable sighandler for crashes [enable] @@ -480,29 +457,11 @@ exit 0 # GOTCHA: the variables below defines the default behavior for autodetection # and have - unless stated otherwise - at least 2 states : yes no # If autodetection is available then the third state is: auto -_mmx=auto -_3dnow=auto -_3dnowext=auto -_mmxext=auto -_sse=auto -_sse2=auto -_ssse3=auto -_cmov=auto -_fast_cmov=auto -_fast_clz=auto -_armv5te=auto -_armv6=auto -_armv6t2=auto -_armvfp=auto -neon=auto -_iwmmxt=auto -_altivec=auto _install=install _pkg_config=auto _windres=auto _cc=auto test "$CC" && _cc="$CC" -_runtime_cpudetection=no _cross_compile=no _prefix="/usr/local" ffmpeg=auto @@ -606,7 +565,6 @@ _sighandler=yes _libdv=auto _cdda=auto _cddb=auto -_big_endian=auto _qtx=auto _coreaudio=auto _corevideo=auto @@ -741,8 +699,6 @@ for ac_option do ;; --enable-translation) _translation=yes ;; --disable-translation) _translation=no ;; - --enable-runtime-cpudetection) _runtime_cpudetection=yes ;; - --disable-runtime-cpudetection) _runtime_cpudetection=no ;; --enable-cross-compile) _cross_compile=yes ;; --disable-cross-compile) _cross_compile=no ;; --enable-mplayer) _mplayer=yes ;; @@ -923,8 +879,6 @@ for ac_option do --disable-select) _select=no ;; --enable-cddb) _cddb=yes ;; --disable-cddb) _cddb=no ;; - --enable-big-endian) _big_endian=yes ;; - --disable-big-endian) _big_endian=no ;; --enable-unrarexec) _unrar_exec=yes ;; --disable-unrarexec) _unrar_exec=no ;; --enable-ftp) _ftp=yes ;; @@ -979,42 +933,6 @@ for ac_option do --enable-win32dll) _win32dll=yes ;; --disable-win32dll) _win32dll=no ;; - --enable-sse) _sse=yes ;; - --disable-sse) _sse=no ;; - --enable-sse2) _sse2=yes ;; - --disable-sse2) _sse2=no ;; - --enable-ssse3) _ssse3=yes ;; - --disable-ssse3) _ssse3=no ;; - --enable-mmxext) _mmxext=yes ;; - --disable-mmxext) _mmxext=no ;; - --enable-3dnow) _3dnow=yes ;; - --disable-3dnow) _3dnow=no _3dnowext=no ;; - --enable-3dnowext) _3dnow=yes _3dnowext=yes ;; - --disable-3dnowext) _3dnowext=no ;; - --enable-cmov) _cmov=yes ;; - --disable-cmov) _cmov=no ;; - --enable-fast-cmov) _fast_cmov=yes ;; - --disable-fast-cmov) _fast_cmov=no ;; - --enable-fast-clz) _fast_clz=yes ;; - --disable-fast-clz) _fast_clz=no ;; - --enable-altivec) _altivec=yes ;; - --disable-altivec) _altivec=no ;; - --enable-armv5te) _armv5te=yes ;; - --disable-armv5te) _armv5te=no ;; - --enable-armv6) _armv6=yes ;; - --disable-armv6) _armv6=no ;; - --enable-armv6t2) _armv6t2=yes ;; - --disable-armv6t2) _armv6t2=no ;; - --enable-armvfp) _armvfp=yes ;; - --disable-armvfp) _armvfp=no ;; - --enable-neon) neon=yes ;; - --disable-neon) neon=no ;; - --enable-iwmmxt) _iwmmxt=yes ;; - --disable-iwmmxt) _iwmmxt=no ;; - --enable-mmx) _mmx=yes ;; - --disable-mmx) # 3Dnow! and MMX2 require MMX - _3dnow=no _3dnowext=no _mmx=no _mmxext=no ;; - *) echo "Unknown parameter: $ac_option" >&2 exit 1 @@ -1084,26 +1002,20 @@ if test -z "$_target" ; then # OS name system_name=$(uname -s 2>&1) case "$system_name" in - Linux|FreeBSD|NetBSD|OpenBSD|DragonFly|BSD/OS|Darwin|QNX|GNU|BeOS|MorphOS|AIX|AmigaOS) + Linux|FreeBSD|NetBSD|OpenBSD|DragonFly|Darwin|GNU|MorphOS) ;; Haiku) - system_name=BeOS + system_name=Haiku ;; GNU/kFreeBSD) system_name=FreeBSD ;; - HP-UX*) - system_name=HP-UX - ;; [cC][yY][gG][wW][iI][nN]*) system_name=CYGWIN ;; MINGW32*) system_name=MINGW32 ;; - OS/2*) - system_name=OS/2 - ;; *) system_name="$system_name-UNKNOWN" ;; @@ -1124,9 +1036,8 @@ if test -z "$_target" ; then # Maybe uname -m (machine hardware name) returns something we # recognize. - # x86/x86pc is used by QNX case "$(uname -m 2>&1)" in - x86_64|amd64|i[3-9]86*|x86|x86pc|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;; + x86_64|amd64|i[3-9]86*|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;; ia64) host_arch=ia64 ;; macppc|ppc) host_arch=ppc ;; ppc64) host_arch=ppc64 ;; @@ -1153,12 +1064,9 @@ else # if test -z "$_target" freebsd) system_name=FreeBSD ;; gnu/kfreebsd) system_name=FreeBSD ;; netbsd) system_name=NetBSD ;; - bsd/os) system_name=BSD/OS ;; openbsd) system_name=OpenBSD ;; dragonfly) system_name=DragonFly ;; - qnx) system_name=QNX ;; morphos) system_name=MorphOS ;; - amigaos) system_name=AmigaOS ;; mingw32*) system_name=MINGW32 ;; *) continue ;; esac @@ -1189,10 +1097,6 @@ if darwin; then _timer=timer-darwin.c fi -if aix ; then - extra_ldflags="$extra_ldflags -lC" -fi - if win32 ; then _exesuf=".exe" extra_cflags="$extra_cflags -fno-common" @@ -1211,29 +1115,12 @@ if mingw32 ; then extra_cflags="$extra_cflags -D__USE_MINGW_ANSI_STDIO=1" fi -if amigaos ; then - _select=no - _sighandler=no - _stream_cache=no - def_stream_cache="#undef CONFIG_STREAM_CACHE" - extra_cflags="-DNEWLIB -D__USE_INLINE__ $extra_cflags" -fi - -if qnx ; then - extra_ldflags="$extra_ldflags -lph" -fi - TMPC="$mplayer_tmpdir/tmp.c" TMPCPP="$mplayer_tmpdir/tmp.cpp" TMPEXE="$mplayer_tmpdir/tmp$_exesuf" TMPH="$mplayer_tmpdir/tmp.h" TMPS="$mplayer_tmpdir/tmp.S" -if test "$_runtime_cpudetection" = yes && ! x86 && ! ppc; then - die "Runtime CPU detection only works for x86, x86-64 and PPC!" -fi - - # Checking CC version... # Intel C++ Compilers (no autoselect, use CC=/some/binary ./configure) if test "$(basename $_cc)" = "icc" || test "$(basename $_cc)" = "ecc"; then @@ -1321,350 +1208,16 @@ fi # XXX: this should be ok.. _cpuinfo="echo" -if test "$_runtime_cpudetection" = no ; then - -# Cygwin has /proc/cpuinfo, but only supports Intel CPUs -# FIXME: Remove the cygwin check once AMD CPUs are supported -if test -r /proc/cpuinfo && ! cygwin; then - # Linux with /proc mounted, extract CPU information from it - _cpuinfo="cat /proc/cpuinfo" -elif test -r /compat/linux/proc/cpuinfo && ! x86 ; then - # FreeBSD with Linux emulation /proc mounted, - # extract CPU information from it - # Don't use it on x86 though, it never reports 3Dnow - _cpuinfo="cat /compat/linux/proc/cpuinfo" -elif darwin && ! x86 ; then - # use hostinfo on Darwin - _cpuinfo="hostinfo" -elif aix; then - # use 'lsattr' on AIX - _cpuinfo="lsattr -E -l proc0 -a type" -elif x86; then - # all other OSes try to extract CPU information from a small helper - # program cpuinfo instead - $_cc -o cpuinfo$_exesuf cpuinfo.c - _cpuinfo="./cpuinfo$_exesuf" -fi - -if x86 ; then - # gather more CPU information - pname=$($_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -n 1) - pvendor=$($_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1) - pfamily=$($_cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1) - pmodel=$($_cpuinfo | grep -v 'model name' | grep 'model' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1) - pstepping=$($_cpuinfo | grep 'stepping' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -n 1) - - exts=$($_cpuinfo | egrep 'features|flags' | cut -d ':' -f 2 | head -n 1) - - pparam=$(echo $exts | sed -e s/xmm/sse/ -e s/kni/sse/) - # SSE implies MMX2, but not all SSE processors report the mmxext CPU flag. - pparam=$(echo $pparam | sed -e 's/sse/sse mmxext/') - - for ext in $pparam ; do - eval test \"\$_$ext\" = auto 2>/dev/null && eval _$ext=kernel_check - done - - echocheck "CPU vendor" - echores "$pvendor ($pfamily:$pmodel:$pstepping)" - - echocheck "CPU type" - echores "$pname" -fi - -fi # test "$_runtime_cpudetection" = no - -if x86 && test "$_runtime_cpudetection" = no ; then - extcheck() { - if test "$1" = kernel_check ; then - echocheck "kernel support of $2" - cat > $TMPC < -#include -static void catch(int sig) { exit(1); } -int main(void) { - signal(SIGILL, catch); - __asm__ volatile ("$3":::"memory"); return 0; -} -EOF - - if cc_check && tmp_run ; then - eval _$2=yes - echores "yes" - _optimizing="$_optimizing $2" - return 0 - else - eval _$2=no - echores "failed" - echo "It seems that your kernel does not correctly support $2." - echo "To use $2 extensions in MPlayer, you have to upgrade/recompile your kernel!" - return 1 - fi - fi - return 0 - } - - extcheck $_mmx "mmx" "emms" - extcheck $_mmxext "mmxext" "sfence" - extcheck $_3dnow "3dnow" "femms" - extcheck $_3dnowext "3dnowext" "pswapd %%mm0, %%mm0" - extcheck $_sse "sse" "xorps %%xmm0, %%xmm0" || _gcc3_ext="$_gcc3_ext -mno-sse" - extcheck $_sse2 "sse2" "xorpd %%xmm0, %%xmm0" || _gcc3_ext="$_gcc3_ext -mno-sse2" - extcheck $_ssse3 "ssse3" "pabsd %%xmm0, %%xmm0" - extcheck $_cmov "cmov" "cmovb %%eax, %%ebx" - - if test "$_gcc3_ext" != ""; then - # if we had to disable sse/sse2 because the active kernel does not - # support this instruction set extension, we also have to tell - # gcc3 to not generate sse/sse2 instructions for normal C code - cflag_check $_march $_gcc3_ext && _march="$_march $_gcc3_ext" - fi - -fi - def_fast_64bit='#define HAVE_FAST_64BIT 0' -def_fast_unaligned='#define HAVE_FAST_UNALIGNED 0' arch_all='X86 IA64 SPARC ARM AVR32 SH4 PPC ALPHA MIPS PA_RISC S390 S390X VAX BFIN XTENSA TOMI GENERIC' subarch_all='X86_32 X86_64 PPC64' case "$host_arch" in i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) - arch='x86' - subarch='x86_32' - def_fast_unaligned='#define HAVE_FAST_UNALIGNED 1' - iproc=486 - proc=i486 - - - if test "$_runtime_cpudetection" = no ; then - case "$pvendor" in - AuthenticAMD) - case "$pfamily" in - 3) proc=i386 iproc=386 ;; - 4) proc=i486 iproc=486 ;; - 5) iproc=586 # LGB: models are: K5/SSA5 K5 K5 K5 ? ? K6 K6 K6-2 K6-3 - # K6 model 13 are the K6-2+ and K6-III+, only differing in cache size. - if test "$pmodel" -eq 9 -o "$pmodel" -eq 13; then - proc=k6-3 - elif test "$pmodel" -eq 5 -o "$pmodel" -eq 10; then - proc=geode - elif test "$pmodel" -ge 8; then - proc=k6-2 - elif test "$pmodel" -ge 6; then - proc=k6 - else - proc=i586 - fi - ;; - 6) iproc=686 - # It's a bit difficult to determine the correct type of Family 6 - # AMD CPUs just from their signature. Instead, we check directly - # whether it supports SSE. - if test "$_sse" = yes; then - # gcc treats athlon-xp, athlon-4 and athlon-mp similarly. - proc=athlon-xp - else - # Again, gcc treats athlon and athlon-tbird similarly. - proc=athlon - fi - ;; - 15) iproc=686 - # k8 cpu-type only supported in gcc >= 3.4.0, but that will be - # caught and remedied in the optimization tests below. - proc=k8 - ;; - - *) proc=amdfam10 iproc=686 - test $_fast_clz = "auto" && _fast_clz=yes - ;; - esac - ;; - GenuineIntel) - case "$pfamily" in - 3) proc=i386 iproc=386 ;; - 4) proc=i486 iproc=486 ;; - 5) iproc=586 - if test "$pmodel" -eq 4 || test "$pmodel" -eq 8; then - proc=pentium-mmx # 4 is desktop, 8 is mobile - else - proc=i586 - fi - ;; - 6) iproc=686 - if test "$pmodel" -ge 15; then - proc=core2 - elif test "$pmodel" -eq 9 -o "$pmodel" -ge 13; then - proc=pentium-m - elif test "$pmodel" -ge 7; then - proc=pentium3 - elif test "$pmodel" -ge 3; then - proc=pentium2 - else - proc=i686 - fi - test $_fast_clz = "auto" && _fast_clz=yes - ;; - 15) iproc=686 - # A nocona in 32-bit mode has no more capabilities than a prescott. - if test "$pmodel" -ge 3; then - proc=prescott - else - proc=pentium4 - test $_fast_clz = "auto" && _fast_clz=yes - fi - test $_fast_cmov = "auto" && _fast_cmov=no - ;; - *) proc=prescott iproc=686 ;; - esac - ;; - CentaurHauls) - case "$pfamily" in - 5) iproc=586 - if test "$pmodel" -ge 8; then - proc=winchip2 - elif test "$pmodel" -ge 4; then - proc=winchip-c6 - else - proc=i586 - fi - ;; - 6) iproc=686 - if test "$pmodel" -ge 9; then - proc=c3-2 - else - proc=c3 - iproc=586 - fi - ;; - *) proc=i686 iproc=i686 ;; - esac - ;; - unknown) - case "$pfamily" in - 3) proc=i386 iproc=386 ;; - 4) proc=i486 iproc=486 ;; - *) proc=i586 iproc=586 ;; - esac - ;; - *) - proc=i586 iproc=586 ;; - esac - test $_fast_clz = "auto" && _fast_clz=no - fi # test "$_runtime_cpudetection" = no - - - # check that gcc supports our CPU, if not, fall back to earlier ones - # LGB: check -mcpu and -march swithing step by step with enabling - # to fall back till 386. - - # gcc >= 3.4.0 doesn't support -mcpu, we have to use -mtune instead - - if [ "$cc_vendor" = "gnu" ] && ([ "$_cc_major" -gt 3 ] || ( [ "$_cc_major" = 3 ] && [ "$_cc_minor" -ge 4 ])) ; then - cpuopt=-mtune - else - cpuopt=-mcpu - fi - - echocheck "GCC & CPU optimization abilities" - if test "$_runtime_cpudetection" = no ; then - if test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then - cflag_check -march=native && proc=native - fi - if test "$proc" = "amdfam10"; then - cflag_check -march=$proc $cpuopt=$proc || proc=k8 - fi - if test "$proc" = "k8"; then - cflag_check -march=$proc $cpuopt=$proc || proc=athlon-xp - fi - if test "$proc" = "athlon-xp"; then - cflag_check -march=$proc $cpuopt=$proc || proc=athlon - fi - if test "$proc" = "k6-3" || test "$proc" = "k6-2"; then - cflag_check -march=$proc $cpuopt=$proc || proc=k6 - fi - if test "$proc" = "k6" || test "$proc" = "c3"; then - if ! cflag_check -march=$proc $cpuopt=$proc; then - if cflag_check -march=i586 $cpuopt=i686; then - proc=i586-i686 - else - proc=i586 - fi - fi - fi - if test "$proc" = "prescott" ; then - cflag_check -march=$proc $cpuopt=$proc || proc=pentium4 - fi - if test "$proc" = "core2" ; then - cflag_check -march=$proc $cpuopt=$proc || proc=pentium-m - fi - if test "$proc" = "pentium4" || test "$proc" = "pentium-m" || test "$proc" = "pentium3" || test "$proc" = "pentium2" || test "$proc" = "athlon" || test "$proc" = "c3-2" || test "$proc" = "geode"; then - cflag_check -march=$proc $cpuopt=$proc || proc=i686 - fi - if test "$proc" = "i686" || test "$proc" = "pentium-mmx" || test "$proc" = "winchip-c6" || test "$proc" = "winchip2"; then - cflag_check -march=$proc $cpuopt=$proc || proc=i586 - fi - if test "$proc" = "i586"; then - cflag_check -march=$proc $cpuopt=$proc || proc=i486 - fi - if test "$proc" = "i486" ; then - cflag_check -march=$proc $cpuopt=$proc || proc=i386 - fi - if test "$proc" = "i386" ; then - cflag_check -march=$proc $cpuopt=$proc || proc=error - fi - if test "$proc" = "error" ; then - echores "CPU optimization disabled. CPU not recognized or your compiler is too old." - _mcpu="" - _march="" - _optimizing="" - elif test "$proc" = "i586-i686"; then - _march="-march=i586" - _mcpu="$cpuopt=i686" - _optimizing="$proc" - else - _march="-march=$proc" - _mcpu="$cpuopt=$proc" - _optimizing="$proc" - fi - else # if test "$_runtime_cpudetection" = no - _mcpu="$cpuopt=generic" - # at least i486 required, for bswap instruction - _march="-march=i486" - cflag_check $_mcpu || _mcpu="$cpuopt=i686" - cflag_check $_mcpu || _mcpu="" - cflag_check $_march $_mcpu || _march="" - fi - - ## Gabucino : --target takes effect here (hopefully...) by overwriting - ## autodetected mcpu/march parameters - if test "$_target" ; then - # TODO: it may be a good idea to check GCC and fall back in all cases - if test "$host_arch" = "i586-i686"; then - _march="-march=i586" - _mcpu="$cpuopt=i686" - else - _march="-march=$host_arch" - _mcpu="$cpuopt=$host_arch" - fi - - proc="$host_arch" - - case "$proc" in - i386) iproc=386 ;; - i486) iproc=486 ;; - i586|k5|k6|k6-2|k6-3|pentium|pentium-mmx) iproc=586 ;; - i686|athlon*|pentium*) iproc=686 ;; - *) iproc=586 ;; - esac - fi - - if test $_cmov = "yes" && test $_fast_cmov = "auto" ; then - _fast_cmov="yes" - else - _fast_cmov="no" - fi - test $_fast_clz = "auto" && _fast_clz=yes - - echores "$proc" + arch='x86' + subarch='x86_32' + iproc=486 + proc=i486 ;; ia64) @@ -1676,111 +1229,13 @@ case "$host_arch" in x86_64|amd64) arch='x86' subarch='x86_64' - def_fast_unaligned='#define HAVE_FAST_UNALIGNED 1' def_fast_64bit='#define HAVE_FAST_64BIT 1' iproc='x86_64' - - # gcc >= 3.4.0 doesn't support -mcpu, we have to use -mtune instead - if test "$cc_vendor" = "gnu" && test "$_cc_major" -gt 3 -o "$_cc_major" -eq 3 -a "$_cc_minor" -ge 4 ; then - cpuopt=-mtune - else - cpuopt=-mcpu - fi - if test "$_runtime_cpudetection" = no ; then - case "$pvendor" in - AuthenticAMD) - case "$pfamily" in - 15) proc=k8 - test $_fast_clz = "auto" && _fast_clz=no - ;; - *) proc=amdfam10;; - esac - ;; - GenuineIntel) - case "$pfamily" in - 6) proc=core2;; - *) - # 64-bit prescotts exist, but as far as GCC is concerned they - # have the same capabilities as a nocona. - proc=nocona - test $_fast_cmov = "auto" && _fast_cmov=no - test $_fast_clz = "auto" && _fast_clz=no - ;; - esac - ;; - *) - proc=error;; - esac - fi # test "$_runtime_cpudetection" = no - - echocheck "GCC & CPU optimization abilities" - # This is a stripped-down version of the i386 fallback. - if test "$_runtime_cpudetection" = no ; then - if test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then - cflag_check -march=native && proc=native - fi - # --- AMD processors --- - if test "$proc" = "amdfam10"; then - cflag_check -march=$proc $cpuopt=$proc || proc=k8 - fi - if test "$proc" = "k8"; then - cflag_check -march=$proc $cpuopt=$proc || proc=athlon-xp - fi - # This will fail if gcc version < 3.3, which is ok because earlier - # versions don't really support 64-bit on amd64. - # Is this a valid assumption? -Corey - if test "$proc" = "athlon-xp"; then - cflag_check -march=$proc $cpuopt=$proc || proc=error - fi - # --- Intel processors --- - if test "$proc" = "core2"; then - cflag_check -march=$proc $cpuopt=$proc || proc=x86-64 - fi - if test "$proc" = "x86-64"; then - cflag_check -march=$proc $cpuopt=$proc || proc=nocona - fi - if test "$proc" = "nocona"; then - cflag_check -march=$proc $cpuopt=$proc || proc=pentium4 - fi - if test "$proc" = "pentium4"; then - cflag_check -march=$proc $cpuopt=$proc || proc=error - fi - - _march="-march=$proc" - _mcpu="$cpuopt=$proc" - if test "$proc" = "error" ; then - echores "CPU optimization disabled. CPU not recognized or your compiler is too old." - _mcpu="" - _march="" - fi - else # if test "$_runtime_cpudetection" = no - # x86-64 is an undocumented option, an intersection of k8 and nocona. - _march="-march=x86-64" - _mcpu="$cpuopt=generic" - cflag_check $_mcpu || _mcpu="x86-64" - cflag_check $_mcpu || _mcpu="" - cflag_check $_march $_mcpu || _march="" - fi - - _optimizing="$proc" - test $_fast_cmov = "auto" && _fast_cmov=yes - test $_fast_clz = "auto" && _fast_clz=yes - - echores "$proc" ;; sparc|sparc64) arch='sparc' iproc='sparc' - if test "$host_arch" = "sparc64" ; then - _vis='yes' - proc='ultrasparc' - def_fast_64bit='#define HAVE_FAST_64BIT 1' - else - proc=v8 - fi - _mcpu="-mcpu=$proc" - _optimizing="$proc" ;; arm*) @@ -1790,9 +1245,7 @@ case "$host_arch" in avr32) arch='avr32' - def_fast_unaligned='#define HAVE_FAST_UNALIGNED 1' iproc='avr32' - test $_fast_clz = "auto" && _fast_clz=yes ;; sh|sh4) @@ -1802,167 +1255,17 @@ case "$host_arch" in ppc|ppc64|powerpc|powerpc64) arch='ppc' - def_dcbzl='#define HAVE_DCBZL 0' - def_fast_unaligned='#define HAVE_FAST_UNALIGNED 1' iproc='ppc' - - if test "$host_arch" = "ppc64" -o "$host_arch" = "powerpc64" ; then - subarch='ppc64' - def_fast_64bit='#define HAVE_FAST_64BIT 1' - fi - echocheck "CPU type" - case $system_name in - Linux) - proc=$($_cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ',' -f 1 | cut -b 2- | head -n 1) - if test -n "$($_cpuinfo | grep altivec)"; then - test $_altivec = auto && _altivec=yes - fi - ;; - Darwin) - proc=$($_cpuinfo | grep "Processor type" | cut -f 3 -d ' ' | sed 's/ppc//') - if [ $(sysctl -n hw.vectorunit) -eq 1 -o \ - "$(sysctl -n hw.optional.altivec 2> /dev/null)" = "1" ]; then - test $_altivec = auto && _altivec=yes - fi - ;; - NetBSD) - # only gcc 3.4 works reliably with AltiVec code under NetBSD - case $cc_version in - 2*|3.0*|3.1*|3.2*|3.3*) - ;; - *) - if [ $(sysctl -n machdep.altivec) -eq 1 ]; then - test $_altivec = auto && _altivec=yes - fi - ;; - esac - ;; - AIX) - proc=$($_cpuinfo | grep 'type' | cut -f 2 -d ' ' | sed 's/PowerPC_//') - ;; - esac - if test "$_altivec" = yes; then - echores "$proc altivec" - else - _altivec=no - echores "$proc" - fi - - echocheck "GCC & CPU optimization abilities" - - if test -n "$proc"; then - case "$proc" in - 601) _march='-mcpu=601' _mcpu='-mtune=601' ;; - 603) _march='-mcpu=603' _mcpu='-mtune=603' ;; - 603e|603ev) _march='-mcpu=603e' _mcpu='-mtune=603e' ;; - 604|604e|604r|604ev) _march='-mcpu=604' _mcpu='-mtune=604' ;; - 740|740/750|745/755) _march='-mcpu=740' _mcpu='-mtune=740' ;; - 750|750CX) _march='-mcpu=750' _mcpu='-mtune=750' ;; - POWER) _march='-mcpu=power' _mcpu='-mtune=power' ;; - POWER2) _march='-mcpu=power2' _mcpu='-mtune=power2' ;; - POWER3) _march='-mcpu=power3' _mcpu='-mtune=power3' ;; - *) ;; - esac - # gcc 3.1(.1) and up supports 7400 and 7450 - if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "1" || test "$_cc_major" -ge "4"; then - case "$proc" in - 7400*|7410*) _march='-mcpu=7400' _mcpu='-mtune=7400' ;; - 7447*|7450*|7455*) _march='-mcpu=7450' _mcpu='-mtune=7450' ;; - *) ;; - esac - fi - # gcc 3.2 and up supports 970 - if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "3" || test "$_cc_major" -ge "4"; then - case "$proc" in - 970*|PPC970*) _march='-mcpu=970' _mcpu='-mtune=970' - def_dcbzl='#define HAVE_DCBZL 1' ;; - *) ;; - esac - fi - # gcc 3.3 and up supports POWER4 - if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "3" || test "$_cc_major" -ge "4"; then - case "$proc" in - POWER4) _march='-mcpu=power4' _mcpu='-mtune=power4' ;; - *) ;; - esac - fi - # gcc 3.4 and up supports 440* - if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "4" || test "$_cc_major" -ge "4"; then - case "$proc" in - 440EP*) _march='-mcpu=440fp' _mcpu='-mtune=440fp' ;; - 440G* ) _march='-mcpu=440' _mcpu='-mtune=440' ;; - *) ;; - esac - fi - # gcc 4.0 and up supports POWER5 - if test "$_cc_major" -ge "4"; then - case "$proc" in - POWER5*) _march='-mcpu=power5' _mcpu='-mtune=power5' ;; - *) ;; - esac - fi - fi - - if test -n "$_mcpu"; then - _optimizing=$(echo $_mcpu | cut -c 8-) - echores "$_optimizing" - else - echores "none" - fi - - test $_fast_clz = "auto" && _fast_clz=yes - ;; alpha*) arch='alpha' iproc='alpha' - def_fast_64bit='#define HAVE_FAST_64BIT 1' - - echocheck "CPU type" - cat > $TMPC << EOF -int main(void) { - unsigned long ver, mask; - __asm__ ("implver %0" : "=r" (ver)); - __asm__ ("amask %1, %0" : "=r" (mask) : "r" (-1)); - printf("%ld-%x\n", ver, ~mask); - return 0; -} -EOF - $_cc -o "$TMPEXE" "$TMPC" - case $("$TMPEXE") in - - 0-0) proc="ev4"; _mvi="0";; - 1-0) proc="ev5"; _mvi="0";; - 1-1) proc="ev56"; _mvi="0";; - 1-101) proc="pca56"; _mvi="1";; - 2-303) proc="ev6"; _mvi="1";; - 2-307) proc="ev67"; _mvi="1";; - 2-1307) proc="ev68"; _mvi="1";; - esac - echores "$proc" - - echocheck "GCC & CPU optimization abilities" - if test "$proc" = "ev68" ; then - cc_check -mcpu=$proc || proc=ev67 - fi - if test "$proc" = "ev67" ; then - cc_check -mcpu=$proc || proc=ev6 - fi - _mcpu="-mcpu=$proc" - echores "$proc" - - test $_fast_clz = "auto" && _fast_clz=yes - - _optimizing="$proc" ;; mips*) arch='mips' iproc='mips' - - test $_fast_clz = "auto" && _fast_clz=yes - ;; hppa) @@ -2001,79 +1304,10 @@ EOF ;; esac # case "$host_arch" in -if test "$_runtime_cpudetection" = yes ; then - if x86 ; then - test "$_cmov" != no && _cmov=yes - x86_32 && _cmov=no - test "$_mmx" != no && _mmx=yes - test "$_3dnow" != no && _3dnow=yes - test "$_3dnowext" != no && _3dnowext=yes - test "$_mmxext" != no && _mmxext=yes - test "$_sse" != no && _sse=yes - test "$_sse2" != no && _sse2=yes - test "$_ssse3" != no && _ssse3=yes - fi - if ppc; then - _altivec=yes - fi -fi - - -# endian testing -echocheck "byte order" -if test "$_big_endian" = auto ; then - cat > $TMPC < $TMPC << EOF -__attribute__((noinline)) static int foo3(int i1, int i2, int i3) { return i3; } -int main(void) { return foo3(1, 2, 3) == 3 ? 0 : 1; } -EOF - cc_check -O2 -mstackrealign && tmp_run && cflags_stackrealign=-mstackrealign - test -z "$cflags_stackrealign" && cc_check -O2 -mstackrealign -fno-unit-at-a-time && - tmp_run && cflags_stackrealign="-mstackrealign -fno-unit-at-a-time" - test -n "$cflags_stackrealign" && echores "yes" || echores "no" -fi # if darwin && test "$cc_vendor" = "gnu" ; then - - # Checking for CFLAGS _install_strip="-s" if test "$_profile" != "" || test "$_debug" != "" ; then @@ -2099,10 +1333,6 @@ else warn_cflags=yes fi -if darwin && test "$cc_vendor" = "gnu" ; then - extra_cflags="-falign-loops=16 -shared-libgcc $extra_cflags" -fi - if test "$cc_vendor" = "gnu" ; then cflag_check -Wundef && WARNFLAGS="-Wundef $WARNFLAGS" # -std=gnu99 is not a warning flag but is placed in WARN_CFLAGS because @@ -2184,151 +1414,6 @@ echores $ebx_available fi #if x86 -#FIXME: This should happen before the check for CFLAGS.. -def_altivec_h='#define HAVE_ALTIVEC_H 0' -if ppc && ( test "$_altivec" = yes || test "$_runtime_cpudetection" = yes ) ; then - - # check if AltiVec is supported by the compiler, and how to enable it - echocheck "GCC AltiVec flags" - if $(cflag_check -maltivec -mabi=altivec) ; then - _altivec_gcc_flags="-maltivec -mabi=altivec" - # check if should be included - if $(header_check altivec.h $_altivec_gcc_flags) ; then - def_altivec_h='#define HAVE_ALTIVEC_H 1' - inc_altivec_h='#include ' - else - if $(cflag_check -faltivec) ; then - _altivec_gcc_flags="-faltivec" - else - _altivec=no - _altivec_gcc_flags="none, AltiVec disabled" - fi - fi - fi - echores "$_altivec_gcc_flags" - - # check if the compiler supports braces for vector declarations - cat > $TMPC << EOF -$inc_altivec_h -int main(void) { (vector int) {1}; return 0; } -EOF - cc_check $_altivec_gcc_flags || die "You need a compiler that supports {} in AltiVec vector declarations." - - # Disable runtime cpudetection if we cannot generate AltiVec code or - # AltiVec is disabled by the user. - test "$_runtime_cpudetection" = yes && test "$_altivec" = no \ - && _runtime_cpudetection=no - - # Show that we are optimizing for AltiVec (if enabled and supported). - test "$_runtime_cpudetection" = no && test "$_altivec" = yes \ - && _optimizing="$_optimizing altivec" - - # If AltiVec is enabled, make sure the correct flags turn up in CFLAGS. - test "$_altivec" = yes && CFLAGS="$CFLAGS $_altivec_gcc_flags" -fi - -if ppc ; then -def_xform_asm='#define HAVE_XFORM_ASM 0' -xform_asm=no -echocheck "XFORM ASM support" -inline_asm_check '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)' && - xform_asm=yes && def_xform_asm='#define HAVE_XFORM_ASM 1' -echores "$xform_asm" -fi - -if arm ; then - echocheck "ARMv5TE (Enhanced DSP Extensions)" - if test $_armv5te = "auto" ; then - _armv5te=no - inline_asm_check '"qadd r0, r0, r0"' && _armv5te=yes - fi - echores "$_armv5te" - - test $_armv5te = "yes" && test $_fast_clz = "auto" && _fast_clz=yes - - echocheck "ARMv6 (SIMD instructions)" - if test $_armv6 = "auto" ; then - _armv6=no - inline_asm_check '"sadd16 r0, r0, r0"' && _armv6=yes - fi - echores "$_armv6" - - echocheck "ARMv6t2 (SIMD instructions)" - if test $_armv6t2 = "auto" ; then - _armv6t2=no - inline_asm_check '"movt r0, #0"' && _armv6t2=yes - fi - echores "$_armv6t2" - - echocheck "ARM VFP" - if test $_armvfp = "auto" ; then - _armvfp=no - inline_asm_check '"fadds s0, s0, s0"' && _armvfp=yes - fi - echores "$_armvfp" - - echocheck "ARM NEON" - if test $neon = "auto" ; then - neon=no - inline_asm_check '"vadd.i16 q0, q0, q0"' && neon=yes - fi - echores "$neon" - - echocheck "iWMMXt (Intel XScale SIMD instructions)" - if test $_iwmmxt = "auto" ; then - _iwmmxt=no - inline_asm_check '"wunpckelub wr6, wr4"' && _iwmmxt=yes - fi - echores "$_iwmmxt" -fi - -cpuexts_all='ALTIVEC MMX MMX2 AMD3DNOW AMD3DNOWEXT SSE SSE2 SSSE3 FAST_CMOV CMOV FAST_CLZ ARMV5TE ARMV6 ARMV6T2 ARMVFP NEON IWMMXT MMI VIS MVI' -test "$_altivec" = yes && cpuexts="ALTIVEC $cpuexts" -test "$_mmx" = yes && cpuexts="MMX $cpuexts" -test "$_mmxext" = yes && cpuexts="MMX2 $cpuexts" -test "$_3dnow" = yes && cpuexts="AMD3DNOW $cpuexts" -test "$_3dnowext" = yes && cpuexts="AMD3DNOWEXT $cpuexts" -test "$_sse" = yes && cpuexts="SSE $cpuexts" -test "$_sse2" = yes && cpuexts="SSE2 $cpuexts" -test "$_ssse3" = yes && cpuexts="SSSE3 $cpuexts" -test "$_cmov" = yes && cpuexts="CMOV $cpuexts" -test "$_fast_cmov" = yes && cpuexts="FAST_CMOV $cpuexts" -test "$_fast_clz" = yes && cpuexts="FAST_CLZ $cpuexts" -test "$_armv5te" = yes && cpuexts="ARMV5TE $cpuexts" -test "$_armv6" = yes && cpuexts="ARMV6 $cpuexts" -test "$_armv6t2" = yes && cpuexts="ARMV6T2 $cpuexts" -test "$_armvfp" = yes && cpuexts="ARMVFP $cpuexts" -test "$neon" = yes && cpuexts="NEON $cpuexts" -test "$_iwmmxt" = yes && cpuexts="IWMMXT $cpuexts" -test "$_vis" = yes && cpuexts="VIS $cpuexts" -test "$_mvi" = yes && cpuexts="MVI $cpuexts" - -# Checking kernel version... -if x86_32 && linux ; then - _k_verc_problem=no - kernel_version=$(uname -r 2>&1) - echocheck "$system_name kernel version" - case "$kernel_version" in - '') kernel_version="?.??"; _k_verc_fail=yes;; - [0-1].[0-9].[0-9]*|2.[0-3].[0-9]*) - _k_verc_problem=yes;; - esac - if test "$_k_verc_problem" = yes && test "$_sse" = yes ; then - _k_verc_fail=yes - fi - if test "$_k_verc_fail" ; then - echores "$kernel_version, fail" - echo "WARNING! If you want to run MPlayer on this system, get prepared for problems!" - echo "2.2.x has limited SSE support. Upgrade the kernel or use --disable-sse if you" - echo "experience crashes. MPlayer tries to autodetect if your kernel correctly" - echo "supports SSE, but you have been warned! If you are using a kernel older than" - echo "2.2.x you must upgrade it to get SSE support!" -# die "Your kernel is too old for this CPU." # works fine on some 2.2.x so don't die (later check will test) - else - echores "$kernel_version, ok" - fi -fi - ###################### # MAIN TESTS GO HERE # ###################### @@ -2423,15 +1508,6 @@ else fi echores "$_sighandler" -echocheck "runtime cpudetection" -if test "$_runtime_cpudetection" = yes ; then - _optimizing="Runtime CPU-Detection enabled" - def_runtime_cpudetection='#define CONFIG_RUNTIME_CPUDETECT 1' -else - def_runtime_cpudetection='#define CONFIG_RUNTIME_CPUDETECT 0' -fi -echores "$_runtime_cpudetection" - echocheck "restrict keyword" for restrict_keyword in restrict __restrict __restrict__ ; do @@ -2776,7 +1852,7 @@ def_threads='#define HAVE_THREADS 0' echocheck "pthread" if linux ; then THREAD_CFLAGS=-D_REENTRANT -elif freebsd || netbsd || openbsd || bsdos ; then +elif freebsd || netbsd || openbsd ; then THREAD_CFLAGS=-D_THREAD_SAFE fi if test "$_pthreads" = auto ; then @@ -2793,15 +1869,13 @@ int main(void) { } EOF _pthreads=no -if ! hpux ; then - for _ld_tmp in "-lpthreadGC2" "" "-lpthread" "-pthread" ; do - # for crosscompilation, we cannot execute the program, be happy if we can link statically - cc_check $THREAD_CFLAGS $_ld_tmp && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && break - done - if test "$_pthreads" = no && mingw32 ; then - _ld_tmp="-lpthreadGC2 -lws2_32" - cc_check $_ld_tmp -DPTW32_STATIC_LIB && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && CFLAGS="$CFLAGS -DPTW32_STATIC_LIB" - fi +for _ld_tmp in "-lpthreadGC2" "" "-lpthread" "-pthread" ; do +# for crosscompilation, we cannot execute the program, be happy if we can link statically +cc_check $THREAD_CFLAGS $_ld_tmp && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && break +done +if test "$_pthreads" = no && mingw32 ; then +_ld_tmp="-lpthreadGC2 -lws2_32" +cc_check $_ld_tmp -DPTW32_STATIC_LIB && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && CFLAGS="$CFLAGS -DPTW32_STATIC_LIB" fi fi if test "$_pthreads" = yes ; then @@ -2925,79 +1999,6 @@ header_check sys/videoio.h && sys_videoio_h=yes && echores "$sys_videoio_h" -echocheck "sys/dvdio.h" -_dvdio=no -# FreeBSD 8.1 has broken dvdio.h -header_check_broken sys/types.h sys/dvdio.h && _dvdio=yes -if test "$_dvdio" = yes ; then - def_dvdio='#define DVD_STRUCT_IN_SYS_DVDIO_H 1' -else - def_dvdio='#undef DVD_STRUCT_IN_SYS_DVDIO_H' -fi -echores "$_dvdio" - - -echocheck "sys/cdio.h" -_cdio=no -# at least OpenSolaris has a broken cdio.h -header_check_broken sys/types.h sys/cdio.h && _cdio=yes -if test "$_cdio" = yes ; then - def_cdio='#define DVD_STRUCT_IN_SYS_CDIO_H 1' -else - def_cdio='#undef DVD_STRUCT_IN_SYS_CDIO_H' -fi -echores "$_cdio" - - -echocheck "linux/cdrom.h" -_cdrom=no -header_check linux/cdrom.h && _cdrom=yes -if test "$_cdrom" = yes ; then - def_cdrom='#define DVD_STRUCT_IN_LINUX_CDROM_H 1' -else - def_cdrom='#undef DVD_STRUCT_IN_LINUX_CDROM_H' -fi -echores "$_cdrom" - - -echocheck "dvd.h" -_dvd=no -header_check dvd.h && _dvd=yes -if test "$_dvd" = yes ; then - def_dvd='#define DVD_STRUCT_IN_DVD_H 1' -else - def_dvd='#undef DVD_STRUCT_IN_DVD_H' -fi -echores "$_dvd" - - -if bsdos; then -echocheck "BSDI dvd.h" -_bsdi_dvd=no -header_check dvd.h && _bsdi_dvd=yes -if test "$_bsdi_dvd" = yes ; then - def_bsdi_dvd='#define DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H 1' -else - def_bsdi_dvd='#undef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H' -fi -echores "$_bsdi_dvd" -fi #if bsdos - - -if hpux; then -# also used by AIX, but AIX does not support VCD and/or libdvdread -echocheck "HP-UX SCSI header" -_hpux_scsi_h=no -header_check sys/scsi.h && _hpux_scsi_h=yes -if test "$_hpux_scsi_h" = yes ; then - def_hpux_scsi_h='#define HPUX_SCTL_IO 1' -else - def_hpux_scsi_h='#undef HPUX_SCTL_IO' -fi -echores "$_hpux_scsi_h" -fi #if hpux - - echocheck "termcap" if test "$_termcap" = auto ; then _termcap=no @@ -4208,13 +3209,11 @@ elif freebsd ; then default_cdrom_device="/dev/acd0" elif openbsd ; then default_cdrom_device="/dev/rcd0c" -elif amigaos ; then - default_cdrom_device="a1ide.device:2" else default_cdrom_device="/dev/cdrom" fi -if win32 || dragonfly || freebsd || openbsd || amigaos ; then +if win32 || dragonfly || freebsd || openbsd ; then default_dvd_device=$default_cdrom_device elif darwin ; then default_dvd_device="/dev/rdiskN" @@ -4226,7 +3225,7 @@ fi echocheck "VCD support" if test "$_vcd" = auto; then _vcd=no - if linux || freebsd || netbsd || openbsd || dragonfly || bsdos || darwin ; then + if linux || freebsd || netbsd || openbsd || dragonfly || darwin ; then _vcd=yes elif mingw32; then header_check ddk/ntddcdrm.h && _vcd=yes @@ -4265,7 +3264,7 @@ fi if test "$_dvdread_internal" = auto ; then _dvdread_internal=no _dvdread=no - if (linux || freebsd || netbsd || openbsd || dragonfly || hpux) && + if (linux || freebsd || netbsd || openbsd || dragonfly) && (test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || test "$_dvdio" = yes || test "$_bsdi_dvd" = yes) || darwin || win32; then @@ -4307,10 +3306,9 @@ echocheck "internal libdvdcss" if test "$_libdvdcss_internal" = auto ; then _libdvdcss_internal=no test "$_dvdread_internal" = yes && test -d libdvdcss && _libdvdcss_internal=yes - hpux && test "$_hpux_scsi_h" = no && _libdvdcss_internal=no fi if test "$_libdvdcss_internal" = yes ; then - if linux || netbsd || openbsd || bsdos ; then + if linux || netbsd || openbsd ; then def_dvd_linux='#define HAVE_LINUX_DVD_STRUCT 1' openbsd && def_dvd_openbsd='#define HAVE_OPENBSD_DVD_STRUCT 1' elif freebsd || dragonfly ; then @@ -4320,8 +3318,6 @@ if test "$_libdvdcss_internal" = yes ; then extra_ldflags="$extra_ldflags -framework IOKit -framework Carbon" elif cygwin ; then cflags_libdvdcss="-DSYS_CYGWIN -DWIN32" - elif beos ; then - cflags_libdvdcss="-DSYS_BEOS" fi cflags_libdvdcss_dvdread="-Ilibdvdcss" def_dvdcss="#define HAVE_DVDCSS_DVDCSS_H 1" @@ -4667,7 +3663,7 @@ fi echocheck "Win32 codecs" if test "$_win32dll" = auto ; then _win32dll=no - if x86_32 && ! qnx; then + if x86_32 ; then _win32dll=yes fi fi @@ -4933,7 +3929,7 @@ fi echores "$_tv" -if freebsd || netbsd || openbsd || dragonfly || bsdos ; then +if freebsd || netbsd || openbsd || dragonfly ; then echocheck "*BSD BT848 bt8xx header" _ioctl_bt848_h=no for file in "machine/ioctl_bt848.h" \ @@ -5005,7 +4001,7 @@ EOF noinputmodules="tv-bsdbt848 $noinputmodules" fi echores "$_tv_bsdbt848" -fi #if freebsd || netbsd || openbsd || dragonfly || bsdos +fi #if freebsd || netbsd || openbsd || dragonfly echocheck "DirectShow TV interface" @@ -5119,7 +4115,7 @@ else fi echores "$_radio_v4l" -if freebsd || netbsd || openbsd || dragonfly || bsdos && +if freebsd || netbsd || openbsd || dragonfly && test "$_radio" = yes && test "$_radio_bsdbt848" = auto ; then echocheck "*BSD BrookTree 848 Radio interface" _radio_bsdbt848=no @@ -5133,7 +4129,7 @@ int main(void) { ioctl(0, RADIO_GETFREQ, 0); return 0; } EOF cc_check && _radio_bsdbt848=yes echores "$_radio_bsdbt848" -fi #if freebsd || netbsd || openbsd || dragonfly || bsdos && _radio && _radio_bsdbt848 +fi #if freebsd || netbsd || openbsd || dragonfly && _radio && _radio_bsdbt848 if test "$_radio_bsdbt848" = yes ; then def_radio_bsdbt848='#define CONFIG_RADIO_BSDBT848 1' @@ -5170,7 +4166,7 @@ echores "$_pvr" echocheck "ftp" if test "$_ftp" = "auto" ; then -test "$networking" = "yes" && ! beos && _ftp=yes +test "$networking" = "yes" && _ftp=yes fi if test "$_ftp" = yes ; then def_ftp='#define CONFIG_FTP 1' @@ -5270,13 +4266,12 @@ fi # Dynamic linking flags # (FIXME: 'echocheck "dynamic linking"' above and modify here accordingly) _ld_dl_dynamic='' -freebsd || netbsd || openbsd || dragonfly || bsdos && _ld_dl_dynamic='-rdynamic' -if test "$_real" = yes || test "$_xanim" = yes && ! win32 && ! qnx && ! darwin ; then +freebsd || netbsd || openbsd || dragonfly && _ld_dl_dynamic='-rdynamic' +if test "$_real" = yes || test "$_xanim" = yes && ! win32 && ! darwin ; then _ld_dl_dynamic='-rdynamic' fi extra_ldflags="$extra_ldflags $_ld_pthread $_ld_dl $_ld_dl_dynamic" -bsdos && extra_ldflags="$extra_ldflags -ldvd" (netbsd || openbsd) && x86_32 && extra_ldflags="$extra_ldflags -li386" def_debug='#undef MP_DEBUG' @@ -5437,7 +4432,6 @@ EXESUFS_ALL = .exe ARCH = $arch $(mak_enable "$arch_all" "$arch" ARCH) $(mak_enable "$subarch_all" "$subarch" ARCH) -$(mak_enable "$cpuexts_all" "$cpuexts" HAVE) MPLAYER = $_mplayer @@ -5634,7 +4628,6 @@ $def_dvdcss /* system headers */ $def_alloca_h -$def_altivec_h $def_malloc_h $def_mman_h $def_mman_has_map_failed @@ -5690,7 +4683,6 @@ $def_unrar_exec $def_charset $def_crash_debug $def_debug -$def_runtime_cpudetection $def_sighandler $def_sortsub $def_stream_cache @@ -5700,12 +4692,15 @@ $def_pthread_cache /* CPU stuff */ #define __CPU__ $iproc $def_ebx_available -$def_words_endian -$def_bigendian $(ff_config_enable "$arch_all" "$arch" "ARCH") $(ff_config_enable "$subarch_all" "$subarch" "ARCH") -$(ff_config_enable "$cpuexts_all" "$cpuexts" "HAVE") +#define HAVE_AMD3DNOW 0 +#define HAVE_MMX ARCH_X86 +#define HAVE_MMX2 ARCH_X86 +#define HAVE_SSE ARCH_X86 +#define HAVE_SSE2 ARCH_X86 +#define HAVE_SSSE3 ARCH_X86 /* Blu-ray/DVD/VCD/CD */ #define DEFAULT_CDROM_DEVICE "$default_cdrom_device" @@ -5724,8 +4719,6 @@ $def_dvd_openbsd $def_dvdio $def_dvdnav $def_dvdread -$def_hpux_scsi_h -$def_sol_scsi_h $def_vcd @@ -5863,7 +4856,6 @@ $def_dcbzl $def_exp2 $def_exp2f $def_fast_64bit -$def_fast_unaligned $def_llrint $def_log2 $def_log2f @@ -5899,9 +4891,6 @@ Config files successfully generated by ./configure $configuration ! Data directory: $_datadir Config direct.: $_confdir - Byte order: $_byte_order - Optimizing for: $_optimizing - Languages: Messages (in addition to English): $language_msg Manual pages: $language_man @@ -5938,8 +4927,7 @@ skipping autodetection. This behavior is unlike what you may be used to from autoconf-based configure scripts that can decide to override you. This greater level of control comes at a price. You may have to provide the correct compiler and linker flags yourself. -If you used one of these options (except --enable-runtime-cpudetection and -similar ones that turn on internal features) and experience a compilation or +If you used one of these options and experience a compilation or linking failure, make sure you have passed the necessary compiler/linker flags to configure. diff --git a/cpudetect.c b/cpudetect.c index fb93116c80..7aa090eca5 100644 --- a/cpudetect.c +++ b/cpudetect.c @@ -16,497 +16,41 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include +#include +#include + +#include + #include "config.h" #include "cpudetect.h" #include "mp_msg.h" CpuCaps gCpuCaps; -#include +static void dump_flag(const char *name, bool val) +{ + mp_msg(MSGT_CPUDETECT, MSGL_V, "CPU: %s: %s\n", name, + val ? "enabled" : "disabled"); +} +void GetCpuCaps(CpuCaps *c) +{ + memset(c, 0, sizeof(*c)); + int flags = av_get_cpu_flags(); #if ARCH_X86 - -#include -#include - -#if defined (__NetBSD__) || defined(__OpenBSD__) -#include -#include -#include -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__APPLE__) -#include -#include -#elif defined(__linux__) -#include -#elif defined(__MINGW32__) || defined(__CYGWIN__) -#include -#elif defined(__AMIGAOS4__) -#include + c->isX86 = 1; + c->hasMMX = flags & AV_CPU_FLAG_MMX; + c->hasMMX2 = flags & AV_CPU_FLAG_MMX2; + c->hasSSE = flags & AV_CPU_FLAG_SSE; + c->hasSSE2 = (flags & AV_CPU_FLAG_SSE2) && !(flags & AV_CPU_FLAG_SSE2SLOW); + c->hasSSE3 = (flags & AV_CPU_FLAG_SSE3) && !(flags & AV_CPU_FLAG_SSE3SLOW); + c->hasSSSE3 = flags & AV_CPU_FLAG_SSSE3; #endif - -/* Thanks to the FreeBSD project for some of this cpuid code, and - * help understanding how to use it. Thanks to the Mesa - * team for SSE support detection and more cpu detect code. - */ - -#if CONFIG_RUNTIME_CPUDETECT -/* I believe this code works. However, it has only been used on a PII and PIII */ - -#if defined(__linux__) && defined(_POSIX_SOURCE) && !ARCH_X86_64 -static void sigill_handler_sse( int signal, struct sigcontext sc ) -{ - mp_msg(MSGT_CPUDETECT,MSGL_V, "SIGILL, " ); - - /* Both the "xorps %%xmm0,%%xmm0" and "divps %xmm0,%%xmm1" - * instructions are 3 bytes long. We must increment the instruction - * pointer manually to avoid repeated execution of the offending - * instruction. - * - * If the SIGILL is caused by a divide-by-zero when unmasked - * exceptions aren't supported, the SIMD FPU status and control - * word will be restored at the end of the test, so we don't need - * to worry about doing it here. Besides, we may not be able to... - */ - sc.eip += 3; - - gCpuCaps.hasSSE=0; + dump_flag("MMX", c->hasMMX); + dump_flag("MMX2", c->hasMMX2); + dump_flag("SSE", c->hasSSE); + dump_flag("SSE2", c->hasSSE2); + dump_flag("SSE3", c->hasSSE3); + dump_flag("SSSE3", c->hasSSSE3); } -#endif /* __linux__ && _POSIX_SOURCE */ - -#if (defined(__MINGW32__) || defined(__CYGWIN__)) && !ARCH_X86_64 -LONG CALLBACK win32_sig_handler_sse(EXCEPTION_POINTERS* ep) -{ - if(ep->ExceptionRecord->ExceptionCode==EXCEPTION_ILLEGAL_INSTRUCTION){ - mp_msg(MSGT_CPUDETECT,MSGL_V, "SIGILL, " ); - ep->ContextRecord->Eip +=3; - gCpuCaps.hasSSE=0; - return EXCEPTION_CONTINUE_EXECUTION; - } - return EXCEPTION_CONTINUE_SEARCH; -} -#endif /* defined(__MINGW32__) || defined(__CYGWIN__) */ - -/* If we're running on a processor that can do SSE, let's see if we - * are allowed to or not. This will catch 2.4.0 or later kernels that - * haven't been configured for a Pentium III but are running on one, - * and RedHat patched 2.2 kernels that have broken exception handling - * support for user space apps that do SSE. - */ - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -#define SSE_SYSCTL_NAME "hw.instruction_sse" -#elif defined(__APPLE__) -#define SSE_SYSCTL_NAME "hw.optional.sse" -#endif - -static void check_os_katmai_support( void ) -{ -#if ARCH_X86_64 - gCpuCaps.hasSSE=1; - gCpuCaps.hasSSE2=1; -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__APPLE__) - int has_sse=0, ret; - size_t len=sizeof(has_sse); - - ret = sysctlbyname(SSE_SYSCTL_NAME, &has_sse, &len, NULL, 0); - if (ret || !has_sse) - gCpuCaps.hasSSE=0; - -#elif defined(__NetBSD__) || defined (__OpenBSD__) -#if __NetBSD_Version__ >= 105250000 || (defined __OpenBSD__) - int has_sse, has_sse2, ret, mib[2]; - size_t varlen; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_SSE; - varlen = sizeof(has_sse); - - mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); - ret = sysctl(mib, 2, &has_sse, &varlen, NULL, 0); - gCpuCaps.hasSSE = ret >= 0 && has_sse; - mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); - - mib[1] = CPU_SSE2; - varlen = sizeof(has_sse2); - mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE2... " ); - ret = sysctl(mib, 2, &has_sse2, &varlen, NULL, 0); - gCpuCaps.hasSSE2 = ret >= 0 && has_sse2; - mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE2 ? "yes.\n" : "no!\n" ); -#else - gCpuCaps.hasSSE = 0; - mp_msg(MSGT_CPUDETECT,MSGL_WARN, "No OS support for SSE, disabling to be safe.\n" ); -#endif -#elif defined(__MINGW32__) || defined(__CYGWIN__) - LPTOP_LEVEL_EXCEPTION_FILTER exc_fil; - if ( gCpuCaps.hasSSE ) { - mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); - exc_fil = SetUnhandledExceptionFilter(win32_sig_handler_sse); - __asm__ volatile ("xorps %xmm0, %xmm0"); - SetUnhandledExceptionFilter(exc_fil); - mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); - } -#elif defined(__linux__) -#if defined(_POSIX_SOURCE) - struct sigaction saved_sigill; - - /* Save the original signal handlers. - */ - sigaction( SIGILL, NULL, &saved_sigill ); - - signal( SIGILL, (void (*)(int))sigill_handler_sse ); - - /* Emulate test for OSFXSR in CR4. The OS will set this bit if it - * supports the extended FPU save and restore required for SSE. If - * we execute an SSE instruction on a PIII and get a SIGILL, the OS - * doesn't support Streaming SIMD Exceptions, even if the processor - * does. - */ - if ( gCpuCaps.hasSSE ) { - mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); - -// __asm__ volatile ("xorps %%xmm0, %%xmm0"); - __asm__ volatile ("xorps %xmm0, %xmm0"); - - mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); - } - - /* Restore the original signal handlers. - */ - sigaction( SIGILL, &saved_sigill, NULL ); - - /* If we've gotten to here and the XMM CPUID bit is still set, we're - * safe to go ahead and hook out the SSE code throughout Mesa. - */ - mp_msg(MSGT_CPUDETECT,MSGL_V, "Tests of OS support for SSE %s\n", gCpuCaps.hasSSE ? "passed." : "failed!" ); -#else - /* We can't use POSIX signal handling to test the availability of - * SSE, so we disable it by default. - */ - mp_msg(MSGT_CPUDETECT,MSGL_WARN, "Cannot test OS support for SSE, disabling to be safe.\n" ); - gCpuCaps.hasSSE=0; -#endif /* _POSIX_SOURCE */ -#else - /* Do nothing on other platforms for now. - */ - mp_msg(MSGT_CPUDETECT,MSGL_WARN, "Cannot test OS support for SSE, leaving disabled.\n" ); - gCpuCaps.hasSSE=0; -#endif /* __linux__ */ -} -#endif - - -// return TRUE if cpuid supported -static int has_cpuid(void) -{ -// code from libavcodec: -#if ARCH_X86_64 - return 1; -#else - long a, c; - __asm__ volatile ( - /* See if CPUID instruction is supported ... */ - /* ... Get copies of EFLAGS into eax and ecx */ - "pushfl\n\t" - "pop %0\n\t" - "mov %0, %1\n\t" - - /* ... Toggle the ID bit in one copy and store */ - /* to the EFLAGS reg */ - "xor $0x200000, %0\n\t" - "push %0\n\t" - "popfl\n\t" - - /* ... Get the (hopefully modified) EFLAGS */ - "pushfl\n\t" - "pop %0\n\t" - : "=a" (a), "=c" (c) - : - : "cc" - ); - - return a != c; -#endif -} - -void -do_cpuid(unsigned int ax, unsigned int *p) -{ -// code from libavcodec: - __asm__ volatile - ("mov %%"REG_b", %%"REG_S"\n\t" - "cpuid\n\t" - "xchg %%"REG_b", %%"REG_S - : "=a" (p[0]), "=S" (p[1]), - "=c" (p[2]), "=d" (p[3]) - : "0" (ax)); -} - -void GetCpuCaps( CpuCaps *caps) -{ - unsigned int regs[4]; - unsigned int regs2[4]; - - memset(caps, 0, sizeof(*caps)); - caps->isX86=1; - caps->cl_size=32; /* default */ - if (!has_cpuid()) { - mp_msg(MSGT_CPUDETECT,MSGL_WARN,"CPUID not supported!??? (maybe an old 486?)\n"); - return; - } - do_cpuid(0x00000000, regs); // get _max_ cpuid level and vendor name - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU vendor name: %.4s%.4s%.4s max cpuid level: %d\n", - (char*) (regs+1),(char*) (regs+3),(char*) (regs+2), regs[0]); - if (regs[0]>=0x00000001) - { - char *tmpstr, *ptmpstr; - unsigned cl_size; - - do_cpuid(0x00000001, regs2); - - caps->cpuType=(regs2[0] >> 8)&0xf; - caps->cpuModel=(regs2[0] >> 4)&0xf; - -// see AMD64 Architecture Programmer's Manual, Volume 3: General-purpose and -// System Instructions, Table 3-2: Effective family computation, page 120. - if(caps->cpuType==0xf){ - // use extended family (P4, IA64, K8) - caps->cpuType=0xf+((regs2[0]>>20)&255); - } - if(caps->cpuType==0xf || caps->cpuType==6) - caps->cpuModel |= ((regs2[0]>>16)&0xf) << 4; - - caps->cpuStepping=regs2[0] & 0xf; - - // general feature flags: - caps->hasTSC = (regs2[3] & (1 << 8 )) >> 8; // 0x0000010 - caps->hasMMX = (regs2[3] & (1 << 23 )) >> 23; // 0x0800000 - caps->hasSSE = (regs2[3] & (1 << 25 )) >> 25; // 0x2000000 - caps->hasSSE2 = (regs2[3] & (1 << 26 )) >> 26; // 0x4000000 - caps->hasSSE3 = (regs2[2] & 1); // 0x0000001 - caps->hasSSSE3 = (regs2[2] & (1 << 9 )) >> 9; // 0x0000200 - caps->hasMMX2 = caps->hasSSE; // SSE cpus supports mmxext too - cl_size = ((regs2[1] >> 8) & 0xFF)*8; - if(cl_size) caps->cl_size = cl_size; - - ptmpstr=tmpstr=GetCpuFriendlyName(regs, regs2); - while(*ptmpstr == ' ') // strip leading spaces - ptmpstr++; - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: %s ", ptmpstr); - free(tmpstr); - mp_msg(MSGT_CPUDETECT,MSGL_V,"(Family: %d, Model: %d, Stepping: %d)\n", - caps->cpuType, caps->cpuModel, caps->cpuStepping); - - } - do_cpuid(0x80000000, regs); - if (regs[0]>=0x80000001) { - mp_msg(MSGT_CPUDETECT,MSGL_V,"extended cpuid-level: %d\n",regs[0]&0x7FFFFFFF); - do_cpuid(0x80000001, regs2); - caps->hasMMX |= (regs2[3] & (1 << 23 )) >> 23; // 0x0800000 - caps->hasMMX2 |= (regs2[3] & (1 << 22 )) >> 22; // 0x400000 - caps->has3DNow = (regs2[3] & (1 << 31 )) >> 31; //0x80000000 - caps->has3DNowExt = (regs2[3] & (1 << 30 )) >> 30; - caps->hasSSE4a = (regs2[2] & (1 << 6 )) >> 6; // 0x0000040 - } - if(regs[0]>=0x80000006) - { - do_cpuid(0x80000006, regs2); - mp_msg(MSGT_CPUDETECT,MSGL_V,"extended cache-info: %d\n",regs2[2]&0x7FFFFFFF); - caps->cl_size = regs2[2] & 0xFF; - } - mp_msg(MSGT_CPUDETECT,MSGL_V,"Detected cache-line size is %u bytes\n",caps->cl_size); -#if 0 - mp_msg(MSGT_CPUDETECT,MSGL_INFO,"cpudetect: MMX=%d MMX2=%d SSE=%d SSE2=%d 3DNow=%d 3DNowExt=%d\n", - gCpuCaps.hasMMX, - gCpuCaps.hasMMX2, - gCpuCaps.hasSSE, - gCpuCaps.hasSSE2, - gCpuCaps.has3DNow, - gCpuCaps.has3DNowExt); -#endif - -#if CONFIG_RUNTIME_CPUDETECT - /* FIXME: Does SSE2 need more OS support, too? */ - if (caps->hasSSE) - check_os_katmai_support(); - if (!caps->hasSSE) - caps->hasSSE2 = 0; -// caps->has3DNow=1; -// caps->hasMMX2 = 0; -// caps->hasMMX = 0; - -#else -#if !HAVE_MMX - if(caps->hasMMX) mp_msg(MSGT_CPUDETECT,MSGL_WARN,"MMX supported but disabled\n"); - caps->hasMMX=0; -#endif -#if !HAVE_MMX2 - if(caps->hasMMX2) mp_msg(MSGT_CPUDETECT,MSGL_WARN,"MMX2 supported but disabled\n"); - caps->hasMMX2=0; -#endif -#if !HAVE_SSE - if(caps->hasSSE) mp_msg(MSGT_CPUDETECT,MSGL_WARN,"SSE supported but disabled\n"); - caps->hasSSE=0; -#endif -#if !HAVE_SSE2 - if(caps->hasSSE2) mp_msg(MSGT_CPUDETECT,MSGL_WARN,"SSE2 supported but disabled\n"); - caps->hasSSE2=0; -#endif -#if !HAVE_AMD3DNOW - if(caps->has3DNow) mp_msg(MSGT_CPUDETECT,MSGL_WARN,"3DNow supported but disabled\n"); - caps->has3DNow=0; -#endif -#if !HAVE_AMD3DNOWEXT - if(caps->has3DNowExt) mp_msg(MSGT_CPUDETECT,MSGL_WARN,"3DNowExt supported but disabled\n"); - caps->has3DNowExt=0; -#endif -#endif // CONFIG_RUNTIME_CPUDETECT -} - -char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){ - char vendor[13]; - char *retname; - int i; - - if (NULL==(retname=malloc(256))) { - mp_msg(MSGT_CPUDETECT,MSGL_FATAL,"Error: GetCpuFriendlyName() not enough memory\n"); - exit(1); - } - retname[0] = '\0'; - - sprintf(vendor,"%.4s%.4s%.4s",(char*)(regs+1),(char*)(regs+3),(char*)(regs+2)); - - do_cpuid(0x80000000,regs); - if (regs[0] >= 0x80000004) - { - // CPU has built-in namestring - for (i = 0x80000002; i <= 0x80000004; i++) - { - do_cpuid(i, regs); - strncat(retname, (char*)regs, 16); - } - } - return retname; -} - -#else /* ARCH_X86 */ - -#ifdef __APPLE__ -#include -#elif defined(__AMIGAOS4__) -/* nothing */ -#else -#include -#include - -static sigjmp_buf jmpbuf; -static volatile sig_atomic_t canjump = 0; - -static void sigill_handler (int sig) -{ - if (!canjump) { - signal (sig, SIG_DFL); - raise (sig); - } - - canjump = 0; - siglongjmp (jmpbuf, 1); -} -#endif /* __APPLE__ */ - -void GetCpuCaps( CpuCaps *caps) -{ - caps->cpuType=0; - caps->cpuModel=0; - caps->cpuStepping=0; - caps->hasMMX=0; - caps->hasMMX2=0; - caps->has3DNow=0; - caps->has3DNowExt=0; - caps->hasSSE=0; - caps->hasSSE2=0; - caps->hasSSE3=0; - caps->hasSSSE3=0; - caps->hasSSE4a=0; - caps->isX86=0; - caps->hasAltiVec = 0; -#if HAVE_ALTIVEC -#ifdef __APPLE__ -/* - rip-off from ffmpeg altivec detection code. - this code also appears on Apple's AltiVec pages. - */ - { - int sels[2] = {CTL_HW, HW_VECTORUNIT}; - int has_vu = 0; - size_t len = sizeof(has_vu); - int err; - - err = sysctl(sels, 2, &has_vu, &len, NULL, 0); - - if (err == 0) - if (has_vu != 0) - caps->hasAltiVec = 1; - } -#elif defined(__AMIGAOS4__) - ULONG result = 0; - - GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); - if (result == VECTORTYPE_ALTIVEC) - caps->hasAltiVec = 1; -#else -/* no Darwin, do it the brute-force way */ -/* this is borrowed from the libmpeg2 library */ - { - signal (SIGILL, sigill_handler); - if (sigsetjmp (jmpbuf, 1)) { - signal (SIGILL, SIG_DFL); - } else { - canjump = 1; - - __asm__ volatile ("mtspr 256, %0\n\t" - "vand %%v0, %%v0, %%v0" - : - : "r" (-1)); - - signal (SIGILL, SIG_DFL); - caps->hasAltiVec = 1; - } - } -#endif /* __APPLE__ */ - mp_msg(MSGT_CPUDETECT,MSGL_V,"AltiVec %sfound\n", (caps->hasAltiVec ? "" : "not ")); -#endif /* HAVE_ALTIVEC */ - - if (ARCH_IA64) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: Intel Itanium\n"); - - if (ARCH_SPARC) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: Sun Sparc\n"); - - if (ARCH_ARM) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: ARM\n"); - - if (ARCH_PPC) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: PowerPC\n"); - - if (ARCH_ALPHA) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: Digital Alpha\n"); - - if (ARCH_MIPS) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: MIPS\n"); - - if (ARCH_PA_RISC) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: Hewlett-Packard PA-RISC\n"); - - if (ARCH_S390) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: IBM S/390\n"); - - if (ARCH_S390X) - mp_msg(MSGT_CPUDETECT,MSGL_V,"CPU: IBM S/390X\n"); - - if (ARCH_VAX) - mp_msg(MSGT_CPUDETECT,MSGL_V, "CPU: Digital VAX\n" ); - - if (ARCH_XTENSA) - mp_msg(MSGT_CPUDETECT,MSGL_V, "CPU: Tensilica Xtensa\n" ); -} -#endif /* !ARCH_X86 */ diff --git a/cpudetect.h b/cpudetect.h index 5ff6c5a78b..51fd7bc50d 100644 --- a/cpudetect.h +++ b/cpudetect.h @@ -19,6 +19,7 @@ #ifndef MPLAYER_CPUDETECT_H #define MPLAYER_CPUDETECT_H +#include #include "config.h" #define CPUTYPE_I386 3 @@ -30,21 +31,16 @@ typedef struct cpucaps_s { int cpuType; - int cpuModel; int cpuStepping; - int hasMMX; - int hasMMX2; - int has3DNow; - int has3DNowExt; - int hasSSE; - int hasSSE2; - int hasSSE3; - int hasSSSE3; - int hasSSE4a; - int isX86; - unsigned cl_size; /* size of cache line */ - int hasAltiVec; - int hasTSC; + bool isX86; + bool hasMMX; + bool hasMMX2; + bool has3DNow; + bool has3DNowExt; + bool hasSSE; + bool hasSSE2; + bool hasSSE3; + bool hasSSSE3; } CpuCaps; extern CpuCaps gCpuCaps; diff --git a/libaf/af_format.c b/libaf/af_format.c index 729b964726..5cee93442c 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "config.h" #include "af.h" @@ -334,7 +335,7 @@ af_info_t af_info_format = { }; static inline uint32_t load24bit(void* data, int pos) { -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN return (((uint32_t)((uint8_t*)data)[3*pos])<<24) | (((uint32_t)((uint8_t*)data)[3*pos+1])<<16) | (((uint32_t)((uint8_t*)data)[3*pos+2])<<8); @@ -346,7 +347,7 @@ static inline uint32_t load24bit(void* data, int pos) { } static inline void store24bit(void* data, int pos, uint32_t expanded_value) { -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN ((uint8_t*)data)[3*pos]=expanded_value>>24; ((uint8_t*)data)[3*pos+1]=expanded_value>>16; ((uint8_t*)data)[3*pos+2]=expanded_value>>8; diff --git a/libaf/af_format.h b/libaf/af_format.h index 5f194c1365..73e4c88c3e 100644 --- a/libaf/af_format.h +++ b/libaf/af_format.h @@ -23,6 +23,7 @@ #ifndef MPLAYER_AF_FORMAT_H #define MPLAYER_AF_FORMAT_H +#include #include "config.h" // Endianness @@ -30,7 +31,7 @@ #define AF_FORMAT_LE (1<<0) // Little Endian #define AF_FORMAT_END_MASK (1<<0) -#if HAVE_BIGENDIAN // Native endian of cpu +#if BYTE_ORDER == BIG_ENDIAN #define AF_FORMAT_NE AF_FORMAT_BE #else #define AF_FORMAT_NE AF_FORMAT_LE @@ -86,7 +87,7 @@ #define AF_FORMAT_AC3_LE (AF_FORMAT_AC3|AF_FORMAT_16BIT|AF_FORMAT_LE) #define AF_FORMAT_AC3_BE (AF_FORMAT_AC3|AF_FORMAT_16BIT|AF_FORMAT_BE) -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define AF_FORMAT_U16_NE AF_FORMAT_U16_BE #define AF_FORMAT_S16_NE AF_FORMAT_S16_BE #define AF_FORMAT_U24_NE AF_FORMAT_U24_BE diff --git a/libao2/ao_coreaudio.c b/libao2/ao_coreaudio.c index d1a93c85e2..ff077b81b6 100644 --- a/libao2/ao_coreaudio.c +++ b/libao2/ao_coreaudio.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "config.h" #include "mp_msg.h" @@ -820,7 +821,7 @@ static int OpenSPDIF(void) /* FIXME: If output stream is not native byte-order, we need change endian somewhere. */ /* Although there's no such case reported. */ -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN if (!(ao->stream_format.mFormatFlags & kAudioFormatFlagIsBigEndian)) #else /* tell mplayer that we need a byteswap on AC3 streams, */ diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c index 9290a73380..99f68d6d2c 100644 --- a/libao2/ao_oss.c +++ b/libao2/ao_oss.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "config.h" #include "mp_msg.h" @@ -320,7 +321,7 @@ ac3_retry: ao_data.format=format; oss_format=format2oss(format); if (oss_format == -1) { -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN oss_format=AFMT_S16_BE; #else oss_format=AFMT_S16_LE; diff --git a/libmpcodecs/ad_hwac3.c b/libmpcodecs/ad_hwac3.c index a11c2c90e7..13bf1da704 100644 --- a/libmpcodecs/ad_hwac3.c +++ b/libmpcodecs/ad_hwac3.c @@ -20,11 +20,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define _GNU_SOURCE #define _XOPEN_SOURCE 600 #include #include #include #include +#include #include #include @@ -551,7 +553,7 @@ static int decode_audio_dts(unsigned char *indata_ptr, int len, unsigned char *b buf16[3] = fsize << 3; if (!convert_16bits) { -#if HAVE_BIGENDIAN +#ifdef BIG_ENDIAN /* BE stream */ if (indata_ptr[0] == 0x1f || indata_ptr[0] == 0x7f) #else diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c index dd277fd20a..e6f0a7e7f7 100644 --- a/libmpcodecs/ad_liba52.c +++ b/libmpcodecs/ad_liba52.c @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#define _GNU_SOURCE #define _XOPEN_SOURCE 600 #include #include @@ -191,9 +192,6 @@ static int init(sh_audio_t *sh_audio) if(gCpuCaps.has3DNow) a52_accel|=MM_ACCEL_X86_3DNOW; #ifdef MM_ACCEL_X86_3DNOWEXT if(gCpuCaps.has3DNowExt) a52_accel|=MM_ACCEL_X86_3DNOWEXT; -#endif -#ifdef MM_ACCEL_PPC_ALTIVEC - if(gCpuCaps.hasAltiVec) a52_accel|=MM_ACCEL_PPC_ALTIVEC; #endif a52_state=a52_init (a52_accel); if (a52_state == NULL) { diff --git a/libmpcodecs/img_format.h b/libmpcodecs/img_format.h index 4200282f98..a0a1c453c7 100644 --- a/libmpcodecs/img_format.h +++ b/libmpcodecs/img_format.h @@ -19,6 +19,7 @@ #ifndef MPLAYER_IMG_FORMAT_H #define MPLAYER_IMG_FORMAT_H +#include #include "config.h" /* RGB/BGR Formats */ @@ -51,7 +52,7 @@ #define IMGFMT_GBRP (('G'<<24)|('B'<<16)|('R'<<8)|24) -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define IMGFMT_ABGR IMGFMT_RGB32 #define IMGFMT_BGRA (IMGFMT_RGB32|64) #define IMGFMT_ARGB IMGFMT_BGR32 @@ -139,7 +140,7 @@ #define IMGFMT_420P10_BE 0x34323052 #define IMGFMT_420P9_LE 0x53303234 #define IMGFMT_420P9_BE 0x34323053 -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define IMGFMT_444P16 IMGFMT_444P16_BE #define IMGFMT_444P10 IMGFMT_444P10_BE #define IMGFMT_444P9 IMGFMT_444P9_BE diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index b49b3c6975..f51fdb4601 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -773,7 +774,7 @@ static struct mp_image *decode(struct sh_video *sh, struct demux_packet *packet, mpi->stride[2] *= 2; } -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN // FIXME: this might cause problems for buffers with FF_BUFFER_HINTS_PRESERVE if (mpi->bpp == 8) swap_palette(mpi->planes[1]); diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 7a774be741..10e6f4d177 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "config.h" #if HAVE_MALLOC_H @@ -254,7 +255,7 @@ void vf_mpi_clear(mp_image_t *mpi, int x0, int y0, int w, int h) unsigned int *p = (unsigned int *) dst; int size = (mpi->bpp >> 3) * w / 4; int i; -#if HAVE_BIGENDIAN +#ifdef BIG_ENDIAN #define CLEAR_PACKEDYUV_PATTERN 0x00800080 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000 #else diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c index 4ccef63054..2d56840fd5 100644 --- a/libmpcodecs/vf_scale.c +++ b/libmpcodecs/vf_scale.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "config.h" #include "mp_msg.h" @@ -405,7 +406,7 @@ static void start_slice(struct vf_instance *vf, mp_image_t *mpi){ static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src[MP_MAX_PLANES], int src_stride[MP_MAX_PLANES], int y, int h, uint8_t *dst[MP_MAX_PLANES], int dst_stride[MP_MAX_PLANES], int interlaced){ const uint8_t *src2[MP_MAX_PLANES]={src[0], src[1], src[2], src[3]}; -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN uint32_t pal2[256]; if (src[1] && !src[2]){ int i; @@ -661,8 +662,7 @@ int get_sws_cpuflags(void){ return (gCpuCaps.hasMMX ? SWS_CPU_CAPS_MMX : 0) | (gCpuCaps.hasMMX2 ? SWS_CPU_CAPS_MMX2 : 0) - | (gCpuCaps.has3DNow ? SWS_CPU_CAPS_3DNOW : 0) - | (gCpuCaps.hasAltiVec ? SWS_CPU_CAPS_ALTIVEC : 0); + | (gCpuCaps.has3DNow ? SWS_CPU_CAPS_3DNOW : 0); } void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam) diff --git a/libmpdemux/asf.h b/libmpdemux/asf.h index a2bf546fd1..ba1eff6e7f 100644 --- a/libmpdemux/asf.h +++ b/libmpdemux/asf.h @@ -19,7 +19,7 @@ #ifndef MPLAYER_ASF_H #define MPLAYER_ASF_H -//#include "config.h" /* for HAVE_BIGENDIAN */ +#include #include #include "libavutil/common.h" #include "mpbswap.h" @@ -105,7 +105,7 @@ typedef struct __attribute__((packed)) { } ASF_stream_chunck_t; // Definition of the stream type -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define ASF_STREAMING_CLEAR 0x2443 // $C #define ASF_STREAMING_DATA 0x2444 // $D #define ASF_STREAMING_END_TRANS 0x2445 // $E @@ -140,7 +140,7 @@ typedef struct { * Some macros to swap little endian structures read from an ASF file * into machine endian format */ -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define le2me_ASF_obj_header_t(h) { \ (h)->size = le2me_64((h)->size); \ } diff --git a/libmpdemux/aviheader.h b/libmpdemux/aviheader.h index 8d226606de..a65ee15392 100644 --- a/libmpdemux/aviheader.h +++ b/libmpdemux/aviheader.h @@ -21,7 +21,8 @@ #include #include -#include "config.h" /* get correct definition of HAVE_BIGENDIAN */ +#include +#include "config.h" #include "libavutil/common.h" #include "mpbswap.h" @@ -229,7 +230,7 @@ typedef enum { * Some macros to swap little endian structures read from an AVI file * into machine endian format */ -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define le2me_MainAVIHeader(h) { \ (h)->dwMicroSecPerFrame = le2me_32((h)->dwMicroSecPerFrame); \ (h)->dwMaxBytesPerSec = le2me_32((h)->dwMaxBytesPerSec); \ diff --git a/libmpdemux/ms_hdr.h b/libmpdemux/ms_hdr.h index 3d6bc07545..5b5dff6008 100644 --- a/libmpdemux/ms_hdr.h +++ b/libmpdemux/ms_hdr.h @@ -19,6 +19,7 @@ #ifndef MPLAYER_MS_HDR_H #define MPLAYER_MS_HDR_H +#include #include "config.h" #ifndef _WAVEFORMATEX_ @@ -81,7 +82,7 @@ typedef struct { #endif #ifndef le2me_BITMAPINFOHEADER -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define le2me_BITMAPINFOHEADER(h) { \ (h)->biSize = le2me_32((h)->biSize); \ (h)->biWidth = le2me_32((h)->biWidth); \ diff --git a/libvo/osd.c b/libvo/osd.c index 992ffc01f3..08cda11a81 100644 --- a/libvo/osd.c +++ b/libvo/osd.c @@ -27,6 +27,7 @@ #include "osd.h" #include "mp_msg.h" #include +#include #include "cpudetect.h" #if ARCH_X86 @@ -35,6 +36,8 @@ static const unsigned long long mask24lh __attribute__((aligned(8))) = 0xFFFF00 static const unsigned long long mask24hl __attribute__((aligned(8))) = 0x0000FFFFFFFFFFFFULL; #endif +#define CONFIG_RUNTIME_CPUDETECT 1 + //Note: we have C, X86-nommx, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one //Plain C versions #if !HAVE_MMX || CONFIG_RUNTIME_CPUDETECT diff --git a/libvo/osd_template.c b/libvo/osd_template.c index 6d8305a3c5..103d169b32 100644 --- a/libvo/osd_template.c +++ b/libvo/osd_template.c @@ -320,7 +320,7 @@ static inline void RENAME(vo_draw_alpha_rgb24)(int w,int h, unsigned char* src, static inline void RENAME(vo_draw_alpha_rgb32)(int w,int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dstbase,int dststride){ int y; -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN dstbase++; #endif #if HAVE_MMX diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c index 9be47c9d8a..3b264b232c 100644 --- a/libvo/vo_x11.c +++ b/libvo/vo_x11.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "config.h" #include "video_out.h" @@ -261,7 +262,7 @@ static void freeMyXImage(void) ImageData = NULL; } -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN #define BO_NATIVE MSBFirst #define BO_NONNATIVE LSBFirst #else @@ -431,7 +432,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, // we can easily "emulate" them. if (out_format & 64 && (IMGFMT_IS_RGB(out_format) || IMGFMT_IS_BGR(out_format))) { out_format &= ~64; -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN out_offset = 1; #else out_offset = -1; diff --git a/loader/win32.c b/loader/win32.c index fb7f48b09e..33d3303ea6 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -133,6 +133,19 @@ static void (*longcount)(long long*)=longcount_stub; static pthread_mutex_t memmut = PTHREAD_MUTEX_INITIALIZER; + +static void do_cpuid(unsigned int ax, unsigned int *p) +{ +// code from libavcodec: + __asm__ volatile + ("mov %%"REG_b", %%"REG_S"\n\t" + "cpuid\n\t" + "xchg %%"REG_b", %%"REG_S + : "=a" (p[0]), "=S" (p[1]), + "=c" (p[2]), "=d" (p[3]) + : "0" (ax)); +} + static unsigned int localcount_stub(void) { unsigned int regs[4]; @@ -1000,7 +1013,6 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si) /* mplayer's way to detect PF's */ { -#include "cpudetect.h" if (gCpuCaps.hasMMX) PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE; @@ -1011,22 +1023,8 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si) if (gCpuCaps.has3DNow) PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE; - if (gCpuCaps.cpuType == 4) - { - cachedsi.dwProcessorType = PROCESSOR_INTEL_486; - cachedsi.wProcessorLevel = 4; - } - else if (gCpuCaps.cpuType >= 5) - { cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM; cachedsi.wProcessorLevel = 5; - } - else - { - cachedsi.dwProcessorType = PROCESSOR_INTEL_386; - cachedsi.wProcessorLevel = 3; - } - cachedsi.wProcessorRevision = gCpuCaps.cpuStepping; cachedsi.dwNumberOfProcessors = 1; /* hardcoded */ } diff --git a/mplayer.c b/mplayer.c index edf7d85be8..20cb1aae7c 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3822,35 +3822,6 @@ static void print_version(void) /* Test for CPU capabilities (and corresponding OS support) for optimizing */ GetCpuCaps(&gCpuCaps); -#if ARCH_X86 - mp_msg(MSGT_CPLAYER, MSGL_V, - "CPUflags: MMX: %d MMX2: %d 3DNow: %d 3DNowExt: %d SSE: %d SSE2: %d SSSE3: %d\n", - gCpuCaps.hasMMX, gCpuCaps.hasMMX2, - gCpuCaps.has3DNow, gCpuCaps.has3DNowExt, - gCpuCaps.hasSSE, gCpuCaps.hasSSE2, gCpuCaps.hasSSSE3); -#if CONFIG_RUNTIME_CPUDETECT - mp_tmsg(MSGT_CPLAYER, MSGL_V, "Compiled with runtime CPU detection.\n"); -#else - mp_tmsg(MSGT_CPLAYER, MSGL_V, "Compiled for x86 CPU with extensions:"); - if (HAVE_MMX) - mp_msg(MSGT_CPLAYER, MSGL_V, " MMX"); - if (HAVE_MMX2) - mp_msg(MSGT_CPLAYER, MSGL_V, " MMX2"); - if (HAVE_AMD3DNOW) - mp_msg(MSGT_CPLAYER, MSGL_V, " 3DNow"); - if (HAVE_AMD3DNOWEXT) - mp_msg(MSGT_CPLAYER, MSGL_V, " 3DNowExt"); - if (HAVE_SSE) - mp_msg(MSGT_CPLAYER, MSGL_V, " SSE"); - if (HAVE_SSE2) - mp_msg(MSGT_CPLAYER, MSGL_V, " SSE2"); - if (HAVE_SSSE3) - mp_msg(MSGT_CPLAYER, MSGL_V, " SSSE3"); - if (HAVE_CMOV) - mp_msg(MSGT_CPLAYER, MSGL_V, " CMOV"); - mp_msg(MSGT_CPLAYER, MSGL_V, "\n"); -#endif /* CONFIG_RUNTIME_CPUDETECT */ -#endif /* ARCH_X86 */ print_libav_versions(); } diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 0fcd3dbc9b..5a11e051ab 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "talloc.h" @@ -177,7 +178,7 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len) if (!buf) return 0; -#if HAVE_BIGENDIAN +#if BYTE_ORDER == BIG_ENDIAN for (i = 0; i < CDIO_CD_FRAMESIZE_RAW / 2; i++) buf[i] = le2me_16(buf[i]); #endif