2011-05-28 21:59:18 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2011 Ryan Lortie
|
2004-02-26 15:30:35 +01:00
|
|
|
*
|
2017-01-05 12:47:07 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2004-02-26 15:30:35 +01:00
|
|
|
*
|
2011-05-28 21:59:18 +02:00
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2004-02-26 15:30:35 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2014-01-23 12:58:29 +01:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2011-05-28 21:59:18 +02:00
|
|
|
*
|
|
|
|
* Author: Ryan Lortie <desrt@desrt.ca>
|
2004-02-26 15:30:35 +01:00
|
|
|
*/
|
2008-03-14 20:30:38 +01:00
|
|
|
|
2012-12-28 05:43:14 +01:00
|
|
|
#ifndef __G_ATOMIC_H__
|
|
|
|
#define __G_ATOMIC_H__
|
|
|
|
|
2011-10-12 06:24:46 +02:00
|
|
|
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
|
2008-03-14 20:30:38 +01:00
|
|
|
#error "Only <glib.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2011-05-29 05:27:24 +02:00
|
|
|
#include <glib/gtypes.h>
|
2004-02-26 15:30:35 +01:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
2008-03-14 20:30:38 +01:00
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2013-01-26 18:37:33 +01:00
|
|
|
gint g_atomic_int_get (const volatile gint *atomic);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
void g_atomic_int_set (volatile gint *atomic,
|
|
|
|
gint newval);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
void g_atomic_int_inc (volatile gint *atomic);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
gboolean g_atomic_int_dec_and_test (volatile gint *atomic);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic,
|
|
|
|
gint oldval,
|
|
|
|
gint newval);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
gint g_atomic_int_add (volatile gint *atomic,
|
|
|
|
gint val);
|
2012-05-25 14:42:50 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-05-29 05:15:07 +02:00
|
|
|
guint g_atomic_int_and (volatile guint *atomic,
|
|
|
|
guint val);
|
2012-05-25 14:42:50 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-05-29 05:15:07 +02:00
|
|
|
guint g_atomic_int_or (volatile guint *atomic,
|
|
|
|
guint val);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
guint g_atomic_int_xor (volatile guint *atomic,
|
|
|
|
guint val);
|
2011-05-28 21:59:18 +02:00
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2013-01-26 18:37:33 +01:00
|
|
|
gpointer g_atomic_pointer_get (const volatile void *atomic);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
void g_atomic_pointer_set (volatile void *atomic,
|
|
|
|
gpointer newval);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
gboolean g_atomic_pointer_compare_and_exchange (volatile void *atomic,
|
|
|
|
gpointer oldval,
|
|
|
|
gpointer newval);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
gssize g_atomic_pointer_add (volatile void *atomic,
|
|
|
|
gssize val);
|
2012-05-25 14:42:50 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-05-29 05:15:07 +02:00
|
|
|
gsize g_atomic_pointer_and (volatile void *atomic,
|
|
|
|
gsize val);
|
2012-05-25 14:42:50 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_30
|
2011-05-29 05:15:07 +02:00
|
|
|
gsize g_atomic_pointer_or (volatile void *atomic,
|
|
|
|
gsize val);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-05-29 05:15:07 +02:00
|
|
|
gsize g_atomic_pointer_xor (volatile void *atomic,
|
|
|
|
gsize val);
|
2011-05-28 21:59:18 +02:00
|
|
|
|
2014-05-27 15:25:37 +02:00
|
|
|
GLIB_DEPRECATED_IN_2_30_FOR(g_atomic_int_add)
|
2011-05-29 05:15:07 +02:00
|
|
|
gint g_atomic_int_exchange_and_add (volatile gint *atomic,
|
2011-10-11 08:34:59 +02:00
|
|
|
gint val);
|
2011-05-22 22:31:43 +02:00
|
|
|
|
2011-05-28 21:59:18 +02:00
|
|
|
G_END_DECLS
|
2011-05-22 22:31:43 +02:00
|
|
|
|
2011-10-18 22:21:50 +02:00
|
|
|
#if defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
|
2011-05-22 22:31:43 +02:00
|
|
|
|
2014-05-27 15:28:08 +02:00
|
|
|
/* We prefer the new C11-style atomic extension of GCC if available */
|
2014-06-20 20:38:45 +02:00
|
|
|
#if defined(__ATOMIC_SEQ_CST) && !defined(__clang__)
|
2014-05-27 15:28:08 +02:00
|
|
|
|
2015-05-04 11:32:21 +02:00
|
|
|
/* This assumes sizeof(int) is 4: gatomic.c statically
|
|
|
|
* asserts that (using G_STATIC_ASSERT at top-level in a header was
|
|
|
|
* problematic, see #730932) */
|
|
|
|
|
2014-05-27 15:28:08 +02:00
|
|
|
#define g_atomic_int_get(atomic) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ *(atomic) : 1); \
|
2014-05-27 15:28:08 +02:00
|
|
|
(gint) __atomic_load_4 ((atomic), __ATOMIC_SEQ_CST); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_int_set(atomic, newval) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ (newval) : 1); \
|
2014-05-27 15:28:08 +02:00
|
|
|
__atomic_store_4 ((atomic), (newval), __ATOMIC_SEQ_CST); \
|
|
|
|
}))
|
|
|
|
|
|
|
|
#if GLIB_SIZEOF_VOID_P == 8
|
|
|
|
|
|
|
|
#define g_atomic_pointer_get(atomic) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-07-10 17:44:22 +02:00
|
|
|
guint64 gapg_temp = __atomic_load_8 ((atomic), __ATOMIC_SEQ_CST); \
|
|
|
|
(gpointer) gapg_temp; \
|
2014-05-27 15:28:08 +02:00
|
|
|
}))
|
|
|
|
#define g_atomic_pointer_set(atomic, newval) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
2014-05-27 15:28:08 +02:00
|
|
|
__atomic_store_8 ((atomic), (gsize) (newval), __ATOMIC_SEQ_CST); \
|
|
|
|
}))
|
|
|
|
|
|
|
|
#else /* GLIB_SIZEOF_VOID_P == 8 */
|
|
|
|
|
2015-05-04 11:32:21 +02:00
|
|
|
/* This assumes that if sizeof(void *) is not 8, then it is 4:
|
|
|
|
* gatomic.c statically asserts that (using G_STATIC_ASSERT
|
|
|
|
* at top-level in a header was problematic, see #730932) */
|
|
|
|
|
2014-05-27 15:28:08 +02:00
|
|
|
#define g_atomic_pointer_get(atomic) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-07-10 17:44:22 +02:00
|
|
|
guint32 gapg_temp = __atomic_load_4 ((atomic), __ATOMIC_SEQ_CST); \
|
|
|
|
(gpointer) gapg_temp; \
|
2014-05-27 15:28:08 +02:00
|
|
|
}))
|
|
|
|
#define g_atomic_pointer_set(atomic, newval) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
2014-05-27 15:28:08 +02:00
|
|
|
__atomic_store_4 ((atomic), (gsize) (newval), __ATOMIC_SEQ_CST); \
|
|
|
|
}))
|
|
|
|
|
|
|
|
#endif /* GLIB_SIZEOF_VOID_P == 8 */
|
|
|
|
|
|
|
|
#else /* defined(__ATOMIC_SEQ_CST) */
|
|
|
|
|
2011-05-28 06:16:39 +02:00
|
|
|
#define g_atomic_int_get(atomic) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ *(atomic) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
__sync_synchronize (); \
|
|
|
|
(gint) *(atomic); \
|
|
|
|
}))
|
2011-05-28 06:16:39 +02:00
|
|
|
#define g_atomic_int_set(atomic, newval) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ (newval) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
*(atomic) = (newval); \
|
|
|
|
__sync_synchronize (); \
|
|
|
|
}))
|
2014-05-27 15:28:08 +02:00
|
|
|
#define g_atomic_pointer_get(atomic) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
|
|
|
__sync_synchronize (); \
|
|
|
|
(gpointer) *(atomic); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_pointer_set(atomic, newval) \
|
|
|
|
(G_GNUC_EXTENSION ({ \
|
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
2014-05-27 15:28:08 +02:00
|
|
|
*(atomic) = (__typeof__ (*(atomic))) (gsize) (newval); \
|
|
|
|
__sync_synchronize (); \
|
|
|
|
}))
|
|
|
|
|
|
|
|
#endif /* !defined(__ATOMIC_SEQ_CST) */
|
|
|
|
|
2011-05-28 21:59:18 +02:00
|
|
|
#define g_atomic_int_inc(atomic) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ *(atomic) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(void) __sync_fetch_and_add ((atomic), 1); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_int_dec_and_test(atomic) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ *(atomic) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
__sync_fetch_and_sub ((atomic), 1) == 1; \
|
|
|
|
}))
|
|
|
|
#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \
|
2018-07-10 17:44:22 +02:00
|
|
|
__sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \
|
2011-05-28 21:59:18 +02:00
|
|
|
}))
|
|
|
|
#define g_atomic_int_add(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(gint) __sync_fetch_and_add ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_int_and(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(guint) __sync_fetch_and_and ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_int_or(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(guint) __sync_fetch_and_or ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_int_xor(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? *(atomic) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(guint) __sync_fetch_and_xor ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
|
|
|
|
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
2018-07-10 17:44:22 +02:00
|
|
|
__sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \
|
2011-05-28 21:59:18 +02:00
|
|
|
}))
|
|
|
|
#define g_atomic_pointer_add(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
|
|
|
(void) (0 ? (val) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(gssize) __sync_fetch_and_add ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_pointer_and(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
|
|
|
(void) (0 ? (val) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(gsize) __sync_fetch_and_and ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_pointer_or(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
|
|
|
(void) (0 ? (val) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(gsize) __sync_fetch_and_or ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
#define g_atomic_pointer_xor(atomic, val) \
|
2014-05-27 15:27:54 +02:00
|
|
|
(G_GNUC_EXTENSION ({ \
|
2011-05-28 21:59:18 +02:00
|
|
|
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
|
2018-02-12 19:20:57 +01:00
|
|
|
(void) (0 ? (gpointer) *(atomic) : NULL); \
|
|
|
|
(void) (0 ? (val) ^ (val) : 1); \
|
2011-05-28 21:59:18 +02:00
|
|
|
(gsize) __sync_fetch_and_xor ((atomic), (val)); \
|
|
|
|
}))
|
|
|
|
|
2011-10-18 22:21:50 +02:00
|
|
|
#else /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */
|
2010-07-11 03:51:34 +02:00
|
|
|
|
2011-05-28 21:59:18 +02:00
|
|
|
#define g_atomic_int_get(atomic) \
|
|
|
|
(g_atomic_int_get ((gint *) (atomic)))
|
|
|
|
#define g_atomic_int_set(atomic, newval) \
|
|
|
|
(g_atomic_int_set ((gint *) (atomic), (gint) (newval)))
|
|
|
|
#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \
|
|
|
|
(g_atomic_int_compare_and_exchange ((gint *) (atomic), (oldval), (newval)))
|
|
|
|
#define g_atomic_int_add(atomic, val) \
|
|
|
|
(g_atomic_int_add ((gint *) (atomic), (val)))
|
|
|
|
#define g_atomic_int_and(atomic, val) \
|
2011-10-18 22:21:17 +02:00
|
|
|
(g_atomic_int_and ((guint *) (atomic), (val)))
|
2011-05-28 21:59:18 +02:00
|
|
|
#define g_atomic_int_or(atomic, val) \
|
2011-10-18 22:21:17 +02:00
|
|
|
(g_atomic_int_or ((guint *) (atomic), (val)))
|
2011-05-28 21:59:18 +02:00
|
|
|
#define g_atomic_int_xor(atomic, val) \
|
2011-10-18 22:21:17 +02:00
|
|
|
(g_atomic_int_xor ((guint *) (atomic), (val)))
|
2011-05-28 21:59:18 +02:00
|
|
|
#define g_atomic_int_inc(atomic) \
|
|
|
|
(g_atomic_int_inc ((gint *) (atomic)))
|
2010-07-11 03:51:34 +02:00
|
|
|
#define g_atomic_int_dec_and_test(atomic) \
|
2011-05-28 21:59:18 +02:00
|
|
|
(g_atomic_int_dec_and_test ((gint *) (atomic)))
|
2004-02-26 15:30:35 +01:00
|
|
|
|
2011-05-28 21:59:18 +02:00
|
|
|
#define g_atomic_pointer_get(atomic) \
|
|
|
|
(g_atomic_pointer_get (atomic))
|
|
|
|
#define g_atomic_pointer_set(atomic, newval) \
|
|
|
|
(g_atomic_pointer_set ((atomic), (gpointer) (newval)))
|
|
|
|
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
|
|
|
|
(g_atomic_pointer_compare_and_exchange ((atomic), (gpointer) (oldval), (gpointer) (newval)))
|
|
|
|
#define g_atomic_pointer_add(atomic, val) \
|
|
|
|
(g_atomic_pointer_add ((atomic), (gssize) (val)))
|
|
|
|
#define g_atomic_pointer_and(atomic, val) \
|
|
|
|
(g_atomic_pointer_and ((atomic), (gsize) (val)))
|
|
|
|
#define g_atomic_pointer_or(atomic, val) \
|
|
|
|
(g_atomic_pointer_or ((atomic), (gsize) (val)))
|
|
|
|
#define g_atomic_pointer_xor(atomic, val) \
|
|
|
|
(g_atomic_pointer_xor ((atomic), (gsize) (val)))
|
|
|
|
|
|
|
|
#endif /* defined(__GNUC__) && defined(G_ATOMIC_OP_USE_GCC_BUILTINS) */
|
2008-03-14 20:30:38 +01:00
|
|
|
|
2004-02-26 15:30:35 +01:00
|
|
|
#endif /* __G_ATOMIC_H__ */
|