From dd43a54b4c7ea0576b74c7e181183071b397ab73 Mon Sep 17 00:00:00 2001 From: waker Date: Sat, 29 Aug 2009 23:40:26 +0200 Subject: added sse2 detection for optmath.h --- Makefile.am | 2 +- acinclude.m4 | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 2 + optmath.h | 2 + 4 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 acinclude.m4 diff --git a/Makefile.am b/Makefile.am index eb25a581..930e6ef4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,7 +36,7 @@ sdk_HEADERS = deadbeef.h deadbeef_LDADD = $(LDADD) $(DEPS_LIBS) gme/Game_Music_Emu-0.5.2/gme/libgme.a sid/sidplay-libs-2.1.0/libsidplay2.a dumb/libdumb.a -AM_CFLAGS = $(DEPS_CFLAGS) -I$(gmepath) -std=c99 -msse2 +AM_CFLAGS = $(DEPS_CFLAGS) $(SIMD_FLAGS) -I$(gmepath) -std=c99 AM_CPPFLAGS = $(DEPS_CFLAGS) -I$(sidpath)/libsidplay/include -I$(sidpath)/builders/resid-builder/include docsdir = $(datadir)/doc/$(PACKAGE) diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 00000000..ef47c978 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,149 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_check_compiler_flags.html +# =========================================================================== +# +# +# COPYLEFT +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Matteo Frigo +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# + +AC_DEFUN([AX_CHECK_COMPILER_FLAGS], +[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX +AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1]) +dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname: +AS_LITERAL_IF([$1], + [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [ + ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], + AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes, + AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no) + _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])], + [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], + eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes, + eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no) + _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS]) +eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1) +AC_MSG_RESULT($ax_check_compiler_flags) +if test "x$ax_check_compiler_flags" = xyes; then + m4_default([$2], :) +else + m4_default([$3], :) +fi +])dnl AX_CHECK_COMPILER_FLAGS + + + +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_gcc_x86_cpuid.html +# =========================================================================== +# +# +# COPYLEFT +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2008 Matteo Frigo +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# + + +AC_DEFUN([AX_GCC_X86_CPUID], +[AC_REQUIRE([AC_PROG_CC]) +AC_LANG_PUSH([C]) +AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1, + [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [ + int op = $1, eax, ebx, ecx, edx; + FILE *f; + /* 64-bit code is easy */ + if (sizeof(long) == 8) { + __asm__("cpuid" + : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) + : "a" (op)); + } else { + __asm__("pushl %%ebx \n\t" + "cpuid \n\t" + "movl %%ebx, %1 \n\t" + "popl %%ebx \n\t" + : "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx) + : "a" (op)); + } + f = fopen("conftest_cpuid", "w"); if (!f) return 1; + fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx); + fclose(f); + return 0; +])], + [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid], + [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid], + [ax_cv_gcc_x86_cpuid_$1=unknown])]) +AC_LANG_POP([C]) +]) + + + +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_ext.html +# =========================================================================== +# +# +# COPYLEFT +# +# Copyright (c) 2008 Christophe Tournayre +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. + +AC_DEFUN([AX_EXT], +[ + #AC_REQUIRE([AX_GCC_X86_CPUID]) + + AX_GCC_X86_CPUID(0x00000001) + ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3` + edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4` + + + AC_CACHE_CHECK([whether sse2 is supported], [ax_have_sse2_ext], + [ + ax_have_sse2_ext=no + if test "$((0x$edx>>26&0x01))" = 1; then + ax_have_sse2_ext=yes + fi + ]) + + if test "$ax_have_sse2_ext" = yes; then + AC_DEFINE(HAVE_SSE2, , [Support SSE2 (Streaming SIMD Extensions 2) instructions]) + AX_CHECK_COMPILER_FLAGS(-msse2, SIMD_FLAGS="$SIMD_FLAGS -msse2", []) + fi + + AC_SUBST(SIMD_FLAGS) +]) + diff --git a/configure.in b/configure.in index 23c482b3..b98b80e4 100644 --- a/configure.in +++ b/configure.in @@ -29,6 +29,8 @@ CPPFLAGS="$CFLAGS" PKG_CHECK_MODULES(DEPS, gtk+-2.0 gthread-2.0 glib-2.0 vorbis vorbisfile mad samplerate alsa) PKG_CHECK_MODULES(LASTFM_DEPS, libcurl) +AX_EXT() + AC_CHECK_LIB([FLAC], [main],,AC_MSG_ERROR([flac not found])) AC_SUBST(DEPS_CFLAGS) AC_SUBST(DEPS_LIBS) diff --git a/optmath.h b/optmath.h index 54271cee..74ebbb38 100644 --- a/optmath.h +++ b/optmath.h @@ -19,7 +19,9 @@ #ifndef __OPTMATH_H #define __OPTMATH_H +#ifdef __SSE2__ // that comes from -msse2 #define __FORCE_SSE2__ +#endif // some maths // taken from vorbis/lib/os.h, (C) 1994-2007 Xiph.Org Foundation http://www.xiph.org/ -- cgit v1.2.3