[cairo] [cairo-commit] 7 commits - src/cairo-array.c src/cairo-cache.c src/cairo-compiler-private.h src/cairo-hull.c src/cairo-pattern.c src/cairo-skiplist.c src/cairo-slope.c src/cairo-wideint-private.h test/.gitignore test/Makefile.am test/twin.c test/twin-ps2-ref.png test/twin-ps3-ref.png test/twin-ref.png

Carl Worth cworth at cworth.org
Mon Oct 13 10:51:04 PDT 2008


> commit 5e3fcb7934f568bb7e304a1c434a9370b693df17
> Author: Chris Wilson <chris at chris-wilson.co.uk>
> Date:   Mon Oct 6 17:02:54 2008 +0100
> 
>     [wideint] Declare the wideint arithmetic functions as const.
>     
>     'const' is a stricter form of 'pure' in that functions declared with that
>     attribute do not access any values other than their arguments (in
>     contrast to 'pure' which is allowed to read from global memory).
...
>  #if __GNUC__ >= 3
>  #define cairo_pure __attribute__((pure))
> +#define cairo_const __attribute__((const))
>  #else
>  #define cairo_pure
> +#define cairo_const
>  #endif

I love having these hints in cairo. It's great to be able to tell the
compiler what it can go ahead and optimize better. But I'd definitely
like to see a comment or two describing the semantics here, for two
reasons:

1. There's a teaching opportunity here. As people see "cairo_const" in
the implementation and wonder how it's different than "const" it would
be nice if they could come here to the header file and find out what it
actually means. That way they could use similar attributes in their own
project, (or, who knows?, augment cairo to support similar attributes
for other compilers).

2. There's a subtle distinction between cairo_pure and cairo_const.
We've made this mistake ourselves already, so let's help ourselves avoid
making it again in the future by documenting exactly what each one
means.

Thanks, as always, for a tremendous amount of very high-quality
improvements to cairo, Chris! I really appreciate all of it.

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.cairographics.org/archives/cairo/attachments/20081013/8d168f68/attachment.pgp 


More information about the cairo mailing list