mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
g_atomic_int_get, g_atomic_pointer_get: accept const arguments
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Matthias Clasen <mclasen@redhat.com> Bug: https://bugzilla.gnome.org/show_bug.cgi?id=692583
This commit is contained in:
parent
f7b31301d5
commit
cf68300d27
@ -111,7 +111,7 @@
|
||||
* Since: 2.4
|
||||
**/
|
||||
gint
|
||||
(g_atomic_int_get) (volatile gint *atomic)
|
||||
(g_atomic_int_get) (const volatile gint *atomic)
|
||||
{
|
||||
return g_atomic_int_get (atomic);
|
||||
}
|
||||
@ -316,9 +316,9 @@ guint
|
||||
* Since: 2.4
|
||||
**/
|
||||
gpointer
|
||||
(g_atomic_pointer_get) (volatile void *atomic)
|
||||
(g_atomic_pointer_get) (const volatile void *atomic)
|
||||
{
|
||||
return g_atomic_pointer_get ((volatile gpointer *) atomic);
|
||||
return g_atomic_pointer_get ((const volatile gpointer *) atomic);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,7 +477,7 @@ gsize
|
||||
* http://msdn.microsoft.com/en-us/library/ms684122(v=vs.85).aspx
|
||||
*/
|
||||
gint
|
||||
(g_atomic_int_get) (volatile gint *atomic)
|
||||
(g_atomic_int_get) (const volatile gint *atomic)
|
||||
{
|
||||
MemoryBarrier ();
|
||||
return *atomic;
|
||||
@ -541,9 +541,9 @@ guint
|
||||
|
||||
|
||||
gpointer
|
||||
(g_atomic_pointer_get) (volatile void *atomic)
|
||||
(g_atomic_pointer_get) (const volatile void *atomic)
|
||||
{
|
||||
volatile gpointer *ptr = atomic;
|
||||
const volatile gpointer *ptr = atomic;
|
||||
|
||||
MemoryBarrier ();
|
||||
return *ptr;
|
||||
|
@ -31,7 +31,7 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
gint g_atomic_int_get (volatile gint *atomic);
|
||||
gint g_atomic_int_get (const volatile gint *atomic);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
void g_atomic_int_set (volatile gint *atomic,
|
||||
gint newval);
|
||||
@ -57,7 +57,7 @@ guint g_atomic_int_xor (volatile guint *a
|
||||
guint val);
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
gpointer g_atomic_pointer_get (volatile void *atomic);
|
||||
gpointer g_atomic_pointer_get (const volatile void *atomic);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
void g_atomic_pointer_set (volatile void *atomic,
|
||||
gpointer newval);
|
||||
|
@ -14,6 +14,8 @@
|
||||
static void
|
||||
test_types (void)
|
||||
{
|
||||
const gint *csp;
|
||||
const gint * const *cspp;
|
||||
guint u, u2;
|
||||
gint s, s2;
|
||||
gpointer vp, vp2;
|
||||
@ -21,6 +23,9 @@ test_types (void)
|
||||
gsize gs, gs2;
|
||||
gboolean res;
|
||||
|
||||
csp = &s;
|
||||
cspp = &csp;
|
||||
|
||||
g_atomic_int_set (&u, 5);
|
||||
u2 = g_atomic_int_get (&u);
|
||||
g_assert_cmpint (u2, ==, 5);
|
||||
@ -100,6 +105,9 @@ test_types (void)
|
||||
g_assert (gs2 == 12);
|
||||
g_assert (gs == 8);
|
||||
|
||||
g_assert (g_atomic_int_get (csp) == s);
|
||||
g_assert (g_atomic_pointer_get (cspp) == csp);
|
||||
|
||||
/* repeat, without the macros */
|
||||
#undef g_atomic_int_set
|
||||
#undef g_atomic_int_get
|
||||
@ -200,6 +208,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
gs2 = g_atomic_pointer_xor (&gs, 4);
|
||||
g_assert (gs2 == 12);
|
||||
g_assert (gs == 8);
|
||||
|
||||
g_assert (g_atomic_int_get (csp) == s);
|
||||
g_assert (g_atomic_pointer_get (cspp) == csp);
|
||||
}
|
||||
|
||||
#define THREADS 10
|
||||
|
Loading…
Reference in New Issue
Block a user