Commit 9a263bb9 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh

revised tests for AltiVec. Define ALTIVEC_EXTRA_CFLAGS for the extra

2003-03-06  Manish Singh  <yosh@gimp.org>

        * configure.in: revised tests for AltiVec. Define ALTIVEC_EXTRA_CFLAGS
        for the extra compiler options needed. Also, support runtime checking
        for AltiVec through the sysctl on Mac OS X, instead of SIGILL assembly
        instruction checking, which needs GNU as.

        * app/base/cpu_accel.c: use the sysctl if available.

        * app/composite/Makefile.am: use ALTIVEC_EXTRA_CFLAGS.

        * app/composite/gimp-composite-altivec.c: conditionally #include
        altivec.h
parent ef6c61fb
2003-03-06 Manish Singh <yosh@gimp.org>
* configure.in: revised tests for AltiVec. Define ALTIVEC_EXTRA_CFLAGS
for the extra compiler options needed. Also, support runtime checking
for AltiVec through the sysctl on Mac OS X, instead of SIGILL assembly
instruction checking, which needs GNU as.
* app/base/cpu_accel.c: use the sysctl if available.
* app/composite/Makefile.am: use ALTIVEC_EXTRA_CFLAGS.
* app/composite/gimp-composite-altivec.c: conditionally #include
altivec.h
2005-03-05 Helvetix Victorinox <helvetix@gimp.org>
* app/composite/gimp-composite-altivec.[ch]
......
......@@ -361,7 +361,31 @@ arch_accel (void)
#endif /* ARCH_X86 && USE_MMX && __GNUC__ */
#if defined (ARCH_PPC) && defined (USE_ALTIVEC) && defined(__GNUC__)
#if defined(ARCH_PPC) && defined (USE_ALTIVEC)
#if defined(HAVE_ALTIVEC_SYSCTL)
#include <sys/sysctl.h>
#define HAVE_ACCEL 1
static guint32
arch_accel (void)
{
gint sels[2] = { CTL_HW, HW_VECTORUNIT };
gboolean has_vu = FALSE;
gsize length = sizeof(has_vu);
gint err;
err = sysctl (sels, 2, &has_vu, &length, NULL, 0);
if (err == 0 && has_vu)
return CPU_ACCEL_PPC_ALTIVEC;
return 0;
}
#elif defined(__GNUC__)
#define HAVE_ACCEL 1
......@@ -403,8 +427,9 @@ arch_accel (void)
return CPU_ACCEL_PPC_ALTIVEC;
}
#endif /* __GNUC__ */
#endif /* ARCH_PPC && USE_ALTIVEC && __GNUC__ */
#endif /* ARCH_PPC && USE_ALTIVEC */
guint32
......
......@@ -4,6 +4,7 @@ libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Composite\" \
$(ALTIVEC_EXTRA_CFLAGS) \
@GTHREAD_CFLAGS@
AM_CCASFLAGS = \
......
......@@ -32,7 +32,10 @@
#include "gimp-composite-altivec.h"
#ifdef COMPILE_ALTIVEC_IS_OKAY
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
#endif
const vector unsigned char alphamask={0,0,0,0xff,0,0,0,0xff,0,0,0,0xff,0,0,0,0xff};
......
......@@ -605,26 +605,64 @@ fi
############################
# Check for Altivec assembly
# Check for AltiVec assembly
############################
AC_ARG_ENABLE(altivec,
[ --enable-altivec enable Altivec support (default=auto)],,
[ --enable-altivec enable AltiVec support (default=auto)],,
enable_altivec=$have_ppc)
if test "x$enable_altivec" = xyes; then
ALTIVEC_EXTRA_CFLAGS=
for flag in '-faltivec' '-maltivec -mabi=altivec'; do
if test -z "$ALTIVEC_EXTRA_CFLAGS"; then
altivec_save_CFLAGS="$CFLAGS"
CFLAGS="$altivec_save_CFLAGS $flag"
AC_MSG_CHECKING([whether [$]CC understands [$]flag])
AC_TRY_COMPILE([], [], [altivec_flag_works=yes], [altivec_flag_works=no])
AC_MSG_RESULT($altivec_flag_works)
CFLAGS="$altivec_save_CFLAGS"
if test "x$altivec_flag_works" = "xyes"; then
ALTIVEC_EXTRA_CFLAGS="$flag"
fi
fi
done
AC_SUBST(ALTIVEC_EXTRA_CFLAGS)
AC_MSG_CHECKING(whether we can compile Altivec code)
AC_MSG_CHECKING(whether we can compile AltiVec code)
AC_COMPILE_IFELSE([asm ("vand %v0, %v0, %v0");],
AC_DEFINE(USE_ALTIVEC, 1, [Define to 1 if Altivec assembly is available.])
AC_MSG_RESULT(yes)
,
if test -z "$ALTIVEC_EXTRA_CFLAGS"; then
enable_altivec=no
AC_MSG_WARN([The compiler does not support the AltiVec command set.])
AC_MSG_RESULT(no)
AC_MSG_WARN([The assembler does not support the Altivec command set.])
)
else
can_use_altivec=no
case "$target_or_host" in
*-*-darwin*)
can_use_altivec=yes
AC_DEFINE(HAVE_ALTIVEC_SYSCTL, 1,
[Define to 1 if the altivec runtime test should use a sysctl.])
;;
*)
AC_COMPILE_IFELSE([asm ("vand %v0, %v0, %v0");],
can_use_altivec=yes, can_use_altivec=no)
;;
esac
AC_MSG_RESULT($can_use_altivec)
if test "x$can_use_altivec" = "xyes"; then
AC_DEFINE(USE_ALTIVEC, 1, [Define to 1 if AltiVec support is available.])
altivec_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$altivec_save_CPPFLAGS $ALTIVEC_EXTRA_CFLAGS"
AC_CHECK_HEADERS(altivec.h)
CPPFLAGS="$altivec_save_CPPFLAGS"
else
enable_altivec=no
AC_MSG_WARN([The assembler does not support the AltiVec command set.])
fi
fi
fi
......@@ -633,8 +671,8 @@ fi
###################################
dnl MacOS X has broken SysV shm
case "$host_os" in
darwin* | rhapsody* | machten*)
case "$target_or_host" in
*-*-darwin* | *-*-rhapsody* | *-*-machten*)
shmdefault=posix
;;
*)
......
......@@ -361,7 +361,31 @@ arch_accel (void)
#endif /* ARCH_X86 && USE_MMX && __GNUC__ */
#if defined (ARCH_PPC) && defined (USE_ALTIVEC) && defined(__GNUC__)
#if defined(ARCH_PPC) && defined (USE_ALTIVEC)
#if defined(HAVE_ALTIVEC_SYSCTL)
#include <sys/sysctl.h>
#define HAVE_ACCEL 1
static guint32
arch_accel (void)
{
gint sels[2] = { CTL_HW, HW_VECTORUNIT };
gboolean has_vu = FALSE;
gsize length = sizeof(has_vu);
gint err;
err = sysctl (sels, 2, &has_vu, &length, NULL, 0);
if (err == 0 && has_vu)
return CPU_ACCEL_PPC_ALTIVEC;
return 0;
}
#elif defined(__GNUC__)
#define HAVE_ACCEL 1
......@@ -403,8 +427,9 @@ arch_accel (void)
return CPU_ACCEL_PPC_ALTIVEC;
}
#endif /* __GNUC__ */
#endif /* ARCH_PPC && USE_ALTIVEC && __GNUC__ */
#endif /* ARCH_PPC && USE_ALTIVEC */
guint32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment