[cairo] Mark cairo_fixed_t conversion functions with
attribute(const)
Chris Wilson
chris at chris-wilson.co.uk
Wed Mar 21 10:51:07 PDT 2007
The cairo_fixed_t conversion functions look apt for the const attribute
as they only operate on their parameters and do not touch memory. They
also look suitable for inlining should anyone have any profile data
suggesting it would be a win...
--
Chris Wilson
-------------- next part --------------
>From 1283c0c6630f52c2af710cd241e0b0f1088c2fac Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 21 Mar 2007 17:43:33 +0000
Subject: [PATCH] Mark cairo_fixed_t conversion functions as const.
Introduce the gcc attribute(const), which implies that function only
operates on its parameters and has no effects other than the return
value. And use the attribute for the cairo_fixed.c functions which
meet this strict specification.
---
src/cairoint.h | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/cairoint.h b/src/cairoint.h
index 6e171e5..cd5f2aa 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -101,6 +101,12 @@ CAIRO_BEGIN_DECLS
#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)
#endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+#define CAIRO_PURE __attribute__((__pure__))
+#else
+#define CAIRO_PURE
+#endif
+
/* slim_internal.h */
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
#define cairo_private __attribute__((__visibility__("hidden")))
@@ -1211,30 +1217,30 @@ _cairo_lround (double d);
/* cairo_fixed.c */
cairo_private cairo_fixed_t
-_cairo_fixed_from_int (int i);
+_cairo_fixed_from_int (int i) CAIRO_PURE;
#define CAIRO_FIXED_ONE _cairo_fixed_from_int (1)
cairo_private cairo_fixed_t
-_cairo_fixed_from_double (double d);
+_cairo_fixed_from_double (double d) CAIRO_PURE;
cairo_private cairo_fixed_t
-_cairo_fixed_from_26_6 (uint32_t i);
+_cairo_fixed_from_26_6 (uint32_t i) CAIRO_PURE;
cairo_private double
-_cairo_fixed_to_double (cairo_fixed_t f);
+_cairo_fixed_to_double (cairo_fixed_t f) CAIRO_PURE;
cairo_private int
-_cairo_fixed_is_integer (cairo_fixed_t f);
+_cairo_fixed_is_integer (cairo_fixed_t f) CAIRO_PURE;
cairo_private int
-_cairo_fixed_integer_part (cairo_fixed_t f);
+_cairo_fixed_integer_part (cairo_fixed_t f) CAIRO_PURE;
cairo_private int
-_cairo_fixed_integer_floor (cairo_fixed_t f);
+_cairo_fixed_integer_floor (cairo_fixed_t f) CAIRO_PURE;
cairo_private int
-_cairo_fixed_integer_ceil (cairo_fixed_t f);
+_cairo_fixed_integer_ceil (cairo_fixed_t f) CAIRO_PURE;
/* cairo_gstate.c */
cairo_private cairo_status_t
--
1.4.4.2
More information about the cairo
mailing list