[vmkit-commits] [vmkit] r90010 - in /vmkit/trunk: include/mvm/Threads/Thread.h lib/Mvm/CommonThread/ctthread.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Nov 27 09:38:33 PST 2009
Author: geoffray
Date: Fri Nov 27 11:38:33 2009
New Revision: 90010
URL: http://llvm.org/viewvc/llvm-project?rev=90010&view=rev
Log:
Port to Snow Leopard.
Modified:
vmkit/trunk/include/mvm/Threads/Thread.h
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=90010&r1=90009&r2=90010&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Fri Nov 27 11:38:33 2009
@@ -292,8 +292,11 @@
/// IDMask - Apply this mask to the stack pointer to get the Thread object.
///
+#if (__WORDSIZE == 64)
+ static const uint64_t IDMask = 0xF7FF00000;
+#else
static const uint64_t IDMask = 0x7FF00000;
-
+#endif
/// MvmThreadMask - Apply this mask to verify that the current thread was
/// created by Mvm.
///
Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=90010&r1=90009&r2=90010&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Fri Nov 27 11:38:33 2009
@@ -17,6 +17,7 @@
#include <signal.h>
#include <cstdio>
#include <ctime>
+#include <errno.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sched.h>
@@ -133,6 +134,13 @@
#define STACK_SIZE 0x100000
#define NR_THREADS 255
+#if (__WORDSIZE == 64)
+#define START_ADDR 0x110000000
+#define END_ADDR 0x170000000
+#else
+#define START_ADDR 0x110000000
+#define END_ADDR 0x70000000
+#endif
/// StackThreadManager - This class allocates all stacks for threads. Because
/// we want fast access to thread local data, and can not rely on platform
@@ -154,11 +162,11 @@
StackThreadManager() {
baseAddr = 0;
- uintptr_t ptr = 0x10000000;
+ uintptr_t ptr = START_ADDR;
// Do an mmap at a fixed address. If the mmap fails for a given address
// use the next one.
- while (!baseAddr && ptr != 0x70000000) {
+ while (!baseAddr && ptr != END_ADDR) {
ptr = ptr + 0x10000000;
#if defined (__MACH__)
uint32 flags = MAP_PRIVATE | MAP_ANON | MAP_FIXED;
@@ -173,7 +181,7 @@
fprintf(stderr, "Can not allocate thread memory\n");
abort();
}
-
+
// Protect the page after the first page. The first page contains thread
// specific data. The second page has no access rights to catch stack
// overflows.
More information about the vmkit-commits
mailing list