[cairo] Mark cairo_fixed_t conversion functions with attribute(const)

Chris Wilson chris at chris-wilson.co.uk
Wed Mar 21 10:57:20 PDT 2007


Actually attach the right patch this time - I tried outsmarting git and
lost.
--
Chris Wilson
-------------- next part --------------
>From 4fba15f347169e69b22744018593c6f52cf6af5c 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..090f5a4 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__ > 4)
+#define CAIRO_CONST __attribute__((__const__))
+#else
+#define CAIRO_CONST
+#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_CONST;
 
 #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_CONST;
 
 cairo_private cairo_fixed_t
-_cairo_fixed_from_26_6 (uint32_t i);
+_cairo_fixed_from_26_6 (uint32_t i) CAIRO_CONST;
 
 cairo_private double
-_cairo_fixed_to_double (cairo_fixed_t f);
+_cairo_fixed_to_double (cairo_fixed_t f) CAIRO_CONST;
 
 cairo_private int
-_cairo_fixed_is_integer (cairo_fixed_t f);
+_cairo_fixed_is_integer (cairo_fixed_t f) CAIRO_CONST;
 
 cairo_private int
-_cairo_fixed_integer_part (cairo_fixed_t f);
+_cairo_fixed_integer_part (cairo_fixed_t f) CAIRO_CONST;
 
 cairo_private int
-_cairo_fixed_integer_floor (cairo_fixed_t f);
+_cairo_fixed_integer_floor (cairo_fixed_t f) CAIRO_CONST;
 
 cairo_private int
-_cairo_fixed_integer_ceil (cairo_fixed_t f);
+_cairo_fixed_integer_ceil (cairo_fixed_t f) CAIRO_CONST;
 
 /* cairo_gstate.c */
 cairo_private cairo_status_t
-- 
1.4.4.2



More information about the cairo mailing list