summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-15 17:26:59 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-15 18:19:08 +0100
commit56c9b2de7a2b93b2e0c59cf98326d8c0d4d508ba (patch)
tree2c4bf3988fa523e971089654ee604a7785cd106f
parentccf84a8883ebb8d2ee8f55eb53da4dfc96887de0 (diff)
Use __uint128_t and __int128_t if available
GCC uses a peculiar name for a real 128-bit integer on x86-64. Speedups, xlib on a gm45 ======================== poppler 41246.56 -> 35102.82: 1.18x speedup swfdec-youtube 12623.01 -> 11936.79: 1.06x speedup Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--build/configure.ac.system2
-rw-r--r--src/cairo-wideint-private.h1
-rw-r--r--src/cairo-wideint-type-private.h6
-rw-r--r--src/cairo-wideint.c91
4 files changed, 50 insertions, 50 deletions
diff --git a/build/configure.ac.system b/build/configure.ac.system
index 3fffb949..3f6ab7e2 100644
--- a/build/configure.ac.system
+++ b/build/configure.ac.system
@@ -87,7 +87,7 @@ fi
dnl Checks for precise integer types
AC_CHECK_HEADERS([stdint.h inttypes.h sys/int_types.h])
-AC_CHECK_TYPES([uint64_t, uint128_t])
+AC_CHECK_TYPES([uint64_t, uint128_t, __uint128_t])
dnl Check for socket support for any2ppm daemon
AC_CHECK_HEADERS([fcntl.h unistd.h signal.h sys/stat.h sys/socket.h sys/poll.h sys/un.h])
diff --git a/src/cairo-wideint-private.h b/src/cairo-wideint-private.h
index ec7fa1f6..d3b01cb0 100644
--- a/src/cairo-wideint-private.h
+++ b/src/cairo-wideint-private.h
@@ -272,6 +272,7 @@ int I _cairo_int128_cmp (cairo_int128_t a, cairo_int128_t b);
#define _cairo_int128_sub(a,b) ((a) - (b))
#define _cairo_int128_mul(a,b) ((a) * (b))
#define _cairo_int64x64_128_mul(a,b) ((int128_t) (a) * (b))
+#define _cairo_int64x32_128_mul(a, b) _cairo_int64x64_128_mul(a, _cairo_int32_to_int64(b))
#define _cairo_int128_lt(a,b) ((a) < (b))
#define _cairo_int128_cmp(a,b) ((a) == (b) ? 0 : (a) < (b) ? -1 : 1)
#define _cairo_int128_is_zero(a) ((a) == 0)
diff --git a/src/cairo-wideint-type-private.h b/src/cairo-wideint-type-private.h
index 3d241502..c7363c02 100644
--- a/src/cairo-wideint-type-private.h
+++ b/src/cairo-wideint-type-private.h
@@ -121,6 +121,12 @@ typedef struct _cairo_quorem64 {
cairo_int64_t rem;
} cairo_quorem64_t;
+/* gcc has a non-standard name. */
+#if HAVE___UINT128_T && !HAVE_UINT128_T
+typedef __uint128_t uint128_t;
+typedef __int128_t int128_t;
+#define HAVE_UINT128_T 1
+#endif
#if !HAVE_UINT128_T
diff --git a/src/cairo-wideint.c b/src/cairo-wideint.c
index 1843a602..2c70d866 100644
--- a/src/cairo-wideint.c
+++ b/src/cairo-wideint.c
@@ -37,10 +37,52 @@
#if HAVE_UINT64_T
+#define uint64_lo32(i) ((i) & 0xffffffff)
+#define uint64_hi32(i) ((i) >> 32)
+#define uint64_lo(i) ((i) & 0xffffffff)
+#define uint64_hi(i) ((i) >> 32)
+#define uint64_shift32(i) ((i) << 32)
+#define uint64_carry32 (((uint64_t) 1) << 32)
+
#define _cairo_uint32s_to_uint64(h,l) ((uint64_t) (h) << 32 | (l))
#else
+#define uint64_lo32(i) ((i).lo)
+#define uint64_hi32(i) ((i).hi)
+
+static cairo_uint64_t
+uint64_lo (cairo_uint64_t i)
+{
+ cairo_uint64_t s;
+
+ s.lo = i.lo;
+ s.hi = 0;
+ return s;
+}
+
+static cairo_uint64_t
+uint64_hi (cairo_uint64_t i)
+{
+ cairo_uint64_t s;
+
+ s.lo = i.hi;
+ s.hi = 0;
+ return s;
+}
+
+static cairo_uint64_t
+uint64_shift32 (cairo_uint64_t i)
+{
+ cairo_uint64_t s;
+
+ s.lo = 0;
+ s.hi = i.lo;
+ return s;
+}
+
+static const cairo_uint64_t uint64_carry32 = { 0, 1 };
+
cairo_uint64_t
_cairo_uint32_to_uint64 (uint32_t i)
{
@@ -308,7 +350,6 @@ _cairo_uint64_divrem (cairo_uint64_t num, cairo_uint64_t den)
#endif /* !HAVE_UINT64_T */
#if HAVE_UINT128_T
-
cairo_uquorem128_t
_cairo_uint128_divrem (cairo_uint128_t num, cairo_uint128_t den)
{
@@ -385,54 +426,6 @@ _cairo_uint128_sub (cairo_uint128_t a, cairo_uint128_t b)
return s;
}
-#if HAVE_UINT64_T
-
-#define uint64_lo32(i) ((i) & 0xffffffff)
-#define uint64_hi32(i) ((i) >> 32)
-#define uint64_lo(i) ((i) & 0xffffffff)
-#define uint64_hi(i) ((i) >> 32)
-#define uint64_shift32(i) ((i) << 32)
-#define uint64_carry32 (((uint64_t) 1) << 32)
-
-#else
-
-#define uint64_lo32(i) ((i).lo)
-#define uint64_hi32(i) ((i).hi)
-
-static cairo_uint64_t
-uint64_lo (cairo_uint64_t i)
-{
- cairo_uint64_t s;
-
- s.lo = i.lo;
- s.hi = 0;
- return s;
-}
-
-static cairo_uint64_t
-uint64_hi (cairo_uint64_t i)
-{
- cairo_uint64_t s;
-
- s.lo = i.hi;
- s.hi = 0;
- return s;
-}
-
-static cairo_uint64_t
-uint64_shift32 (cairo_uint64_t i)
-{
- cairo_uint64_t s;
-
- s.lo = 0;
- s.hi = i.lo;
- return s;
-}
-
-static const cairo_uint64_t uint64_carry32 = { 0, 1 };
-
-#endif
-
cairo_uint128_t
_cairo_uint64x64_128_mul (cairo_uint64_t a, cairo_uint64_t b)
{