[Pixman] optimize for gaussian blur

2012-06-29 Thread Henry (Yu) Song - SISA
Hi, All

New to pixman.  There is a convolution filter in pixman, wondering if there is 
any optimization for Gaussian blur instead of generic convolution blur in 
pixman?

Thanks

Henry
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [ANNOUNCE] pixman release 0.26.2 now available

2012-06-29 Thread Matt Turner
A new pixman release 0.26.2 is now available. This is a stable release. It
contains some bug fixes, custom build rules for ARM/iwMMXt, and an important
bug fix for MMX/x86.

tar.gz:
http://cairographics.org/releases/pixman-0.26.2.tar.gz
http://xorg.freedesktop.org/archive/individual/lib/pixman-0.26.2.tar.gz

tar.bz2:
http://xorg.freedesktop.org/archive/individual/lib/pixman-0.26.2.tar.bz2

Hashes:
MD5:  69af3cf4ce6515ee01b0960edf8009fb  pixman-0.26.2.tar.gz
MD5:  2b57fb3038be4890ec433d11176280cd  pixman-0.26.2.tar.bz2
SHA1: ba71d029d174aa8b9d23b1072ab76e6b4ea3de59  pixman-0.26.2.tar.gz
SHA1: c7cdb5803061ee6614acc66258b0339ad4e52314  pixman-0.26.2.tar.bz2

GPG signature:
http://cairographics.org/releases/pixman-0.26.2.tar.gz.sha1.asc
(signed by Matt Turner matts...@gmail.com)

Git:
git://git.freedesktop.org/git/pixman
tag: pixman-0.26.2

Log:
Matt Turner (6):
  Post-release version bump to 0.26.1
  mmx: add missing _mm_empty calls
  autotools: use custom build rule to build iwMMXt code
  configure.ac: add iwmmxt2 configure flag
  Fix distcheck due to custom iwMMXt rules
  Pre-release version bump to 0.26.2

Siarhei Siamashka (2):
  test: OpenMP 2.5 requires signed loop iteration variables
  test: fix bisecting issue in fuzzer-find-diff.pl

Søren Sandmann Pedersen (1):
  test: Add missing break in stress-test.c



pgpgxsYR8Ypir.pgp
Description: PGP signature
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 01/10] pixman-cpu.c: Rename disabled to _pixman_disabled() and export it

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

---
 pixman/pixman-cpu.c |   22 +++---
 pixman/pixman-private.h |2 ++
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
index aa9036f..a0d2f8c 100644
--- a/pixman/pixman-cpu.c
+++ b/pixman/pixman-cpu.c
@@ -729,8 +729,8 @@ pixman_have_sse2 (void)
 #endif /* __amd64__ */
 #endif
 
-static pixman_bool_t
-disabled (const char *name)
+pixman_bool_t
+_pixman_disabled (const char *name)
 {
 const char *env;
 
@@ -767,44 +767,44 @@ _pixman_choose_implementation (void)
 
 imp = _pixman_implementation_create_general();
 
-if (!disabled (fast))
+if (!_pixman_disabled (fast))
imp = _pixman_implementation_create_fast_path (imp);
 
 #ifdef USE_X86_MMX
-if (!disabled (mmx)  pixman_have_mmx ())
+if (!_pixman_disabled (mmx)  pixman_have_mmx ())
imp = _pixman_implementation_create_mmx (imp);
 #endif
 
 #ifdef USE_SSE2
-if (!disabled (sse2)  pixman_have_sse2 ())
+if (!_pixman_disabled (sse2)  pixman_have_sse2 ())
imp = _pixman_implementation_create_sse2 (imp);
 #endif
 
 #ifdef USE_ARM_SIMD
-if (!disabled (arm-simd)  pixman_have_arm_simd ())
+if (!_pixman_disabled (arm-simd)  pixman_have_arm_simd ())
imp = _pixman_implementation_create_arm_simd (imp);
 #endif
 
 #ifdef USE_ARM_IWMMXT
-if (!disabled (arm-iwmmxt)  pixman_have_arm_iwmmxt ())
+if (!_pixman_disabled (arm-iwmmxt)  pixman_have_arm_iwmmxt ())
imp = _pixman_implementation_create_mmx (imp);
 #endif
 #ifdef USE_LOONGSON_MMI
-if (!disabled (loongson-mmi)  pixman_have_loongson_mmi ())
+if (!_pixman_disabled (loongson-mmi)  pixman_have_loongson_mmi ())
imp = _pixman_implementation_create_mmx (imp);
 #endif
 #ifdef USE_ARM_NEON
-if (!disabled (arm-neon)  pixman_have_arm_neon ())
+if (!_pixman_disabled (arm-neon)  pixman_have_arm_neon ())
imp = _pixman_implementation_create_arm_neon (imp);
 #endif
 
 #ifdef USE_MIPS_DSPR2
-if (!disabled (mips-dspr2)  pixman_have_mips_dspr2 ())
+if (!_pixman_disabled (mips-dspr2)  pixman_have_mips_dspr2 ())
imp = _pixman_implementation_create_mips_dspr2 (imp);
 #endif
 
 #ifdef USE_VMX
-if (!disabled (vmx)  pixman_have_vmx ())
+if (!_pixman_disabled (vmx)  pixman_have_vmx ())
imp = _pixman_implementation_create_vmx (imp);
 #endif
 
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 72e3b4f..89020c9 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -574,6 +574,8 @@ _pixman_implementation_create_vmx (pixman_implementation_t 
*fallback);
 pixman_implementation_t *
 _pixman_choose_implementation (void);
 
+pixman_bool_t
+_pixman_disabled (const char *name);
 
 
 /*
-- 
1.7.10.4

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 00/10] Cleanups to CPU detection

2012-06-29 Thread Søren Sandmann Pedersen
git://people.freedesktop.org/~sandmann/pixman

in the branch cpudetectfiles.

Hi,

The following patches contains some cleanups to the CPU detection in
general, and some improvements to the x86 specific parts in particular.

I was looking at making use of some of the newer x86 SIMD instruction
sets and realized that (a) we don't ever call cpuid on x86-64, we just
assume that MMX and SSE2 are present, and (b) pixman-cpu.c is a royal
mess.

The following patches split pixman-cpu.c into four different files:
pixman-arm.c, pixman-mips.c, pixman-ppc.c, and pixman-x86.c. All the
files are still compiled on all arhicitectures, but they have #ifdefs
in them that make them no-ops on the ones that they are not specific
to. The remaining bits of pixman-cpu.c are moved into
pixman-implementation.c

There are also some cleanups to the logic for all architectures. In
particular, all the have_feature() functions are gone and replaced
with a single function that detects all the features that the CPU
offers. This function is implemented by each #ifdef variation, and
then this is called from shared code.

The changes to x86 are the most involved. There is now a
pixman_cpuid() function that uses inline assembly on GCC and the
cpuid__ intrinsic on MSVC. The assembly is written such that it will
work on both 32 and 64 bit; the main change required was the save %ebx
in %esi instead of on the stack.

There is also a have_cpuid() function that detects the presence of
cpuid. On MSVC, this simply returns TRUE, so the an MSVC-compiled
pixman will now not work on old 486s. I am very tempted to remove this
on GCC as well and just require cpuid to be present for pixman work.

These two functions together make it possible to write the CPU
detection code in plain C, rather than the #ifdef ridden mess of
assembly it used to be.

I have tested the patches on ppc64, x86-64, x86-32, and on an ARM
Cortex A8 running Linux, but more testing would definitely be
appreciated. In particular if you use MSVC, MIPS, XO-1, or ARM on
Android/iPhone.


Thanks,
Soren

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 07/10] Simplify MIPS CPU detection

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

There is no reason to have pixman_have_feature functions when all
they do is call pixman_have_mips_feature().

Instead rename pixman_have_mips_feature() to have_feature() and call
it directly from _pixman_mips_get_implementations(). Also on
non-Linux, just make have_feature() return FALSE.
---
 pixman/pixman-mips.c |   44 +---
 1 file changed, 9 insertions(+), 35 deletions(-)

diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
index 9d3ee59..2b280c6 100644
--- a/pixman/pixman-mips.c
+++ b/pixman/pixman-mips.c
@@ -30,21 +30,18 @@
 #include string.h
 #include stdlib.h
 
-#if defined (__linux__) /* linux ELF */
-
 static pixman_bool_t
-pixman_have_mips_feature (const char *search_string)
+have_feature (const char *search_string)
 {
-const char *file_name = /proc/cpuinfo;
+#if defined (__linux__) /* linux ELF */
 /* Simple detection of MIPS features at runtime for Linux.
  * It is based on /proc/cpuinfo, which reveals hardware configuration
  * to user-space applications.  According to MIPS (early 2010), no similar
  * facility is universally available on the MIPS architectures, so it's up
  * to individual OSes to provide such.
  */
-
+const char *file_name = /proc/cpuinfo;
 char cpuinfo_line[256];
-
 FILE *f = NULL;
 
 if ((f = fopen (file_name, r)) == NULL)
@@ -60,51 +57,28 @@ pixman_have_mips_feature (const char *search_string)
 }
 
 fclose (f);
+#endif
 
-/* Did not find string in the proc file. */
+/* Did not find string in the proc file, or not Linux ELF. */
 return FALSE;
 }
 
-#if defined(USE_MIPS_DSPR2)
-pixman_bool_t
-pixman_have_mips_dspr2 (void)
-{
- /* Only currently available MIPS core that supports DSPr2 is 74K. */
-return pixman_have_mips_feature (MIPS 74K);
-}
 #endif
 
-#if defined(USE_LOONGSON_MMI)
-pixman_bool_t
-pixman_have_loongson_mmi (void)
-{
-/* I really don't know if some Loongson CPUs don't have MMI. */
-return pixman_have_mips_feature (Loongson);
-}
-#endif
-
-#else /* linux ELF */
-
-#define pixman_have_mips_dspr2() FALSE
-#define pixman_have_loongson_mmi() FALSE
-
-#endif /* linux ELF */
-
-#endif /* USE_MIPS_DSPR2 || USE_LOONGSON_MMI */
-
 pixman_implementation_t *
 _pixman_mips_get_implementations (pixman_implementation_t *imp)
 {
 #ifdef USE_LOONGSON_MMI
-if (!_pixman_disabled (loongson-mmi)  pixman_have_loongson_mmi ())
+/* I really don't know if some Loongson CPUs don't have MMI. */
+if (!_pixman_disabled (loongson-mmi)  have_feature (Loongson))
imp = _pixman_implementation_create_mmx (imp);
 #endif
 
 #ifdef USE_MIPS_DSPR2
-if (!_pixman_disabled (mips-dspr2)  pixman_have_mips_dspr2 ())
+/* Only currently available MIPS core that supports DSPr2 is 74K. */
+if (!_pixman_disabled (mips-dspr2)  have_feature (MIPS 74K))
imp = _pixman_implementation_create_mips_dspr2 (imp);
 #endif
 
 return imp;
 }
-
-- 
1.7.10.4

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 03/10] Move ARM specific CPU detection to a new file pixman-arm.c

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

Similar to the x86 commit, this moves the ARM specific CPU detection
to its own file which exports a pixman_arm_get_implementations()
function that is supposed to be a noop on non-ARM.
---
 pixman/Makefile.sources |1 +
 pixman/pixman-arm.c |  295 +++
 pixman/pixman-cpu.c |  254 +---
 pixman/pixman-private.h |3 +
 4 files changed, 300 insertions(+), 253 deletions(-)
 create mode 100644 pixman/pixman-arm.c

diff --git a/pixman/Makefile.sources b/pixman/Makefile.sources
index 4e0137a..7f2b75f 100644
--- a/pixman/Makefile.sources
+++ b/pixman/Makefile.sources
@@ -8,6 +8,7 @@ libpixman_sources = \
pixman-conical-gradient.c   \
pixman-cpu.c\
pixman-x86.c\
+   pixman-arm.c\
pixman-edge.c   \
pixman-edge-accessors.c \
pixman-fast-path.c  \
diff --git a/pixman/pixman-arm.c b/pixman/pixman-arm.c
new file mode 100644
index 000..6625d7f
--- /dev/null
+++ b/pixman/pixman-arm.c
@@ -0,0 +1,295 @@
+/*
+ * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided as is
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include pixman-private.h
+
+#if defined(USE_ARM_SIMD) || defined(USE_ARM_NEON) || defined(USE_ARM_IWMMXT)
+
+#include string.h
+#include stdlib.h
+
+#if defined(USE_ARM_SIMD)  defined(_MSC_VER)
+/* Needed for EXCEPTION_ILLEGAL_INSTRUCTION */
+#include windows.h
+#endif
+
+#if defined(__APPLE__)
+#include TargetConditionals.h
+#endif
+
+#if defined(_MSC_VER)
+
+#if defined(USE_ARM_SIMD)
+extern int pixman_msvc_try_arm_simd_op ();
+
+pixman_bool_t
+pixman_have_arm_simd (void)
+{
+static pixman_bool_t initialized = FALSE;
+static pixman_bool_t have_arm_simd = FALSE;
+
+if (!initialized)
+{
+   __try {
+   pixman_msvc_try_arm_simd_op ();
+   have_arm_simd = TRUE;
+   } __except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION) {
+   have_arm_simd = FALSE;
+   }
+   initialized = TRUE;
+}
+
+return have_arm_simd;
+}
+
+#endif /* USE_ARM_SIMD */
+
+#if defined(USE_ARM_NEON)
+extern int pixman_msvc_try_arm_neon_op ();
+
+pixman_bool_t
+pixman_have_arm_neon (void)
+{
+static pixman_bool_t initialized = FALSE;
+static pixman_bool_t have_arm_neon = FALSE;
+
+if (!initialized)
+{
+   __try
+   {
+   pixman_msvc_try_arm_neon_op ();
+   have_arm_neon = TRUE;
+   }
+   __except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION)
+   {
+   have_arm_neon = FALSE;
+   }
+   initialized = TRUE;
+}
+
+return have_arm_neon;
+}
+
+#endif /* USE_ARM_NEON */
+
+#elif (defined (__APPLE__)  defined(TARGET_OS_IPHONE)) /* iOS 
(iPhone/iPad/iPod touch) */
+
+/* Detection of ARM NEON on iOS is fairly simple because iOS binaries
+ * contain separate executable images for each processor architecture.
+ * So all we have to do is detect the armv7 architecture build. The
+ * operating system automatically runs the armv7 binary for armv7 devices
+ * and the armv6 binary for armv6 devices.
+ */
+
+pixman_bool_t
+pixman_have_arm_simd (void)
+{
+#if defined(USE_ARM_SIMD)
+return TRUE;
+#else
+return FALSE;
+#endif
+}
+
+pixman_bool_t
+pixman_have_arm_neon (void)
+{
+#if defined(USE_ARM_NEON)  defined(__ARM_NEON__)
+/* This is an armv7 cpu build */
+return TRUE;
+#else
+/* This is an armv6 cpu build */
+return FALSE;
+#endif
+}
+
+pixman_bool_t
+pixman_have_arm_iwmmxt (void)
+{
+#if defined(USE_ARM_IWMMXT)
+return FALSE;
+#else
+return FALSE;
+#endif
+}
+
+#elif defined (__linux__) || defined(__ANDROID__) || defined(ANDROID) /* linux 
ELF or ANDROID */
+
+static pixman_bool_t 

[Pixman] [PATCH 02/10] Move x86 specific CPU detection to a new file pixman-x86.c

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

Extract the x86 specific parts of pixman-cpu.c and put them in their
own file called pixman-x86.c which exports one function
pixman_x86_get_implementations() that creates the MMX and SSE2
implementations. This file is supposed to be compiled on all
architectures, but pixman_x86_get_implementations() should be a noop
on non-x86.
---
 pixman/Makefile.sources |1 +
 pixman/pixman-cpu.c |  250 +
 pixman/pixman-private.h |6 +
 pixman/pixman-x86.c |  282 +++
 4 files changed, 291 insertions(+), 248 deletions(-)
 create mode 100644 pixman/pixman-x86.c

diff --git a/pixman/Makefile.sources b/pixman/Makefile.sources
index 11f959d..4e0137a 100644
--- a/pixman/Makefile.sources
+++ b/pixman/Makefile.sources
@@ -7,6 +7,7 @@ libpixman_sources = \
pixman-combine64.c  \
pixman-conical-gradient.c   \
pixman-cpu.c\
+   pixman-x86.c\
pixman-edge.c   \
pixman-edge-accessors.c \
pixman-fast-path.c  \
diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
index a0d2f8c..0bfc90f 100644
--- a/pixman/pixman-cpu.c
+++ b/pixman/pixman-cpu.c
@@ -491,244 +491,6 @@ pixman_have_loongson_mmi (void)
 
 #endif /* USE_MIPS_DSPR2 || USE_LOONGSON_MMI */
 
-#if defined(USE_X86_MMX) || defined(USE_SSE2)
-/* The CPU detection code needs to be in a file not compiled with
- * -mmmx -msse, as gcc would generate CMOV instructions otherwise
- * that would lead to SIGILL instructions on old CPUs that don't have
- * it.
- */
-#if !defined(__amd64__)  !defined(__x86_64__)  !defined(_M_AMD64)
-
-#ifdef HAVE_GETISAX
-#include sys/auxv.h
-#endif
-
-typedef enum
-{
-NO_FEATURES = 0,
-MMX = 0x1,
-MMX_EXTENSIONS = 0x2,
-SSE = 0x6,
-SSE2 = 0x8,
-CMOV = 0x10
-} cpu_features_t;
-
-
-static unsigned int
-detect_cpu_features (void)
-{
-unsigned int features = 0;
-unsigned int result = 0;
-
-#ifdef HAVE_GETISAX
-if (getisax (result, 1))
-{
-   if (result  AV_386_CMOV)
-   features |= CMOV;
-   if (result  AV_386_MMX)
-   features |= MMX;
-   if (result  AV_386_AMD_MMX)
-   features |= MMX_EXTENSIONS;
-   if (result  AV_386_SSE)
-   features |= SSE;
-   if (result  AV_386_SSE2)
-   features |= SSE2;
-}
-#else
-char vendor[13];
-#ifdef _MSC_VER
-int vendor0 = 0, vendor1, vendor2;
-#endif
-vendor[0] = 0;
-vendor[12] = 0;
-
-#ifdef __GNUC__
-/* see p. 118 of amd64 instruction set manual Vol3 */
-/* We need to be careful about the handling of %ebx and
- * %esp here. We can't declare either one as clobbered
- * since they are special registers (%ebx is the PIC
- * register holding an offset to global data, %esp the
- * stack pointer), so we need to make sure they have their
- * original values when we access the output operands.
- */
-__asm__ (
-pushf\n
-pop %%eax\n
-mov %%eax, %%ecx\n
-xor $0x0020, %%eax\n
-push %%eax\n
-popf\n
-pushf\n
-pop %%eax\n
-mov $0x0, %%edx\n
-xor %%ecx, %%eax\n
-jz 1f\n
-
-mov $0x, %%eax\n
-push %%ebx\n
-cpuid\n
-mov %%ebx, %%eax\n
-pop %%ebx\n
-mov %%eax, %1\n
-mov %%edx, %2\n
-mov %%ecx, %3\n
-mov $0x0001, %%eax\n
-push %%ebx\n
-cpuid\n
-pop %%ebx\n
-1:\n
-mov %%edx, %0\n
-   : =r (result),
-=m (vendor[0]),
-=m (vendor[4]),
-=m (vendor[8])
-   :
-   : %eax, %ecx, %edx
-);
-
-#elif defined (_MSC_VER)
-
-_asm {
-   pushfd
-   pop eax
-   mov ecx, eax
-   xor eax, 0020h
-   push eax
-   popfd
-   pushfd
-   pop eax
-   mov edx, 0
-   xor eax, ecx
-   jz nocpuid
-
-   mov eax, 0
-   push ebx
-   cpuid
-   mov eax, ebx
-   pop ebx
-   mov vendor0, eax
-   mov vendor1, edx
-   mov vendor2, ecx
-   mov eax, 1
-   push ebx
-   cpuid
-   pop ebx
-nocpuid:
-   mov result, edx
-}
-memmove (vendor + 0, vendor0, 4);
-memmove (vendor + 4, vendor1, 4);
-memmove (vendor + 8, vendor2, 4);
-
-#else
-#   error unsupported compiler
-#endif
-
-features = 0;
-if (result)
-{
-   /* result now contains the standard feature bits */
-   if (result  (1  15))
-   features |= CMOV;
-   if (result  (1  23))
-   features |= MMX;
-   if (result  (1  25))
-   features |= SSE;
-   if (result  (1  26))
-   features |= SSE2;
-   if ((features  MMX)  !(features  SSE) 
-   (strcmp (vendor, AuthenticAMD) == 0 ||
-strcmp (vendor, Geode by NSC) == 0))
-   {

[Pixman] [PATCH 09/10] Simplifications to ARM CPU detection

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

Organize pixman-arm.c such that each operating system/compiler exports
a detect_cpu_features() function that returns a bitmask with the
various features that we are interested in. A new function
have_feature() then calls this function, caches the result, and return
whether the given feature is available.

The result is that all the pixman_have_arm_feature functions become
redundant and can be deleted.
---
 pixman/pixman-arm.c |  244 ++-
 1 file changed, 87 insertions(+), 157 deletions(-)

diff --git a/pixman/pixman-arm.c b/pixman/pixman-arm.c
index 6625d7f..23374e4 100644
--- a/pixman/pixman-arm.c
+++ b/pixman/pixman-arm.c
@@ -25,132 +25,83 @@
 
 #include pixman-private.h
 
+typedef enum
+{
+ARM_V7 = (1  0),
+ARM_V6 = (1  1),
+ARM_VFP= (1  2),
+ARM_NEON   = (1  3),
+ARM_IWMMXT = (1  4)
+} arm_cpu_features_t;
+
 #if defined(USE_ARM_SIMD) || defined(USE_ARM_NEON) || defined(USE_ARM_IWMMXT)
 
-#include string.h
-#include stdlib.h
+#if defined(_MSC_VER)
 
-#if defined(USE_ARM_SIMD)  defined(_MSC_VER)
 /* Needed for EXCEPTION_ILLEGAL_INSTRUCTION */
 #include windows.h
-#endif
 
-#if defined(__APPLE__)
-#include TargetConditionals.h
-#endif
-
-#if defined(_MSC_VER)
-
-#if defined(USE_ARM_SIMD)
+extern int pixman_msvc_try_arm_neon_op ();
 extern int pixman_msvc_try_arm_simd_op ();
 
-pixman_bool_t
-pixman_have_arm_simd (void)
+static arm_cpu_features_t
+detect_cpu_features (void)
 {
-static pixman_bool_t initialized = FALSE;
-static pixman_bool_t have_arm_simd = FALSE;
+arm_cpu_features_t features = 0;
 
-if (!initialized)
+__try
+{
+   pixman_msvc_try_arm_simd_op ();
+   features |= ARM_V6;
+}
+__except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION)
 {
-   __try {
-   pixman_msvc_try_arm_simd_op ();
-   have_arm_simd = TRUE;
-   } __except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION) {
-   have_arm_simd = FALSE;
-   }
-   initialized = TRUE;
 }
 
-return have_arm_simd;
-}
-
-#endif /* USE_ARM_SIMD */
-
-#if defined(USE_ARM_NEON)
-extern int pixman_msvc_try_arm_neon_op ();
-
-pixman_bool_t
-pixman_have_arm_neon (void)
-{
-static pixman_bool_t initialized = FALSE;
-static pixman_bool_t have_arm_neon = FALSE;
-
-if (!initialized)
+__try
+{
+   pixman_msvc_try_arm_neon_op ();
+   features |= ARM_NEON;
+}
+__except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION)
 {
-   __try
-   {
-   pixman_msvc_try_arm_neon_op ();
-   have_arm_neon = TRUE;
-   }
-   __except (GetExceptionCode () == EXCEPTION_ILLEGAL_INSTRUCTION)
-   {
-   have_arm_neon = FALSE;
-   }
-   initialized = TRUE;
 }
 
-return have_arm_neon;
+return features;
 }
 
-#endif /* USE_ARM_NEON */
-
-#elif (defined (__APPLE__)  defined(TARGET_OS_IPHONE)) /* iOS 
(iPhone/iPad/iPod touch) */
-
-/* Detection of ARM NEON on iOS is fairly simple because iOS binaries
- * contain separate executable images for each processor architecture.
- * So all we have to do is detect the armv7 architecture build. The
- * operating system automatically runs the armv7 binary for armv7 devices
- * and the armv6 binary for armv6 devices.
- */
+#elif defined(__APPLE__)  defined(TARGET_OS_IPHONE) /* iOS */
 
-pixman_bool_t
-pixman_have_arm_simd (void)
-{
-#if defined(USE_ARM_SIMD)
-return TRUE;
-#else
-return FALSE;
-#endif
-}
+#include TargetConditionals.h
 
-pixman_bool_t
-pixman_have_arm_neon (void)
+static arm_cpu_features_t
+detect_cpu_features (void)
 {
-#if defined(USE_ARM_NEON)  defined(__ARM_NEON__)
-/* This is an armv7 cpu build */
-return TRUE;
-#else
-/* This is an armv6 cpu build */
-return FALSE;
+arm_cpu_features_t features = 0;
+
+features |= ARM_V6;
+
+/* Detection of ARM NEON on iOS is fairly simple because iOS binaries
+ * contain separate executable images for each processor architecture.
+ * So all we have to do is detect the armv7 architecture build. The
+ * operating system automatically runs the armv7 binary for armv7 devices
+ * and the armv6 binary for armv6 devices.
+ */
+#if defined(__ARM_NEON__)
+features |= ARM_NEON;
 #endif
-}
 
-pixman_bool_t
-pixman_have_arm_iwmmxt (void)
-{
-#if defined(USE_ARM_IWMMXT)
-return FALSE;
-#else
-return FALSE;
-#endif
+return features;
 }
 
-#elif defined (__linux__) || defined(__ANDROID__) || defined(ANDROID) /* linux 
ELF or ANDROID */
-
-static pixman_bool_t arm_has_v7 = FALSE;
-static pixman_bool_t arm_has_v6 = FALSE;
-static pixman_bool_t arm_has_vfp = FALSE;
-static pixman_bool_t arm_has_neon = FALSE;
-static pixman_bool_t arm_has_iwmmxt = FALSE;
-static pixman_bool_t arm_tests_initialized = FALSE;
-
-#if defined(__ANDROID__) || defined(ANDROID) /* Android device 

[Pixman] [PATCH 05/10] Move MIPS specific CPU detection to its own file, pixman-mips.c

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

---
 pixman/Makefile.sources |1 +
 pixman/pixman-cpu.c |   77 +
 pixman/pixman-mips.c|  110 +++
 pixman/pixman-private.h |3 ++
 4 files changed, 115 insertions(+), 76 deletions(-)
 create mode 100644 pixman/pixman-mips.c

diff --git a/pixman/Makefile.sources b/pixman/Makefile.sources
index 414ac02..73758ff 100644
--- a/pixman/Makefile.sources
+++ b/pixman/Makefile.sources
@@ -8,6 +8,7 @@ libpixman_sources = \
pixman-conical-gradient.c   \
pixman-cpu.c\
pixman-x86.c\
+   pixman-mips.c   \
pixman-arm.c\
pixman-ppc.c\
pixman-edge.c   \
diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
index 914f116..5cef480 100644
--- a/pixman/pixman-cpu.c
+++ b/pixman/pixman-cpu.c
@@ -22,76 +22,10 @@
 #ifdef HAVE_CONFIG_H
 #include config.h
 #endif
-
-#include string.h
 #include stdlib.h
 
 #include pixman-private.h
 
-#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
-
-#if defined (__linux__) /* linux ELF */
-
-static pixman_bool_t
-pixman_have_mips_feature (const char *search_string)
-{
-const char *file_name = /proc/cpuinfo;
-/* Simple detection of MIPS features at runtime for Linux.
- * It is based on /proc/cpuinfo, which reveals hardware configuration
- * to user-space applications.  According to MIPS (early 2010), no similar
- * facility is universally available on the MIPS architectures, so it's up
- * to individual OSes to provide such.
- */
-
-char cpuinfo_line[256];
-
-FILE *f = NULL;
-
-if ((f = fopen (file_name, r)) == NULL)
-return FALSE;
-
-while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
-{
-if (strstr (cpuinfo_line, search_string) != NULL)
-{
-fclose (f);
-return TRUE;
-}
-}
-
-fclose (f);
-
-/* Did not find string in the proc file. */
-return FALSE;
-}
-
-#if defined(USE_MIPS_DSPR2)
-pixman_bool_t
-pixman_have_mips_dspr2 (void)
-{
- /* Only currently available MIPS core that supports DSPr2 is 74K. */
-return pixman_have_mips_feature (MIPS 74K);
-}
-#endif
-
-#if defined(USE_LOONGSON_MMI)
-pixman_bool_t
-pixman_have_loongson_mmi (void)
-{
-/* I really don't know if some Loongson CPUs don't have MMI. */
-return pixman_have_mips_feature (Loongson);
-}
-#endif
-
-#else /* linux ELF */
-
-#define pixman_have_mips_dspr2() FALSE
-#define pixman_have_loongson_mmi() FALSE
-
-#endif /* linux ELF */
-
-#endif /* USE_MIPS_DSPR2 || USE_LOONGSON_MMI */
-
 pixman_bool_t
 _pixman_disabled (const char *name)
 {
@@ -136,16 +70,7 @@ _pixman_choose_implementation (void)
 imp = _pixman_x86_get_implementations (imp);
 imp = _pixman_arm_get_implementations (imp);
 imp = _pixman_ppc_get_implementations (imp);
-
-#ifdef USE_LOONGSON_MMI
-if (!_pixman_disabled (loongson-mmi)  pixman_have_loongson_mmi ())
-   imp = _pixman_implementation_create_mmx (imp);
-#endif
-
-#ifdef USE_MIPS_DSPR2
-if (!_pixman_disabled (mips-dspr2)  pixman_have_mips_dspr2 ())
-   imp = _pixman_implementation_create_mips_dspr2 (imp);
-#endif
+imp = _pixman_mips_get_implementations (imp);
 
 imp = _pixman_implementation_create_noop (imp);
 
diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
new file mode 100644
index 000..9d3ee59
--- /dev/null
+++ b/pixman/pixman-mips.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided as is
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include pixman-private.h
+
+#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
+
+#include string.h
+#include stdlib.h
+
+#if defined 

[Pixman] [PATCH 06/10] Move the remaining bits of pixman-cpu into pixman-implementation.c

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

---
 pixman/Makefile.sources|1 -
 pixman/pixman-cpu.c|   79 
 pixman/pixman-implementation.c |   51 ++
 3 files changed, 51 insertions(+), 80 deletions(-)
 delete mode 100644 pixman/pixman-cpu.c

diff --git a/pixman/Makefile.sources b/pixman/Makefile.sources
index 73758ff..6472994 100644
--- a/pixman/Makefile.sources
+++ b/pixman/Makefile.sources
@@ -6,7 +6,6 @@ libpixman_sources = \
pixman-combine32.c  \
pixman-combine64.c  \
pixman-conical-gradient.c   \
-   pixman-cpu.c\
pixman-x86.c\
pixman-mips.c   \
pixman-arm.c\
diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
deleted file mode 100644
index 5cef480..000
--- a/pixman/pixman-cpu.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright © 2000 SuSE, Inc.
- * Copyright © 2007 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  SuSE makes no representations about the
- * suitability of this software for any purpose.  It is provided as is
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifdef HAVE_CONFIG_H
-#include config.h
-#endif
-#include stdlib.h
-
-#include pixman-private.h
-
-pixman_bool_t
-_pixman_disabled (const char *name)
-{
-const char *env;
-
-if ((env = getenv (PIXMAN_DISABLE)))
-{
-   do
-   {
-   const char *end;
-   int len;
-
-   if ((end = strchr (env, ' ')))
-   len = end - env;
-   else
-   len = strlen (env);
-
-   if (strlen (name) == len  strncmp (name, env, len) == 0)
-   {
-   printf (pixman: Disabled %s implementation\n, name);
-   return TRUE;
-   }
-
-   env += len;
-   }
-   while (*env++);
-}
-
-return FALSE;
-}
-
-pixman_implementation_t *
-_pixman_choose_implementation (void)
-{
-pixman_implementation_t *imp;
-
-imp = _pixman_implementation_create_general();
-
-if (!_pixman_disabled (fast))
-   imp = _pixman_implementation_create_fast_path (imp);
-
-imp = _pixman_x86_get_implementations (imp);
-imp = _pixman_arm_get_implementations (imp);
-imp = _pixman_ppc_get_implementations (imp);
-imp = _pixman_mips_get_implementations (imp);
-
-imp = _pixman_implementation_create_noop (imp);
-
-return imp;
-}
-
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index c769ab8..77d0906 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -223,3 +223,54 @@ _pixman_implementation_dest_iter_init 
(pixman_implementation_t *imp,
 
 (*imp-dest_iter_init) (imp, iter);
 }
+
+pixman_bool_t
+_pixman_disabled (const char *name)
+{
+const char *env;
+
+if ((env = getenv (PIXMAN_DISABLE)))
+{
+   do
+   {
+   const char *end;
+   int len;
+
+   if ((end = strchr (env, ' ')))
+   len = end - env;
+   else
+   len = strlen (env);
+
+   if (strlen (name) == len  strncmp (name, env, len) == 0)
+   {
+   printf (pixman: Disabled %s implementation\n, name);
+   return TRUE;
+   }
+
+   env += len;
+   }
+   while (*env++);
+}
+
+return FALSE;
+}
+
+pixman_implementation_t *
+_pixman_choose_implementation (void)
+{
+pixman_implementation_t *imp;
+
+imp = _pixman_implementation_create_general();
+
+if (!_pixman_disabled (fast))
+   imp = _pixman_implementation_create_fast_path (imp);
+
+imp = _pixman_x86_get_implementations (imp);
+imp = _pixman_arm_get_implementations (imp);
+imp = _pixman_ppc_get_implementations (imp);
+imp = _pixman_mips_get_implementations (imp);
+
+imp = _pixman_implementation_create_noop (imp);
+
+return imp;
+}
-- 
1.7.10.4

___
Pixman mailing list

[Pixman] [PATCH 04/10] Move PowerPC specific CPU detection to its own file pixman-ppc.c

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

---
 pixman/Makefile.sources |1 +
 pixman/pixman-cpu.c |  165 +---
 pixman/pixman-ppc.c |  192 +++
 pixman/pixman-private.h |3 +
 4 files changed, 197 insertions(+), 164 deletions(-)
 create mode 100644 pixman/pixman-ppc.c

diff --git a/pixman/Makefile.sources b/pixman/Makefile.sources
index 7f2b75f..414ac02 100644
--- a/pixman/Makefile.sources
+++ b/pixman/Makefile.sources
@@ -9,6 +9,7 @@ libpixman_sources = \
pixman-cpu.c\
pixman-x86.c\
pixman-arm.c\
+   pixman-ppc.c\
pixman-edge.c   \
pixman-edge-accessors.c \
pixman-fast-path.c  \
diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
index 319d71f..914f116 100644
--- a/pixman/pixman-cpu.c
+++ b/pixman/pixman-cpu.c
@@ -26,167 +26,8 @@
 #include string.h
 #include stdlib.h
 
-#if defined(__APPLE__)
-#include TargetConditionals.h
-#endif
-
 #include pixman-private.h
 
-#ifdef USE_VMX
-
-/* The CPU detection code needs to be in a file not compiled with
- * -maltivec -mabi=altivec, as gcc would try to save vector register
- * across function calls causing SIGILL on cpus without Altivec/vmx.
- */
-static pixman_bool_t initialized = FALSE;
-static volatile pixman_bool_t have_vmx = TRUE;
-
-#ifdef __APPLE__
-#include sys/sysctl.h
-
-static pixman_bool_t
-pixman_have_vmx (void)
-{
-if (!initialized)
-{
-   size_t length = sizeof(have_vmx);
-   int error =
-   sysctlbyname (hw.optional.altivec, have_vmx, length, NULL, 0);
-
-   if (error)
-   have_vmx = FALSE;
-
-   initialized = TRUE;
-}
-return have_vmx;
-}
-
-#elif defined (__OpenBSD__)
-#include sys/param.h
-#include sys/sysctl.h
-#include machine/cpu.h
-
-static pixman_bool_t
-pixman_have_vmx (void)
-{
-if (!initialized)
-{
-   int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
-   size_t length = sizeof(have_vmx);
-   int error =
-   sysctl (mib, 2, have_vmx, length, NULL, 0);
-
-   if (error != 0)
-   have_vmx = FALSE;
-
-   initialized = TRUE;
-}
-return have_vmx;
-}
-
-#elif defined (__linux__)
-#include sys/types.h
-#include sys/stat.h
-#include fcntl.h
-#include unistd.h
-#include stdio.h
-#include linux/auxvec.h
-#include asm/cputable.h
-
-static pixman_bool_t
-pixman_have_vmx (void)
-{
-if (!initialized)
-{
-   char fname[64];
-   unsigned long buf[64];
-   ssize_t count = 0;
-   pid_t pid;
-   int fd, i;
-
-   pid = getpid ();
-   snprintf (fname, sizeof(fname) - 1, /proc/%d/auxv, pid);
-
-   fd = open (fname, O_RDONLY);
-   if (fd = 0)
-   {
-   for (i = 0; i = (count / sizeof(unsigned long)); i += 2)
-   {
-   /* Read more if buf is empty... */
-   if (i == (count / sizeof(unsigned long)))
-   {
-   count = read (fd, buf, sizeof(buf));
-   if (count = 0)
-   break;
-   i = 0;
-   }
-
-   if (buf[i] == AT_HWCAP)
-   {
-   have_vmx = !!(buf[i + 1]  PPC_FEATURE_HAS_ALTIVEC);
-   initialized = TRUE;
-   break;
-   }
-   else if (buf[i] == AT_NULL)
-   {
-   break;
-   }
-   }
-   close (fd);
-   }
-}
-if (!initialized)
-{
-   /* Something went wrong. Assume 'no' rather than playing
-  fragile tricks with catching SIGILL. */
-   have_vmx = FALSE;
-   initialized = TRUE;
-}
-
-return have_vmx;
-}
-
-#else /* !__APPLE__  !__OpenBSD__  !__linux__ */
-#include signal.h
-#include setjmp.h
-
-static jmp_buf jump_env;
-
-static void
-vmx_test (intsig,
- siginfo_t *si,
- void * unused)
-{
-longjmp (jump_env, 1);
-}
-
-static pixman_bool_t
-pixman_have_vmx (void)
-{
-struct sigaction sa, osa;
-int jmp_result;
-
-if (!initialized)
-{
-   sa.sa_flags = SA_SIGINFO;
-   sigemptyset (sa.sa_mask);
-   sa.sa_sigaction = vmx_test;
-   sigaction (SIGILL, sa, osa);
-   jmp_result = setjmp (jump_env);
-   if (jmp_result == 0)
-   {
-   asm volatile ( vor 0, 0, 0 );
-   }
-   sigaction (SIGILL, osa, NULL);
-   have_vmx = (jmp_result == 0);
-   initialized = TRUE;
-}
-return have_vmx;
-}
-
-#endif /* __APPLE__ */
-#endif /* USE_VMX */
-
 #if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
 
 #if defined (__linux__) /* linux ELF */
@@ -294,6 +135,7 @@ _pixman_choose_implementation (void)
 
 imp = _pixman_x86_get_implementations (imp);
 imp = _pixman_arm_get_implementations (imp);
+imp = 

[Pixman] [PATCH 10/10] Simplify CPU detection on PPC.

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

Get rid of the initialized and have_vmx static variables in
pixman-ppc.c There is no point to them since CPU detection only
happens once per process.

On Linux, just read /proc/self/auxv instead of generating the filename
with getpid() and don't bother with the stack buffer. Instead just
read the aux entries one by one.
---
 pixman/pixman-ppc.c |  113 +--
 1 file changed, 38 insertions(+), 75 deletions(-)

diff --git a/pixman/pixman-ppc.c b/pixman/pixman-ppc.c
index 786f204..f1bea1e 100644
--- a/pixman/pixman-ppc.c
+++ b/pixman/pixman-ppc.c
@@ -31,26 +31,20 @@
  * -maltivec -mabi=altivec, as gcc would try to save vector register
  * across function calls causing SIGILL on cpus without Altivec/vmx.
  */
-static pixman_bool_t initialized = FALSE;
-static volatile pixman_bool_t have_vmx = TRUE;
-
 #ifdef __APPLE__
 #include sys/sysctl.h
 
 static pixman_bool_t
 pixman_have_vmx (void)
 {
-if (!initialized)
-{
-   size_t length = sizeof(have_vmx);
-   int error =
-   sysctlbyname (hw.optional.altivec, have_vmx, length, NULL, 0);
+size_t length = sizeof(have_vmx);
+int error, have_mmx;
 
-   if (error)
-   have_vmx = FALSE;
+sysctlbyname (hw.optional.altivec, have_vmx, length, NULL, 0);
+
+if (error)
+   return FALSE;
 
-   initialized = TRUE;
-}
 return have_vmx;
 }
 
@@ -62,22 +56,20 @@ pixman_have_vmx (void)
 static pixman_bool_t
 pixman_have_vmx (void)
 {
-if (!initialized)
-{
-   int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
-   size_t length = sizeof(have_vmx);
-   int error =
-   sysctl (mib, 2, have_vmx, length, NULL, 0);
+int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
+size_t length = sizeof(have_vmx);
+int error, have_vmx;
 
-   if (error != 0)
-   have_vmx = FALSE;
+error = sysctl (mib, 2, have_vmx, length, NULL, 0);
+
+if (error != 0)
+   return FALSE;
 
-   initialized = TRUE;
-}
 return have_vmx;
 }
 
 #elif defined (__linux__)
+
 #include sys/types.h
 #include sys/stat.h
 #include fcntl.h
@@ -89,51 +81,27 @@ pixman_have_vmx (void)
 static pixman_bool_t
 pixman_have_vmx (void)
 {
-if (!initialized)
+int have_vmx = FALSE;
+int fd;
+struct
 {
-   char fname[64];
-   unsigned long buf[64];
-   ssize_t count = 0;
-   pid_t pid;
-   int fd, i;
+   unsigned long type;
+   unsigned long value;
+} aux;
 
-   pid = getpid ();
-   snprintf (fname, sizeof(fname) - 1, /proc/%d/auxv, pid);
-
-   fd = open (fname, O_RDONLY);
-   if (fd = 0)
+fd = open (/proc/self/auxv, O_RDONLY);
+if (fd = 0)
+{
+   while (read (fd, aux, sizeof (aux)) == sizeof (aux))
{
-   for (i = 0; i = (count / sizeof(unsigned long)); i += 2)
+   if (aux.type == AT_HWCAP  (aux.value  PPC_FEATURE_HAS_ALTIVEC))
{
-   /* Read more if buf is empty... */
-   if (i == (count / sizeof(unsigned long)))
-   {
-   count = read (fd, buf, sizeof(buf));
-   if (count = 0)
-   break;
-   i = 0;
-   }
-
-   if (buf[i] == AT_HWCAP)
-   {
-   have_vmx = !!(buf[i + 1]  PPC_FEATURE_HAS_ALTIVEC);
-   initialized = TRUE;
-   break;
-   }
-   else if (buf[i] == AT_NULL)
-   {
-   break;
-   }
+   have_vmx = TRUE;
+   break;
}
-   close (fd);
}
-}
-if (!initialized)
-{
-   /* Something went wrong. Assume 'no' rather than playing
-  fragile tricks with catching SIGILL. */
-   have_vmx = FALSE;
-   initialized = TRUE;
+
+   close (fd);
 }
 
 return have_vmx;
@@ -159,22 +127,17 @@ pixman_have_vmx (void)
 struct sigaction sa, osa;
 int jmp_result;
 
-if (!initialized)
+sa.sa_flags = SA_SIGINFO;
+sigemptyset (sa.sa_mask);
+sa.sa_sigaction = vmx_test;
+sigaction (SIGILL, sa, osa);
+jmp_result = setjmp (jump_env);
+if (jmp_result == 0)
 {
-   sa.sa_flags = SA_SIGINFO;
-   sigemptyset (sa.sa_mask);
-   sa.sa_sigaction = vmx_test;
-   sigaction (SIGILL, sa, osa);
-   jmp_result = setjmp (jump_env);
-   if (jmp_result == 0)
-   {
-   asm volatile ( vor 0, 0, 0 );
-   }
-   sigaction (SIGILL, osa, NULL);
-   have_vmx = (jmp_result == 0);
-   initialized = TRUE;
+   asm volatile ( vor 0, 0, 0 );
 }
-return have_vmx;
+sigaction (SIGILL, osa, NULL);
+return (jmp_result == 0);
 }
 
 #endif /* __APPLE__ */
-- 
1.7.10.4

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 08/10] Cleanups and simplifications in x86 CPU feature detection

2012-06-29 Thread Søren Sandmann Pedersen
From: Søren Sandmann Pedersen s...@redhat.com

A new function pixman_cpuid() is added that runs the cpuid instruction
and returns the results.

On GCC this function uses inline assembly that is written such that it
will work on both 32 and 64 bit. Compared to the old code, the only
difference is %ebx is saved in %esi instead of on the stack. Saving 32
bit registers on a 64 bit stack is difficult or impossible because in
64 bit mode, the push and pop instructions work on 64 bit registers.

On MSVC, the function calls the __cpuid intrinsic.

There is also a new function called have_cpuid() which detects whether
cpuid is available. On x86-64 and MSVC, it simply returns TRUE; on
x86-32 bit, it checks whether the 22nd bit of eflags can be
modified. On MSVC this does have the consequence that pixman will no
longer work CPUS without cpuid (ie., older than 486 and some 486
models).

These two functions together makes it possible to write a generic
detect_cpu_features() in plain C. This function is then used in a new
have_feature() function that checks whether a specific set of feature
bits is available.

Aside from the cleanups and simplifications, the main benefit from
this patch is that pixman now can do feature detection on x86-64, so
that newer instruction sets such as SSSE3 and SSE4.1 can be used. (And
apparently the assumption that x86-64 CPUs always have MMX and SSE2 is
no longer correct: Knight's Corner is x86-64, but doesn't have them).
---
 pixman/pixman-x86.c |  311 +--
 1 file changed, 129 insertions(+), 182 deletions(-)

diff --git a/pixman/pixman-x86.c b/pixman/pixman-x86.c
index 52ad3df..84590d2 100644
--- a/pixman/pixman-x86.c
+++ b/pixman/pixman-x86.c
@@ -32,30 +32,25 @@
  * that would lead to SIGILL instructions on old CPUs that don't have
  * it.
  */
-#if !defined(__amd64__)  !defined(__x86_64__)  !defined(_M_AMD64)
-
-#ifdef HAVE_GETISAX
-#include sys/auxv.h
-#endif
 
 typedef enum
 {
-NO_FEATURES = 0,
-MMX = 0x1,
-MMX_EXTENSIONS = 0x2,
-SSE = 0x6,
-SSE2 = 0x8,
-CMOV = 0x10
+X86_MMX= (1  0),
+X86_MMX_EXTENSIONS = (1  1),
+X86_SSE= (1  2) | X86_MMX_EXTENSIONS,
+X86_SSE2   = (1  3),
+X86_CMOV   = (1  4)
 } cpu_features_t;
 
+#ifdef HAVE_GETISAX
 
-static unsigned int
+#include sys/auxv.h
+
+static cpu_features_t
 detect_cpu_features (void)
 {
-unsigned int features = 0;
-unsigned int result = 0;
-
-#ifdef HAVE_GETISAX
+cpu_features_t features;
+
 if (getisax (result, 1))
 {
if (result  AV_386_CMOV)
@@ -69,15 +64,47 @@ detect_cpu_features (void)
if (result  AV_386_SSE2)
features |= SSE2;
 }
+
+return features;
+}
+
+#else
+
+static pixman_bool_t
+have_cpuid (void)
+{
+#if defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) || defined 
(_MSC_VER)
+
+return TRUE;
+
+#elif defined (__GNUC__)
+uint32_t result;
+
+__asm__ volatile (
+pushf\n\t
+pop %%eax\n\t
+mov %%eax, %%ecx \n\t
+xor $0x0020, %%eax   \n\t
+push %%eax   \n\t
+popf \n\t
+pushf\n\t
+pop %%eax\n\t
+xor %%ecx, %%eax \n\t
+   mov %%eax, %0 \n\t
+   : =r (result)
+   :
+   : %eax, %ecx);
+
+return !!result;
+
 #else
-char vendor[13];
-#ifdef _MSC_VER
-int vendor0 = 0, vendor1, vendor2;
+#error Unknown compiler
 #endif
-vendor[0] = 0;
-vendor[12] = 0;
-
-#ifdef __GNUC__
+}
+
+static void
+pixman_cpuid (uint32_t feature, uint32_t *a, uint32_t *b, uint32_t *c, 
uint32_t *d)
+{
 /* see p. 118 of amd64 instruction set manual Vol3 */
 /* We need to be careful about the handling of %ebx and
  * %esp here. We can't declare either one as clobbered
@@ -86,195 +113,115 @@ detect_cpu_features (void)
  * stack pointer), so we need to make sure they have their
  * original values when we access the output operands.
  */
-__asm__ (
-pushf\n
-pop %%eax\n
-mov %%eax, %%ecx\n
-xor $0x0020, %%eax\n
-push %%eax\n
-popf\n
-pushf\n
-pop %%eax\n
-mov $0x0, %%edx\n
-xor %%ecx, %%eax\n
-jz 1f\n
-   
-mov $0x, %%eax\n
-push %%ebx\n
-cpuid\n
-mov %%ebx, %%eax\n
-pop %%ebx\n
-mov %%eax, %1\n
-mov %%edx, %2\n
-mov %%ecx, %3\n
-mov $0x0001, %%eax\n
-push %%ebx\n
-cpuid\n
-pop %%ebx\n
-1:\n
-mov %%edx, %0\n
-   : =r (result),
- =m (vendor[0]),
- =m (vendor[4]),
- =m (vendor[8])
-   :
-   : %eax, %ecx, %edx
-);
-
+#if defined 

Re: [Pixman] [PATCH 00/10] Cleanups to CPU detection

2012-06-29 Thread Søren Sandmann
Søren Sandmann Pedersen sandm...@cs.au.dk writes:

 git://people.freedesktop.org/~sandmann/pixman

 in the branch cpudetectfiles.

This got mangled by git send-mail. It should have said:


TL;DR:
Please test these patches, especially on MSVC, XO-1, MIPS and
mobile ARM. They are available here:

git://people.freedesktop.org/~sandmann/pixman

in the branch cpudetectfiles.


Soren
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH] mmx: Use expand_alpha instead of mask/shift

2012-06-29 Thread Matt Turner
---
 pixman/pixman-mmx.c |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index bff8585..071cdfd 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -1618,9 +1618,7 @@ mmx_composite_over__n_ (pixman_implementation_t 
*imp,
 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, 
src_line, 1);
 
 mask = _pixman_image_get_solid (imp, mask_image, dest_image-bits.format);
-mask = 0xff00;
-mask = mask | mask  8 | mask  16 | mask  24;
-vmask = load (mask);
+vmask = expand_alpha (load (mask));
 
 while (height--)
 {
@@ -1689,9 +1687,7 @@ mmx_composite_over_x888_n_ (pixman_implementation_t 
*imp,
 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, 
src_line, 1);
 mask = _pixman_image_get_solid (imp, mask_image, dest_image-bits.format);
 
-mask = 0xff00;
-mask = mask | mask  8 | mask  16 | mask  24;
-vmask = load (mask);
+vmask = expand_alpha (load (mask));
 srca = MC (4x00ff);
 
 while (height--)
-- 
1.7.3.4

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 00/10] Cleanups to CPU detection

2012-06-29 Thread Alan Coopersmith
On 06/29/12 01:44 PM, Søren Sandmann Pedersen wrote:
 I was looking at making use of some of the newer x86 SIMD instruction
 sets and realized that (a) we don't ever call cpuid on x86-64, we just
 assume that MMX and SSE2 are present,

I thought the amd64 ABI guaranteed MMX  SSE2 would always be present - is
that not the case?

-- 
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 00/10] Cleanups to CPU detection

2012-06-29 Thread Matt Turner
On Fri, Jun 29, 2012 at 5:20 PM, Alan Coopersmith
alan.coopersm...@oracle.com wrote:
 On 06/29/12 01:44 PM, Søren Sandmann Pedersen wrote:
 I was looking at making use of some of the newer x86 SIMD instruction
 sets and realized that (a) we don't ever call cpuid on x86-64, we just
 assume that MMX and SSE2 are present,

 I thought the amd64 ABI guaranteed MMX  SSE2 would always be present - is
 that not the case?

SSE2 seems to be required by the ABI, but I don't know why MMX would
(maybe x87 FPU is, and by extension MMX?).

I'm guessing here -- but since newer AMD chips dropped 3DNow, I would
think it'd be possible for future chips to drop MMX as well.
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 00/10] Cleanups to CPU detection

2012-06-29 Thread Søren Sandmann
Alan Coopersmith alan.coopersm...@oracle.com writes:

 On 06/29/12 01:44 PM, Søren Sandmann Pedersen wrote:
 I was looking at making use of some of the newer x86 SIMD instruction
 sets and realized that (a) we don't ever call cpuid on x86-64, we just
 assume that MMX and SSE2 are present,

 I thought the amd64 ABI guaranteed MMX  SSE2 would always be present - is
 that not the case?

The problem is not so much that assumption, but the fact that for newer
instruction sets such as SSSE3 and AVX, we do need to call cpuid even on
x86-64. So the main point is just preparing the code for that.

But in fact, I'm pretty sure I saw in some Knight's Corner (which is
x86-64) manual, linked from here:

http://software.intel.com/en-us/forums/showthread.php?t=105443

that it doesn't support SSE and MMX, only the new 512 bit vector
instructions. I can't find it now though, so maybe I was
hallucinating. They do say that that chip is not binary compatible with
other x86 chips, and in the instruction manual chapter 4.8, they say
that the state of mm0 through mm7 and xmm0 through xmm7 is NA.


Soren
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 00/10] Cleanups to CPU detection

2012-06-29 Thread Alan Coopersmith
On 06/29/12 02:36 PM, sandm...@cs.au.dk wrote:
 Alan Coopersmith alan.coopersm...@oracle.com writes:
 
 On 06/29/12 01:44 PM, Søren Sandmann Pedersen wrote:
 I was looking at making use of some of the newer x86 SIMD instruction
 sets and realized that (a) we don't ever call cpuid on x86-64, we just
 assume that MMX and SSE2 are present,

 I thought the amd64 ABI guaranteed MMX  SSE2 would always be present - is
 that not the case?
 
 The problem is not so much that assumption, but the fact that for newer
 instruction sets such as SSSE3 and AVX, we do need to call cpuid even on
 x86-64. So the main point is just preparing the code for that.
 
 But in fact, I'm pretty sure I saw in some Knight's Corner (which is
 x86-64) manual, linked from here:
 
 http://software.intel.com/en-us/forums/showthread.php?t=105443
 
 that it doesn't support SSE and MMX, only the new 512 bit vector
 instructions. I can't find it now though, so maybe I was
 hallucinating. They do say that that chip is not binary compatible with
 other x86 chips, and in the instruction manual chapter 4.8, they say
 that the state of mm0 through mm7 and xmm0 through xmm7 is NA.

Ah, okay.   It should't hurt, and if it may be useful going forward,
then go for it.


-- 
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 08/10] Cleanups and simplifications in x86 CPU feature detection

2012-06-29 Thread Søren Sandmann
Alan Coopersmith alan.coopersm...@oracle.com writes:

 Don't you need to update the feature flags set in the getisax code to match
 the renaming you did to cpu_features_t ?

Yes, I do, and I also need to initialize features to 0 and reinstate the
results variable.


Thanks,
Soren
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 08/10] Cleanups and simplifications in x86 CPU feature detection

2012-06-29 Thread Alan Coopersmith
On 06/29/12 01:44 PM, Søren Sandmann Pedersen wrote:
  typedef enum
  {
 -NO_FEATURES = 0,
 -MMX = 0x1,
 -MMX_EXTENSIONS = 0x2,
 -SSE = 0x6,
 -SSE2 = 0x8,
 -CMOV = 0x10
 +X86_MMX  = (1  0),
 +X86_MMX_EXTENSIONS   = (1  1),
 +X86_SSE  = (1  2) | X86_MMX_EXTENSIONS,
 +X86_SSE2 = (1  3),
 +X86_CMOV = (1  4)
  } cpu_features_t;
  
 +#ifdef HAVE_GETISAX
  
 -static unsigned int
 +#include sys/auxv.h
 +
 +static cpu_features_t
  detect_cpu_features (void)
  {
 -unsigned int features = 0;
 -unsigned int result = 0;
 -
 -#ifdef HAVE_GETISAX
 +cpu_features_t features;
 +
  if (getisax (result, 1))
  {
   if (result  AV_386_CMOV)
 @@ -69,15 +64,47 @@ detect_cpu_features (void)
   if (result  AV_386_SSE2)
   features |= SSE2;
  }
 +

Don't you need to update the feature flags set in the getisax code to match
the renaming you did to cpu_features_t ?

-- 
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 3/5] mmx: add scaled bilinear over_8888_8_8888

2012-06-29 Thread Matt Turner
On Wed, Jun 27, 2012 at 10:38 PM, Matt Turner matts...@gmail.com wrote:
 Reduces runtime of firefox-fishtank trace from 1510 to 1030 seconds on 
 Loongson.

 ---
  pixman/pixman-mmx.c |   84 
 +++
  1 files changed, 84 insertions(+), 0 deletions(-)

Loongson:
image firefox-fishtank 1665.163 1670.370   0.17%3/3
image firefox-fishtank 1037.738 1040.218   0.19%3/3

ARM/iwMMXt:
image firefox-fishtank 2042.723 2045.308   0.10%3/3
image firefox-fishtank 1487.282 1492.640   0.17%3/3
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [PATCH 5/5] mmx: optimize bilinear function when using 7-bit precision

2012-06-29 Thread Matt Turner
On Wed, Jun 27, 2012 at 10:38 PM, Matt Turner matts...@gmail.com wrote:
 ---
 Reduces runtime of firefox-planet-gnome trace from 156 to 153 seconds on 
 Loongson.

 Increases runtime of firefox-fishtank trace from 1030 to 1060 seconds. Why?

  pixman/pixman-mmx.c |   45 -
  1 files changed, 32 insertions(+), 13 deletions(-)

Loongson:
image firefox-fishtank 1037.738 1040.218   0.19%3/3
image firefox-fishtank 1056.611 1057.581   0.20%3/3

ARM/iwMMXt:
image firefox-fishtank 1487.282 1492.640   0.17%3/3
image firefox-fishtank 1363.913 1364.366   0.11%3/3

I'm mostly okay with the slight decrease in performance on Loongson,
given the speed-up on ARM (and on x86). Maybe look at it later..
___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman