#define CONTENTION_CLASSES 11
static volatile gint g_bit_lock_contended[CONTENTION_CLASSES];
+#if (defined (i386) || defined (__amd64__))
+ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+ #define USE_ASM_GOTO 1
+ #endif
+#endif
+
/**
* g_bit_lock:
* @address: a pointer to an integer
g_bit_lock (volatile gint *address,
gint lock_bit)
{
-#if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
+#ifdef USE_ASM_GOTO
retry:
asm volatile goto ("lock bts %1, (%0)\n"
"jc %l[contended]"
g_bit_trylock (volatile gint *address,
gint lock_bit)
{
-#if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
+#ifdef USE_ASM_GOTO
gboolean result;
asm volatile ("lock bts %2, (%1)\n"
g_bit_unlock (volatile gint *address,
gint lock_bit)
{
-#if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
+#ifdef USE_ASM_GOTO
asm volatile ("lock btr %1, (%0)"
: /* no output */
: "r" (address), "r" (lock_bit)
g_return_if_fail (lock_bit < 32);
{
-#if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
+#ifdef USE_ASM_GOTO
retry:
asm volatile goto ("lock bts %1, (%0)\n"
"jc %l[contended]"
g_return_val_if_fail (lock_bit < 32, FALSE);
{
-#if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
+#ifdef USE_ASM_GOTO
gboolean result;
asm volatile ("lock bts %2, (%1)\n"
g_return_if_fail (lock_bit < 32);
{
-#if defined (__GNUC__) && (defined (i386) || defined (__amd64__))
+#ifdef USE_ASM_GOTO
asm volatile ("lock btr %1, (%0)"
: /* no output */
: "r" (address), "r" ((gsize) lock_bit)