]]),
AC_LANG_POP([C++])
AC_MSG_RESULT(yes)
- AC_DEFINE(LLVM_MULTITHREADED, 1, Build multithreading support into LLVM),
+ AC_DEFINE(LLVM_HAS_ATOMICS, 1, Has gcc/MSVC atomic intrinsics),
AC_MSG_RESULT(no)
- AC_DEFINE(LLVM_MULTITHREADED, 0, Build multithreading support into LLVM)
+ AC_DEFINE(LLVM_HAS_ATOMICS, 0, Has gcc/MSVC atomic intrinsics)
AC_MSG_WARN([LLVM will be built thread-unsafe because atomic builtins are missing]))
dnl===-----------------------------------------------------------------------===
unset(HAVE_FFI_CALL CACHE)
endif( LLVM_ENABLE_FFI )
-# Define LLVM_MULTITHREADED if gcc atomic builtins exists.
+# Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported.
include(CheckAtomic)
if( LLVM_ENABLE_PIC )
#endif
return 0;
}
-" LLVM_MULTITHREADED)
+" LLVM_HAS_ATOMICS)
-if( NOT LLVM_MULTITHREADED )
+if( NOT LLVM_HAS_ATOMICS )
message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing")
endif()
echo "${ECHO_T}yes" >&6; }
cat >>confdefs.h <<\_ACEOF
-#define LLVM_MULTITHREADED 1
+#define LLVM_HAS_ATOMICS 1
_ACEOF
else
echo "${ECHO_T}no" >&6; }
cat >>confdefs.h <<\_ACEOF
-#define LLVM_MULTITHREADED 0
+#define LLVM_HAS_ATOMICS 0
_ACEOF
{ echo "$as_me:$LINENO: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&5
/* Installation directory for man pages */
#cmakedefine LLVM_MANDIR "${LLVM_MANDIR}"
-/* Build multithreading support into LLVM */
-#cmakedefine LLVM_MULTITHREADED ${LLVM_MULTITHREADED}
+/* Has gcc/MSVC atomic intrinsics */
+#define LLVM_HAS_ATOMICS ${LLVM_HAS_ATOMICS}
/* LLVM architecture name for the native architecture, if available */
#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
/* Installation directory for man pages */
#undef LLVM_MANDIR
-/* Build multithreading support into LLVM */
-#undef LLVM_MULTITHREADED
+/* Has gcc/MSVC atomic intrinsics */
+#undef LLVM_HAS_ATOMICS
/* LLVM architecture name for the native architecture, if available */
#undef LLVM_NATIVE_ARCH
/* Installation directory for man pages */
#cmakedefine LLVM_MANDIR "${LLVM_MANDIR}"
-/* Build multithreading support into LLVM */
-#cmakedefine LLVM_MULTITHREADED ${LLVM_MULTITHREADED}
+/* Has gcc/MSVC atomic intrinsics */
+#define LLVM_HAS_ATOMICS ${LLVM_HAS_ATOMICS}
/* LLVM architecture name for the native architecture, if available */
#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
/* Installation directory for man pages */
#undef LLVM_MANDIR
-/* Build multithreading support into LLVM */
-#undef LLVM_MULTITHREADED
+/* Has gcc/MSVC atomic intrinsics */
+#undef LLVM_HAS_ATOMICS
/* LLVM architecture name for the native architecture, if available */
#undef LLVM_NATIVE_ARCH
#endif
void sys::MemoryFence() {
-#if LLVM_MULTITHREADED==0
+#if LLVM_HAS_ATOMICS == 0
return;
#else
# if defined(__GNUC__)
sys::cas_flag sys::CompareAndSwap(volatile sys::cas_flag* ptr,
sys::cas_flag new_value,
sys::cas_flag old_value) {
-#if LLVM_MULTITHREADED==0
+#if LLVM_HAS_ATOMICS == 0
sys::cas_flag result = *ptr;
if (result == old_value)
*ptr = new_value;
}
sys::cas_flag sys::AtomicIncrement(volatile sys::cas_flag* ptr) {
-#if LLVM_MULTITHREADED==0
+#if LLVM_HAS_ATOMICS == 0
++(*ptr);
return *ptr;
#elif defined(__GNUC__)
}
sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) {
-#if LLVM_MULTITHREADED==0
+#if LLVM_HAS_ATOMICS == 0
--(*ptr);
return *ptr;
#elif defined(__GNUC__)
}
sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
-#if LLVM_MULTITHREADED==0
+#if LLVM_HAS_ATOMICS == 0
*ptr += val;
return *ptr;
#elif defined(__GNUC__)
static sys::Mutex* global_lock = 0;
bool llvm::llvm_start_multithreaded() {
-#ifdef LLVM_MULTITHREADED
+#if ENABLE_THREADS != 0
assert(!multithreaded_mode && "Already multithreaded!");
multithreaded_mode = true;
global_lock = new sys::Mutex(true);
}
void llvm::llvm_stop_multithreaded() {
-#ifdef LLVM_MULTITHREADED
+#if ENABLE_THREADS != 0
assert(multithreaded_mode && "Not currently multithreaded!");
// We fence here to insure that all threaded operations are complete BEFORE we
if (multithreaded_mode) global_lock->release();
}
-#if defined(LLVM_MULTITHREADED) && defined(HAVE_PTHREAD_H)
+#if ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)
#include <pthread.h>
struct ThreadInfo {
error:
::pthread_attr_destroy(&Attr);
}
-#elif defined(LLVM_MULTITHREADED) && defined(LLVM_ON_WIN32)
+#elif ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
#include "Windows/Windows.h"
#include <process.h>