After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 632557 - [macros] Define restrict keyword if not available
[macros] Define restrict keyword if not available
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other Linux
: Normal enhancement
: 0.10.32
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-10-19 13:53 UTC by Sebastian Dröge (slomo)
Modified: 2010-12-03 19:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
macros: Define restrict keyword if not available (1.00 KB, patch)
2010-10-19 13:54 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2010-10-19 13:53:51 UTC
See attached patch.
Comment 1 Sebastian Dröge (slomo) 2010-10-19 13:54:11 UTC
Created attachment 172723 [details] [review]
macros: Define restrict keyword if not available

This change always defines the restrict keyword if a
non-C99 C compiler is used. In the case of GCC >= 4
it will be defined to __restrict__, in all other
cases to nothing. This allows to use the restrict
keyword unconditionally.
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2010-11-07 16:17:19 UTC
good idea. please push after freeze :)
Comment 3 Sebastian Dröge (slomo) 2010-12-02 18:03:53 UTC
commit a797b9f22bf548ff5caa70d670d26aaaade6540e
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Tue Oct 19 15:52:30 2010 +0200

    macros: Define restrict keyword if not available
    
    This change always defines the restrict keyword if a
    non-C99 C compiler is used. In the case of GCC >= 4
    it will be defined to __restrict__, in all other
    cases to nothing. This allows to use the restrict
    keyword unconditionally.
Comment 4 David Schleef 2010-12-02 23:54:59 UTC
Do we really want to do this in the global namespace?  If we want to use this in headers, we should define GST_RESTRICT.
Comment 5 Sebastian Dröge (slomo) 2010-12-03 17:01:29 UTC
What problems do you see here? It's the same as for "inline", which is defined by GLib headers if it isn't available
Comment 6 David Schleef 2010-12-03 19:48:33 UTC
Good point.

I suppose the only error is if some theoretical non-gcc compiler supports restrict, but not c99.  In that case, any 'restrict' in user code gets defined away, which *might* cause a minor performance loss.

We can deal with that if it happens.