llvm.org GIT mirror llvm / 627445f
Rename LLVM_MULTITHREADED define and fix build without threads. Patch by Arrowdodger. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140064 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 8 years ago
10 changed file(s) with 24 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
15141514 ]]),
15151515 AC_LANG_POP([C++])
15161516 AC_MSG_RESULT(yes)
1517 AC_DEFINE(LLVM_MULTITHREADED, 1, Build multithreading support into LLVM),
1517 AC_DEFINE(LLVM_HAS_ATOMICS, 1, Has gcc/MSVC atomic intrinsics),
15181518 AC_MSG_RESULT(no)
1519 AC_DEFINE(LLVM_MULTITHREADED, 0, Build multithreading support into LLVM)
1519 AC_DEFINE(LLVM_HAS_ATOMICS, 0, Has gcc/MSVC atomic intrinsics)
15201520 AC_MSG_WARN([LLVM will be built thread-unsafe because atomic builtins are missing]))
15211521
15221522 dnl===-----------------------------------------------------------------------===
271271 unset(HAVE_FFI_CALL CACHE)
272272 endif( LLVM_ENABLE_FFI )
273273
274 # Define LLVM_MULTITHREADED if gcc atomic builtins exists.
274 # Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported.
275275 include(CheckAtomic)
276276
277277 if( LLVM_ENABLE_PIC )
2121 #endif
2222 return 0;
2323 }
24 " LLVM_MULTITHREADED)
24 " LLVM_HAS_ATOMICS)
2525
26 if( NOT LLVM_MULTITHREADED )
26 if( NOT LLVM_HAS_ATOMICS )
2727 message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing")
2828 endif()
2102621026 echo "${ECHO_T}yes" >&6; }
2102721027
2102821028 cat >>confdefs.h <<\_ACEOF
21029 #define LLVM_MULTITHREADED 1
21029 #define LLVM_HAS_ATOMICS 1
2103021030 _ACEOF
2103121031
2103221032 else
2103721037 echo "${ECHO_T}no" >&6; }
2103821038
2103921039 cat >>confdefs.h <<\_ACEOF
21040 #define LLVM_MULTITHREADED 0
21040 #define LLVM_HAS_ATOMICS 0
2104121041 _ACEOF
2104221042
2104321043 { echo "$as_me:$LINENO: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&5
565565 /* Installation directory for man pages */
566566 #cmakedefine LLVM_MANDIR "${LLVM_MANDIR}"
567567
568 /* Build multithreading support into LLVM */
569 #cmakedefine LLVM_MULTITHREADED ${LLVM_MULTITHREADED}
568 /* Has gcc/MSVC atomic intrinsics */
569 #define LLVM_HAS_ATOMICS ${LLVM_HAS_ATOMICS}
570570
571571 /* LLVM architecture name for the native architecture, if available */
572572 #cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
563563 /* Installation directory for man pages */
564564 #undef LLVM_MANDIR
565565
566 /* Build multithreading support into LLVM */
567 #undef LLVM_MULTITHREADED
566 /* Has gcc/MSVC atomic intrinsics */
567 #undef LLVM_HAS_ATOMICS
568568
569569 /* LLVM architecture name for the native architecture, if available */
570570 #undef LLVM_NATIVE_ARCH
4545 /* Installation directory for man pages */
4646 #cmakedefine LLVM_MANDIR "${LLVM_MANDIR}"
4747
48 /* Build multithreading support into LLVM */
49 #cmakedefine LLVM_MULTITHREADED ${LLVM_MULTITHREADED}
48 /* Has gcc/MSVC atomic intrinsics */
49 #define LLVM_HAS_ATOMICS ${LLVM_HAS_ATOMICS}
5050
5151 /* LLVM architecture name for the native architecture, if available */
5252 #cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
4545 /* Installation directory for man pages */
4646 #undef LLVM_MANDIR
4747
48 /* Build multithreading support into LLVM */
49 #undef LLVM_MULTITHREADED
48 /* Has gcc/MSVC atomic intrinsics */
49 #undef LLVM_HAS_ATOMICS
5050
5151 /* LLVM architecture name for the native architecture, if available */
5252 #undef LLVM_NATIVE_ARCH
2121 #endif
2222
2323 void sys::MemoryFence() {
24 #if LLVM_MULTITHREADED==0
24 #if LLVM_HAS_ATOMICS == 0
2525 return;
2626 #else
2727 # if defined(__GNUC__)
3737 sys::cas_flag sys::CompareAndSwap(volatile sys::cas_flag* ptr,
3838 sys::cas_flag new_value,
3939 sys::cas_flag old_value) {
40 #if LLVM_MULTITHREADED==0
40 #if LLVM_HAS_ATOMICS == 0
4141 sys::cas_flag result = *ptr;
4242 if (result == old_value)
4343 *ptr = new_value;
5252 }
5353
5454 sys::cas_flag sys::AtomicIncrement(volatile sys::cas_flag* ptr) {
55 #if LLVM_MULTITHREADED==0
55 #if LLVM_HAS_ATOMICS == 0
5656 ++(*ptr);
5757 return *ptr;
5858 #elif defined(__GNUC__)
6565 }
6666
6767 sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) {
68 #if LLVM_MULTITHREADED==0
68 #if LLVM_HAS_ATOMICS == 0
6969 --(*ptr);
7070 return *ptr;
7171 #elif defined(__GNUC__)
7878 }
7979
8080 sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
81 #if LLVM_MULTITHREADED==0
81 #if LLVM_HAS_ATOMICS == 0
8282 *ptr += val;
8383 return *ptr;
8484 #elif defined(__GNUC__)
2323 static sys::Mutex* global_lock = 0;
2424
2525 bool llvm::llvm_start_multithreaded() {
26 #ifdef LLVM_MULTITHREADED
26 #if ENABLE_THREADS != 0
2727 assert(!multithreaded_mode && "Already multithreaded!");
2828 multithreaded_mode = true;
2929 global_lock = new sys::Mutex(true);
3838 }
3939
4040 void llvm::llvm_stop_multithreaded() {
41 #ifdef LLVM_MULTITHREADED
41 #if ENABLE_THREADS != 0
4242 assert(multithreaded_mode && "Not currently multithreaded!");
4343
4444 // We fence here to insure that all threaded operations are complete BEFORE we
6262 if (multithreaded_mode) global_lock->release();
6363 }
6464
65 #if defined(LLVM_MULTITHREADED) && defined(HAVE_PTHREAD_H)
65 #if ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)
6666 #include
6767
6868 struct ThreadInfo {
101101 error:
102102 ::pthread_attr_destroy(&Attr);
103103 }
104 #elif defined(LLVM_MULTITHREADED) && defined(LLVM_ON_WIN32)
104 #elif ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
105105 #include "Windows/Windows.h"
106106 #include
107107