rename ENABLE_THREADS to LLVM_ENABLE_THREADS

Now that it needs to be exported in a public header (Valgrind.h)
it should be prefixed to avoid collision with other projects.
Add it to llvm-config.h as well.

This'll require regenerating the configure script after this
commit, but I don't have the required autoconf version.

llvm-svn: 145214
This commit is contained in:
Dylan Noblesmith 2011-11-28 00:48:58 +00:00
parent daef41b1d1
commit efddf20126
10 changed files with 30 additions and 22 deletions

View File

@ -538,12 +538,13 @@ AC_ARG_ENABLE(threads,
[Use threads if available (default is YES)]),,
enableval=default)
case "$enableval" in
yes) AC_SUBST(ENABLE_THREADS,[1]) ;;
no) AC_SUBST(ENABLE_THREADS,[0]) ;;
default) AC_SUBST(ENABLE_THREADS,[1]) ;;
yes) AC_SUBST(LLVM_ENABLE_THREADS,[1]) ;;
no) AC_SUBST(LLVM_ENABLE_THREADS,[0]) ;;
default) AC_SUBST(LLVM_ENABLE_THREADS,[1]) ;;
*) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;;
esac
AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled])
AC_DEFINE_UNQUOTED([LLVM_ENABLE_THREADS],$LLVM_ENABLE_THREADS,
[Define if threads enabled])
dnl Allow disablement of pthread.h
AC_ARG_ENABLE(pthreads,
@ -1144,7 +1145,7 @@ AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],
dnl pthread locking functions are optional - but llvm will not be thread-safe
dnl without locks.
if test "$ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
if test "$LLVM_ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
AC_CHECK_LIB(pthread, pthread_mutex_init)
AC_SEARCH_LIBS(pthread_mutex_lock,pthread,
AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1],
@ -1235,7 +1236,7 @@ AC_CHECK_HEADERS([sys/mman.h sys/param.h sys/resource.h sys/time.h sys/uio.h])
AC_CHECK_HEADERS([sys/types.h sys/ioctl.h malloc/malloc.h mach/mach.h])
AC_CHECK_HEADERS([valgrind/valgrind.h])
AC_CHECK_HEADERS([fenv.h])
if test "$ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
if test "$LLVM_ENABLE_THREADS" -eq 1 && test "$ENABLE_PTHREADS" -eq 1 ; then
AC_CHECK_HEADERS(pthread.h,
AC_SUBST(HAVE_PTHREAD, 1),
AC_SUBST(HAVE_PTHREAD, 0))

View File

@ -379,14 +379,15 @@ endif( PURE_WINDOWS )
set(RETSIGTYPE void)
if( LLVM_ENABLE_THREADS )
if( HAVE_PTHREAD_H OR WIN32 )
set(ENABLE_THREADS 1)
# Check if threading primitives aren't supported on this platform
if( NOT HAVE_PTHREAD_H AND NOT WIN32 )
set(LLVM_ENABLE_THREADS 0)
endif()
endif()
if( ENABLE_THREADS )
if( LLVM_ENABLE_THREADS )
message(STATUS "Threads enabled.")
else( ENABLE_THREADS )
else( LLVM_ENABLE_THREADS )
message(STATUS "Threads disabled.")
endif()

View File

@ -32,9 +32,6 @@
/* Define if position independent code is enabled */
#cmakedefine ENABLE_PIC
/* Define if threads enabled */
#cmakedefine ENABLE_THREADS ${ENABLE_THREADS}
/* Define if timestamp information (e.g., __DATE___) is allowed */
#cmakedefine ENABLE_TIMESTAMPS ${ENABLE_TIMESTAMPS}
@ -554,6 +551,9 @@
/* Installation directory for documentation */
#cmakedefine LLVM_DOCSDIR "${LLVM_DOCSDIR}"
/* Define if threads enabled */
#cmakedefine01 LLVM_ENABLE_THREADS
/* Installation directory for config files */
#cmakedefine LLVM_ETCDIR "${LLVM_ETCDIR}"

View File

@ -31,6 +31,9 @@
/* Installation directory for documentation */
#cmakedefine LLVM_DOCSDIR "${LLVM_DOCSDIR}"
/* Define if threads enabled */
#cmakedefine01 LLVM_ENABLE_THREADS
/* Installation directory for config files */
#cmakedefine LLVM_ETCDIR "${LLVM_ETCDIR}"

View File

@ -31,6 +31,9 @@
/* Installation directory for documentation */
#undef LLVM_DOCSDIR
/* Define if threads enabled */
#undef LLVM_ENABLE_THREADS
/* Installation directory for config files */
#undef LLVM_ETCDIR

View File

@ -20,7 +20,7 @@
#include "llvm/Config/config.h"
#include <stddef.h>
#if ENABLE_THREADS != 0 && !defined(NDEBUG)
#if LLVM_ENABLE_THREADS != 0 && !defined(NDEBUG)
// tsan (Thread Sanitizer) is a valgrind-based tool that detects these exact
// functions by name.
extern "C" {
@ -42,7 +42,7 @@ namespace sys {
// Otherwise valgrind may continue to execute the old version of the code.
void ValgrindDiscardTranslations(const void *Addr, size_t Len);
#if ENABLE_THREADS != 0 && !defined(NDEBUG)
#if LLVM_ENABLE_THREADS != 0 && !defined(NDEBUG)
// Thread Sanitizer is a valgrind tool that finds races in code.
// See http://code.google.com/p/data-race-test/wiki/DynamicAnnotations .

View File

@ -19,7 +19,7 @@
//=== independent code.
//===----------------------------------------------------------------------===//
#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
#if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
// Define all methods as no-ops if threading is explicitly disabled
namespace llvm {
using namespace sys;

View File

@ -20,7 +20,7 @@
//=== independent code.
//===----------------------------------------------------------------------===//
#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
#if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
// Define all methods as no-ops if threading is explicitly disabled
namespace llvm {
using namespace sys;

View File

@ -19,7 +19,7 @@
//=== independent code.
//===----------------------------------------------------------------------===//
#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
#if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
// Define all methods as no-ops if threading is explicitly disabled
namespace llvm {
using namespace sys;

View File

@ -24,7 +24,7 @@ static bool multithreaded_mode = false;
static sys::Mutex* global_lock = 0;
bool llvm::llvm_start_multithreaded() {
#if ENABLE_THREADS != 0
#if LLVM_ENABLE_THREADS != 0
assert(!multithreaded_mode && "Already multithreaded!");
multithreaded_mode = true;
global_lock = new sys::Mutex(true);
@ -39,7 +39,7 @@ bool llvm::llvm_start_multithreaded() {
}
void llvm::llvm_stop_multithreaded() {
#if ENABLE_THREADS != 0
#if LLVM_ENABLE_THREADS != 0
assert(multithreaded_mode && "Not currently multithreaded!");
// We fence here to insure that all threaded operations are complete BEFORE we
@ -63,7 +63,7 @@ void llvm::llvm_release_global_lock() {
if (multithreaded_mode) global_lock->release();
}
#if ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)
#if LLVM_ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)
#include <pthread.h>
struct ThreadInfo {
@ -102,7 +102,7 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
error:
::pthread_attr_destroy(&Attr);
}
#elif ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
#elif LLVM_ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
#include "Windows/Windows.h"
#include <process.h>