Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1966 - in trunk: CMake Core/Thread Core/Util Engine/Display
- Date: Sat, 5 Jan 2008 19:06:08 -0700 (MST)
Author: boulos
Date: Sat Jan 5 19:06:06 2008
New Revision: 1966
Modified:
trunk/CMake/ConfigArchitecture.cmake
trunk/CMake/ConfigCompilerFlags.cmake
trunk/CMake/Macros.cmake
trunk/Core/Thread/Thread_pthreads.cc
trunk/Core/Thread/Thread_win32.cc
trunk/Core/Util/Plugin.h
trunk/Engine/Display/PureOpenGLDisplay.cc
Log:
CMake/ConfigArchitecture.cmake
CMake/ConfigCompilerFlags.cmake
CMake/Macros.cmake
Adding logic to detect Leopard by version of kernel and defining
APPLE_LEOPARD when it's the case.
Core/Thread/Thread_win32.cc
I guess I opened this and it had nasty tabs, etc...
Core/Thread/Thread_pthreads.cc
Now the check for whether or not you're on Leopard isn't GCC only
(should work with ICC now, Ingo)
Core/Util/Plugin.h
While I was at it, I figured I'd get rid of my own deprecated issues
in Plugin.
Engine/Display/PureOpenGLDisplay.cc
Another nasty tab.
Modified: trunk/CMake/ConfigArchitecture.cmake
==============================================================================
--- trunk/CMake/ConfigArchitecture.cmake (original)
+++ trunk/CMake/ConfigArchitecture.cmake Sat Jan 5 19:06:06 2008
@@ -1,6 +1,6 @@
# This file will set architecture and system variables. Compiler
# flags should go into ConfigComipilerFlags.cmake.
-
+INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Macros.cmake)
# Assume that if we are running on an Itanium (ia64), then it is an
# SGI linux system
@@ -15,6 +15,9 @@
# Obtain output of /usr/bin/macine
EXEC_PROGRAM("/usr/bin/machine" OUTPUT_VARIABLE APPLE_MACHINE)
+ EXEC_PROGRAM("/usr/bin/uname" ARGS "-r" OUTPUT_VARIABLE APPLE_VERSION)
+
+ COMPARE_VERSION_STRINGS(${APPLE_VERSION} "9.0.0" APPLE_LEOPARD_CMP)
# Apple G4
IF (${APPLE_MACHINE} MATCHES "ppc7450")
SET(APPLE_G4 TRUE)
@@ -30,6 +33,10 @@
SET(APPLE_X86 TRUE)
ENDIF (${APPLE_MACHINE} MATCHES "i486")
+ IF (${APPLE_LEOPARD_CMP} GREATER -1)
+ SET(APPLE_LEOPARD TRUE)
+ ENDIF(${APPLE_LEOPARD_CMP} GREATER -1)
+
# MESSAGE("APPLE_G4 = ${APPLE_G4}")
# MESSAGE("APPLE_G5 = ${APPLE_G5}")
# MESSAGE("APPLE_X86 = ${APPLE_X86}")
Modified: trunk/CMake/ConfigCompilerFlags.cmake
==============================================================================
--- trunk/CMake/ConfigCompilerFlags.cmake (original)
+++ trunk/CMake/ConfigCompilerFlags.cmake Sat Jan 5 19:06:06 2008
@@ -150,9 +150,11 @@
APPEND_TO_STRING(GCC_OPT "-msse -msse2 -msse3 -mfpmath=sse")
ENDIF (APPLE_X86)
-# Check for broken LD on Leopard.
-IF (APPLE)
+IF (APPLE_LEOPARD)
+ ADD_DEFINITIONS(-DAPPLE_LEOPARD)
+
+ # Check for broken LD on Leopard.
# Note: In leopard the ld version string is:
# @(#)PROGRAM:ld PROJECT:ld64-77
# while in previous versions it is:
@@ -167,7 +169,7 @@
SET(APPLE_LEOPARD_LD TRUE)
ENDIF(APPLE_LD_VERSION MATCHES "ld64-77")
-ENDIF(APPLE)
+ENDIF(APPLE_LEOPARD)
##############################################################
## X86
Modified: trunk/CMake/Macros.cmake
==============================================================================
--- trunk/CMake/Macros.cmake (original)
+++ trunk/CMake/Macros.cmake Sat Jan 5 19:06:06 2008
@@ -77,7 +77,6 @@
ENDMACRO(SUBDIRS_IF)
SET(MANTA_THREE_PART_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+")
-
# Computes the realtionship between two version strings. A version
# string is a number delineated by '.'s such as 1.3.2 and 0.99.9.1.
# You can feed version strings with different number of dot versions,
Modified: trunk/Core/Thread/Thread_pthreads.cc
==============================================================================
--- trunk/Core/Thread/Thread_pthreads.cc (original)
+++ trunk/Core/Thread/Thread_pthreads.cc Sat Jan 5 19:06:06 2008
@@ -94,12 +94,8 @@
#endif
#ifdef __APPLE__
- #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
- #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
- #define SigContext ucontext_t
- #else
- #define SigContext struct sigcontext
- #endif
+ #ifdef APPLE_LEOPARD
+ #define SigContext ucontext_t
#else
#define SigContext struct sigcontext
#endif
Modified: trunk/Core/Thread/Thread_win32.cc
==============================================================================
--- trunk/Core/Thread/Thread_win32.cc (original)
+++ trunk/Core/Thread/Thread_win32.cc Sat Jan 5 19:06:06 2008
@@ -83,9 +83,9 @@
#define MAXTHREADS 4000
namespace Manta {
- // a naive way to get Thread::self when the compiler
+ // a naive way to get Thread::self when the compiler
// doesn't support thread-local storage
- map<int, Thread*> threadids;
+ map<int, Thread*> threadids;
// NOTE - Do not give semaphores or mutexes names - there's a good chance
that
// if they have the same name they will conflict with each other (multiple
semaphores
@@ -105,11 +105,11 @@
static void initialize() { Thread::initialize(); }
};
-
+
struct Mutex_private {
HANDLE lock;
};
-
+
struct Semaphore_private {
HANDLE hSema;
};
@@ -126,7 +126,7 @@
~CrowdMonitor_private();
};
- // implemented with help from the article at
+ // implemented with help from the article at
//
http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
struct ConditionVariable_private {
Mutex waiters_count_lock_;
@@ -182,19 +182,19 @@
Mutex::Mutex(const char* name)
{
- priv_ = new Mutex_private;
- priv_->lock = CreateMutex(NULL,0,0);
- if (priv_->lock == 0)
- {
- throw ThreadError(std::string("CreateMutex failed")
- +threadError());
- }
-
- if(getenv("THREAD_SHOWINIT"))
- fprintf(stderr, "Mutex: %s\n", name);
- int length = strlen(name);
- name_ = new char[length+1];
- sprintf((char*)name_,"%s",name);
+ priv_ = new Mutex_private;
+ priv_->lock = CreateMutex(NULL,0,0);
+ if (priv_->lock == 0)
+ {
+ throw ThreadError(std::string("CreateMutex failed")
+ +threadError());
+ }
+
+ if(getenv("THREAD_SHOWINIT"))
+ fprintf(stderr, "Mutex: %s\n", name);
+ int length = strlen(name);
+ name_ = new char[length+1];
+ sprintf((char*)name_,"%s",name);
}
Mutex::~Mutex()
@@ -207,49 +207,49 @@
void Mutex::lock()
{
- WaitForSingleObject(priv_->lock,INFINITE);
+ WaitForSingleObject(priv_->lock,INFINITE);
}
void Mutex::unlock()
{
- ReleaseMutex(priv_->lock);
+ ReleaseMutex(priv_->lock);
}
bool Mutex::tryLock()
{
- int check = WaitForSingleObject(priv_->lock,0);
- if (check == WAIT_OBJECT_0)
- return 1;
- else if (check == WAIT_TIMEOUT)
- return 0;
- else
- {
- throw ThreadError(std::string("Mutex::try_lock failed")
- +threadError());
- }
- return 0; // never happens
+ int check = WaitForSingleObject(priv_->lock,0);
+ if (check == WAIT_OBJECT_0)
+ return 1;
+ else if (check == WAIT_TIMEOUT)
+ return 0;
+ else
+ {
+ throw ThreadError(std::string("Mutex::try_lock failed")
+ +threadError());
+ }
+ return 0; // never happens
}
static Thread_private* active[MAXTHREADS];
static int numActive;
-static HANDLE sched_lock;
-__declspec(dllexport) HANDLE main_sema;
+static HANDLE sched_lock;
+__declspec(dllexport) HANDLE main_sema;
//static HANDLE control_c_sema;
Semaphore::Semaphore(const char* name,int count)
{
- priv_ = new Semaphore_private;
- priv_->hSema =
CreateSemaphore(NULL,count,MAX(1000,MIN(2*count,100)),0);
- if (priv_->hSema == 0)
- {
- throw ThreadError(std::string("CreateSemaphore failed")
- +threadError());
- }
- if(getenv("THREAD_SHOWINIT"))
- fprintf(stderr, "Semaphore: %s\n", name);
- int length = strlen(name);
- name_ = new char[length+1];
- sprintf((char*)name_,"%s",name);
+ priv_ = new Semaphore_private;
+ priv_->hSema =
CreateSemaphore(NULL,count,MAX(1000,MIN(2*count,100)),0);
+ if (priv_->hSema == 0)
+ {
+ throw ThreadError(std::string("CreateSemaphore failed")
+ +threadError());
+ }
+ if(getenv("THREAD_SHOWINIT"))
+ fprintf(stderr, "Semaphore: %s\n", name);
+ int length = strlen(name);
+ name_ = new char[length+1];
+ sprintf((char*)name_,"%s",name);
}
Semaphore::~Semaphore()
@@ -262,42 +262,42 @@
void Semaphore::down(int dec)
{
- int check;
- for (int loop = 0;loop<dec;loop++) {
- check = WaitForSingleObject(priv_->hSema,INFINITE);
- if (check != WAIT_OBJECT_0)
- {
- if (check == WAIT_ABANDONED);
- else if (check == WAIT_TIMEOUT);
- else if (check == (int) WAIT_FAILED)
- {
- throw
ThreadError(std::string("WaitForSingleObject failed")
- +threadError());
- }
- else;
- }
- }
+ int check;
+ for (int loop = 0;loop<dec;loop++) {
+ check = WaitForSingleObject(priv_->hSema,INFINITE);
+ if (check != WAIT_OBJECT_0)
+ {
+ if (check == WAIT_ABANDONED);
+ else if (check == WAIT_TIMEOUT);
+ else if (check == (int) WAIT_FAILED)
+ {
+ throw
ThreadError(std::string("WaitForSingleObject failed")
+ +threadError());
+ }
+ else;
+ }
+ }
}
bool Semaphore::tryDown()
{
- int check = WaitForSingleObject(priv_->hSema,0);
- if (check == WAIT_OBJECT_0)
- return 0;
- else if (check == WAIT_TIMEOUT)
- return 1;
- else
- {
- throw ThreadError(std::string("WaitForSingleObject failed")
- +threadError());
- }
- return 0; // never happens
+ int check = WaitForSingleObject(priv_->hSema,0);
+ if (check == WAIT_OBJECT_0)
+ return 0;
+ else if (check == WAIT_TIMEOUT)
+ return 1;
+ else
+ {
+ throw ThreadError(std::string("WaitForSingleObject failed")
+ +threadError());
+ }
+ return 0; // never happens
}
void Semaphore::up(int inc)
{
- long count;
- ReleaseSemaphore(priv_->hSema,inc,&count);
+ long count;
+ ReleaseSemaphore(priv_->hSema,inc,&count);
}
@@ -473,7 +473,7 @@
priv_->num_writers++;
priv_->lock.unlock();
Thread::couldBlockDone(oldstate);
-}
+}
void
CrowdMonitor::writeUnlock()
@@ -540,13 +540,13 @@
sema_ = CreateSemaphore(NULL,0,50,NULL);
if (sema_ == 0) {
throw ThreadError(std::string("CreateSemaphore failed")
- +threadError());
+ +threadError());
}
-
+
waiters_done_ = CreateEvent(NULL, FALSE, FALSE, NULL);
if (waiters_done_ == 0) {
throw ThreadError(std::string("CreateEvent failed")
- +threadError());
+ +threadError());
}
}
@@ -558,12 +558,12 @@
ConditionVariable::ConditionVariable(const char* name)
: name_(name)
{
- if (!Thread::isInitialized())
+ if (!Thread::isInitialized())
Thread_private::initialize();
if(getenv("THREAD_SHOWINIT"))
fprintf(stderr, "ConditionVariable: %s\n", name);
priv_ = new ConditionVariable_private(name);
-
+
}
ConditionVariable::~ConditionVariable()
@@ -603,7 +603,7 @@
success = false;
else
throw ThreadError(std::string("SignalObjectAndWait failed: ")
- +threadError());
+ +threadError());
}
priv_->waiters_count_lock_.lock();
@@ -612,19 +612,19 @@
// check to see if we're the last waiter after broadcast
int last_waiter = priv_->was_broadcast_ && priv_->waiters_count_ == 0;
priv_->waiters_count_lock_.unlock();
-
+
if (last_waiter) {
// signal waiters_done and wait for mutex (to ensure fairness)
err = SignalObjectAndWait(priv_->waiters_done_, m.priv_->lock, INFINITE,
FALSE);
if (err != WAIT_OBJECT_0)
throw ThreadError(std::string("SignalObjectAndWait failed: ")
- +threadError());
+ +threadError());
}
else
- m.lock();
+ m.lock();
Thread::pop_bstack(p, oldstate);
-
+
return success;
}
@@ -633,8 +633,8 @@
{
priv_->waiters_count_lock_.lock();
int have_waiters = priv_->waiters_count_ > 0;
- priv_->waiters_count_lock_.unlock();
-
+ priv_->waiters_count_lock_.unlock();
+
if (have_waiters)
ReleaseSemaphore(priv_->sema_, 1, 0);
}
@@ -644,7 +644,7 @@
{
priv_->waiters_count_lock_.lock();
int have_waiters = 0;
-
+
if (priv_->waiters_count_ > 0) {
// broadcast
priv_->was_broadcast_ = 1;
@@ -654,31 +654,31 @@
if (have_waiters) {
// wake up waiting threads
ReleaseSemaphore(priv_->sema_, priv_->waiters_count_, 0);
-
+
priv_->waiters_count_lock_.unlock();
-
+
// wait for threads to acquire semaphore
WaitForSingleObject(priv_->waiters_done_, INFINITE);
priv_->was_broadcast_ = 0;
}
- else
+ else
priv_->waiters_count_lock_.unlock();
}
static void lock_scheduler()
{
- if(WaitForSingleObject(sched_lock,INFINITE)!=WAIT_OBJECT_0) {
- throw ThreadError(std::string("lock_scheduler failed")
- +threadError());
- }
+ if(WaitForSingleObject(sched_lock,INFINITE)!=WAIT_OBJECT_0) {
+ throw ThreadError(std::string("lock_scheduler failed")
+ +threadError());
+ }
}
static void unlock_scheduler()
{
- if(!ReleaseMutex(sched_lock)) {
- throw ThreadError(std::string("unlock_scheduler failed")
- +threadError());
- }
+ if(!ReleaseMutex(sched_lock)) {
+ throw ThreadError(std::string("unlock_scheduler failed")
+ +threadError());
+ }
}
/*
@@ -705,20 +705,20 @@
{
FILE* fp=stderr;
for(int i=0;i<numActive;i++){
- Thread_private* p=active[i];
- const char* tname=p->thread?p->thread->getThreadName():"???";
- fprintf(fp, " %d: %s (", p->threadid, tname);
- if(p->thread){
- if(p->thread->isDaemon())
- fprintf(fp, "daemon, ");
- if(p->thread->isDetached())
- fprintf(fp, "detached, ");
- }
- fprintf(fp, "state=%s", Thread::getStateString(p->state));
- for(int i=0;i<p->bstacksize;i++){
- fprintf(fp, ", %s", p->blockstack[i]);
- }
- fprintf(fp, ")\n");
+ Thread_private* p=active[i];
+ const char* tname=p->thread?p->thread->getThreadName():"???";
+ fprintf(fp, " %d: %s (", p->threadid, tname);
+ if(p->thread){
+ if(p->thread->isDaemon())
+ fprintf(fp, "daemon, ");
+ if(p->thread->isDetached())
+ fprintf(fp, "detached, ");
+ }
+ fprintf(fp, "state=%s", Thread::getStateString(p->state));
+ for(int i=0;i<p->bstacksize;i++){
+ fprintf(fp, ", %s", p->blockstack[i]);
+ }
+ fprintf(fp, ")\n");
}
}
@@ -759,65 +759,65 @@
return;
// Wait forever...
- cerr << "waiting forever" << endl;
- HANDLE wait;
- wait = CreateSemaphore(0,0,10,0);
- if(WaitForSingleObject(wait,INFINITE)!=WAIT_OBJECT_0) {
- throw ThreadError(std::string("WaitForSingleObject (exit_handler)
failed")
- +threadError());
- }
- cerr << "didn't wait forever!" << endl;
+ cerr << "waiting forever" << endl;
+ HANDLE wait;
+ wait = CreateSemaphore(0,0,10,0);
+ if(WaitForSingleObject(wait,INFINITE)!=WAIT_OBJECT_0) {
+ throw ThreadError(std::string("WaitForSingleObject (exit_handler)
failed")
+ +threadError());
+ }
+ cerr << "didn't wait forever!" << endl;
}
#endif
void Thread::initialize()
{
- // atexit() has a semantic bug in win32, so we block in main.cc
instead.
+ // atexit() has a semantic bug in win32, so we block in main.cc
instead.
//atexit(exit_handler);
- sched_lock = CreateMutex(0,0,0);
- if (!sched_lock) {
- throw ThreadError(std::string("CreateMutex (sched_lock) failed")
- +threadError());
- }
+ sched_lock = CreateMutex(0,0,0);
+ if (!sched_lock) {
+ throw ThreadError(std::string("CreateMutex (sched_lock) failed")
+ +threadError());
+ }
ThreadGroup::s_default_group=new ThreadGroup("default group", 0);
Thread* mainthread=new Thread(ThreadGroup::s_default_group, "main");
mainthread->priv_=new Thread_private;
mainthread->priv_->thread=mainthread;
- mainthread->priv_->threadid = GetCurrentThreadId();
+ mainthread->priv_->threadid = GetCurrentThreadId();
mainthread->priv_->state=RUNNING;
mainthread->priv_->bstacksize=0;
threadids[mainthread->priv_->threadid] = mainthread;
- cerr << "mainthread id = " << mainthread->priv_->threadid << endl;
+ cerr << "mainthread id = " << mainthread->priv_->threadid << endl;
- //thread_local = new ThreadLocalMemory;
- //thread_local->current_thread = mainthread;
+ //thread_local = new ThreadLocalMemory;
+ //thread_local->current_thread = mainthread;
mainthread->priv_->done = CreateSemaphore(0,0,10,0);
- if (!mainthread->priv_->done) {
- throw ThreadError(std::string("CreateSemaphore (done) failed")
- +threadError());
- }
-
- mainthread->priv_->delete_ready = CreateSemaphore(0,0,10,0);
- if (!mainthread->priv_->delete_ready) {
- throw ThreadError(std::string("CreateSemaphore (delete_ready)
failed")
- +threadError());
- }
-
- mainthread->priv_->main_sema = CreateSemaphore(0,2,MAXTHREADS,0);
- if (!mainthread->priv_->main_sema) {
- throw ThreadError(std::string("CreateSemaphore (main_sema) failed")
- +threadError());
- }
-
- mainthread->priv_->control_c_sema = CreateSemaphore(0,1,MAXTHREADS,0);
- if (!mainthread->priv_->control_c_sema) {
- throw ThreadError(std::string("CreateSemaphore (control_c_sema)
failed")
- +threadError());
- }
+ if (!mainthread->priv_->done) {
+ throw ThreadError(std::string("CreateSemaphore (done) failed")
+ +threadError());
+ }
+
+ mainthread->priv_->delete_ready = CreateSemaphore(0,0,10,0);
+ if (!mainthread->priv_->delete_ready) {
+ throw ThreadError(std::string("CreateSemaphore (delete_ready)
failed")
+ +threadError());
+ }
+
+ mainthread->priv_->main_sema = CreateSemaphore(0,2,MAXTHREADS,0);
+ if (!mainthread->priv_->main_sema) {
+ throw ThreadError(std::string("CreateSemaphore (main_sema) failed")
+ +threadError());
+ }
+
+ mainthread->priv_->control_c_sema =
CreateSemaphore(0,1,MAXTHREADS,0);
+ if (!mainthread->priv_->control_c_sema) {
+ throw ThreadError(std::string("CreateSemaphore (control_c_sema)
failed")
+ +threadError());
+ }
lock_scheduler();
active[numActive]=mainthread->priv_;
@@ -826,11 +826,11 @@
//#if 0
if(!getenv("THREAD_NO_CATCH_SIGNALS")) {
- install_signal_handlers();
+ install_signal_handlers();
}
//#endif
Thread::initialized = true;
-
+ cerr << "Win32 threads initialized\n";
}
void Thread_run(Thread* t)
@@ -838,12 +838,12 @@
// in the try-except functionality, we have access to the entire stack
trace in the except () clause
// (it has access to the stack before executing the exception handler
while it determines where to land
// the exception
-#ifdef _MSC_VER
+#ifdef _MSC_VER
__try {
#endif
t->run_body();
#ifdef _MSC_VER
- }
__except(Thread::niceAbort(((LPEXCEPTION_POINTERS)GetExceptionInformation())->ContextRecord),
+ }
__except(Thread::niceAbort(((LPEXCEPTION_POINTERS)GetExceptionInformation())->ContextRecord),
EXCEPTION_CONTINUE_SEARCH) {
}
@@ -864,17 +864,17 @@
ReleaseSemaphore(priv->done, 1, 0);
// Wait to be deleted...
- if (WaitForSingleObject(priv->delete_ready,INFINITE)!=WAIT_OBJECT_0) {
- throw ThreadError(std::string("WaitForSingleObject (delete_ready)
failed")
- +threadError());
- }
+ if (WaitForSingleObject(priv->delete_ready,INFINITE)!=WAIT_OBJECT_0)
{
+ throw ThreadError(std::string("WaitForSingleObject (delete_ready)
failed")
+ +threadError());
+ }
+
-
- delete thread;
+ delete thread;
// Allow this thread to run anywhere...
if(thread->cpu_ != -1)
- thread->migrate(-1);
+ thread->migrate(-1);
lock_scheduler();
//thread_local->current_thread = 0;
@@ -885,11 +885,11 @@
/* Remove it from the active queue */
int i;
for(i=0;i<numActive;i++){
- if(active[i]==priv)
- break;
+ if(active[i]==priv)
+ break;
}
for(i++;i<numActive;i++){
- active[i-1]=active[i];
+ active[i-1]=active[i];
}
numActive--;
@@ -897,24 +897,24 @@
// condition.
int done=true;
for(int i=0;i<numActive;i++){
- Thread_private* p=active[i];
- if(!p->thread->isDaemon()){
- done=false;
- break;
- }
+ Thread_private* p=active[i];
+ if(!p->thread->isDaemon()){
+ done=false;
+ break;
+ }
}
-
+
unlock_scheduler();
if(done)
- Thread::exitAll(0);
+ Thread::exitAll(0);
if(priv->threadid == 0){
- priv->state=Thread::PROGRAM_EXIT;
- if (WaitForSingleObject(main_sema,INFINITE)!=WAIT_OBJECT_0) {
- throw ThreadError(std::string("WaitForSingleObject (main_sema)
failed")
- +threadError());
- }
+ priv->state=Thread::PROGRAM_EXIT;
+ if (WaitForSingleObject(main_sema,INFINITE)!=WAIT_OBJECT_0) {
+ throw ThreadError(std::string("WaitForSingleObject (main_sema)
failed")
+ +threadError());
+ }
}
// get rid of the tls hack
threadids.erase(GetCurrentThreadId());
@@ -974,20 +974,20 @@
void Thread::os_start(bool stopped)
{
if(!Thread::initialized)
- Thread_private::initialize();
+ Thread_private::initialize();
priv_=new Thread_private;
priv_->done = CreateSemaphore(0,0,100,0);
- if (!priv_->done) {
- throw ThreadError(std::string("CreateSemaphore (done) failed")
- +threadError());
- }
- priv_->delete_ready = CreateSemaphore(0,0,100,0);
- if (!priv_->delete_ready) {
- throw ThreadError(std::string("CreateSemaphore (delete_ready)
failed")
- +threadError());
- }
+ if (!priv_->done) {
+ throw ThreadError(std::string("CreateSemaphore (done) failed")
+ +threadError());
+ }
+ priv_->delete_ready = CreateSemaphore(0,0,100,0);
+ if (!priv_->delete_ready) {
+ throw ThreadError(std::string("CreateSemaphore (delete_ready)
failed")
+ +threadError());
+ }
priv_->state=STARTUP;
priv_->bstacksize=0;
@@ -996,12 +996,12 @@
priv_->main_sema = main_sema;
lock_scheduler();
- priv_->t =
CreateThread(0,stacksize_,start_threads,priv_,(stopped?CREATE_SUSPENDED:0),(unsigned
long*)&priv_->threadid);
+ priv_->t =
CreateThread(0,stacksize_,start_threads,priv_,(stopped?CREATE_SUSPENDED:0),(unsigned
long*)&priv_->threadid);
threadids[priv_->threadid] = this;
- if (!priv_->t) {
- throw ThreadError(std::string("CreateThread failed")
- +threadError());
- }
+ if (!priv_->t) {
+ throw ThreadError(std::string("CreateThread failed")
+ +threadError());
+ }
active[numActive]=priv_;
numActive++;
unlock_scheduler();
@@ -1012,16 +1012,16 @@
lock_scheduler();
int done=true;
for(int i=0;i<numActive;i++){
- Thread_private* p=active[i];
- if(!p->thread->isDaemon()){
- done=false;
- break;
- }
+ Thread_private* p=active[i];
+ if(!p->thread->isDaemon()){
+ done=false;
+ break;
+ }
}
unlock_scheduler();
if(done)
- Thread::exitAll(0);
+ Thread::exitAll(0);
}
void Thread::detach()
@@ -1050,26 +1050,26 @@
void Thread::yield()
{
- Sleep(0);
+ Sleep(0);
}
int Thread::numProcessors()
{
- SYSTEM_INFO sysinfo;
- GetSystemInfo(&sysinfo);
- return sysinfo.dwNumberOfProcessors;
+ SYSTEM_INFO sysinfo;
+ GetSystemInfo(&sysinfo);
+ return sysinfo.dwNumberOfProcessors;
}
int Thread::push_bstack(Thread_private* p, Thread::ThreadState state,
- const char* name)
+ const char* name)
{
int oldstate=p->state;
p->state=state;
p->blockstack[p->bstacksize]=name;
p->bstacksize++;
if(p->bstacksize>MAXBSTACK){
- fprintf(stderr, "Blockstack Overflow!\n");
- Thread::niceAbort();
+ fprintf(stderr, "Blockstack Overflow!\n");
+ Thread::niceAbort();
}
return oldstate;
}
@@ -1078,7 +1078,7 @@
{
p->bstacksize--;
p->state=(ThreadState)oldstate;
-}
+}
void ThreadGroup::gangSchedule()
{
Modified: trunk/Core/Util/Plugin.h
==============================================================================
--- trunk/Core/Util/Plugin.h (original)
+++ trunk/Core/Util/Plugin.h Sat Jan 5 19:06:06 2008
@@ -4,12 +4,19 @@
#include <string.h>
#include <string>
#include <iostream>
+
+#if defined(__APPLE__)
+ #if defined(APPLE_LEOPARD)
+ #define MANTA_USE_MACH_O 0
+ #else
+ #define MANTA_USE_MACH_O 1
+ #endif
+#endif
+
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#elif defined(__APPLE__)
-// NOTE(boulos): We should also not take this path but use dlfcn if
-// we're on Leopard (as apparently dyld is now deprecated)
+#elif MANTA_USE_MACH_O
#include <mach-o/dyld.h>
#else
#include <dlfcn.h>
@@ -33,7 +40,7 @@
if (!object)
throw InputError("Can't open plugin: " + std::string(name));
-#elif defined(__APPLE__)
+#elif MANTA_USE_MACH_O
object = NSAddImage(name, NSADDIMAGE_OPTION_NONE);
if (!object)
throw InputError("Can't open plugin: " + std::string(name));
@@ -48,7 +55,7 @@
#ifdef _WIN32
if (object)
FreeLibrary(object);
-#elif defined(__APPLE__)
+#elif MANTA_USE_MACH_O
// don't free the const mach_header*
#else
if (object)
@@ -61,7 +68,7 @@
#ifdef _WIN32
address = (void*)GetProcAddress(object, symbol);
-#elif defined(__APPLE__)
+#elif MANTA_USE_MACH_O
// NOTE(boulos): Thanks to incredible smarts, the symbols in
// Mach files get an _ in front of them...
char underscored[1024];
@@ -85,7 +92,7 @@
char name[1024];
#ifdef _WIN32
typedef HMODULE DSOType;
-#elif defined(__APPLE__)
+#elif MANTA_USE_MACH_O
typedef const struct mach_header* DSOType;
#else // Unix systems
typedef void* DSOType;
Modified: trunk/Engine/Display/PureOpenGLDisplay.cc
==============================================================================
--- trunk/Engine/Display/PureOpenGLDisplay.cc (original)
+++ trunk/Engine/Display/PureOpenGLDisplay.cc Sat Jan 5 19:06:06 2008
@@ -592,7 +592,7 @@
if (resize_buffer) {
// Allocate more space for the buffer.
- // Reset the contents of the texSize-sized buffer object
+ // Reset the contnets of the texSize-sized buffer object
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo->texSize, NULL,
GL_STREAM_DRAW_ARB);
}
- [Manta] r1966 - in trunk: CMake Core/Thread Core/Util Engine/Display, boulos, 01/05/2008
Archive powered by MHonArc 2.6.16.