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 660743 - macro wrappers for g_once_init_enter/leave
macro wrappers for g_once_init_enter/leave
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gthread
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 660747
 
 
Reported: 2011-10-03 05:15 UTC by Allison Karlitskaya (desrt)
Modified: 2011-10-04 15:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
macro wrappers for g_once_init_enter/leave (6.84 KB, patch)
2011-10-03 18:53 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Allison Karlitskaya (desrt) 2011-10-03 05:15:30 UTC
g_once_init_enter/leave() is a totally awesome API with one wart: it takes gsize* when you almost always want to deal in pointers.

We have some macro magic that makes g_atomic_pointer_*() work with any pointer-sized value.  We should add the same for g_once_init.
Comment 1 Allison Karlitskaya (desrt) 2011-10-03 18:53:35 UTC
Created attachment 198138 [details] [review]
macro wrappers for g_once_init_enter/leave

Give the macro wrapper treatment to g_once_init_enter() and leave() in
the same style that we did for gatomic.

It is now possible to use these macros with any pointer-sized object,
and not just gsize.  The leave() macro ensures that the initialisation
result is a compatible type with the pointer that it is being written
to.

Just like with gatomic, there could be problems caused by use of (void*)
casts.  We'll see how that goes, and reevaluate if necessary.
Comment 2 Matthias Clasen 2011-10-04 11:42:22 UTC
Review of attachment 198138 [details] [review]:

ok
Comment 3 Matthias Clasen 2011-10-04 11:43:00 UTC
Should add a warning to the README though, about possible problems with explicit casts.
Comment 4 Allison Karlitskaya (desrt) 2011-10-04 15:00:54 UTC
Attachment 198138 [details] pushed as 794c1a3 - macro wrappers for g_once_init_enter/leave
Comment 5 Allison Karlitskaya (desrt) 2011-10-04 15:01:51 UTC
Added a couple of README notes in a separate commit.