===================================================================
@@ -216,6 +216,7 @@ CFLAGS="$save_CFLAGS $XCFLAGS"
# Check for __sync_val_compare_and_swap, but only after the target has
# had a chance to set XCFLAGS.
LIBITM_CHECK_SYNC_BUILTINS
+LIBITM_CHECK_64BIT_SYNC_BUILTINS
# Cleanup and exit.
CFLAGS="$save_CFLAGS"
===================================================================
@@ -84,6 +84,10 @@ GTM::gtm_transaction::operator delete(vo
thr->free_tx[idx] = tx;
}
+#ifndef HAVE_64BIT_SYNC_BUILTINS
+static pthread_mutex_t global_tid_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
uint32_t
GTM::gtm_transaction::begin_transaction (uint32_t prop, const gtm_jmpbuf *jb)
{
@@ -99,7 +103,13 @@ GTM::gtm_transaction::begin_transaction
tx->prev = gtm_tx();
if (tx->prev)
tx->nesting = tx->prev->nesting + 1;
+#ifdef HAVE_64BIT_SYNC_BUILTINS
tx->id = __sync_add_and_fetch (&global_tid, 1);
+#else
+ pthread_mutex_lock (&global_tid_lock);
+ tx->id = ++global_tid;
+ pthread_mutex_unlock (&global_tid_lock);
+#endif
tx->jb = *jb;
set_gtm_tx (tx);
===================================================================
@@ -12,6 +12,20 @@ AC_DEFUN([LIBITM_CHECK_SYNC_BUILTINS], [
[Define to 1 if the target supports __sync_*_compare_and_swap])
fi])
+dnl Check whether the target supports 64-bit __sync_*_compare_and_swap.
+AC_DEFUN([LIBITM_CHECK_64BIT_SYNC_BUILTINS], [
+ AC_CACHE_CHECK([whether the target supports 64-bit __sync_*_compare_and_swap],
+ libitm_cv_have_64bit_sync_builtins, [
+ AC_TRY_LINK([#include <stdint.h>],
+ [uint64_t foo, bar;
+ bar = __sync_val_compare_and_swap(&foo, 0, 1);],
+ libitm_cv_have_64bit_sync_builtins=yes,
+ libitm_cv_have_64bit_sync_builtins=no)])
+ if test $libitm_cv_have_64bit_sync_builtins = yes; then
+ AC_DEFINE(HAVE_64BIT_SYNC_BUILTINS, 1,
+ [Define to 1 if the target supports 64-bit __sync_*_compare_and_swap])
+ fi])
+
dnl Check whether the target supports hidden visibility.
AC_DEFUN([LIBITM_CHECK_ATTRIBUTE_VISIBILITY], [
AC_CACHE_CHECK([whether the target supports hidden visibility],