else \
for (int i = __elision_aconf.try_tbegin; i > 0; i--) \
{ \
- if (__builtin_tbegin (0)) \
+ if (__libc_tbegin (0)) \
{ \
if (is_lock_free) \
{ \
ret = 1; \
break; \
} \
- __builtin_tabort (_ABORT_LOCK_BUSY); \
+ __libc_tabort (_ABORT_LOCK_BUSY); \
} \
else \
if (!__get_new_count (&adapt_count,i)) \
if (__elision_aconf.try_tbegin > 0) \
{ \
if (write) \
- __builtin_tabort (_ABORT_NESTED_TRYLOCK); \
+ __libc_tabort (_ABORT_NESTED_TRYLOCK); \
ret = ELIDE_LOCK (adapt_count, is_lock_free); \
} \
ret; \
{
if (is_lock_free)
{
- __builtin_tend (0);
+ __libc_tend (0);
return true;
}
return false;
__lll_trylock_elision (int *futex, short *adapt_count)
{
/* Implement POSIX semantics by forbiding nesting elided trylocks. */
- __builtin_tabort (_ABORT_NESTED_TRYLOCK);
+ __libc_tabort (_ABORT_NESTED_TRYLOCK);
/* Only try a transaction if it's worth it. */
if (*adapt_count > 0)
goto use_lock;
}
- if (__builtin_tbegin (0))
+ if (__libc_tbegin (0))
{
if (*futex == 0)
return 0;
/* Lock was busy. Fall back to normal locking. */
- __builtin_tabort (_ABORT_LOCK_BUSY);
+ __libc_tabort (_ABORT_LOCK_BUSY);
}
else
{
__ret; \
})
-#define __builtin_tbegin(tdb) _tbegin ()
-#define __builtin_tend(nested) _tend ()
-#define __builtin_tabort(abortcode) _tabort (abortcode)
-#define __builtin_get_texasru() _texasru ()
+#define __libc_tbegin(tdb) _tbegin ()
+#define __libc_tend(nested) _tend ()
+#define __libc_tabort(abortcode) _tabort (abortcode)
+#define __builtin_get_texasru() _texasru ()
#else
# include <htmintrin.h>
+
+# ifdef __TM_FENCE__
+ /* New GCC behavior. */
+# define __libc_tbegin(R) __builtin_tbegin (R);
+# define __libc_tend(R) __builtin_tend (R);
+# define __libc_tabort(R) __builtin_tabort (R);
+# else
+ /* Workaround an old GCC behavior. Earlier releases of GCC 4.9 and 5.0,
+ didn't use to treat __builtin_tbegin, __builtin_tend and
+ __builtin_tabort as compiler barriers, moving instructions into and
+ out the transaction.
+ Remove this when glibc drops support for GCC 5.0. */
+# define __libc_tbegin(R) \
+ ({ __asm__ volatile("" ::: "memory"); \
+ unsigned int __ret = __builtin_tbegin (R); \
+ __asm__ volatile("" ::: "memory"); \
+ __ret; \
+ })
+# define __libc_tabort(R) \
+ ({ __asm__ volatile("" ::: "memory"); \
+ unsigned int __ret = __builtin_tabort (R); \
+ __asm__ volatile("" ::: "memory"); \
+ __ret; \
+ })
+# define __libc_tend(R) \
+ ({ __asm__ volatile("" ::: "memory"); \
+ unsigned int __ret = __builtin_tend (R); \
+ __asm__ volatile("" ::: "memory"); \
+ __ret; \
+ })
+# endif /* __TM_FENCE__ */
#endif /* __HTM__ */
#endif /* __ASSEMBLER__ */