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 531902 - Use GCC atomic buildins for g_atomic*
Use GCC atomic buildins for g_atomic*
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.16.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
: 603780 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-05-07 08:09 UTC by Sebastian Dröge (slomo)
Modified: 2010-05-11 17:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (10.65 KB, patch)
2010-01-05 11:39 UTC, Hiroyuki Ikezoe
committed Details | Review

Description Sebastian Dröge (slomo) 2008-05-07 08:09:24 UTC
Hi,
it would be nice if glib could use the GCC atomics if building with GCC, at least for architectures were we don't have special assembly code.

See
http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Atomic-Builtins.html#Atomic-Builtins
Comment 1 Joshua Element Green 2009-06-13 20:09:23 UTC
PulseAudio has pretty complete atomic operations, from what I can tell, supporting gcc 4.1, libatomic_ops and the Linux kernel as well as inline assembler fallbacks for several architectures, including ARM6+.  Perhaps this code should just be adapted to glib?
Comment 2 Hiroyuki Ikezoe 2010-01-05 11:39:28 UTC
Created attachment 150832 [details] [review]
Proposed patch

Use GCC builtin atomic operation if these are available.
Add a new file to avoid ifdef macro hell.
Comment 3 Matthias Clasen 2010-01-06 22:25:35 UTC
Looks very good in general; the one comment I got is that the casts in 

+  return __sync_bool_compare_and_swap ((long *)atomic,
+				       (long)oldval, (long)newval);

are probably unnecessary.
Comment 4 Hiroyuki Ikezoe 2010-01-07 10:37:29 UTC
Pushed with removal of needless casts.

http://git.gnome.org/browse/glib/commit/?id=37716bd00a7911de545ebca3dc7a248503eaf46e
Comment 5 Loïc Minier 2010-02-09 14:30:52 UTC
*** Bug 603780 has been marked as a duplicate of this bug. ***
Comment 6 Behdad Esfahbod 2010-05-11 17:36:38 UTC
For what it's worth, this introduced bug 617491.  Not sure how I didn't see this one going in earlier this year.
Comment 7 Behdad Esfahbod 2010-05-11 17:46:56 UTC
In bug 617491 I'm suggesting the patch that was committed be reverted and cleaned up / discussed before going in again.