summaryrefslogtreecommitdiffstats
path: root/include/llvm/System
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
committered <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
commitcf5cd875b51255602afaed29deb636b66b295671 (patch)
tree9794dc36f22f2a2b3f8063829d8a9b3a7794acc8 /include/llvm/System
parent5c1b5c146f3df07c75174aff06c3bb0968f6857e (diff)
downloadFreeBSD-src-cf5cd875b51255602afaed29deb636b66b295671.zip
FreeBSD-src-cf5cd875b51255602afaed29deb636b66b295671.tar.gz
Import LLVM r74383.
Diffstat (limited to 'include/llvm/System')
-rw-r--r--include/llvm/System/Atomic.h17
-rw-r--r--include/llvm/System/ThreadLocal.h41
2 files changed, 50 insertions, 8 deletions
diff --git a/include/llvm/System/Atomic.h b/include/llvm/System/Atomic.h
index c0612f9..4ec117b 100644
--- a/include/llvm/System/Atomic.h
+++ b/include/llvm/System/Atomic.h
@@ -20,14 +20,15 @@ namespace llvm {
namespace sys {
void MemoryFence();
- uint32_t CompareAndSwap32(volatile uint32_t* ptr,
- uint32_t new_value,
- uint32_t old_value);
- int32_t AtomicIncrement32(volatile int32_t* ptr);
- int32_t AtomicDecrement32(volatile int32_t* ptr);
- int32_t AtomicAdd32(volatile int32_t* ptr, int32_t val);
-
- int64_t AtomicAdd64(volatile int64_t* ptr, int64_t val);
+ typedef uint32_t cas_flag;
+ cas_flag CompareAndSwap(volatile cas_flag* ptr,
+ cas_flag new_value,
+ cas_flag old_value);
+ cas_flag AtomicIncrement(volatile cas_flag* ptr);
+ cas_flag AtomicDecrement(volatile cas_flag* ptr);
+ cas_flag AtomicAdd(volatile cas_flag* ptr, cas_flag val);
+ cas_flag AtomicMul(volatile cas_flag* ptr, cas_flag val);
+ cas_flag AtomicDiv(volatile cas_flag* ptr, cas_flag val);
}
}
diff --git a/include/llvm/System/ThreadLocal.h b/include/llvm/System/ThreadLocal.h
new file mode 100644
index 0000000..39b1e64
--- /dev/null
+++ b/include/llvm/System/ThreadLocal.h
@@ -0,0 +1,41 @@
+//===- llvm/System/ThreadLocal.h - Thread Local Data ------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the llvm::sys::ThreadLocal class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SYSTEM_THREAD_LOCAL_H
+#define LLVM_SYSTEM_THREAD_LOCAL_H
+
+#include "llvm/System/Threading.h"
+#include <cassert>
+
+namespace llvm {
+ namespace sys {
+ class ThreadLocalImpl {
+ void* data;
+ public:
+ ThreadLocalImpl();
+ virtual ~ThreadLocalImpl();
+ void setInstance(const void* d);
+ const void* getInstance();
+ };
+
+ template<class T>
+ class ThreadLocal : public ThreadLocalImpl {
+ public:
+ ThreadLocal() : ThreadLocalImpl() { }
+ T* get() { return static_cast<T*>(getInstance()); }
+ void set(T* d) { setInstance(d); }
+ };
+ }
+}
+
+#endif
OpenPOWER on IntegriCloud