diff --git a/CMakeLists.txt b/CMakeLists.txt index e3bf339cb33a6b04a49837cf2091ded249e4ad5b..4329212bb9d019eb8293c7b63eb4e88dee9b89d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,26 @@ IF(OTB_COMPILE_JPEG2000) ENDIF(NOT BUILD_SHARED_LIBS) ENDIF(OTB_COMPILE_JPEG2000) +#----------------------------------------------------------------------------- +# Option for OpenThreads (necessary because used by the new version of OSSIM library +# Find OpenThread library +IF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake") + FIND_PACKAGE(OpenThreads) +ELSE(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake") + INCLUDE(${OTB_SOURCE_DIR}/FindOpenThreads.cmake) +ENDIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake") + +SET(OTB_USE_EXTERNAL_OPENTHREADS 1) +IF(OPENTHREADS_FOUND) + INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR}) + LINK_DIRECTORIES( ${OPENTHREADS_LIBRARY} ) +ELSE(OPENTHREADS_FOUND) + ADD_DEFINITIONS(-DOTB_USE_INTERNAL_OPENTHREADS) + SET(OTB_USE_EXTERNAL_OPENTHREADS 0) + SET(OPENTHREADS_INCLUDE_DIR "${OTB_SOURCE_DIR}/Utilities/otbopenthreads/OpenThreads/include") + SET(OPENTHREADS_LIBRARY "OpenThreads" ) + INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR}) +ENDIF(OPENTHREADS_FOUND) #----------------------------------------------------------------------------- diff --git a/Testing/Utilities/CMakeLists.txt b/Testing/Utilities/CMakeLists.txt index 2d652533bede3c040516711825bf49d19bd8880a..af9494a9413aa36d83d491173ce991b48c3ddd07 100644 --- a/Testing/Utilities/CMakeLists.txt +++ b/Testing/Utilities/CMakeLists.txt @@ -334,6 +334,19 @@ ADD_TEST(utOpenJpegDecoder ${UTILITIES_TESTS} ENDIF(OTB_COMPILE_JPEG2000) +# ------- lib OpenThreads ------------------------------ +IF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + ADD_TEST(utOpenthreadsSimpleThreader ${UTILITIES_TESTS} + openthreadsSimpleThreader + 2 # [NUM_ELTS] + 1 # [NUM_THREADS] + ) + ADD_TEST(utOpenthreadsWorkCrew ${UTILITIES_TESTS} + openthreadsWorkCrew + 1 # [NUM_THREADS] + ) +ENDIF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + # ------- SIFT ------------------------------------- ADD_TEST(ut2DSiftImageSquareSyntheticRotate10 ${UTILITIES_TESTS} itk2DScaleInvariantFeatureImageFilterTest @@ -422,6 +435,16 @@ IF(OTB_COMPILE_JPEG2000) SET(UtilitiesTests_SRCS ${UtilitiesTests_SRCS} openJpegEncoder.cxx openJpegDecoder.cxx) ENDIF(OTB_COMPILE_JPEG2000) + + +IF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + SET(UtilitiesTests_SRCS ${UtilitiesTests_SRCS} + openthreadsThreadObserver.cpp + openthreadsThreadReporter.cpp + openthreadsWorkCrew.cpp + openthreadsSimpleThreader.cpp ) +ENDIF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}") @@ -438,6 +461,10 @@ IF(OTB_COMPILE_JPEG2000) TARGET_LINK_LIBRARIES(otbUtilitiesTests otbopenjpeg) ENDIF(OTB_COMPILE_JPEG2000) +IF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + TARGET_LINK_LIBRARIES(otbUtilitiesTests OpenThreads) +ENDIF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + IF(UNIX) TARGET_LINK_LIBRARIES (otbUtilitiesTests m) ENDIF(UNIX) @@ -487,5 +514,4 @@ ENDIF(UNIX) # TARGET_LINK_LIBRARIES (otb6SMainWithCallFunction m) # ENDIF(UNIX) - ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Utilities/openthreadsSimpleThreader.cpp b/Testing/Utilities/openthreadsSimpleThreader.cpp new file mode 100755 index 0000000000000000000000000000000000000000..4e9aa4acbafebe2bd1e29de2cbffb944651e3fc1 --- /dev/null +++ b/Testing/Utilities/openthreadsSimpleThreader.cpp @@ -0,0 +1,228 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include <sys/types.h> +#include <cassert> +#include <cstdio> +#include <iostream> +#include <vector> +#include <OpenThreads/Thread> +#include <OpenThreads/Mutex> +#include <OpenThreads/Barrier> +#include "openthreadsThreadObserver.h" +#include "openthreadsThreadReporter.h" + +#ifdef _WIN32 +#include <process.h> +#define getpid() _getpid() +#else +#include <unistd.h> +#endif + +OpenThreads::Barrier bar; + +int GLOBAL_NUM_THREADS; + +//----------------------------------------------------------------------------- +// Custom Thread Observer (w/finished count) +// +class MyThreadObserver : public ThreadObserver { + +public: + + MyThreadObserver() : ThreadObserver(), _finishedCount(0) {}; + + virtual ~MyThreadObserver() {}; + + void threadFinished(const int threadId) { + + ThreadObserver::threadFinished(threadId); + + ++_finishedCount; + } + + int getFinishedCount() {return _finishedCount;}; + + +private: + + volatile int _finishedCount; + +}; + +// check the working of OpenThreads::Thread::CurrentThread() +static OpenThreads::Thread* CurrentChecker(){ + return OpenThreads::Thread::CurrentThread(); +}; + +//----------------------------------------------------------------------------- +// Custom thread class - with reporting +// +class MyThread : public OpenThreads::Thread, public ThreadReporter { + +public: + + MyThread(int *dataPtr, int numElts) : OpenThreads::Thread(), + ThreadReporter(), + _dataPtr(dataPtr), _numElts(numElts), _quitflag(false) {}; + + virtual ~MyThread() {}; + + virtual void run() { + + if( CurrentChecker()!=this) + notifyObserversMessage(getThreadId(), "Thread::CurrentThread is NOT working"); + else + notifyObserversMessage(getThreadId(), "Thread::CurrentThread is working"); + + + bar.block(GLOBAL_NUM_THREADS); // Sync the threads. + + char tmp[80]; + sprintf(tmp, "StackSize: %d\n", static_cast<int>(getStackSize())); + + notifyObserversStarted(getThreadId()); + notifyObserversMessage(getThreadId(), "This is a thread message."); + notifyObserversMessage(getThreadId(), tmp); + + register int i; + for (i=0; i<_numElts; ++i) { + _dataPtr[i] = getThreadId(); + } + + notifyObserversMessage(getThreadId(), "Finished my work"); + + bar.block(GLOBAL_NUM_THREADS); // Sync the threads. + + //--------------------------------------------------------------------- + // Now that we've done our work, wait for a sign that we should quit. + // + while (true) { + + _quitmutex.lock(); + if(_quitflag == true) break; + _quitmutex.unlock(); + + OpenThreads::Thread::YieldCurrentThread(); + } + + + notifyObserversFinished(getThreadId()); + + } + + void quit() { + + _quitmutex.lock(); + _quitflag = true; + _quitmutex.unlock(); + + } + +private: + + int *_dataPtr; + + int _numElts; + + volatile bool _quitflag; + + OpenThreads::Mutex _quitmutex; +}; + + +int openthreadsSimpleThreader(int argc, char *argv []) { + + if(argc != 3) { + std::cout << "Usage: simpleThreader [NUM_ELTS] [NUM_THREADS] " + << std::endl; + return 0; + }; + + std::cout << "Root Thread ID: " << getpid() << std::endl; + + int NUM_ELTS = atoi(argv[1]); + int NUM_THREADS = atoi(argv[2]); + + GLOBAL_NUM_THREADS = NUM_THREADS + 1; + + MyThreadObserver observer; + register int i; + + int *dataArray = new int[NUM_ELTS]; + std::vector<MyThread *> threads; + + for(i=0; i<NUM_ELTS; ++i) { + + dataArray[i] = -1; + } + + OpenThreads::Thread::SetConcurrency(NUM_THREADS); + + OpenThreads::Thread::Init(); + for(i=0; i<NUM_THREADS; ++i) { + int status; + MyThread *thread = new MyThread(dataArray + (i*(NUM_ELTS/NUM_THREADS)), + NUM_ELTS/NUM_THREADS); + threads.push_back(thread); + thread->addObserver(&observer); + thread->setStackSize(1024*256); + status = thread->start(); + assert(status == 0); + } + + bar.block(GLOBAL_NUM_THREADS); // Block 'till ready + bar.block(GLOBAL_NUM_THREADS); // Block 'till finished + +// char val; +// std::cout << "Press any key + return to quit." << std::endl; +// std::cin >> val; + + // Notify the threads to quit, wait for this to happen. + for(i=0;i<static_cast<int>(threads.size());++i) { + MyThread *thread = threads[i]; + thread->quit(); + } + + while(observer.getFinishedCount() != NUM_THREADS) { + // Spin our wheels. + } + + std::cout << "Data Array: " << std::endl; + for(i=0; i < NUM_THREADS; ++i) { + register int j; + for (j=0; j<NUM_ELTS/NUM_THREADS; ++j) { + std::cout << dataArray[(i*NUM_ELTS/NUM_THREADS)+j] << " "; + } + std::cout << std::endl; + } + std::cout << std::endl; + + // Delete all the threads. + for(i=0;i<static_cast<int>(threads.size());++i) { + MyThread *thread = threads[i]; + delete thread; + } + + threads.clear(); + + delete [] dataArray; + + return EXIT_SUCCESS; +} + diff --git a/Testing/Utilities/openthreadsThreadObserver.cpp b/Testing/Utilities/openthreadsThreadObserver.cpp new file mode 100755 index 0000000000000000000000000000000000000000..3c6df1090871fb187a99d1d9fd45625bc48909a3 --- /dev/null +++ b/Testing/Utilities/openthreadsThreadObserver.cpp @@ -0,0 +1,45 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include <cstdio> +#include "openthreadsThreadObserver.h" + +void ThreadObserver::threadStarted(const int threadId) { + + printf("Thread %d started.\n", threadId); + +} + +void ThreadObserver::threadFinished(const int threadId) { + + printf("Thread %d finished.\n", threadId); + +} + +void ThreadObserver::threadMessage(const int threadId, const char *message) { + + printf("Thread Message (%d) : %s\n", threadId, message); + +} + +void ThreadObserver::threadError(const int threadId, + const char *errorMessage) { + + printf("Thread Message (%d) : %s\n", threadId, errorMessage); + +} diff --git a/Testing/Utilities/openthreadsThreadObserver.h b/Testing/Utilities/openthreadsThreadObserver.h new file mode 100755 index 0000000000000000000000000000000000000000..231023a37d6a01d3f4152dfa50221cf947b27fb3 --- /dev/null +++ b/Testing/Utilities/openthreadsThreadObserver.h @@ -0,0 +1,45 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadObserver.h - provide a basic thread observer class +// ~~~~~~~~~~~~~~~~ +// + +#ifndef _THREADOBSERVER_H_ +#define _THREADOBSERVER_H_ + +class ThreadObserver { + +public: + + ThreadObserver() {}; + + virtual ~ThreadObserver() {}; + + virtual void threadStarted (const int threadId); + + virtual void threadFinished(const int threadId); + + virtual void threadMessage(const int threadId, const char *message); + + virtual void threadError(const int threadId, const char *errorMessage); + +}; + +#endif diff --git a/Testing/Utilities/openthreadsThreadReporter.cpp b/Testing/Utilities/openthreadsThreadReporter.cpp new file mode 100755 index 0000000000000000000000000000000000000000..835b0b90ff3003b1af202007c4b4b48dafc4eb56 --- /dev/null +++ b/Testing/Utilities/openthreadsThreadReporter.cpp @@ -0,0 +1,135 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadReporter - Basic Thread Reporter class. +// ~~~~~~~~~~~~~~~ +// + +#include "openthreadsThreadReporter.h" + +//----------------------------------------------------------------------------- +// +// Description: Constructor +// +// Use: public +// +ThreadReporter::ThreadReporter() { + _observers.clear(); +} + +//----------------------------------------------------------------------------- +// +// Description: Destructor +// +// Use: public +// +ThreadReporter::~ThreadReporter() { + _observers.clear(); +} + +//----------------------------------------------------------------------------- +// +// Description: Add an observer to the list +// +// Use: public +// +void ThreadReporter::addObserver(ThreadObserver *observer) { + + _observers.push_back(observer); + +} + +//----------------------------------------------------------------------------- +// +// Description: Remove an observer from the list +// +// Use: public +// +void ThreadReporter::removeObserver(ThreadObserver *observer) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + if(*iter == observer) { + _observers.erase(iter); + return; + } + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers the thread has started +// +// Use: protected +// +void ThreadReporter::notifyObserversStarted(const int threadId) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadStarted(threadId); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers the thread has finished +// +// Use: protected +// +void ThreadReporter::notifyObserversFinished(const int threadId) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadFinished(threadId); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers of a thread message +// +// Use: protected +// +void ThreadReporter::notifyObserversMessage(const int threadId, + const char *message) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadMessage(threadId, message); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers of a thread error +// +// Use: protected +// +void ThreadReporter::notifyObserversError(const int threadId, + const char *errorMessage) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadError(threadId, errorMessage); + } +} diff --git a/Testing/Utilities/openthreadsThreadReporter.h b/Testing/Utilities/openthreadsThreadReporter.h new file mode 100755 index 0000000000000000000000000000000000000000..24843fd8d326033154a69db944919912cef3de3b --- /dev/null +++ b/Testing/Utilities/openthreadsThreadReporter.h @@ -0,0 +1,58 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadReporter - Basic thread reporter class. +// ~~~~~~~~~~~~~~~ +// + +#ifndef _THREADREPORTER_H_ +#define _THREADREPORTER_H_ + +#include <list> +#include "openthreadsThreadObserver.h" + +class ThreadReporter { + +public: + + ThreadReporter(); + + virtual ~ThreadReporter(); + + void addObserver(ThreadObserver *observer); + + void removeObserver(ThreadObserver *observer); + +protected: + + void notifyObserversStarted(const int threadId); + + void notifyObserversFinished(const int threadId); + + void notifyObserversMessage(const int threadId, const char *message); + + void notifyObserversError(const int threadId, const char *errorMessage); + +private: + + std::list<ThreadObserver *> _observers; + +}; + +#endif diff --git a/Testing/Utilities/openthreadsWorkCrew.cpp b/Testing/Utilities/openthreadsWorkCrew.cpp new file mode 100755 index 0000000000000000000000000000000000000000..450f3b8392568e0e048a8fb47e79d667daab04aa --- /dev/null +++ b/Testing/Utilities/openthreadsWorkCrew.cpp @@ -0,0 +1,424 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include <cstdio> +#include <sys/types.h> +#include <unistd.h> +#include <iostream> +#include <vector> +#include <cassert> +#include <cerrno> +#include "openthreadsThreadObserver.h" +#include "openthreadsThreadReporter.h" + +//----------------------------------------------------------------------------- +// For the threads +// +#include <OpenThreads/Thread> +#include <OpenThreads/Mutex> +#include <OpenThreads/Condition> +#include <OpenThreads/Barrier> + +extern int errno; + +#ifdef DEBUG +# define DPRINTF(arg) printf arg +#else +# define DPRINTF(arg) +#endif + + +//----------------------------------------------------------------------------- +// Create a data structure for the worker's to work on +// +struct WorkData { + + WorkData * next; // Next work item. + std::vector<float> datapts; // Data points. + +}; + +//----------------------------------------------------------------------------- +// Create a data structure for the crew. +// +struct Crew { + + int crewSize; // Number of workers in the crew. + long workCount; // Number of work items. + WorkData *first, *last; // First & last work items. + + OpenThreads::Mutex mutex; + OpenThreads::Condition go; + OpenThreads::Condition done; + OpenThreads::Barrier bar; + +}; + +class WorkerThread : public OpenThreads::Thread { + +public: + + WorkerThread(Crew *crew, float *workResult) : OpenThreads::Thread(), + _crew(crew), _result(workResult) { + + _bar = &_crew->bar; + _mutex = &_crew->mutex; + _go = &_crew->go; + _done = &_crew->done; + + }; + + virtual ~WorkerThread() {}; + +protected: + + virtual void run() { + + int status; + + DPRINTF(("Created Thread %d\n", getProcessId())); + + //--------------------------------------------------------------------- + // Block until all of the crew members are ready. + // + _bar->block(_crew->crewSize+1); + + DPRINTF(("Reving Thread %d\n", getProcessId())); + + //--------------------------------------------------------------------- + // Lock the crew mutex + // + status = _mutex->lock(); + DPRINTF(("Thread %d got lock\n", getProcessId())); + assert(status == 0); + + //--------------------------------------------------------------------- + // There will be no work to do when the crew members are created, + // so wait for the go signal. + // + while(_crew->workCount == 0) { + + DPRINTF(("Thread %d waiting to go\n", getProcessId())); + status = _go->wait(_mutex); + assert(status == 0); + + DPRINTF(("Thread %d going\n", getProcessId())); + } + + //--------------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + + //--------------------------------------------------------------------- + // While there's work to do, do it ! + // + while(true) { + + DPRINTF(("Thread %d entered while loop.\n", getProcessId())); + + //----------------------------------------------------------------- + // Lock the crew mutex + // + status = _mutex->lock(); + assert(status == 0); + + //----------------------------------------------------------------- + // Wait while there is nothing to do. If _crew->first == 0, + // there's no work. But if _crew->workCount == 0, we're done. + // + while(_crew->first == 0) { + + DPRINTF(("Thread %d waiting for work\n", getProcessId())); + + status = _go->wait(_mutex); + assert(status == 0); + + DPRINTF(("Thread %d woke, %#lx, %d\n", + getProcessId(), _crew->first, _crew->workCount)); + } + + //----------------------------------------------------------------- + // Remove and process a work item. + // + _work = _crew->first; + _crew->first = _work->next; + if(_crew->first == 0) { + _crew->last = 0; + }; + + DPRINTF(("Thread %d took, %#lx, leaves first %#lx, last %#lx\n", + getProcessId(), _work, _crew->first, _crew->last)); + + //----------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + //----------------------------------------------------------------- + // Okay, we have a work item, process it. + // + float proc_result = pr_processWork(); + + //----------------------------------------------------------------- + // Lock the crew mutex to decrement the work count, and + // update the result. + // + status = _mutex->lock(); + assert(status == 0); + + *(_result) += proc_result; + + --_crew->workCount; + + DPRINTF(("Thread %d decremented work count to %d\n", + getProcessId(), _crew->workCount)); + + if(_crew->workCount <= 0) { + DPRINTF(("Thread %d done.\n", getProcessId())); + + //------------------------------------------------------------- + // Signal that we have finished our job. + // + status = _done->broadcast(); + assert(status == 0); + + //------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + break; + } + + //---------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + } + + }; + +private: + + float pr_processWork() { + + //--------------------------------------------------------------------- + // Just take the numbers and add them + // + float result = 0; + register unsigned int i, j; + float total; + for(i=0; i<_work->datapts.size();++i) { + for(total=0, j=0; j<10000000; ++j) { +#if defined(WIN32) && !defined(__CYGWIN__) + total += double(rand()) / double(RAND_MAX); + total -= double(rand()) / double(RAND_MAX); +#else + total += drand48(); + total -= drand48(); +#endif + } + result += _work->datapts[i] + total; + result -= total; + } + + _work->next = 0; + delete _work; + _work = 0; + + return result; + + } + +private: + + WorkData *_work; + + Crew *_crew; + + OpenThreads::Mutex *_mutex; + + OpenThreads::Condition *_go; + + OpenThreads::Condition *_done; + + OpenThreads::Barrier *_bar; + + float *_result; + +}; + +int crew_create(Crew *crew, + float & result, std::vector<WorkerThread *> &workers) { + + int crew_index; + int status; + + //------------------------------------------------------------------------- + // Create the worker threads. + // + for(crew_index = 0; crew_index < crew->crewSize; ++crew_index) { + + WorkerThread *thread = new WorkerThread(crew, &result); + workers.push_back(thread); + status = thread->start(); + assert(status == 0); + + } + + crew->bar.block(crew->crewSize+1); + + return 0; +} + +int crew_start(Crew *crew) { + + + int status = 0; + + //------------------------------------------------------------------------- + // Lock the crew mutex + // + status = crew->mutex.lock(); + if(status != 0) { + DPRINTF(("Lock Error: %s\n", strerror(errno))); + } + assert(status == 0); + + DPRINTF(("Checking busy signal.\n")); + + //------------------------------------------------------------------------- + // If the crew is busy, wait 'till they're done. + // + while(crew->workCount > 0) { + + status = crew->done.wait(&(crew->mutex)); + if(status != 0) { + + status = crew->mutex.lock(); + return status; + } + } + + DPRINTF(("Crew not busy, creating some work data.\n")); + + errno = 0; + + //------------------------------------------------------------------------- + // Create some work data. + // + register int i; + for(i=0; i<4; ++i) { + WorkData *work = new WorkData; + work->datapts.push_back(10.0); + work->next = 0; + if(crew->first == 0) { + crew->first = work; + crew->last = work; + } else { + crew->last->next = work; + crew->last = work; + } + ++crew->workCount; + } + + DPRINTF(("Giving the go-ahead.\n")); + + status = crew->go.signal(); + if(status != 0) { + delete crew->first; + crew->first = NULL; + crew->workCount = 0; + status = crew->mutex.unlock(); + return status; + } + + DPRINTF(("Waiting on the crew to finish....\n")); + + while(crew->workCount > 0) { + + DPRINTF(("Work Count: %d\n", crew->workCount)); + status = crew->done.wait(&(crew->mutex)); + assert(status == 0); + } + + DPRINTF(("Crew finished.\n")); + + status = crew->mutex.unlock(); + assert(status == 0); + + return 0; +} + +int openthreadsWorkCrew (int argc, char *argv []) { + + std::vector<WorkerThread *> workers; + + if(argc != 2) { + std::cout << "Usage: workCrew [NUM_THREADS] " << std::endl; + return 0; + }; + + const int NUM_THREADS = atoi(argv[1]); + + DPRINTF(("ROOT PID = %d\n", getpid())); + + Crew *crew = new Crew; + + crew->crewSize = NUM_THREADS; + crew->workCount = 0; + crew->first = 0; + crew->last = 0; + + float result = 0; + unsigned int status = crew_create(crew, result, workers); + assert(status == 0); + + status = crew_start(crew); + assert(status == 0); + + printf("FINAL RESULT: %f\n", result); + + for(status = 0; status < workers.size(); ++status) { + + WorkerThread *thread = workers[status]; + delete thread; + + } + workers.clear(); + + delete crew; + return EXIT_SUCCESS; +} + + + + + + + + + + diff --git a/Testing/Utilities/otbUtilitiesTests.cxx b/Testing/Utilities/otbUtilitiesTests.cxx index 3913f49395ae813cb9a43d3f7ff9ba01ef1dc141..f67b6416feafbad175445ae462b272103856376a 100644 --- a/Testing/Utilities/otbUtilitiesTests.cxx +++ b/Testing/Utilities/otbUtilitiesTests.cxx @@ -44,5 +44,10 @@ REGISTER_TEST(itk2DScaleInvariantFeatureImageFilterTest); REGISTER_TEST(openJpegEncoder); REGISTER_TEST(openJpegDecoder); #endif +// register OPENTHREADS testing +#ifdef OTB_USE_INTERNAL_OPENTHREADS + REGISTER_TEST(openthreadsSimpleThreader); + REGISTER_TEST(openthreadsWorkCrew); +#endif } diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 067aa4688f5dc61bcb3c934b8152cbbd7db19197..9d4f4341fc86d2c43859c4caf79cbec637b059a6 100755 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -5,8 +5,13 @@ IF(NOT OTB_USE_EXTERNAL_ITK) SUBDIRS(ITK) ENDIF(NOT OTB_USE_EXTERNAL_ITK) +IF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + SUBDIRS( otbopenthreads ) +ENDIF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + + IF(OTB_COMPILE_JPEG2000) - SUBDIRS( otbopenjpeg) + SUBDIRS( otbopenjpeg ) ENDIF(OTB_COMPILE_JPEG2000) IF(OTB_USE_VISU_GUI) diff --git a/Utilities/otbopenthreads/CMakeLists.txt b/Utilities/otbopenthreads/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..8b6a92bbf03c4db48b732d86c6d72fdb4d642853 --- /dev/null +++ b/Utilities/otbopenthreads/CMakeLists.txt @@ -0,0 +1,4 @@ +SUBDIRS(OpenThreads) + +#INCLUDE_DIRECTORIES("${OTB_SOURCE_DIR}/Utilities/otbopenthreads/OpenThreads/include") +#INCLUDE_DIRECTORIES("${OTB_SOURCE_DIR}/Utilities/otbopenthreads/OpenThreads/include/OpenThreads") diff --git a/Utilities/otbopenthreads/OpenThreads/AUTHORS.txt b/Utilities/otbopenthreads/OpenThreads/AUTHORS.txt new file mode 100755 index 0000000000000000000000000000000000000000..f7dcc984df961676d422066c12c748e8b660fc55 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/AUTHORS.txt @@ -0,0 +1,11 @@ +The Open Thread Group consists of: + +Sean Spicer......Original project author (posix threads) and maintainer. +Jack Lees........Friendly neighborhood API tester/contributer/developer + e.g. (Jack-of-all-trades) +Don Burns........Master of multi-threaded windowing and scene-graphs +Robert Osfield...The Open Scene Graph Yoda +Boris Bralo......Developed the Win32 implementation + +The numerous developers who contribute on a daily basis to the design, +testing, and general discussion surrounding OpenThreads. \ No newline at end of file diff --git a/Utilities/otbopenthreads/OpenThreads/CMakeLists.txt b/Utilities/otbopenthreads/OpenThreads/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..9a2a04d2b9ba431bf9028c95aeb2a3ba0cd539f1 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/CMakeLists.txt @@ -0,0 +1,231 @@ +IF(WIN32) + CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR) +ELSE(WIN32) + IF(APPLE) + CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR) + ELSE(APPLE) + CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0 FATAL_ERROR) + ENDIF(APPLE) +ENDIF(WIN32) + + +PROJECT(OpenThreads) + +# We have some custom .cmake scripts not in the official distribution. +# Maybe this can be used override existing behavior if needed? +SET(CMAKE_MODULE_PATH "${OpenThreads_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") + +################################################################################ +# Installation stuff + +# We want to build SONAMES shared librariess +SET(OPENTHREADS_SONAMES TRUE) + +SET(CMAKE_DEBUG_POSTFIX "d") +#SET(INSTALL_BINDIR OpenThreads/bin) +#SET(INSTALL_INCDIR OpenThreads/include) +#SET(INSTALL_LIBDIR OpenThreads/lib) +#SET(INSTALL_DOCDIR OpenThreads/docs) + + +SET(CMAKE_DEBUG_POSTFIX "d") + +SET(LIB_POSTFIX "") +IF(UNIX AND NOT WIN32 AND NOT APPLE) + IF(CMAKE_SIZEOF_VOID_P MATCHES "8") + SET(LIB_POSTFIX "64") + ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8") +ENDIF(UNIX AND NOT WIN32 AND NOT APPLE) + +################################################################################ + + +# Add a source group for the include headers so they are seen in IDEs. +# Hmmm, this isn't working for me in Xcode. +# SOURCE_GROUP( +# "Header Files" +# FILES ${OpenThreads_PUBLIC_HEADERS} +# ) + +# Make the headers visible to everything +INCLUDE_DIRECTORIES( + ${OpenThreads_SOURCE_DIR}/include +) + +# This is mainly for Windows declspec, but other platforms know +# what to do with it. +ADD_DEFINITIONS(-DOPENTHREADS_EXPORTS) + +# User Options +# OTB modifications +#OPTION(DYNAMIC_OPENTHREADS "Set to ON to build OpenThreads for dynamic linking. Use OFF for static." ON) +#IF (DYNAMIC_OPENTHREADS) +# SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED") +#ELSE (DYNAMIC_OPENTHREADS) +# SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC") +#ENDIF(DYNAMIC_OPENTHREADS) +IF( OTB_BUILD_SHARED_LIBS ) + SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED") +ELSE( OTB_BUILD_SHARED_LIBS ) + SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC") +ENDIF( OTB_BUILD_SHARED_LIBS ) + + + +# Use our modified version of FindThreads.cmake which has Sproc hacks. +FIND_PACKAGE(Threads) + +# OTB Modifications +#SUBDIRS(src/OpenThreads examples) +SUBDIRS(src/OpenThreads) + +# FIXME: Make optional install test programs +# FIXME: /bin directory not correct for Windows +# INSTALL_TARGETS(/bin OpenThreads) + +#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME}) +# OTB modifications +# Alls bin or lib in OTB bin directory +#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin) +SET(OUTPUT_BINDIR ${OTB_BINARY_DIR}/bin) +MAKE_DIRECTORY(${OUTPUT_BINDIR}) +SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR}) + +#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}) +#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib) +SET(OUTPUT_LIBDIR ${OTB_BINARY_DIR}/bin) +MAKE_DIRECTORY(${OUTPUT_LIBDIR}) +SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR}) + +################################################################################ +# Create bin and lib directories if required + +IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib) +ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + + + + +############################################################################### +# This is for an advanced option to give aggressive warnings +# under different compilers. If yours is not implemented, this option +# will not be made available. +IF(CMAKE_COMPILER_IS_GNUCXX) + # To be complete, we might also do GNUCC flags, + # but everything here is C++ code. + # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another + # interesting C-specific flag. + # Also, there is a bug in gcc 4.0. Under C++, -pedantic will create + # errors instead of warnings for certain issues, including superfluous + # semicolons and commas, and the use of long long. -fpermissive seems + # to be the workaround. + SET(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wnewline-eof -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -Wshadow -Woverloaded-virtual -fpermissive") +ELSE(CMAKE_COMPILER_IS_GNUCXX) + IF(MSVC) + # FIXME: What are good aggressive warning flags for Visual Studio? + # And do we need to further subcase this for different versions of VS? + # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005 + SET(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS "/Wall /W4") + ELSE(MSVC) + # CMake lacks an elseif, so other non-gcc, non-VS compilers need + # to be listed below. If unhandled, OPENTHREADS_AGGRESSIVE_WARNING_FLAGS should + # remain unset. + ENDIF(MSVC) +ENDIF(CMAKE_COMPILER_IS_GNUCXX) + +# This part is for the CMake menu option to toggle the warnings on/off. +# This will only be made available if we set values for OPENTHREADS_AGGRESSIVE_WARNING_FLAGS. +IF(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS) + OPTION(OPENTHREADS_USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" OFF) + MARK_AS_ADVANCED(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) + + IF(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) + IF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}") + SET(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "Old CXX flags") + SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 1 CACHE INTERNAL "Old CXX flags was set") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENTHREADS_AGGRESSIVE_WARNING_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE) + ENDIF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}") + ELSE(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) + # FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was + # set. The better way would be to parse the string and remove each + # option explicitly. + IF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}") + SET(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE) + SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 0 CACHE INTERNAL "Old CXX flags was set") + ENDIF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}") + ENDIF(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) +ENDIF(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS) + + +############################################################################### +# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 +# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. +IF(APPLE) + # These are just defaults/recommendations, but how we want to build + # out of the box. But the user needs to be able to change these options. + # So we must only set the values the first time CMake is run, or we + # will overwrite any changes the user sets. + # FORCE is used because the options are not reflected in the UI otherwise. + IF(NOT OPENTHREADS_CONFIG_HAS_BEEN_RUN_BEFORE) + # This is really fragile, but CMake doesn't provide the OS system + # version information we need. (Darwin versions can be changed + # independently of OS X versions.) + # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically. + IF(EXISTS /Developer/SDKs/10.5.sdk) + SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE) + ELSE(EXISTS /Developer/SDKs/10.5.sdk) + IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) + # Unix layer on Tiger is 64-bit clean/ready so I think + # it is okay to build 64-bit here. This presumes we + # keep non-64-bit ready APIs (e.g. Carbon) out + # of OpenThreads. + SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE) + #SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE) + ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) + # No Universal Binary support + ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) + ENDIF(EXISTS /Developer/SDKs/10.5.sdk) + ENDIF(NOT OPENTHREADS_CONFIG_HAS_BEEN_RUN_BEFORE) +ENDIF(APPLE) + + + +################################################################################ +# For Doxygen +INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL) + +# To build the documention, you will have to enable it +# and then do the equivalent of "make DoxygenDoc". +IF(BUILD_DOCUMENTATION) + IF(DOT) + SET(HAVE_DOT YES) + ELSE(DOT) + SET(HAVE_DOT NO) + ENDIF(DOT) + # This processes our Doxyfile.in and substitutes paths to generate + # a final Doxyfile + CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/docs/doxyfile.cmake + ${PROJECT_BINARY_DIR}/docs/doxyfile + ) + # This creates a new target to build documentation. + # It runs ${DOXYGEN} which is the full path and executable to + # Doxygen on your system, set by the FindDoxygen.cmake module + # (called by FindDocumentation.cmake). + # It runs the final generated Doxyfile against it. + # The DOT_PATH is substituted into the Doxyfile. + ADD_CUSTOM_TARGET(DoxygenDoc ${DOXYGEN} + ${PROJECT_BINARY_DIR}/docs/doxyfile + ) +ENDIF(BUILD_DOCUMENTATION) + + +# This needs to be run very last so other parts of the scripts can take +# advantage of this. +IF(NOT OPENTHREADS_CONFIG_HAS_BEEN_RUN_BEFORE) + SET(OPENTHREADS_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") +ENDIF(NOT OPENTHREADS_CONFIG_HAS_BEEN_RUN_BEFORE) + + diff --git a/Utilities/otbopenthreads/OpenThreads/CMakeModules/FindThreads.cmake b/Utilities/otbopenthreads/OpenThreads/CMakeModules/FindThreads.cmake new file mode 100755 index 0000000000000000000000000000000000000000..370f7e0196ff5d313f3d8ae7a9e92f9796927908 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/CMakeModules/FindThreads.cmake @@ -0,0 +1,115 @@ +# - This module determines the thread library of the system. +# The following variables are set +# CMAKE_THREAD_LIBS_INIT - the thread library +# CMAKE_USE_SPROC_INIT - are we using sproc? +# CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads? +# CMAKE_USE_PTHREADS_INIT - are we using pthreads +# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads + +# This module is a modification of the version found in the official +# CMake distribution. The problem is that the built in version's Sproc +# handling is undesirable for us. The official module assumes you use +# Sproc if it exists on your system. We assume you might have both Pthreads +# and Sproc on your system in which case the user needs to choose. +# Furthermore, we prefer to provide Pthreads as the default option instead +# of Sproc. + +INCLUDE (CheckIncludeFile) +INCLUDE (CheckIncludeFiles) +INCLUDE (CheckLibraryExists) + +# Do we have sproc? +IF(CMAKE_SYSTEM MATCHES IRIX) + CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H) +ENDIF(CMAKE_SYSTEM MATCHES IRIX) + +CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H) +IF(CMAKE_HAVE_PTHREAD_H) + # We have pthread.h + # Let's check for the library now. + SET(CMAKE_HAVE_THREADS_LIBRARY) + IF(NOT THREADS_HAVE_PTHREAD_ARG) + # Do we have -lpthreads + CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) + IF(CMAKE_HAVE_PTHREADS_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + ENDIF(CMAKE_HAVE_PTHREADS_CREATE) + # Ok, how about -lpthread + CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) + IF(CMAKE_HAVE_PTHREAD_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthread") + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + ENDIF(CMAKE_HAVE_PTHREAD_CREATE) + IF(CMAKE_SYSTEM MATCHES "SunOS.*") + # On sun also check for -lthread + CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) + IF(CMAKE_HAVE_THR_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lthread") + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + ENDIF(CMAKE_HAVE_THR_CREATE) + ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") + ENDIF(NOT THREADS_HAVE_PTHREAD_ARG) + + IF(NOT CMAKE_HAVE_THREADS_LIBRARY) + # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread + IF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG") + MESSAGE(STATUS "Check if compiler accepts -pthread") + TRY_RUN(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG + ${CMAKE_BINARY_DIR} + ${CMAKE_ROOT}/Modules/CheckForPthreads.c + CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread + OUTPUT_VARIABLE OUTPUT) + IF(THREADS_HAVE_PTHREAD_ARG) + IF(THREADS_PTHREAD_ARG MATCHES "^2$") + MESSAGE(STATUS "Check if compiler accepts -pthread - yes") + ELSE(THREADS_PTHREAD_ARG MATCHES "^2$") + MESSAGE(STATUS "Check if compiler accepts -pthread - no") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n") + ENDIF(THREADS_PTHREAD_ARG MATCHES "^2$") + ELSE(THREADS_HAVE_PTHREAD_ARG) + MESSAGE(STATUS "Check if compiler accepts -pthread - no") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n") + ENDIF(THREADS_HAVE_PTHREAD_ARG) + ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG") + IF(THREADS_HAVE_PTHREAD_ARG) + SET(CMAKE_THREAD_LIBS_INIT "-pthread") + ELSE(THREADS_HAVE_PTHREAD_ARG) + ENDIF(THREADS_HAVE_PTHREAD_ARG) + ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY) +ELSE(CMAKE_HAVE_PTHREAD_H) + IF(CMAKE_HAVE_SPROC_H) + # We have sproc but not pthread so the answer is obvious. + SET(CMAKE_USE_SPROC_INIT 1) + ENDIF(CMAKE_HAVE_SPROC_H) +ENDIF(CMAKE_HAVE_PTHREAD_H) + +IF(CMAKE_THREAD_LIBS_INIT) + SET(CMAKE_USE_PTHREADS_INIT 1) +ENDIF(CMAKE_THREAD_LIBS_INIT) + +IF(CMAKE_SYSTEM MATCHES "Windows") + SET(CMAKE_USE_WIN32_THREADS_INIT 1) +ENDIF(CMAKE_SYSTEM MATCHES "Windows") + +IF(CMAKE_USE_PTHREADS_INIT) + IF(CMAKE_SYSTEM MATCHES "HP-UX-*") + SET(CMAKE_THREAD_LIBS_INIT "-lcma") + SET(CMAKE_USE_PTHREADS_INIT 1) + SET(CMAKE_HP_PTHREADS_INIT 1) + ENDIF(CMAKE_SYSTEM MATCHES "HP-UX-*") + + IF(CMAKE_SYSTEM MATCHES "OSF1-V*") + SET(CMAKE_USE_PTHREADS_INIT 0) + SET(CMAKE_THREAD_LIBS_INIT ) + ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V*") + + IF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*") + SET(CMAKE_USE_PTHREADS_INIT 1) + SET(CMAKE_THREAD_LIBS_INIT ) + SET(CMAKE_USE_WIN32_THREADS_INIT 0) + ENDIF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*") +ENDIF(CMAKE_USE_PTHREADS_INIT) + diff --git a/Utilities/otbopenthreads/OpenThreads/COPYING.txt b/Utilities/otbopenthreads/OpenThreads/COPYING.txt new file mode 100755 index 0000000000000000000000000000000000000000..c9b1a1adb01cfa862aff52c2ee992c1920d5db85 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/COPYING.txt @@ -0,0 +1,577 @@ + OpenSceneGraph Public License, Version 0.0 + ========================================== + + Copyright (C) 2002 Robert Osfield. + + Everyone is permitted to copy and distribute verbatim copies + of this licence document, but changing it is not allowed. + + OPENSCENEGRAPH PUBLIC LICENCE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + This library is free software; you can redistribute it and/or modify it + under the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 + or later. + + Notes: the OSGPL is based on the LGPL, with the 4 exceptions laid in the wxWindows + section below. The LGPL in the final section of this license. + + +------------------------------------------------------------------------------- + + wxWindows Library Licence, Version 3 + ==================================== + + Copyright (C) 1998 Julian Smart, Robert Roebling [, ...] + + Everyone is permitted to copy and distribute verbatim copies + of this licence document, but changing it is not allowed. + + WXWINDOWS LIBRARY LICENCE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public Licence as published by + the Free Software Foundation; either version 2 of the Licence, or (at + your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library + General Public Licence for more details. + + You should have received a copy of the GNU Library General Public Licence + along with this software, usually in a file named COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA. + + EXCEPTION NOTICE + + 1. As a special exception, the copyright holders of this library give + permission for additional uses of the text contained in this release of + the library as licenced under the wxWindows Library Licence, applying + either version 3 of the Licence, or (at your option) any later version of + the Licence as published by the copyright holders of version 3 of the + Licence document. + + 2. The exception is that you may use, copy, link, modify and distribute + under the user's own terms, binary object code versions of works based + on the Library. + + 3. If you copy code from files distributed under the terms of the GNU + General Public Licence or the GNU Library General Public Licence into a + copy of this library, as this licence permits, the exception does not + apply to the code that you add in this way. To avoid misleading anyone as + to the status of such modified files, you must delete this exception + notice from such code and/or adjust the licensing conditions notice + accordingly. + + 4. If you write modifications of your own for this library, it is your + choice whether to permit this exception to apply to your modifications. + If you do not wish that, you must delete the exception notice from such + code and/or adjust the licensing conditions notice accordingly. + + +------------------------------------------------------------------------------ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/Utilities/otbopenthreads/OpenThreads/ChangeLog b/Utilities/otbopenthreads/OpenThreads/ChangeLog new file mode 100755 index 0000000000000000000000000000000000000000..8d8da30f0cde86ffdb52d17850305431aa557a20 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/ChangeLog @@ -0,0 +1,682 @@ +2005-11-15 22:12 robert + + * win32_src/: Win32Condition.h, Win32ThreadBarrier.cpp: Converted + to dos endings. + +2005-11-15 18:31 robert + + * Make/makedefs: From Sean Spicer, compile fixes for Intel + compiler. + +2005-11-11 10:48 robert + + * Make/instrules: From Colin McDonald, build fix for Solaris. + +2005-11-03 11:36 robert + + * win32_src/HandleHolder.h: From Thibault Genessay, + + "Under Windows, the current implementation of the operator bool() + of the HandleHolder class can return true even if the handle is + not valid. This happens when Win32 calls return NULL instead of + INVALID_HANDLE_VALUE as expected by the operator bool(). + + The modified file makes the OpenThreads::Thread::start() method + return non-zero in this case, and should also ensure that other + calls to Win32 functions returning handles are correctly checked. + " + +2005-09-28 15:02 robert + + * include/OpenThreads/Exports: From Chris Hanson, "Minor changes to + support Win32 static library linking, when used in conjunction + with static-enabled .dsp (forthcoming)." + +2005-06-24 16:39 robert + + * Make/makedefs: From Colin McDonald: + + "Some makedefs fixes for Solaris: + + For multithreaded applications the -mt option must be + specified on both + the compile and link steps, to ensure correct behaviour. + According to + the Sun compiler documentation it sets REENTRANT flags in the + system + header files, and links the -lthread library in the correct + order. + + When compiling shared libraries the -KPIC option should be + specified. + Although Solaris will handle shared libraries without + position-independent code there is a performance penalty. + The linker + reference manual says: 'If a shared object is built from code + that is + not position-independent, the text segment will usually + require a large + number of relocations to be performed at runtime. Although + the runtime + linker is equipped to handle this, the system overhead this + creates can + cause serious performance degradation'." + +2005-05-24 16:54 robert + + * win32_src/Win32Thread.cpp: Added pragma to remove depreacted API + warning under VS8.0 + +2005-05-20 22:11 robert + + * include/OpenThreads/Thread, pthread_src/PThread.c++, + sproc_src/SprocThread.c++, win32_src/Win32Thread.cpp: Renamed + Thread::usleep(uint) to Thread::microSleep(uint) to avoid compile + problems when usleep is defined by extenal dependencies. + +2005-05-13 11:55 bbralo + + * win32_src/: Win32Thread.cpp, Win32ThreadPrivateData.h: removed + unneded variables (stackSizeLocked and idSet ) + +2005-05-13 10:10 bbralo + + * win32_src/Win32ThreadBarrier.cpp: removed extra ScopedLock + +2005-05-12 21:54 don + + * win32_src/Win32ThreadBarrier.cpp: Changed scoped lock to just + non-scoped lock in invalidate(), as release() must be called + after the lock has been unlocked. Avoiding deadlock. + +2005-05-12 21:42 don + + * win32_src/Win32ThreadBarrier.cpp: Fixed barrier::invalidate + non-compile on win32 + +2005-05-12 21:37 don + + * win32_src/Win32ThreadBarrier.cpp: Small typo in invalidate() + +2005-05-12 17:55 don + + * include/OpenThreads/Barrier, pthread_src/PThreadBarrier.c++, + win32_src/Win32ThreadBarrier.cpp: Added Barrier::invalidate() + +2005-05-11 20:23 don + + * Make/instrules: Fix for links in instrules + +2005-05-10 10:07 robert + + * Make/dolink.sh: Changed -ne to $LINK_ECHO_OPTION to fix cross + platform compile issues + +2005-05-04 10:16 robert + + * include/OpenThreads/: Barrier, Condition, Mutex, Thread: From + Martin Aumueller, commented out unused parameters to prevent + warnings. + +2005-04-28 06:08 robert + + * Make/dolink.sh: From Marco Jez, added -ne option echo usage to + fix stdout/stderr redirection error under Mingw. + +2005-04-26 14:45 don + + * Make/instrules: er.. added the um.. @ to the inst line.... for + inst_headers + +2005-04-25 14:48 don + + * Make/instrules: Small fix in instrules to check for status of + header files + +2005-04-24 17:04 sspicer + + * include/OpenThreads/Thread, pthread_src/PThread.c++, + sproc_src/SprocThread.c++, win32_src/Win32Thread.cpp: + Prefix PRIORITY and SCHEDULE params with THREAD_ + +2005-04-22 09:34 bbralo + + * README.txt: test acces + +2005-04-18 08:59 robert + + * examples_src/: GNUmakefile, simplethreader/SimpleThreader.cpp, + workcrew/ThreadReporter.h, workcrew/WorkCrew.c++: From Bob + Kuehne, warning fixes for OSX build. From Robert Osfield, + warnings fixes for Linux build. + +2005-04-11 21:47 sspicer + + * include/OpenThreads/Thread, pthread_src/PThread.c++, + sproc_src/SprocThread.c++, win32_src/Win32Thread.cpp: + Commit Boris' changes to the trunk after testing. -sean + +2005-04-08 10:03 bbralo + + * include/OpenThreads/Thread: usleep implementation + +2005-04-08 09:57 bbralo + + * win32_src/Win32Thread.cpp, sproc_src/SprocThread.c++, + pthread_src/PThread.c++: usleep implementation + +2005-04-05 19:00 donburns + + * Make/: distrules, instrules, makedefs, makerpms, makerules, + rpm.header: Updates for HP-UX build system on acc (not gcc). + +2005-03-24 13:55 donburns + + * Make/makerules: Added static target for mac build + +2005-02-05 04:07 donburns + + * Make/: distrules, makerpms, rpm.files, rpm.header: Added RPM + build files + +2005-01-15 23:13 donburns + + * Make/makedefs, Make/makerules, include/OpenThreads/ScopedLock: + Updated make environment to build static libs on Linux Add c++ + header to ScopedLock to assist editors + +2004-12-04 23:33 donburns + + * Make/openthreads.pc: Changed version number for package config + +2004-11-20 10:13 robertosfield + + * Make/makedefs: From John Shue, fix for FreeBSD build + +2004-11-17 16:22 robertosfield + + * GNUmakefile: From Thom DeCarlo, change to force Cygwin build to + use Win32 threads. + +2004-11-15 19:53 robertosfield + + * Make/openthreads.pc: From Loic Dachary, added pk-config file. + +2004-11-15 09:57 robertosfield + + * Make/makedefs: From Loic Dachary, fixes to soname generation. + +2004-11-14 17:19 robertosfield + + * Make/makedefs: Added option for compiling with soname under Linux + when the env is set: + + export COMPILE_OSG_OP_OT_WITH_SONAMES=YES + +2004-09-27 23:27 donburns + + * win32_src/GNUmakefile: Fixed C++FILES to CXXFILES + +2004-08-30 11:13 bbralo + + * win32_src/Win32Thread.cpp: setProcessorAffinity + +2004-08-28 20:54 donburns + + * pthread_src/PThread.c++: Small change for IRIX to make + processorAffinity work + +2004-08-27 17:45 donburns + + * include/OpenThreads/Thread, pthread_src/PThread.c++, + pthread_src/PThreadPrivateData.h: Added setProcessorAffinity() to + Pthread header and Pthread implementation for __sgi + +2004-08-17 15:34 sspicer + + * include/OpenThreads/Barrier, pthread_src/PThreadBarrier.c++, + sproc_src/SprocBarrier.c++, win32_src/Win32ThreadBarrier.cpp: + Added Barrier::release(), Barrier::numThreadsCurrentlyBlocked(). + +2004-08-09 17:03 robertosfield + + * Make/makedefs: Set REVISION number back to 0 after 1.3 release. + +2004-08-09 17:01 robertosfield + + * Make/makedefs: Set relase and revision number for 1.3 release + +2004-08-09 17:01 robertosfield + + * include/OpenThreads/Thread: Minor fix to indentation + +2004-07-26 16:49 robertosfield + + * include/OpenThreads/ScopedLock: Added a return to the end of the + file to fix a warning under IRIX. + +2004-07-26 16:46 robertosfield + + * win32_src/OpenThreads.dsp: Made the keyword substitution use -ko + and did a unix2dos, to ensure that windows file endings are + maintained. + +2004-05-18 08:55 bbralo + + * win32_src/Win32Thread.cpp: cancelCleanup after run() iff thread + is canceled. Change suggested by Frank Lindeman + +2004-05-15 09:42 robertosfield + + * win32_src/GNUmakefile: GNUmakefle for Cygwin/mingw build (from + Norman Vine, if my memory serves me correctly:) + +2004-05-12 14:18 bbralo + + * win32_src/HandleHolder.h: HandleHolder for proper handling of + win32 HANDLE-s + +2004-05-12 09:42 bbralo + + * win32_src/OpenThreads.mak: HandleHolder.h + ScopedLock in + includes + +2004-05-12 09:32 bbralo + + * win32_src/: Win32ThreadPrivateData.h, OpenThreads.dsp, + WIN32Condition.cpp, Win32ConditionPrivateData.h, Win32Thread.cpp: + HandleHolder for proper handling of win32 HANDLE-s + +2004-05-11 17:25 bbralo + + * win32_src/Win32Thread.cpp: *close thread handle in + ~Win32ThredaPrivateData() *implementation of + PrintSchedulingInfo() + +2004-05-10 08:24 bbralo + + * win32_src/Win32ConditionPrivateData.h: added try catch block in + wait() - fix for hang on exit. + +2004-04-14 23:36 donburns + + * sproc_src/SprocThread.c++: Added startThread() to the sproc + implementation of Thread. + +2004-04-10 16:49 donburns + + * Make/makedefs: Added -DOPENTHREADS_EXPORT to Cygwin and Mingw + defines + +2004-02-27 09:34 bbralo + + * win32_src/Win32Thread.cpp: fix for broken STLs where size_t is + not in std ( VC < 7.1 ) + +2004-02-24 20:41 sspicer + + * pthread_src/: PThreadBarrierPrivateData.h, PThreadCondition.c++, + PThreadConditionPrivateData.h, PThreadMutexPrivateData.h, + PThreadPrivateData.h: + Fix improper placement of "namespace" directives in pthread_src. + +2003-10-27 19:27 sspicer + + * pthread_src/PThreadCondition.c++: + Fix PThreadCondition.c++ build error on MacOS X Panther. + +2003-10-06 17:05 sspicer + + * examples_src/simplethreader/SimpleThreader.cpp: + Some small fixes to support IRIX sproc. + +2003-10-06 17:03 sspicer + + * sproc_src/: GNUmakefile, SharedArena.c++, SharedArena.h, + SprocBarrier.c++, SprocBarrierPrivateData.h, SprocCondition.c++, + SprocConditionPrivateData.h, SprocMutex.c++, + SprocMutexPrivateData.h, SprocThread.c++, + SprocThreadPrivateActions.h, SprocThreadPrivateData.h: + Initial commit. + +2003-09-16 08:42 robertosfield + + * pthread_src/PThread.c++: And return 0 to pthread cancel + implemenation to catch the case when no thread is running. + +2003-09-12 20:52 robertosfield + + * GNUmakefile, Make/makedefs, pthread_src/GNUmakefile, + pthread_src/PThreadCondition.c++: From Norman Vine, fixes for + Cygwin + Mingw builds + +2003-09-12 10:32 robertosfield + + * win32_src/: Makefile, OpenThreads.mak: From Norman Vine, + Makefile's for OpenThreads win32. + +2003-09-10 22:37 robertosfield + + * examples_src/simplethreader/simplethreader.dsp: Did a to_dos to + fix unix line endings. + +2003-09-10 14:29 robertosfield + + * win32_src/Win32Thread.cpp: Fix for warning under Windows. + +2003-09-06 08:57 robertosfield + + * pthread_src/PThread.c++, win32_src/Win32Thread.cpp: Added an if + (pd->isRunning) check to the pthread + win32 thread + Thread::cancel() implementation to prevent cancel's being done on + an non running thread. This has been introduced to + "speculatively" solve a crash that has been reported on the OSG + that looked like an example of cancel() being called the thread + was started. + +2003-09-01 09:37 robertosfield + + * pthread_src/PThread.c++, win32_src/Win32Thread.cpp: Added a cout + to warn of thread still running when the destructor is entered. + +2003-08-29 23:24 robertosfield + + * win32_src/OpenThreads.dsp: Fixes to project files. + +2003-08-29 14:30 robertosfield + + * win32_src/Win32Thread.cpp: Comment out the + (WaitForSingleObject(pd->tid,INFINITE)!=WAIT_OBJECT_0) in the + win32 cancel implemention. + +2003-08-29 12:33 bbralo + + * win32_src/: OpenThreads.dsp, WIN32Condition.cpp, + Win32ConditionPrivateData.h, Win32Thread.cpp, + Win32ThreadBarrier.cpp: Thread cancelation support take 3 :-) * + cancelEvent in Win32 thread implementation. Event is signaled in + cancel() * testCancel() checks event (with + WaitForSingleObject(cancelEvent, 0) ) * cooperativeWait( handle, + timeout ) cheks cancelEvent besides handle and exits if + cancelEvent is signaled * Thread::cancel() has right semantics + finally - deffered - signal cancelEvent than wait for thread + to exit - async - terminateThread unconditionally - + disable - do nothing + +2003-08-29 12:03 bbralo + + * win32_src/Win32ThreadPrivateData.h: added cancelEvent member for + thread cancelation support + +2003-08-29 12:01 bbralo + + * include/OpenThreads/ScopedLock: ScopedLock and ReveseScopedLock + templates + +2003-08-29 11:59 bbralo + + * include/OpenThreads/Thread: added getImplementation() (needed for + Win32) + +2003-08-29 11:27 robertosfield + + * win32_src/Win32ConditionPrivateData.h: Changed INFINITE wait time + to timeout_ms to be consistent with the wat() input paramters. + +2003-08-28 15:13 bbralo + + * win32_src/: OpenThreads.dsp, WIN32Condition.cpp, + Win32ConditionPrivateData.h, Win32Thread.cpp, + Win32ThreadBarrier.cpp, Win32ThreadPrivateData.h: thread + cancelation issues: * condition::wait and condition::broadcast() + now uses WaitForMultipleObject API with second handle being + thread handle. *to make this work change is made in + thread::cancel -reintroduced WaitForSingleObject but with + shorter timeout this time. This shold take care delays on exit + * remove unneeded testCanlel() calls + +2003-08-26 08:37 robertosfield + + * win32_src/Win32ConditionPrivateData.h: Moved position of Thread* + thread = CurrentThread() out of the inner loop. + +2003-08-25 13:59 robertosfield + + * win32_src/Win32ConditionPrivateData.h: Compile fix for Win32. + +2003-08-23 15:50 robertosfield + + * win32_src/: WIN32Condition.cpp, Win32ConditionPrivateData.h, + Win32Thread.cpp, Win32ThreadBarrier.cpp: Win32 build and bug + fixes from Marco Jez. + +2003-08-22 21:50 robertosfield + + * win32_src/Win32Thread.cpp: Marco's change to testCancel() to use + GetCurrentThreadId(). + +2003-08-22 21:45 robertosfield + + * win32_src/Win32ConditionPrivateData.h: Fixes to Win32 threading + code. + +2003-08-22 18:42 robertosfield + + * win32_src/: WIN32Condition.cpp, Win32ConditionPrivateData.h, + Win32Thread.cpp, Win32ThreadBarrier.cpp: To the Win32 + implemenation: + + Added checks for valid CurrentThread() when issuing + testCancel(). + + Added time slicing the wait() implementation with + testCancel() being + issued on each slice. + +2003-08-21 21:21 robertosfield + + * win32_src/Win32Thread.cpp: Fixed typo. + +2003-08-21 21:14 robertosfield + + * win32_src/: WIN32Condition.cpp, Win32Thread.cpp, + Win32ThreadBarrier.cpp: Added testCancel into + Thread::YeildCurrentThread(), Barrier and Condition code under + Win32 to help respond to cancel requests. + +2003-08-19 19:19 sspicer + + * Make/makedefs, examples_src/simplethreader/SimpleThreader.cpp, + include/OpenThreads/Thread, pthread_src/PThread.c++, + win32_src/Win32Thread.cpp: + Change Thread::Yield() to Thread::YieldCurrentThread() to avoid + name collisions on Windows. + +2003-08-07 16:52 sspicer + + * pthread_src/PThread.c++: + remove setCancelModeAsyncronous from the destructor, could cause + havoc. + +2003-08-07 16:50 sspicer + + * include/OpenThreads/Condition: + Make methods virtual. + +2003-08-07 15:10 sspicer + + * include/OpenThreads/: Barrier, Condition, Exports, Mutex, Thread: + + Bring headers inline with what was in osgcvs.no-ip.com. Namely + add c++ to top of headers, and comment out pragma. + +2003-08-06 14:49 sspicer + + * win32_src/OpenThreads.dsp: + Change release version to use non-debug dll. + +2003-08-05 22:41 sspicer + + * examples_src/: simplethreader/GNUmakefile, workcrew/GNUmakefile, + workcrew/WorkCrew.c++: + Fixing examples. + +2003-08-04 14:29 sspicer + + * pthread_src/PThreadCondition.c++: + typedef ::timespec to OpenThreads::timespec for OSX 10.3. + +2003-07-23 10:40 bbralo + + * win32_src/Win32ConditionPrivateData.h: added Interlocked + primitives for waiters count + +2003-07-23 09:37 donburns + + * include/OpenThreads/Exports, win32_src/OpenThreads.dsp: Windows + builds are never complete.... Fixed a couple more booboos. + +2003-07-23 08:45 donburns + + * win32_src/: OpenThread.dsp, OpenThread.dsw, OpenThreads.dsp, + OpenThreads.dsw: fixed windows build (again). + +2003-07-22 17:27 donburns + + * win32_src/: OpenThreads.dsp, OpenThreads.dsw: + Added OpenThreads.dsw and OpenThreads.dsp + +2003-07-22 10:17 bbralo + + * win32_src/OpenThread.dsw: added simplethreader project into + workspace + +2003-07-22 10:15 bbralo + + * win32_src/: WIN32Condition.cpp, Win32BarrierPrivateData.h, + Win32ConditionPrivateData.h, Win32MutexPrivateData.h, + Win32ThreadBarrier.cpp, Win32Mutex.cpp: fix CR/LF + +2003-07-22 10:07 bbralo + + * win32_src/: Win32Thread.cpp, Win32ThreadPrivateData.h: + CurrentThread() implementation + +2003-07-22 10:05 bbralo + + * include/OpenThreads/Exports: changed #pragma comment( lib .. ) to + reflect new name + +2003-07-22 10:03 bbralo + + * include/OpenThreads/Thread: CurrentThread() implementation for + win32 + +2003-07-22 10:00 bbralo + + * examples_src/simplethreader/: SimpleThreader.c++, + ThreadObserver.c++, ThreadReporter.c++: Changed extension from + c++ to cpp for VC to work. + +2003-07-22 09:59 bbralo + + * examples_src/simplethreader/: SimpleThreader.cpp, + ThreadObserver.cpp, ThreadReporter.cpp, simplethreader.dsp, + simplethreader.plg: Changed extension from c++ to cpp for VC to + work. Added CurrentChecker() for testing of + Thread::CurrentThread() workings. Various WIN32 fixes + +2003-07-22 09:57 bbralo + + * examples_src/simplethreader/: GNUmakefile, ThreadReporter.h: + Changed extension from c++ to cpp for VC to work. Added + CurrentChecker() for testing of Thread::CurrentThread() workings. + Changed include <list.h> into more standard sequence #include + <list> ->using std::list Various WIN32 fixes + +2003-07-22 00:36 sspicer + + * include/OpenThreads/Thread, pthread_src/PThread.c++, + pthread_src/PThreadPrivateData.h, win32_src/Win32Thread.cpp: + Implement first pass at Thread::CurrentThread() to return a + pointer to the current thread being executed. If NULL, this + probably means it's the main thread. Also change Thread::yield + -> Thread::Yield() and make it static. + +2003-07-18 22:16 sspicer + + * AUTHORS.txt, COPYING.txt, ChangeLog, GNUmakefile, INSTALL.txt, + README.txt, TODO.txt, Make/cygwin_plugin_def, Make/distrules, + Make/docrules, Make/dolink.sh, Make/help.sh, Make/helprules, + Make/instrules, Make/makedefs, Make/makedirdefs, + Make/makedirrules, Make/makeinnosetup, Make/makepkg, + Make/makerpms, Make/makerules, Make/versionrules, bin/README, + docs/doxyfile, examples_src/GNUmakefile, + examples_src/simplethreader/GNUmakefile, + examples_src/simplethreader/SimpleThreader.c++, + examples_src/simplethreader/ThreadObserver.c++, + examples_src/simplethreader/ThreadObserver.h, + examples_src/simplethreader/ThreadReporter.c++, + examples_src/simplethreader/ThreadReporter.h, + examples_src/workcrew/GNUmakefile, + examples_src/workcrew/ThreadObserver.c++, + examples_src/workcrew/ThreadObserver.h, + examples_src/workcrew/ThreadReporter.c++, + examples_src/workcrew/ThreadReporter.h, + examples_src/workcrew/WorkCrew.c++, include/OpenThreads/Barrier, + include/OpenThreads/Condition, include/OpenThreads/Exports, + include/OpenThreads/Mutex, include/OpenThreads/Thread, + lib/README, pthread_src/GNUmakefile, pthread_src/PThread.c++, + pthread_src/PThreadBarrier.c++, + pthread_src/PThreadBarrierPrivateData.h, + pthread_src/PThreadCondition.c++, + pthread_src/PThreadConditionPrivateData.h, + pthread_src/PThreadMutex.c++, + pthread_src/PThreadMutexPrivateData.h, + pthread_src/PThreadPrivateData.h, win32_src/OpenThread.dsp, + win32_src/OpenThread.dsw, win32_src/WIN32Condition.cpp, + win32_src/Win32BarrierPrivateData.h, win32_src/Win32Condition.h, + win32_src/Win32ConditionPrivateData.h, win32_src/Win32Mutex.cpp, + win32_src/Win32MutexPrivateData.h, win32_src/Win32Thread.cpp, + win32_src/Win32ThreadBarrier.cpp, + win32_src/Win32ThreadPrivateData.h: Initial Import from + osgcvs.no-ip.net, 7.18.2003 + +2003-07-18 22:16 sspicer + + * AUTHORS.txt, COPYING.txt, ChangeLog, GNUmakefile, INSTALL.txt, + README.txt, TODO.txt, Make/cygwin_plugin_def, Make/distrules, + Make/docrules, Make/dolink.sh, Make/help.sh, Make/helprules, + Make/instrules, Make/makedefs, Make/makedirdefs, + Make/makedirrules, Make/makeinnosetup, Make/makepkg, + Make/makerpms, Make/makerules, Make/versionrules, bin/README, + docs/doxyfile, examples_src/GNUmakefile, + examples_src/simplethreader/GNUmakefile, + examples_src/simplethreader/SimpleThreader.c++, + examples_src/simplethreader/ThreadObserver.c++, + examples_src/simplethreader/ThreadObserver.h, + examples_src/simplethreader/ThreadReporter.c++, + examples_src/simplethreader/ThreadReporter.h, + examples_src/workcrew/GNUmakefile, + examples_src/workcrew/ThreadObserver.c++, + examples_src/workcrew/ThreadObserver.h, + examples_src/workcrew/ThreadReporter.c++, + examples_src/workcrew/ThreadReporter.h, + examples_src/workcrew/WorkCrew.c++, include/OpenThreads/Barrier, + include/OpenThreads/Condition, include/OpenThreads/Exports, + include/OpenThreads/Mutex, include/OpenThreads/Thread, + lib/README, pthread_src/GNUmakefile, pthread_src/PThread.c++, + pthread_src/PThreadBarrier.c++, + pthread_src/PThreadBarrierPrivateData.h, + pthread_src/PThreadCondition.c++, + pthread_src/PThreadConditionPrivateData.h, + pthread_src/PThreadMutex.c++, + pthread_src/PThreadMutexPrivateData.h, + pthread_src/PThreadPrivateData.h, win32_src/OpenThread.dsp, + win32_src/OpenThread.dsw, win32_src/WIN32Condition.cpp, + win32_src/Win32BarrierPrivateData.h, win32_src/Win32Condition.h, + win32_src/Win32ConditionPrivateData.h, win32_src/Win32Mutex.cpp, + win32_src/Win32MutexPrivateData.h, win32_src/Win32Thread.cpp, + win32_src/Win32ThreadBarrier.cpp, + win32_src/Win32ThreadPrivateData.h: Initial revision + diff --git a/Utilities/otbopenthreads/OpenThreads/INSTALL.txt b/Utilities/otbopenthreads/OpenThreads/INSTALL.txt new file mode 100755 index 0000000000000000000000000000000000000000..9aff1a761845d1b4b81ac2a5f7727795ed8cb4ff --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/INSTALL.txt @@ -0,0 +1,22 @@ +This is a C++ thread library. To make: + +All platforms + + prompt> gmake + +To use GNU compilers on IRIX, Sun + + prompt> gmake COMPILER=gnu + +To build 64 bit on IRIX, Sun, Linux + + prompt> gmake ARCH=64 + +prefix=/usr/local + +Header files....$prefix/include +Libraries.......$prefix/lib/OpenThreadPThread + +Questions/Comment/Suggestions to: to be announced + + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/cygwin_plugin_def b/Utilities/otbopenthreads/OpenThreads/Make/cygwin_plugin_def new file mode 100755 index 0000000000000000000000000000000000000000..010d27c76dfeda2c3916111cf6d565e1c155b69a --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/cygwin_plugin_def @@ -0,0 +1,15 @@ + +# +# blessed are those who try to make Windows behave like it should ... +# + +ifeq ($(OS),CYGWIN) +TARGET_BASENAME := $(PLUGIN_PREFIX)$(TARGET_BASENAME) +PLUGIN_PREFIX := cyg +endif + +ifeq ($(OS),MINGW) +TARGET_BASENAME := $(PLUGIN_PREFIX)$(TARGET_BASENAME) +PLUGIN_PREFIX := lib +endif + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/distrules b/Utilities/otbopenthreads/OpenThreads/Make/distrules new file mode 100755 index 0000000000000000000000000000000000000000..0ed17448b39f65d72fa03e4819ae9cf83057fc69 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/distrules @@ -0,0 +1,5 @@ +distribution : + @sh $(MAKEDIST) OpenThreads Make/rpm.header Make/rpm.files + +cleandist: + @$(MAKECLEANDIST) diff --git a/Utilities/otbopenthreads/OpenThreads/Make/docrules b/Utilities/otbopenthreads/OpenThreads/Make/docrules new file mode 100755 index 0000000000000000000000000000000000000000..c17cbe917aa8b8289bbc0ca60a05364736ebde11 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/docrules @@ -0,0 +1,4 @@ +documentation : + cd docs && doxygen doxyfile + + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/dolink.sh b/Utilities/otbopenthreads/OpenThreads/Make/dolink.sh new file mode 100755 index 0000000000000000000000000000000000000000..346f423d4a3376c9e477ff270479a67900f15400 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/dolink.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +bye() +{ + echo $1 + exit 1 +} + +TOPDIR=$1 +LNSRC=$2 +LNDEST=$3 +LINKCMD=$4 + +## Check command line + + +[ $# -lt 4 ] && bye "Usage: $0 <Top Directory> <Link Source> <Link Destination> <Link command>" + +## Check for existence of link source file +[ -n "$LNSRC" ] || bye "Internal error (LNSRC definition)" + +## Check for existence of link destination file +[ -n "$LNDEST" ] || bye "Internal error (LNDEST definition)" + +if diff -s $TOPDIR/$LNDEST $LNSRC >/dev/null 2>&1 +then + echo " =====> $LNSRC and $TOPDIR/$LNDEST are in sync" +else + echo " =====> resetting $TOPDIR/$LNDEST to point to $LNSRC" + + ## At this point, we must create a link at the link destination + ## which points back to our link source. This requires us to + ## build a path FROM the destination back to the source + + #1) Get the source directory as an absolute path + SRCDIR=`pwd`/`dirname $LNSRC` + + #2) Get the destination directory as an absolute path (TOPDIR is + ## a relative path from the current directory). + cd $TOPDIR + ROOTDIR=`pwd` + DESTDIR=`dirname "$ROOTDIR"/"$LNDEST"` + + #3) Build a ../../ chain from the destination directory to the + ## current directory (ROOTDIR), which will become the prefix to + ## the path + T=`dirname $LNDEST` + while [ "$T" != "." ] + do + T=`dirname $T`;PFX=../"$PFX" + done + + #4) strip the absolute path prefix of SRCDIR leading to the current + ## directory, so we are left with the relative path from the current + ## directory to the link source directory. Prefix that with PFX. + LINK=`echo $LINK_ECHO_OPTION $SRCDIR | sed -e "s,$ROOTDIR/,$PFX,"`/`basename $LNDEST` + + #5) Create the links by changing to the destination directory, + ## removing any old versions of the link and creating a new one + [ -d `dirname $LNDEST` ] || mkdir -p `dirname $LNDEST` + cd `dirname $LNDEST` + rm -f `basename $LNDEST` + $LINKCMD $LINK `basename $LNDEST` +fi + +exit 0 diff --git a/Utilities/otbopenthreads/OpenThreads/Make/help.sh b/Utilities/otbopenthreads/OpenThreads/Make/help.sh new file mode 100755 index 0000000000000000000000000000000000000000..45f7c0cf096bf949168da2fbd28a255b0ef751ee --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/help.sh @@ -0,0 +1,164 @@ +#!/bin/sh + +OS=$1 +TOPDIR=$2 +INST_LIBS=$3 +INST_PLUGINS=$4 +INST_INCLUDE=$5 +INST_DEMOS=$6 +INST_DEMO_SRC=$7 +INST_DOC=$8 +INST_DATA=$9 + + +cat <<- EOF + +The following targets can be used with any subsystem as well as the top +level build (build in the OpenThreads Root directory). Note that debug +versions and optimized version of targets reside in parallel. + + make - Same as 'make opt' + make opt - Makes optimized versions of all targets + make debug - Makes debug versions of all targets. + make clean - Removes all object files (both optimized and debug + versions) + make cleanopt - Removes optimized version of object files + make cleandbg - Removes debug version of object files + make cleandepend - Removes Makedepend file (both optimized and debug + versions) + make cleandependopt - Removes optimized version Makedepend file + make cleandependdbg - Removes debug version Makedepend file + make cleantarget - Removes only targets but leaves object files (both + optimized and debug versions) + make cleantargetopt - Removes only optimized targets but leaves optimized + objects files. + make cleantargetdbg - Removes only debug targets but leaves debug object + files + make clobber - Removes object files and targets (both optimized and + debug versions) + make clobberopt - Removes optimized object files and targets + make clobberdbg - Removes debug object files and targets + make beautify - Pretty print C++ files + make documentation - Builds documentation database for current target + make depend - Force a rebuild of the dependency file. Note that + dependency files are generated automatically during + builds. + +Note for Linux users: +On some linux kernels (2.4 kernels with backdated 2.6 functionality) there is a two param sched_setaffinity defined, instead of +the standard three param sched_setaffinity. This will lead to a compile failure, if this occurs then use the make line: + + make COMPILE_USING_TWO_PARAM_sched_setaffinity=yes + +Or set up the COMPILE_USING_TWO_PARAM_sched_setaffinity env var in your .bashrc + + export COMPILE_USING_TWO_PARAM_sched_setaffinity=yes + make + + +Solaris and IRIX can build 64 bit targets. These require the ARCH=64 argument. +For example: + + make ARCH=64 - Same as 'make ARCH=64 opt' + make ARCH=64 opt - Builds 64 bit optimized targets + make ARCH=64 debug - Builds 64 bit debug versions of targets + make ARCH=64 clean - Removes all 64 bit object files (both optimized and + debug versions). + + etc. + +The following targets may only be issued from the top-level OpenThreads build: + + make install - Install both execution environment and development + targets + make instbin - Install execution environment targets only. These + consist of libraries, plugins and demo programs. + Libraries are installed in + o $INST_LIBS, + plugins are installed in + o $INST_PLUGINS, + and demos are installed in + o $INST_DEMOS + on $OS + + make instdev - Install development targets only. These consist of + header files, source code to the demo programs, and + documentation. + Header files are install in + o $INST_INCLUDE, + demo source code is installed in + o $INST_DEMO_SRC, + and documentation is installed in + o $INST_DOC + on $OS + + make instlinks - Installs symbolic links at install locations for both + execution environment and development targets rather + than copyied files. Installing links is ideal for a + development environment for avoiding confusion about + which binaries are being run or linked to. + + make instlinksbin - Installs symbolic links at install locations for + execution environment targets only. + make instlinksdev - Installs symbolic links at install locations for + development targets only + make instclean - Removes installed targets (files or links) from + installation locations for both execution environment + and development targets + make instcleanbin - Removes installed targets from installation locations + for execution environment targets only + make instcleandev - Removes installed targets from installation locations + for defelopment targets only + +Note that the following variables can be used to directly override the default +installation locations for $OS. + + make INST_LIBS=<libs_location> \\ + INST_PLUGINS=<plugins_location>\\ + INST_INCLUDE=<header_file_location>\\ + INST_DEMOS=<demos_location>\\ + INST_DEMO_SRC=<demo_src_location>\\ + INST_DOC=<doc_location>\\ + install + + - Installs libraries in <libs_location>, plugins in + <plugins_location>, header files in + <header_file_location>, demos in <demos_location>, + demo source code in <demo_src_location> and + documentation in <doc_location> + +Note also that INST_LIBS, INST_PLUGINS, and INST_INCLUDE share a common +prefix by default: INST_LOCATION. Further INST_DEMOS, INST_DEMOS_SRC, +INST_DOC, and INST_DATA share a common prefix by default : INST_SHARE_PREFIX. +This provides a short cut for the above 'make' usage. For example, + + make INST_LOCATION=/usr install + + +These values can be tested by reissuing 'make help' with these arguments. + +After doing a 'make install' or 'make instlinks', and if not already added, +add + + $INST_DEMOS + +to your PATH environmental variable to run the demos. If it is not already +present, add + + $INST_LIBS + +and + + $INST_PLUGINS + +to your LD_LIBRARY_PATH environmental variable. When compiling programs +using OpenThreads headers add to your -I compile flags: + + $INST_INCLUDE + + + + +EOF + +exit 0 diff --git a/Utilities/otbopenthreads/OpenThreads/Make/helprules b/Utilities/otbopenthreads/OpenThreads/Make/helprules new file mode 100755 index 0000000000000000000000000000000000000000..aab99f75f21b2b454283b4e91d77ef1f91708602 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/helprules @@ -0,0 +1,11 @@ +help: + $(TOPDIR)/Make/help.sh \ + $(OS) \ + $(TOPDIR) \ + $(INST_LIBS) \ + $(INST_PLUGINS) \ + $(INST_INCLUDE) \ + $(INST_DEMOS) \ + $(INST_DEMO_SRC) \ + $(INST_DOC) \ + $(INST_DATA) | more diff --git a/Utilities/otbopenthreads/OpenThreads/Make/instrules b/Utilities/otbopenthreads/OpenThreads/Make/instrules new file mode 100755 index 0000000000000000000000000000000000000000..85d17f4d3939e6c886146f7bf8f56e51c541159a --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/instrules @@ -0,0 +1,50 @@ + +install : default instclean + @$(MAKE) __inst_lib + @$(MAKE) __inst_headers + +instlinks : instclean + $(LINK) `pwd`/include/OpenThreads $(INST_INCLUDE)/OpenThreads + [ -d $(INST_LIBS) ] || mkdir -p $(INST_LIBS) + $(LINK) `pwd`/lib/$(OS)$(ARCH)/$(LIB_PREFIX)OpenThreads.$(LIB_EXT) $(INST_LIBS)/$(LIB_PREFIX)OpenThreads.$(LIB_EXT) + +instclean : + rm -rf $(INST_INCLUDE)/OpenThreads + rm -f $(INST_LIBS)/$(LIB_PREFIX)OpenThreads.$(LIB_EXT) +ifdef IMP_LIB_EXT + rm -f $(INST_IMP_LIBS)/libOpenThreads.$(IMP_LIB_EXT) +endif + +instlibonly : + @$(MAKE) __inst_lib + +__inst_lib: + @[ -d $(INST_LIBS) ] || mkdir -p $(INST_LIBS) + @$(INSTXCMD) $(LIBINST)/$(LIB_PREFIX)OpenThreads.$(LIB_EXT) $(INST_LIBS)/$(LIB_PREFIX)OpenThreads.$(LIB_EXT) +ifdef IMP_LIB_EXT + @[ -d $(INST_IMP_LIBS) ] || mkdir -p $(INST_IMP_LIBS) + $(INSTXCMD) $(IMP_LIBINST)/libOpenThreads.$(IMP_LIB_EXT) $(INST_IMP_LIBS)/libOpenThreads.$(IMP_LIB_EXT) +endif + +__inst_headers: + @[ -d $(INST_INCLUDE)/OpenThreads ] || mkdir -p $(INST_INCLUDE)/OpenThreads + for f in include/OpenThreads/* ; do \ + if [ ! -d $$f ]; \ + then \ + [ "`head -1 $$f | cut -c 1-12`" = "/* -*-c++-*-" ] && \ + echo $(INSTRCMD) $$f $(INST_INCLUDE)/OpenThreads; \ + $(INSTRCMD) $$f $(INST_INCLUDE)/OpenThreads; \ + fi; \ + done + + +__inst_share: + @for d in `find share/ -type d -print | grep -v CVS`; do \ + [ -d $(INST_LOCATION)/$$d ] || mkdir -p $(INST_LOCATION)/$$d; \ + done + @for f in `find share/ -type f -print | grep -v CVS`; do \ + $(INSTRCMD) $$f $(INST_LOCATION)/$$f; \ + done + + + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/makedefs b/Utilities/otbopenthreads/OpenThreads/Make/makedefs new file mode 100755 index 0000000000000000000000000000000000000000..30e79c359b0985af9c76097b9506f3ad658db172 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/makedefs @@ -0,0 +1,444 @@ +SHELL = /bin/sh +OS := $(shell uname) + +## We don't care about architectural distinguishers in the OS +## such as IRIX64, IRIX32, etc. so we truncate IRIX?? to IRIX +ifeq ($(findstring IRIX,$(OS)),IRIX) +OS := IRIX +endif + +## Make CYGWIN_XXXX CYGWIN so it's "Windows cross platform" :) +ifeq ($(findstring CYGWIN,$(OS)),CYGWIN) +OS := CYGWIN +#OS := MINGW +endif + +## Make MINGW_XXXX MINGW so it's "Windows cross platform" :) +ifeq ($(findstring MINGW,$(OS)),MINGW) +OS := MINGW +endif + +# TOPDIR needs to be redefined for every GNUmakefile +TOPDIR ?= ../ +THISDIR = . +MAKEFILE = GNUmakefile +MAKEDEPEND = ignore + +####################################################################### +## +## VERSIONING SEMANTICS +## +## Version consistes of <major> . <minor> . <release> - <revision> +## Where: +## major : Production (0 = pre-production) +## minor : 0-7 = Production minor, 8 = Alpha, 9 = Beta +## release : Release tag +## revision: Release revision - 0 = development (cutting edge). +## +## Usage: +## Default - VERSION_REVISION is set to the value defined here +## Env variable OPENTHREADS_VERSION_REVISION overrides default +## e.g.: +## % setenv OPENTHREADS_VERSION_REVISION 5 +## % make version +## Command line overrides env variable +## % make VERSION_REVISION= +####################################################################### +VERSION_MAJOR = 1 +VERSION_MINOR = 5 +VERSION_RELEASE = 0 +VERSION_REVISION ?= 0 +ifneq (,$(OPENTHREADS_VERSION_REVISION)) +VERSION_REVISION = $(OPENTHREADS_VERSION_REVISION) +endif +VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE) + + +DEF = -DOPENTHREADS_VERSION=\"$(VERSION)\" \ + -DOPENTHREADS_VERSION_REVISION="$(VERSION_REVISION)" +# -DGLX_GLXEXT_PROTOTYPES + +ALLOW_PRIORITY_SCHEDULING = 0; +ifeq ($(ALLOW_PRIORITY_SCHEDULING),1) + DEF += -DALLOW_PRIORITY_SCHEDULING +endif + +STATICLIB_EXT = a +STATICLIB = $(LIB).$(STATICLIB_EXT) + +INC = -I$(TOPDIR)/include + +CXXFLAGS = $(ARCHARGS) $(DOF) $(DEF) $(INC) +LDFLAGS = $(ARCHARGS) $(DOF) $(LINKARGS) -L$(TOPDIR)/lib/$(OS)$(ARCH) +OBJS = $(CXXFILES:.cpp=.o) \ + $(C++FILES:.c++=.o) \ + $(CFILES:.c=.o) \ + $(YACCFILES:.y=.o) \ + $(LEXFILES:.l=.o) + +EXE_EXT = + +DOF = $(OPTF) +DEBUGDIR = $(OS)$(ARCH).Debug +OPTDIR = $(OS)$(ARCH).Opt +BININST = bin/$(OS)$(ARCH) +LIBINST = lib/$(OS)$(ARCH) +IMP_LIBINST = lib/$(OS)$(ARCH) + +INST_LOCATION ?= /usr/local +INST_LIBS = $(INST_LOCATION)/lib$(ARCH_EXT) +INST_INCLUDE = $(INST_LOCATION)/include +INST_SHARE = $(INST_LOCATION)/share +INST_DEMOS = $(INST_LOCATION)/OpenThreads/bin +INST_SRC = $(INST_LOCATION)/OpenThreads/src +INST_DOC = $(INST_LOCATION)/OpenThreads/doc +INST_DATA = $(INST_SHARE)/OpenThreads/data +INST_DEMO_SRC = $(INST_SRC)/demos + +LINK = ln -sf +INSTXCMD = install -m 755 +INSTRCMD = install -m 644 +INSTLINKCMD = $(LINK) + +LIB_PREFIX = lib +LIB_EXT = so + +MAKEDIST = echo " === Distribution build is not implemented yet for $(OS)"; printf "\n" +INSTLOGFILE = /tmp/.openThreads_inst_log + +YFLAGS = -d + +RECURSIVE_TARGETS = \ + opt \ + debug \ + static \ + staticdebug \ + clean \ + cleandepend \ + cleandependopt \ + cleandependdbg \ + cleandbg \ + cleanopt \ + cleantarget \ + cleantargetopt \ + cleantargetdbg \ + clobber \ + clobberdbg \ + clobberopt \ + beautify \ + docs \ + depend \ + + +ifeq ($(USE_OPEN_THREAD),1) +DEF += -D_USE_OPEN_THREAD +INC += $(INC_OPEN_THREAD) +LDFLAGS += $(LIB_OPEN_THREAD) +OPEN_THREAD_LIB = -lOpenThreads +else +PTHREAD_LIB = -lpthread +endif + +#### SUN OS Specific definitions +ifeq ($(OS),SunOS) + + ARCH = 32 + +#### if using g++ on a sun + ifeq ($(COMPILER),gnu) + ifeq (x$(CXX),x) + CXX = g++ + endif + INC += + DEPARG = -M + DEF += -W -Wall -fPIC -fpermissive + OPTF = -O3 + DBGF = -g + SHARED = -shared -fPIC + ifeq ($(ARCH),64) + ARCHARGS = -m64 + else + ARCHARGS = + endif +#### using forte compilers (default) + else + CXX = CC + INC += + DEPARG = -xM1 + DEF += -features=extensions -mt -KPIC + OPTF = -xO4 + DBGF = -g + SHARED = -G + ifeq ($(ARCH),64) + ARCHARGS = -xarch=v9 + else + ARCHARGS = + endif + endif + LINKARGS = -mt + INSTXCMD = cp + INSTRCMD = cp + INST_LOCATION ?= /opt/OpenThreads + INST_LIBS = $(INST_LOCATION)/lib$(ARCH_EXT) + INST_INCLUDE = $(INST_LOCATION)/include + MAKEDIST = $(TOPDIR)/Make/makepkg +endif + +#### IRIX Specific definitions +ifeq ($(OS),IRIX) + + CXX = CC + DEPARG = -M + INC += -I${TOPDIR}/include + DEF += -LANG:std -OPT:Olimit=0 \ + -DEBUG:woff=1682 -DEBUG:woff=3303 \ + -MDupdate $(MAKEDEPEND) \ + OPTF = -O2 + DBGF = -g + SHARED = -shared + ARCH = 32 +ifeq ($(ARCH),64) + ARCHARGS = -64 +else + ARCHARGS = -n32 +endif + ARCH_EXT = $(ARCH) + LINKARGS = -L${TOPDIR}/lib -LANG:std -OPT:Olimit=0 + INSTXCMD = cp + INSTRCMD = cp +endif + +#### Linux specific definitions + +ifeq ($(OS),Linux) +SYSARCH := $(shell arch) + ifeq ($(COMPILER),intel) + CXX = icpc + CXXFLAGS += -x c++ -cxxlib-gcc -gcc-version=323 + DEF += -fPIC + OPTF = -O2 + DBGF = -g + ifeq ($(SYSARCH),ia64) + ARCH = IA64 + else + ARCH = 32 + endif + else + ifeq (x$(CXX),x) + CXX = g++ + endif + +ifeq ("$(COMPILE_OSG_OP_OT_WITH_SONAMES)","YES") + LDFLAGS += -Wl,-soname -Wl,$@.$(LIB_EXT).0 +endif + + ###DEF += -fPIC + OPTF = -O2 + DBGF = -ggdb -gstabs + ifeq ($(SYSARCH),x86_64) + ARCH = 64 + ifeq (x$(CXX),x) + CXX = g++ + endif + DEF += -fPIC + else + ARCH = 32 + endif + endif + + DEPARG = -M + INC += + DEF += + SHARED = -shared + ARCHARGS = +ifeq ($(SYSARCH),x86_64) + LINKARGS = -L/usr/X11R6/lib64 +else + LINKARGS = -L/usr/X11R6/lib +endif + MAKEDIST = $(TOPDIR)/Make/makerpms +endif + +#### FreeBSD specific definitions +ifeq ($(OS),FreeBSD) + SYSARCH := $(shell uname -p) + ifeq (x$(CXX),x) + CXX = g++ + endif + ifeq (x$(PTHREAD_CFLAGS),x) + PTHREAD_CFLAGS = -pthread + endif + ifeq (x$(PTHREAD_LIBS),x) + PTHREAD_LIBS = -pthread + endif + ifeq (x$(ARCH),x) + ARCH = $(SYSARCH) + endif + DEPARG = -MM + INC += -I/usr/local/include -I/usr/X11R6/include + DEF += -W -Wall $(PTHREAD_CFLAGS) + OPTF = -O2 + DBGF = -g + SHARED = -shared + ifeq ($(SYSARCH),amd64) + ARCHARGS = -fPIC + else + ARCHARGS = + endif + LINKARGS = $(PTHREAD_LIBS) +endif + +#### MacOS X specific definitions +ifeq ($(OS),Darwin) + ifeq (x$(CXX),x) + CXX = g++ + endif + DEPARG = -M + INC += -I/usr/X11R6/include + DEF += -Wall -D__DARWIN_OSX__ + OPTF = -O2 + DBGF = -gstabs+ -ggdb + SHARED = -shared + ARCH = 32 + ARCHARGS = + LINKARGS = -L/usr/X11R6/lib -framework Carbon + LIB_EXT = dylib +endif + +#### Cygwin/Mingw specific definitions +ifeq ($(OS),CYGWIN) + CXX = c++ + DEPARG = -M + INC += -DWIN32 + DEF += -DWIN32 -Wall -DOPENTHREADS_EXPORTS + OPTF = -O2 + DBGF = -g + SHARED = -shared \ + -Wl,--out-implib,lib$(TARGET_BASENAME).dll.a \ + -Wl,--export-all-symbols + + EXE_EXT =.exe + ARCH = 32 + ARCHARGS = + LINKARGS = -W -Wall + DYNAMICLIBRARYLIB = + + GL_LIBS = -lglu32 -lopengl32 + X_LIBS = -lgdi32 -luser32 + SOCKET_LIBS = + OTHER_LIBS = $(GL_LIBS) + + PTHREAD_LIB = -lpthread + + LIBINST = bin/$(OS)$(ARCH) + IMP_LIBINST = lib/$(OS)$(ARCH) + + LIB_PREFIX = cyg + LIB_EXT = dll + IMP_LIB_EXT = dll.a + LINK = cp -f + + INST_LOCATION ?= /usr/local/OpenThreads + INST_INCLUDE = $(INST_LOCATION)/include + INST_SHARE_PREFIX = $(INST_LOCATION) + INST_SRC = $(INST_SHARE_PREFIX)/src + INST_EXAMPLES = $(INST_SHARE_PREFIX)/bin + INST_EXAMPLE_SRC = $(INST_SHARE_PREFIX)/src/demos + INST_DOC = $(INST_SHARE_PREFIX)/doc + INST_DATA = $(INST_SHARE_PREFIX)/data + MAKEDIST = $(TOPDIR)/Make/makeinnosetup + +endif + +#### Cygwin/Mingw specific definitions +ifeq ($(OS),MINGW) + CXX = c++ -mthreads + + DEPARG = -M + INC += + DEF += -DWIN32 -Wall -DOPENTHREADS_EXPORTS + OPTF = -O2 + DBGF = -g + SHARED = -shared -mthreads \ + -Wl,--export-all-symbols \ + -Wl,--output-def,lib$(TARGET_BASENAME).def \ + -Wl,--out-implib,lib$(TARGET_BASENAME).dll.a \ + + EXE_EXT =.exe + ARCH = 32 + ARCHARGS = + LINKARGS = -W -Wall + DYNAMICLIBRARYLIB = + + GL_LIBS = -lglu32 -lopengl32 + X_LIBS = -lgdi32 -luser32 + SOCKET_LIBS = + OTHER_LIBS = $(GL_LIBS) -lwinmm + PTHREAD_LIB = + OPEN_THREAD_LIB = -lOpenThreadsWin32 + + LIBINST = bin/$(OS)$(ARCH) + IMP_LIBINST = lib/$(OS)$(ARCH) + + LIB_PREFIX = lib + LIB_EXT = dll + IMP_LIB_EXT = dll.a + PLUGIN_EXT = dll + + LINK = cp -f + + INST_LOCATION ?= /usr/local/OpenThreads + INST_LIBS = $(INST_LOCATION)/bin + INST_IMP_LIBS = $(INST_LOCATION)/lib + INST_INCLUDE = $(INST_LOCATION)/include + INST_SHARE = $(INST_LOCATION) + INST_DEMOS = $(INST_SHARE)/bin + INST_DEMO_SRC = $(INST_SHARE)/src/demos + INST_DOC = $(INST_SHARE)/doc + INST_DATA = $(INST_SHARE)/data + MAKEDIST = $(TOPDIR)/Make/makeinnosetup +endif + +#### HP-UX Specific definitions + +ifeq ($(OS),HP-UX) + CXX = aCC -AA -mt + DEPARG = -w +make -E + INC += + DEF += +Z -z + OPTF = +O2 + DBGF = -g + SHARED = +Z -b -z -Wl,+s + ARCH = 32 + LDFLAGS = + LINKARGS = -lpthread + LIB_EXT = sl + PLUGIN_EXT = sl + DYNAMICLIBRARYLIB = -ldld + OTHER_LIBS = -lm + INSTXCMD = install -c -m 755 + INSTRCMD = install -c -m 644 +endif + +#### AIX Specific Additions + +ifeq ($(OS),AIX) + CXX = g++ -D_REENTRANT + DEPARG = -M + INC += + DEF += + OPTF = -O + DBGF = -g + SHARED = + ARCH = 32 + LDFLAGS = + LINKARGS = -lpthread + LIB_EXT = a + PLUGIN_EXT = a + DYNAMICLIBRARYLIB = -ldld + OTHER_LIBS = -lm +endif + + +VPATH=.. + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/makedirdefs b/Utilities/otbopenthreads/OpenThreads/Make/makedirdefs new file mode 100755 index 0000000000000000000000000000000000000000..ee29325c49400f27a9beb909abf91aee5b59c8e3 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/makedirdefs @@ -0,0 +1,10 @@ + +################################################################ +# Directories traversed from the top level +TOP_LEVEL_DIRS = src + + +################################################################ +# Directories traversed in the TOPDIR/src directory +SRC_DIRS = \ + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/makedirrules b/Utilities/otbopenthreads/OpenThreads/Make/makedirrules new file mode 100755 index 0000000000000000000000000000000000000000..8add1ff831b8f3e791d3704e338519d492dffc1f --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/makedirrules @@ -0,0 +1,6 @@ + +default : $(DIRS) + @for f in $(DIRS); do cd $$f; $(MAKE) $@ || exit 1; cd ..; done + +$(RECURSIVE_TARGETS) : $(DIRS) + @for f in $(DIRS); do cd $$f; $(MAKE) $@ || exit 1; cd ..; done diff --git a/Utilities/otbopenthreads/OpenThreads/Make/makeinnosetup b/Utilities/otbopenthreads/OpenThreads/Make/makeinnosetup new file mode 100755 index 0000000000000000000000000000000000000000..e8fe804f3e73c037aa3dfeccec256f265d14cc74 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/makeinnosetup @@ -0,0 +1,139 @@ +#!/bin/sh + +VERSION=`make -s version` + +list_files() +{ + cat <<- EOF +include/OpenThreads/Barrier include/OpenThreads +include/OpenThreads/Condition include/OpenThreads +include/OpenThreads/Exports include/OpenThreads +include/OpenThreads/Mutex include/OpenThreads +include/OpenThreads/Thread include/OpenThreads +lib/Win32/OpenThreadsWin32.lib lib +lib/Win32/OpenThreadsWin32d.lib lib +bin/Win32/OpenThreadsWin32.dll bin +bin/Win32/OpenThreadsWin32d.dll bin +EOF +} + +print_header() +{ + cat <<- EOF +[Setup] +AppName=OpenThreads +AppVerName=OpenThreads $VERSION +AppPublisher=The Open Thread Group +AppPublisherURL=http://www.andesengineering.com/OpenThreads +AppSupportURL=http://www.andesengineering.com/OpenThreads +AppUpdatesURL=http://www.andesengineering.com/OpenThreads +DefaultDirName={pf}\OpenThreads +DisableDirPage=yes +DefaultGroupName=OpenThreads +DisableProgramGroupPage=yes +LicenseFile=COPYING.txt +EOF +} + +# Usage: +# do_dir $DIR +# + +print_file_entry() +{ + DIR=$1 + FILE=$2 + printf "Source: \"%s\\\%s\"; DestDir: \"{app}\\\%s\\\"; Flags: ignoreversion\n"\ + $DIR $FILE $DIR + +} + +print_files() +{ + echo "[Files]" + + list_files | while read src dst + do + DOS_SRC=`echo $src | sed 's/\\//\\\/g'` + DOS_DST=`echo $dst | sed 's/\\//\\\/g'` + + printf "Source: \"%s\"; DestDir: \"{app}\\\%s\\\"; Flags: ignoreversion\n"\ + $DOS_SRC $DOS_DST + done +} + +print_script() +{ + print_header + print_files +} + +BUILD_ISS=1 +BUILD_DISTRIBUTION=1 +CLEAN_UP=1 + +while [ $# -gt 0 ] +do + case $1 in + -c ) + BUILD_ISS=0 + BUILD_DISTRIBUTION=0 + CLEAN_UP=1 + ;; + + -d ) + BUILD_ISS=0 + BUILD_DISTRIBUTION=1 + CLEAN_UP=0 + ;; + + -n ) + CLEAN_UP=0 + ;; + + -s ) + BUILD_ISS=1 + BUILD_DISTRIBUTION=0 + CLEAN_UP=0 + ;; + esac + + shift; +done + +if [ $BUILD_ISS = 1 ] +then + echo Building Inno Setup script .... + rm -f openthread.iss + + print_script | awk '{ printf "%s\r\n", $0 }' > openthread.iss +fi + +if [ $BUILD_DISTRIBUTION = 1 ] +then + echo Building distribution ... + OS=`uname | cut -b1-6` + + if [ "$OS" = "CYGWIN" ] + then + C:/Program\ Files/Inno\ Setup\ 3/iscc.exe openthread.iss + [ -d dist/Win32 ] || mkdir -p dist/Win32 + mv Output/setup.exe dist/Win32/OpenThreads_"$VERSION"_setup.exe + rm -rf Output + else + echo " Distribution may only be built under Cygwin with Inno Setup" + fi +fi + +if [ $CLEAN_UP = 1 ] +then + echo Cleaning up... + rm -f openthread.iss +fi + + + + + + + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/makepkg b/Utilities/otbopenthreads/OpenThreads/Make/makepkg new file mode 100755 index 0000000000000000000000000000000000000000..f36f616afbfca295a55db0b23c0a5725bbcf311f --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/makepkg @@ -0,0 +1,188 @@ +#!/bin/sh + + +die() +{ + echo >& $1 + exit 1 +} + +x() +{ + echo $* + $* +} + + + +print_pkginfo() +{ + + __pstamp=`fgrep $LOGNAME /etc/passwd | cut -f5 -d":"` + cat <<- EOF +PKG="$1" +NAME="$2" +`[ "$OS" = "SunOS" ] && echo ARCH=sparc` +VERSION=`$TOPDIR/bin/osgversion` +CATEGORY="application,graphics,opengl" +DESC="$3" +BASEDIR="/opt/" +VENDOR="OpenSceneGraph" +EMAIL="info@openscenegraph.org" +PSTAMP=$__pstamp +URL="http://openscenegraph.org" +MAXINST="1" +EOF + +} + +print_prototype() +{ + echo "i pkginfo" + [ -f depend ] && echo "i depend" + + for d in $* + do + d=`echo $d | sed 's/\/opt\///` + echo "d none $d ? root sys" + done + + for d in $* + do + for f in `ls -1 $d` + do + f=$d/$f + if [ -f $f ] + then + [ -x $f ] && MODE=0555 || MODE=0444 + dest=`echo $f | sed 's/\/opt\///'` + echo "f none $dest=$f $MODE root sys" + fi + done + done + +} + +make_installable() +{ + PKGNAME=$1 + PKGDIR=$PKGNAME.pkg + DISTNAME="$PKGNAME"-"`$TOPDIR/bin/osgversion`"-"$OS".shar + + THISDIR=`pwd` + cd $PKGSUBDIR + + cat << INSTALL_EOF > $DISTNAME + +#!/bin/sh +cat <<- 'LEOF' | uudecode -p | gzip -d -c | tar xvf - +`tar cvf - $PKGDIR | gzip | uuencode .tmpuu` +LEOF + +/bin/sh << EOF +echo =========== INSTALLING $DISTNAME ================= +pkgadd -d $PKGNAME.pkg $PKGNAME +rm -rf $PKGDIR +EOF + + +INSTALL_EOF + + chmod +x $DISTNAME + cd $THISDIR +} + + +make_package() +{ + PKGNAME=$1 + PKGDIR=$PKGSUBDIR/$PKGNAME.pkg + x rm -rf $PKGDIR + x mkdir $PKGDIR + + echo Making pkginfo ... + print_pkginfo "$1" "$2" "$3" > $PKGDIR/pkginfo + + shift; shift; shift + + echo Making prototype ... + + print_prototype $* > $PKGDIR/prototype + +# DISTNAME="$PKGNAME"-"`$TOPDIR/bin/osgversion`"-"$OS"-"local" + + THISDIR=`pwd` + x cd $PKGDIR + x pkgmk -d . + x cd $THISDIR +# make_installable $PKGNAME $PKGDIR $DISTNAME +# x pkgtrans -s $PKGDIR $DISTNAME $PKGNAME +# x mv "$PKGDIR"/"$DISTNAME" "$PKGDIR"/.. +} + + +OS=$1 +TOPDIR=$2 +INST_LIBS=$3 +INST_PLUGINS=$4 +INST_INCLUDE=$5 +INST_DEMOS=$6 +INST_SRC=$7 +INST_DEMO_SRC=$8 +shift;shift; shift;shift; shift;shift; shift;shift; +INST_DOC=$1 +INST_DATA=$2 + + +PKGSUBDIR=dist/PKG + +make_package\ + "OpenSceneGraph" \ + "Open Scene Graph - Run-time environment"\ + "An OpenGL based scene graph. This installation includes a set of run-time libraries, and demo programs"\ + $INST_LIBS $INST_PLUGINS $INST_DEMOS\ + +make_installable "OpenSceneGraph" + +# +# Capture include directories +# +SUBDIRS=`ls $TOPDIR/include | grep -v CVS` +INSTARG="" +for d in $SUBDIRS +do + dd="$INST_INCLUDE"/"$d" + [ -d $dd ] && INSTARG="$INSTARG $dd" +done + +# +# Capthre Demos subdirectories +# +SUBDIRS=`ls $TOPDIR/src/Demos | grep -v CVS` +for d in $SUBDIRS +do + dd="$INST_DEMO_SRC"/"$d" + [ -d $dd ] && INSTARG="$INSTARG $dd" +done + +# +# Capture Make subdirectory +# +dd="$INST_SRC"/"Make" + +echo dd is $dd +ls $dd + +[ -d $dd ] && INSTARG="$INSTARG $dd" + + +make_package\ + "OpenSceneGraph-dev"\ + "Open Scene Graph - Development environment"\ + "An OpenGL based scene graph. This installation includes header files and demo program source files"\ + $INSTARG + +make_installable "OpenSceneGraph-dev" + + +exit 0 diff --git a/Utilities/otbopenthreads/OpenThreads/Make/makerpms b/Utilities/otbopenthreads/OpenThreads/Make/makerpms new file mode 100755 index 0000000000000000000000000000000000000000..7ef64ff75ab302c5f7fd365240e6e7a41ad09761 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/makerpms @@ -0,0 +1,130 @@ +#!/bin/sh + +PRODUCT=$1 +RPM_HEADER=$2 +RPM_FILES=$3 + +SYS_SRC_DIR=/usr/src/packages/ + +VERSION=`make -s version` +rev=`echo $VERSION | cut -f1 -d"-"` +rel=`echo $VERSION | cut -f2 -d"-"` +TARBALL_NAME=$PRODUCT-$VERSION.tar.gz +TARBALL_DEST=$SYS_SRC_DIR/SOURCES/$TARBALL_NAME + +printRPMHeaderBeforeDescription() +{ + cat $RPM_HEADER | awk \ + 'BEGIN{flag=1}\ + { \ + if ($1 == "Description:" )\ + flag = 0;\ + if( flag == 1 ) \ + print $0; \ + }' +} + +printRPMHeaderAfterDescription() +{ + cat $RPM_HEADER | awk \ + 'BEGIN{flag=0}\ + { \ + if( flag == 1 ) \ + print $0; \ + if ($1 == "Description:" )\ + flag = 1;\ + }' +} + +makeSpec() +{ + cat <<-LEOF +Name: $PRODUCT +`printRPMHeaderBeforeDescription` +Version: $rev +Release: $rel +Source: $TARBALL_NAME +Packager: `awk -f - /etc/passwd <<-EOF +BEGIN { FS=":"} +{ + if( \\$1 == "$LOGNAME" ) + print \\$5 +} +EOF` + +%description + +`printRPMHeaderAfterDescription` + +%prep + +%setup + +%build + +%install + +tar cf - . | tar xvfC - / + +%files + +LEOF + + cat $RPM_FILES | while read perm src dst + do + echo "%attr($perm, root, root) $dst" + done + echo +} + +makedir() +{ + [ -d $1 ] || mkdir -p $1 +} + +makeTarball() +{ + IDIR=$PRODUCT-$rev + [ -d $IDIR ] && rm -rf $IDIR + + cat $RPM_FILES | while read perm src dst + do + makedir $IDIR/`dirname $dst` + install $src $IDIR/$dst + done + + tar cf - $IDIR | gzip > $TARBALL_DEST +} + +check_args() +{ + if [ ! -f $RPM_HEADER ] + then + echo RPM Header file == $RPM_HEADER == missing + return 1 + fi + if [ ! -f $RPM_FILES ] + then + echo RPM Files file == $RPM_FILES == missing + return 1 + fi + + return 0 +} + +if ! check_args +then + exit 1; +fi + +makeTarball + +makeSpec > $PRODUCT.spec + +rpmbuild -bb --clean $PRODUCT.spec + +exit 0 + + + + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/makerules b/Utilities/otbopenthreads/OpenThreads/Make/makerules new file mode 100755 index 0000000000000000000000000000000000000000..126edc9c437ec28cd08c564371b5ea51abc3859c --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/makerules @@ -0,0 +1,167 @@ + +default : opt + +opt : $(LIB:=.opt) \ + $(EXEC:=.opt) \ + +debug : $(LIB:=.dbg) \ + $(EXEC:=.dbg) \ + +static: $(LIB:=.static) \ + $(EXEC:=.opt) \ + +staticdebug: $(LIB:=.staticdbg) \ + $(EXEC:=.dbg) + +cleandepend : cleandependopt cleandependdbg + +cleandependopt : + @[ -d $(OPTDIR) ] && cd $(OPTDIR); rm -f Makedepend; rm -rf .depend + +cleandependdbg : + @[ -d $(DEBUGDIR) ] && cd $(DEBUGDIR); rm -f Makedepend; rm -rf .depend + +cleantarget : cleantargetopt cleantargetdbg + +cleantargetopt : + @[ -d $(OPTDIR) ] && cd $(OPTDIR); rm -f $(EXEC)$(EXE_EXT) $(LIB).$(LIB_EXT) + +cleantargetdbg : + @[ -d $(DEBUGDIR) ] && cd $(DEBUGDIR); rm -f $(EXEC)$(EXE_EXT) $(LIB).$(LIB_EXT) + +clean : cleanopt cleandbg + +cleanopt : + @[ -d $(OPTDIR) ] && cd $(OPTDIR); rm -f $(OBJS) Makedepend; rm -rf .depend + +cleandbg : + @[ -d $(DEBUGDIR) ] && cd $(DEBUGDIR); rm -f $(OBJS) Makedepend; rm -rf .depend + +clobber : clobberdbg clobberopt + +clobberopt : + rm -rf $(OPTDIR) + +clobberdbg : + rm -rf $(DEBUGDIR) + + +$(EXEC): $(OBJS) + $(CXX) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ + +## Mac OSX makes the distinction between -dynamiclib and -bundle +## causing us to have to make a special case here, rather than +## just redefining the SHARED argument. + +ifeq ($(OS),Darwin) + $(LIB) : $(OBJS) + $(CXX) $(LDFLAGS) -dynamiclib $(OBJS) $(LIBS) -o $@.$(LIB_EXT) + touch $@ + +$(STATICLIB): $(OBJS) + ar rv $@ $? + +else + + $(LIB) : $(OBJS) + $(CXX) $(LDFLAGS) $(SHARED) $(OBJS) $(LIBS) -o $@.$(LIB_EXT) + + $(STATICLIB): $(OBJS) + ar rv $@ $? + +endif # not Darwin + +$(EXEC:=.dbg) : + @[ -d $(DEBUGDIR) ] || mkdir $(DEBUGDIR) + @cd $(DEBUGDIR); \ + $(MAKE) -f ../GNUmakefile "DOF=$(DBGF)" TOPDIR=../${TOPDIR} \ + THISDIR=../$(THISDIR) \ + MAKEDEPEND=Makedepend $(EXEC) + @$(MAKE) LNSRC=$(DEBUGDIR)/$(EXEC)$(EXE_EXT) LNDEST=$(BININST)/$(EXEC)$(EXE_EXT) __link + + +$(LIB:=.dbg) : + @[ -d $(DEBUGDIR) ] || mkdir $(DEBUGDIR) + @cd $(DEBUGDIR); \ + $(MAKE) -f ../$(MAKEFILE) "DOF=$(DBGF)" TOPDIR=../${TOPDIR} \ + THISDIR=../$(THISDIR) \ + MAKEDEPEND=Makedepend $(LIB) + @$(MAKE) LNSRC=$(DEBUGDIR)/$(LIB).$(LIB_EXT) LNDEST=$(LIBINST)/$(LIB).$(LIB_EXT) __link +ifdef IMP_LIB_EXT + @$(MAKE) LNSRC=$(DEBUGDIR)/lib$(TARGET_BASENAME).$(IMP_LIB_EXT) LNDEST=$(IMP_LIBINST)/lib$(TARGET_BASENAME).$(IMP_LIB_EXT) __link +endif + +$(LIB:=.staticdbg) : + [ -d $(DEBUGDIR) ] || mkdir $(DEBUGDIR) + cd $(DEBUGDIR); \ + $(MAKE) -f ../$(MAKEFILE) "DOF=$(DBGF)" TOPDIR=../${TOPDIR} \ + THISDIR=../$(THISDIR) \ + MAKEDEPEND=Makedepend $(STATICLIB) + @$(MAKE) LNSRC=$(DEBUGDIR)/$(STATICLIB) LNDEST=$(LIBINST)/$(STATICLIB) __link + +$(EXEC:=.opt) : + @[ -d $(OPTDIR) ] || mkdir $(OPTDIR) + @cd $(OPTDIR); \ + $(MAKE) -f ../GNUmakefile DOF=$(OPTF) TOPDIR=../${TOPDIR} \ + THISDIR=../$(THISDIR) \ + MAKEDEPEND=Makedepend $(EXEC) + @$(MAKE) LNSRC=$(OPTDIR)/$(EXEC)$(EXE_EXT) LNDEST=$(BININST)/$(EXEC)$(EXE_EXT) __link + + +$(LIB:=.opt) : + @[ -d $(OPTDIR) ] || mkdir $(OPTDIR) + @cd $(OPTDIR); \ + $(MAKE) -f ../$(MAKEFILE) DOF=$(OPTF) TOPDIR=../${TOPDIR} \ + THISDIR=../$(THISDIR) \ + MAKEDEPEND=Makedepend $(LIB) + @$(MAKE) LNSRC=$(OPTDIR)/$(LIB).$(LIB_EXT) LNDEST=$(LIBINST)/$(LIB).$(LIB_EXT) __link +ifdef IMP_LIB_EXT + @$(MAKE) LNSRC=$(OPTDIR)/lib$(TARGET_BASENAME).$(IMP_LIB_EXT) LNDEST=$(IMP_LIBINST)/lib$(TARGET_BASENAME).$(IMP_LIB_EXT) __link +endif + +$(LIB:=.static) : + [ -d $(OPTDIR) ] || mkdir $(OPTDIR) + cd $(OPTDIR); \ + $(MAKE) -f ../$(MAKEFILE) DOF=$(OPTF) TOPDIR=../${TOPDIR} \ + THISDIR=../$(THISDIR) \ + MAKEDEPEND=Makedepend $(STATICLIB) + @$(MAKE) LNSRC=$(OPTDIR)/$(STATICLIB) LNDEST=$(LIBINST)/$(STATICLIB) __link + + +Makedepend : $(CXXFILES) $(C++FILES) $(CFILES) +ifeq ($(OS),IRIX) + touch $@ +else + @ touch $@ + @if [ ! -d .depend ] ; then \ + mkdir .depend; \ + depfiles="$+"; \ + else \ + depfiles="$?"; \ + fi; \ + if [ ! -z "$$depfiles" ]; then \ + for f in $$depfiles; do \ + echo "$(CXX) $(DEPARG) $(INC) $$f pipeto .depend/`basename $$f`"; \ + $(CXX) $(DEPARG) $(INC) $$f > .depend/`basename $$f`; \ + grep $$f $@ || echo include .depend/`basename $$f` >> Makedepend ; \ + done; \ + fi +endif + +.SUFFIXES: .cpp .o +.cpp.o: + $(CXX) $(CXXFLAGS) -c $< +.SUFFIXES: .c++ .o +.c++.o: + $(CXX) $(CXXFLAGS) -c $< + +depend : $(MAKEDEPEND) + +__link : + @sh $(TOPDIR)/Make/dolink.sh $(TOPDIR) $(LNSRC) $(LNDEST) "$(LINK)" + +__instfiles : + @echo $(INSTFILES) + +sinclude $(MAKEDEPEND) + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/openthreads.pc b/Utilities/otbopenthreads/OpenThreads/Make/openthreads.pc new file mode 100755 index 0000000000000000000000000000000000000000..b10c86b1a36f509c3b53b0a4e9c90d4bea2e6090 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/openthreads.pc @@ -0,0 +1,14 @@ +# pkg-config source file + +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: openthreads +Description: Object-Oriented (OO) thread interface for C++ programmers +Version: 1.5 +Requires: +Conflicts: +Libs: -L${libdir} -lOpenThreads +Cflags: -I${includedir} diff --git a/Utilities/otbopenthreads/OpenThreads/Make/rpm.files b/Utilities/otbopenthreads/OpenThreads/Make/rpm.files new file mode 100755 index 0000000000000000000000000000000000000000..7e7cdf9788de62a51732bdd85391ad2e6b01d34f --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/rpm.files @@ -0,0 +1,7 @@ +755 lib/Linux32/libOpenThreads.so /usr/lib/libOpenThreads.so +644 include/OpenThreads/Barrier /usr/include/OpenThreads/Barrier +644 include/OpenThreads/Condition /usr/include/OpenThreads/Condition +644 include/OpenThreads/Exports /usr/include/OpenThreads/Exports +644 include/OpenThreads/Mutex /usr/include/OpenThreads/Mutex +644 include/OpenThreads/ScopedLock /usr/include/OpenThreads/ScopedLock +644 include/OpenThreads/Thread /usr/include/OpenThreads/Thread diff --git a/Utilities/otbopenthreads/OpenThreads/Make/rpm.header b/Utilities/otbopenthreads/OpenThreads/Make/rpm.header new file mode 100755 index 0000000000000000000000000000000000000000..ebaf30763de9141b38b9cd699827dc641ea5de19 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/rpm.header @@ -0,0 +1,6 @@ +Summary: A light weight, cross-platform threading library +Copyright: LGPL +Group: Real-Time +Description: +This library is intended to provide a minimal & complete Object-Oriented (OO) thread interface for C++ programmers. It is loosely modeled on the Java thread API, and the POSIX Threads standards. + diff --git a/Utilities/otbopenthreads/OpenThreads/Make/versionrules b/Utilities/otbopenthreads/OpenThreads/Make/versionrules new file mode 100755 index 0000000000000000000000000000000000000000..19828fd145635f3a5cba455815a1d89785cce719 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Make/versionrules @@ -0,0 +1,21 @@ +####################################################################### +## +## VERSIONING SEMANTICS +## +## Version consistes of <major> . <minor> . <release> - <revision> +## Where: +## major : Production (0 = pre-production) +## minor : 0-7 = Production minor, 8 = Alpha, 9 = Beta +## release : Release tag +## revision: Release revision - 0 = development (cutting edge). +## +## +## 'make version' will print the version with a +####################################################################### +version : + @if [ "$(VERSION_REVISION)" = "0" ]; then \ + release=`date +%Y%m%d%H%M`; \ + else \ + release=$(VERSION_REVISION); \ + fi; \ + echo $(VERSION)-$$release; diff --git a/Utilities/otbopenthreads/OpenThreads/README.txt b/Utilities/otbopenthreads/OpenThreads/README.txt new file mode 100755 index 0000000000000000000000000000000000000000..c91c7c515f79557fe185a7818d207bdf4e74e707 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/README.txt @@ -0,0 +1,34 @@ + +This library is intended to provide a minimal & complete Object-Oriented (OO) +thread interface for C++ programmers. It is loosely modeled on the Java thread +API, and the POSIX Threads standards. The architecture of the library is +designed around "swappable" thread models which are defined at compile-time +in a shared object library. + +It is of importance to note that while a factory pattern design could have been +used to achieve the goal of genaric interface, it would have required the +programmer to allocate each of the 4 fundemental types (Thread, Mutex, Barrier, +& Condition ) on the heap. Due to the cost associated with heap allocation +for some of these constructs, such allocation was deemed unacceptable, and thus +the factory pattern was not used. + +Instead, a somewhat obtuse - but effective - technique was chosen to provide +the necessary data/implementation hiding. This technique uses private void +pointers to encapsulate object private data. The void pointers actually point +at concrete data structures, but give a uniform interface to the dso. + +It is the intent of the Open Thread Group that the interfaces (header files) +will be used to construct optimized implementations using platform optimized +multi-processing constructs such as the sproc methods used on IRIX & windows +threads. A sample implementation has been provided using the POSIX standards. + +A doxygen file has been provided to create code documentation & man pages. +It can be found in the root directory under docs/ + +Although the Open Thread Group does not have an email alias at this point in +time, one may contact the group via Don Burns (don@andesengineernig.com) or +Robert Osfield (robert@openscenegraph.com). + + +- The Open Thread Group + diff --git a/Utilities/otbopenthreads/OpenThreads/TODO.txt b/Utilities/otbopenthreads/OpenThreads/TODO.txt new file mode 100755 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/TODO.txt @@ -0,0 +1 @@ + diff --git a/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/English.lproj/InfoPlist.strings b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/English.lproj/InfoPlist.strings new file mode 100755 index 0000000000000000000000000000000000000000..d9560c4253bc4b251b1b7fed89b1431c27ddd09f Binary files /dev/null and b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/English.lproj/InfoPlist.strings differ diff --git a/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/Info.plist b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/Info.plist new file mode 100755 index 0000000000000000000000000000000000000000..314a0b5627ce69db9bad9dcdc8ed7f5a33e6c1cd --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/Info.plist @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>OpenThreads</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>org.OpenThreads.OpenThreads</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.4.4</string> + <key>CSResourcesFileMapped</key> + <true/> +</dict> +</plist> diff --git a/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads.xcode/project.pbxproj b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads.xcode/project.pbxproj new file mode 100755 index 0000000000000000000000000000000000000000..1fa4c1ab97887caef77b4dd45b1c578bc875010c --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads.xcode/project.pbxproj @@ -0,0 +1,573 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + 034768DDFF38A45A11DB9C8B = { + children = ( + 8D07F2C80486CC7A007CD1D0, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = "<group>"; + }; +//030 +//031 +//032 +//033 +//034 +//080 +//081 +//082 +//083 +//084 + 0867D690FE84028FC02AAC07 = { + buildSettings = { + }; + buildStyles = ( + 4F0BB7EC011F40E904CA0E50, + 4F0BB7ED011F40E904CA0E50, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 0867D691FE84028FC02AAC07; + productRefGroup = 034768DDFF38A45A11DB9C8B; + projectDirPath = ""; + targets = ( + 8D07F2BC0486CC7A007CD1D0, + ); + }; + 0867D691FE84028FC02AAC07 = { + children = ( + BE11833F05D7005800EB53E5, + 08FB77ACFE841707C02AAC07, + 089C1665FE841158C02AAC07, + 0867D69AFE84028FC02AAC07, + 034768DDFF38A45A11DB9C8B, + ); + isa = PBXGroup; + name = OpenThreads; + refType = 4; + sourceTree = "<group>"; + }; + 0867D69AFE84028FC02AAC07 = { + children = ( + 08FB77AAFE841565C02AAC07, + ); + isa = PBXGroup; + name = "External Frameworks and Libraries"; + refType = 4; + sourceTree = "<group>"; + }; + 089C1665FE841158C02AAC07 = { + children = ( + 8D07F2C70486CC7A007CD1D0, + 089C1666FE841158C02AAC07, + ); + isa = PBXGroup; + name = Resources; + refType = 4; + sourceTree = "<group>"; + }; + 089C1666FE841158C02AAC07 = { + children = ( + 089C1667FE841158C02AAC07, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + sourceTree = "<group>"; + }; + 089C1667FE841158C02AAC07 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + sourceTree = "<group>"; + }; + 08FB77AAFE841565C02AAC07 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Carbon.framework; + path = /System/Library/Frameworks/Carbon.framework; + refType = 0; + sourceTree = "<absolute>"; + }; + 08FB77ACFE841707C02AAC07 = { + children = ( + BE11832A05D6FE3800EB53E5, + BE11832B05D6FE3800EB53E5, + BE11832C05D6FE3800EB53E5, + BE11832D05D6FE3800EB53E5, + BE11832E05D6FE3800EB53E5, + BE11832F05D6FE3800EB53E5, + BE11833005D6FE3800EB53E5, + BE11833105D6FE3800EB53E5, + 32BAE0B70371A74B00C91783, + ); + isa = PBXGroup; + name = Source; + refType = 4; + sourceTree = "<group>"; + }; +//080 +//081 +//082 +//083 +//084 +//320 +//321 +//322 +//323 +//324 + 32BAE0B70371A74B00C91783 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = OpenThreads_Prefix.pch; + refType = 2; + sourceTree = SOURCE_ROOT; + }; +//320 +//321 +//322 +//323 +//324 +//4F0 +//4F1 +//4F2 +//4F3 +//4F4 + 4F0BB7EC011F40E904CA0E50 = { + buildSettings = { + COPY_PHASE_STRIP = NO; + DEBUGGING_SYMBOLS = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + OPTIMIZATION_CFLAGS = "-O0"; + ZERO_LINK = YES; + }; + isa = PBXBuildStyle; + name = Development; + }; + 4F0BB7ED011F40E904CA0E50 = { + buildSettings = { + COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_OPTIMIZATION_LEVEL = s; + ZERO_LINK = NO; + }; + isa = PBXBuildStyle; + name = Deployment; + }; +//4F0 +//4F1 +//4F2 +//4F3 +//4F4 +//8D0 +//8D1 +//8D2 +//8D3 +//8D4 + 8D07F2BC0486CC7A007CD1D0 = { + buildPhases = ( + 8D07F2BD0486CC7A007CD1D0, + 8D07F2BF0486CC7A007CD1D0, + 8D07F2C10486CC7A007CD1D0, + 8D07F2C30486CC7A007CD1D0, + 8D07F2C50486CC7A007CD1D0, + ); + buildRules = ( + ); + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_SEARCH_PATHS = ""; + FRAMEWORK_VERSION = A; + GCC_ENABLE_TRIGRAPHS = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = OpenThreads_Prefix.pch; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; + GCC_WARN_UNKNOWN_PRAGMAS = NO; + HEADER_SEARCH_PATHS = ../../include; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_SEARCH_PATHS = ""; + LIBRARY_STYLE = Dynamic; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = "-seg1addr 0x1FF00000"; + PRODUCT_NAME = OpenThreads; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = framework; + }; + dependencies = ( + ); + isa = PBXNativeTarget; + name = OpenThreads; + productInstallPath = "$(HOME)/Library/Frameworks"; + productName = OpenThreads; + productReference = 8D07F2C80486CC7A007CD1D0; + productType = "com.apple.product-type.framework"; + }; + 8D07F2BD0486CC7A007CD1D0 = { + buildActionMask = 2147483647; + files = ( + BE11837D05D7083B00EB53E5, + BE11837E05D7083B00EB53E5, + BE11837F05D7083B00EB53E5, + BE11838005D7083B00EB53E5, + BE11838105D7083B00EB53E5, + BE11838205D7083B00EB53E5, + 8D07F2BE0486CC7A007CD1D0, + BE11833405D6FE3900EB53E5, + BE11833605D6FE3900EB53E5, + BE11833805D6FE3900EB53E5, + BE11833905D6FE3900EB53E5, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D07F2BE0486CC7A007CD1D0 = { + fileRef = 32BAE0B70371A74B00C91783; + isa = PBXBuildFile; + settings = { + }; + }; + 8D07F2BF0486CC7A007CD1D0 = { + buildActionMask = 2147483647; + files = ( + 8D07F2C00486CC7A007CD1D0, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D07F2C00486CC7A007CD1D0 = { + fileRef = 089C1666FE841158C02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; + 8D07F2C10486CC7A007CD1D0 = { + buildActionMask = 2147483647; + files = ( + BE11835105D7022C00EB53E5, + BE11835205D7022C00EB53E5, + BE11835405D7022C00EB53E5, + BE11835605D7022C00EB53E5, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D07F2C30486CC7A007CD1D0 = { + buildActionMask = 2147483647; + files = ( + 8D07F2C40486CC7A007CD1D0, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D07F2C40486CC7A007CD1D0 = { + fileRef = 08FB77AAFE841565C02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; + 8D07F2C50486CC7A007CD1D0 = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8D07F2C70486CC7A007CD1D0 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = text.plist; + path = Info.plist; + refType = 4; + sourceTree = "<group>"; + }; + 8D07F2C80486CC7A007CD1D0 = { + explicitFileType = wrapper.framework; + includeInIndex = 0; + isa = PBXFileReference; + path = OpenThreads.framework; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; +//8D0 +//8D1 +//8D2 +//8D3 +//8D4 +//BE0 +//BE1 +//BE2 +//BE3 +//BE4 + BE11832A05D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = "PThread.c++"; + path = "../../pthread_src/PThread.c++"; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11832B05D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = "PThreadBarrier.c++"; + path = "../../pthread_src/PThreadBarrier.c++"; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11832C05D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = PThreadBarrierPrivateData.h; + path = ../../pthread_src/PThreadBarrierPrivateData.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11832D05D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = "PThreadCondition.c++"; + path = "../../pthread_src/PThreadCondition.c++"; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11832E05D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = PThreadConditionPrivateData.h; + path = ../../pthread_src/PThreadConditionPrivateData.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11832F05D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = "PThreadMutex.c++"; + path = "../../pthread_src/PThreadMutex.c++"; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11833005D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = PThreadMutexPrivateData.h; + path = ../../pthread_src/PThreadMutexPrivateData.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11833105D6FE3800EB53E5 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = PThreadPrivateData.h; + path = ../../pthread_src/PThreadPrivateData.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11833405D6FE3900EB53E5 = { + fileRef = BE11832C05D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11833605D6FE3900EB53E5 = { + fileRef = BE11832E05D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11833805D6FE3900EB53E5 = { + fileRef = BE11833005D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11833905D6FE3900EB53E5 = { + fileRef = BE11833105D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11833F05D7005800EB53E5 = { + children = ( + BE11835905D7027D00EB53E5, + ); + isa = PBXGroup; + name = Header; + refType = 4; + sourceTree = "<group>"; + }; + BE11835105D7022C00EB53E5 = { + fileRef = BE11832A05D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11835205D7022C00EB53E5 = { + fileRef = BE11832B05D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11835405D7022C00EB53E5 = { + fileRef = BE11832D05D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11835605D7022C00EB53E5 = { + fileRef = BE11832F05D6FE3800EB53E5; + isa = PBXBuildFile; + settings = { + }; + }; + BE11835905D7027D00EB53E5 = { + children = ( + BE11836E05D7082A00EB53E5, + BE11836F05D7082A00EB53E5, + BE11837005D7082A00EB53E5, + BE11837105D7082A00EB53E5, + BE11837205D7082A00EB53E5, + BE11837305D7082A00EB53E5, + ); + isa = PBXGroup; + name = OpenThreads; + refType = 4; + sourceTree = "<group>"; + }; + BE11836E05D7082A00EB53E5 = { + explicitFileType = sourcecode.cpp.h; + fileEncoding = 30; + isa = PBXFileReference; + name = Barrier; + path = ../../include/OpenThreads/Barrier; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11836F05D7082A00EB53E5 = { + explicitFileType = sourcecode.cpp.h; + fileEncoding = 30; + isa = PBXFileReference; + name = Condition; + path = ../../include/OpenThreads/Condition; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11837005D7082A00EB53E5 = { + explicitFileType = sourcecode.cpp.h; + fileEncoding = 30; + isa = PBXFileReference; + name = Exports; + path = ../../include/OpenThreads/Exports; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11837105D7082A00EB53E5 = { + explicitFileType = sourcecode.cpp.h; + fileEncoding = 30; + isa = PBXFileReference; + name = Mutex; + path = ../../include/OpenThreads/Mutex; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11837205D7082A00EB53E5 = { + explicitFileType = sourcecode.cpp.h; + fileEncoding = 30; + isa = PBXFileReference; + name = ScopedLock; + path = ../../include/OpenThreads/ScopedLock; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11837305D7082A00EB53E5 = { + explicitFileType = sourcecode.cpp.h; + fileEncoding = 30; + isa = PBXFileReference; + name = Thread; + path = ../../include/OpenThreads/Thread; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + BE11837D05D7083B00EB53E5 = { + fileRef = BE11836E05D7082A00EB53E5; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + BE11837E05D7083B00EB53E5 = { + fileRef = BE11836F05D7082A00EB53E5; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + BE11837F05D7083B00EB53E5 = { + fileRef = BE11837005D7082A00EB53E5; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + BE11838005D7083B00EB53E5 = { + fileRef = BE11837105D7082A00EB53E5; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + BE11838105D7083B00EB53E5 = { + fileRef = BE11837205D7082A00EB53E5; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + BE11838205D7083B00EB53E5 = { + fileRef = BE11837305D7082A00EB53E5; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + }; + rootObject = 0867D690FE84028FC02AAC07; +} diff --git a/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads.xcodeproj/project.pbxproj b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads.xcodeproj/project.pbxproj new file mode 100755 index 0000000000000000000000000000000000000000..303d5773cc78dba59a0055b934738ea23e888a7a --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads.xcodeproj/project.pbxproj @@ -0,0 +1,448 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 00DAF8AA0BBE1A0E00EFEB98 /* Block in Headers */ = {isa = PBXBuildFile; fileRef = 00DAF8A70BBE1A0E00EFEB98 /* Block */; settings = {ATTRIBUTES = (Public, ); }; }; + 00DAF8AB0BBE1A0F00EFEB98 /* ReadWriteMutex in Headers */ = {isa = PBXBuildFile; fileRef = 00DAF8A80BBE1A0E00EFEB98 /* ReadWriteMutex */; settings = {ATTRIBUTES = (Public, ); }; }; + 00DAF8AC0BBE1A0F00EFEB98 /* ReentrantMutex in Headers */ = {isa = PBXBuildFile; fileRef = 00DAF8A90BBE1A0E00EFEB98 /* ReentrantMutex */; settings = {ATTRIBUTES = (Public, ); }; }; + 8D07F2BE0486CC7A007CD1D0 /* OpenThreads_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32BAE0B70371A74B00C91783 /* OpenThreads_Prefix.pch */; }; + 8D07F2C00486CC7A007CD1D0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; }; + 8D07F2C40486CC7A007CD1D0 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB77AAFE841565C02AAC07 /* Carbon.framework */; }; + BE11833405D6FE3900EB53E5 /* PThreadBarrierPrivateData.h in Headers */ = {isa = PBXBuildFile; fileRef = BE11832C05D6FE3800EB53E5 /* PThreadBarrierPrivateData.h */; }; + BE11833605D6FE3900EB53E5 /* PThreadConditionPrivateData.h in Headers */ = {isa = PBXBuildFile; fileRef = BE11832E05D6FE3800EB53E5 /* PThreadConditionPrivateData.h */; }; + BE11833805D6FE3900EB53E5 /* PThreadMutexPrivateData.h in Headers */ = {isa = PBXBuildFile; fileRef = BE11833005D6FE3800EB53E5 /* PThreadMutexPrivateData.h */; }; + BE11833905D6FE3900EB53E5 /* PThreadPrivateData.h in Headers */ = {isa = PBXBuildFile; fileRef = BE11833105D6FE3800EB53E5 /* PThreadPrivateData.h */; }; + BE11835105D7022C00EB53E5 /* PThread.c++ in Sources */ = {isa = PBXBuildFile; fileRef = BE11832A05D6FE3800EB53E5 /* PThread.c++ */; }; + BE11835205D7022C00EB53E5 /* PThreadBarrier.c++ in Sources */ = {isa = PBXBuildFile; fileRef = BE11832B05D6FE3800EB53E5 /* PThreadBarrier.c++ */; }; + BE11835405D7022C00EB53E5 /* PThreadCondition.c++ in Sources */ = {isa = PBXBuildFile; fileRef = BE11832D05D6FE3800EB53E5 /* PThreadCondition.c++ */; }; + BE11835605D7022C00EB53E5 /* PThreadMutex.c++ in Sources */ = {isa = PBXBuildFile; fileRef = BE11832F05D6FE3800EB53E5 /* PThreadMutex.c++ */; }; + BE11837D05D7083B00EB53E5 /* Barrier in Headers */ = {isa = PBXBuildFile; fileRef = BE11836E05D7082A00EB53E5 /* Barrier */; settings = {ATTRIBUTES = (Public, ); }; }; + BE11837E05D7083B00EB53E5 /* Condition in Headers */ = {isa = PBXBuildFile; fileRef = BE11836F05D7082A00EB53E5 /* Condition */; settings = {ATTRIBUTES = (Public, ); }; }; + BE11837F05D7083B00EB53E5 /* Exports in Headers */ = {isa = PBXBuildFile; fileRef = BE11837005D7082A00EB53E5 /* Exports */; settings = {ATTRIBUTES = (Public, ); }; }; + BE11838005D7083B00EB53E5 /* Mutex in Headers */ = {isa = PBXBuildFile; fileRef = BE11837105D7082A00EB53E5 /* Mutex */; settings = {ATTRIBUTES = (Public, ); }; }; + BE11838105D7083B00EB53E5 /* ScopedLock in Headers */ = {isa = PBXBuildFile; fileRef = BE11837205D7082A00EB53E5 /* ScopedLock */; settings = {ATTRIBUTES = (Public, ); }; }; + BE11838205D7083B00EB53E5 /* Thread in Headers */ = {isa = PBXBuildFile; fileRef = BE11837305D7082A00EB53E5 /* Thread */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 00DAF8A70BBE1A0E00EFEB98 /* Block */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = Block; path = ../../include/OpenThreads/Block; sourceTree = SOURCE_ROOT; }; + 00DAF8A80BBE1A0E00EFEB98 /* ReadWriteMutex */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = ReadWriteMutex; path = ../../include/OpenThreads/ReadWriteMutex; sourceTree = SOURCE_ROOT; }; + 00DAF8A90BBE1A0E00EFEB98 /* ReentrantMutex */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = ReentrantMutex; path = ../../include/OpenThreads/ReentrantMutex; sourceTree = SOURCE_ROOT; }; + 089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; + 08FB77AAFE841565C02AAC07 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; }; + 32BAE0B70371A74B00C91783 /* OpenThreads_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenThreads_Prefix.pch; sourceTree = SOURCE_ROOT; }; + 8D07F2C70486CC7A007CD1D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; + 8D07F2C80486CC7A007CD1D0 /* OpenThreads.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OpenThreads.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + BE11832A05D6FE3800EB53E5 /* PThread.c++ */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = "PThread.c++"; path = "../../pthread_src/PThread.c++"; sourceTree = SOURCE_ROOT; }; + BE11832B05D6FE3800EB53E5 /* PThreadBarrier.c++ */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = "PThreadBarrier.c++"; path = "../../pthread_src/PThreadBarrier.c++"; sourceTree = SOURCE_ROOT; }; + BE11832C05D6FE3800EB53E5 /* PThreadBarrierPrivateData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PThreadBarrierPrivateData.h; path = ../../pthread_src/PThreadBarrierPrivateData.h; sourceTree = SOURCE_ROOT; }; + BE11832D05D6FE3800EB53E5 /* PThreadCondition.c++ */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = "PThreadCondition.c++"; path = "../../pthread_src/PThreadCondition.c++"; sourceTree = SOURCE_ROOT; }; + BE11832E05D6FE3800EB53E5 /* PThreadConditionPrivateData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PThreadConditionPrivateData.h; path = ../../pthread_src/PThreadConditionPrivateData.h; sourceTree = SOURCE_ROOT; }; + BE11832F05D6FE3800EB53E5 /* PThreadMutex.c++ */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = "PThreadMutex.c++"; path = "../../pthread_src/PThreadMutex.c++"; sourceTree = SOURCE_ROOT; }; + BE11833005D6FE3800EB53E5 /* PThreadMutexPrivateData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PThreadMutexPrivateData.h; path = ../../pthread_src/PThreadMutexPrivateData.h; sourceTree = SOURCE_ROOT; }; + BE11833105D6FE3800EB53E5 /* PThreadPrivateData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PThreadPrivateData.h; path = ../../pthread_src/PThreadPrivateData.h; sourceTree = SOURCE_ROOT; }; + BE11836E05D7082A00EB53E5 /* Barrier */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 30; name = Barrier; path = ../../include/OpenThreads/Barrier; sourceTree = SOURCE_ROOT; }; + BE11836F05D7082A00EB53E5 /* Condition */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 30; name = Condition; path = ../../include/OpenThreads/Condition; sourceTree = SOURCE_ROOT; }; + BE11837005D7082A00EB53E5 /* Exports */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 30; name = Exports; path = ../../include/OpenThreads/Exports; sourceTree = SOURCE_ROOT; }; + BE11837105D7082A00EB53E5 /* Mutex */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 30; name = Mutex; path = ../../include/OpenThreads/Mutex; sourceTree = SOURCE_ROOT; }; + BE11837205D7082A00EB53E5 /* ScopedLock */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 30; name = ScopedLock; path = ../../include/OpenThreads/ScopedLock; sourceTree = SOURCE_ROOT; }; + BE11837305D7082A00EB53E5 /* Thread */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 30; name = Thread; path = ../../include/OpenThreads/Thread; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D07F2C30486CC7A007CD1D0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D07F2C40486CC7A007CD1D0 /* Carbon.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 034768DDFF38A45A11DB9C8B /* Products */ = { + isa = PBXGroup; + children = ( + 8D07F2C80486CC7A007CD1D0 /* OpenThreads.framework */, + ); + name = Products; + sourceTree = "<group>"; + }; + 0867D691FE84028FC02AAC07 /* OpenThreads */ = { + isa = PBXGroup; + children = ( + BE11833F05D7005800EB53E5 /* Header */, + 08FB77ACFE841707C02AAC07 /* Source */, + 089C1665FE841158C02AAC07 /* Resources */, + 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */, + 034768DDFF38A45A11DB9C8B /* Products */, + ); + name = OpenThreads; + sourceTree = "<group>"; + }; + 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 08FB77AAFE841565C02AAC07 /* Carbon.framework */, + ); + name = "External Frameworks and Libraries"; + sourceTree = "<group>"; + }; + 089C1665FE841158C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + 8D07F2C70486CC7A007CD1D0 /* Info.plist */, + 089C1666FE841158C02AAC07 /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = "<group>"; + }; + 08FB77ACFE841707C02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + BE11832A05D6FE3800EB53E5 /* PThread.c++ */, + BE11832B05D6FE3800EB53E5 /* PThreadBarrier.c++ */, + BE11832C05D6FE3800EB53E5 /* PThreadBarrierPrivateData.h */, + BE11832D05D6FE3800EB53E5 /* PThreadCondition.c++ */, + BE11832E05D6FE3800EB53E5 /* PThreadConditionPrivateData.h */, + BE11832F05D6FE3800EB53E5 /* PThreadMutex.c++ */, + BE11833005D6FE3800EB53E5 /* PThreadMutexPrivateData.h */, + BE11833105D6FE3800EB53E5 /* PThreadPrivateData.h */, + 32BAE0B70371A74B00C91783 /* OpenThreads_Prefix.pch */, + ); + name = Source; + sourceTree = "<group>"; + }; + BE11833F05D7005800EB53E5 /* Header */ = { + isa = PBXGroup; + children = ( + BE11835905D7027D00EB53E5 /* OpenThreads */, + ); + name = Header; + sourceTree = "<group>"; + }; + BE11835905D7027D00EB53E5 /* OpenThreads */ = { + isa = PBXGroup; + children = ( + BE11836E05D7082A00EB53E5 /* Barrier */, + 00DAF8A70BBE1A0E00EFEB98 /* Block */, + BE11836F05D7082A00EB53E5 /* Condition */, + BE11837005D7082A00EB53E5 /* Exports */, + BE11837105D7082A00EB53E5 /* Mutex */, + 00DAF8A80BBE1A0E00EFEB98 /* ReadWriteMutex */, + 00DAF8A90BBE1A0E00EFEB98 /* ReentrantMutex */, + BE11837205D7082A00EB53E5 /* ScopedLock */, + BE11837305D7082A00EB53E5 /* Thread */, + ); + name = OpenThreads; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 8D07F2BD0486CC7A007CD1D0 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 00DAF8AA0BBE1A0E00EFEB98 /* Block in Headers */, + 00DAF8AB0BBE1A0F00EFEB98 /* ReadWriteMutex in Headers */, + 00DAF8AC0BBE1A0F00EFEB98 /* ReentrantMutex in Headers */, + BE11837D05D7083B00EB53E5 /* Barrier in Headers */, + BE11837E05D7083B00EB53E5 /* Condition in Headers */, + BE11837F05D7083B00EB53E5 /* Exports in Headers */, + BE11838005D7083B00EB53E5 /* Mutex in Headers */, + BE11838105D7083B00EB53E5 /* ScopedLock in Headers */, + BE11838205D7083B00EB53E5 /* Thread in Headers */, + 8D07F2BE0486CC7A007CD1D0 /* OpenThreads_Prefix.pch in Headers */, + BE11833405D6FE3900EB53E5 /* PThreadBarrierPrivateData.h in Headers */, + BE11833605D6FE3900EB53E5 /* PThreadConditionPrivateData.h in Headers */, + BE11833805D6FE3900EB53E5 /* PThreadMutexPrivateData.h in Headers */, + BE11833905D6FE3900EB53E5 /* PThreadPrivateData.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 8D07F2BC0486CC7A007CD1D0 /* OpenThreads */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0011012F0873634F0015C576 /* Build configuration list for PBXNativeTarget "OpenThreads" */; + buildPhases = ( + 8D07F2BD0486CC7A007CD1D0 /* Headers */, + 8D07F2BF0486CC7A007CD1D0 /* Resources */, + 8D07F2C10486CC7A007CD1D0 /* Sources */, + 8D07F2C30486CC7A007CD1D0 /* Frameworks */, + 8D07F2C50486CC7A007CD1D0 /* Rez */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = OpenThreads; + productInstallPath = "$(HOME)/Library/Frameworks"; + productName = OpenThreads; + productReference = 8D07F2C80486CC7A007CD1D0 /* OpenThreads.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0867D690FE84028FC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 001101330873634F0015C576 /* Build configuration list for PBXProject "OpenThreads" */; + hasScannedForEncodings = 1; + mainGroup = 0867D691FE84028FC02AAC07 /* OpenThreads */; + productRefGroup = 034768DDFF38A45A11DB9C8B /* Products */; + projectDirPath = ""; + targets = ( + 8D07F2BC0486CC7A007CD1D0 /* OpenThreads */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D07F2BF0486CC7A007CD1D0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D07F2C00486CC7A007CD1D0 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXRezBuildPhase section */ + 8D07F2C50486CC7A007CD1D0 /* Rez */ = { + isa = PBXRezBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXRezBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D07F2C10486CC7A007CD1D0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BE11835105D7022C00EB53E5 /* PThread.c++ in Sources */, + BE11835205D7022C00EB53E5 /* PThreadBarrier.c++ in Sources */, + BE11835405D7022C00EB53E5 /* PThreadCondition.c++ in Sources */, + BE11835605D7022C00EB53E5 /* PThreadMutex.c++ in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C1666FE841158C02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C1667FE841158C02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = "<group>"; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 001101300873634F0015C576 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + DEBUGGING_SYMBOLS = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_VERSION = A; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_ENABLE_TRIGRAPHS = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = OpenThreads_Prefix.pch; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; + GCC_WARN_UNKNOWN_PRAGMAS = NO; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_STYLE = Dynamic; + MACH_O_TYPE = mh_dylib; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ( + "-seg1addr", + 0x1FF00000, + ); + PRODUCT_NAME = OpenThreads; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = framework; + ZERO_LINK = YES; + }; + name = Development; + }; + 001101310873634F0015C576 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_VERSION = A; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_ENABLE_TRIGRAPHS = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = OpenThreads_Prefix.pch; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; + GCC_WARN_UNKNOWN_PRAGMAS = NO; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_STYLE = Dynamic; + MACH_O_TYPE = mh_dylib; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ( + "-seg1addr", + 0x1FF00000, + ); + PRODUCT_NAME = OpenThreads; + SECTORDER_FLAGS = ""; + STRIP_INSTALLED_PRODUCT = YES; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = framework; + ZERO_LINK = NO; + }; + name = Deployment; + }; + 001101320873634F0015C576 /* Default */ = { + isa = XCBuildConfiguration; + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_VERSION = A; + GCC_ENABLE_TRIGRAPHS = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = OpenThreads_Prefix.pch; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; + GCC_WARN_UNKNOWN_PRAGMAS = NO; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_STYLE = Dynamic; + MACH_O_TYPE = mh_dylib; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ( + "-seg1addr", + 0x1FF00000, + ); + PRODUCT_NAME = OpenThreads; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = ( + "-Wmost", + "-Wno-four-char-constants", + "-Wno-unknown-pragmas", + ); + WRAPPER_EXTENSION = framework; + }; + name = Default; + }; + 001101340873634F0015C576 /* Development */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + GCC_AUTO_VECTORIZATION = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + HEADER_SEARCH_PATHS = ( + ../../include, + "$(inherited)", + ); + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + STRIP_STYLE = "non-global"; + }; + name = Development; + }; + 001101350873634F0015C576 /* Deployment */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + DEPLOYMENT_POSTPROCESSING = YES; + GCC_AUTO_VECTORIZATION = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = s; + HEADER_SEARCH_PATHS = ../../include; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + STRIP_STYLE = "non-global"; + }; + name = Deployment; + }; + 001101360873634F0015C576 /* Default */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + GCC_AUTO_VECTORIZATION = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 3; + HEADER_SEARCH_PATHS = ../../include; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + STRIP_STYLE = "non-global"; + }; + name = Default; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0011012F0873634F0015C576 /* Build configuration list for PBXNativeTarget "OpenThreads" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 001101300873634F0015C576 /* Development */, + 001101310873634F0015C576 /* Deployment */, + 001101320873634F0015C576 /* Default */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Default; + }; + 001101330873634F0015C576 /* Build configuration list for PBXProject "OpenThreads" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 001101340873634F0015C576 /* Development */, + 001101350873634F0015C576 /* Deployment */, + 001101360873634F0015C576 /* Default */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Default; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0867D690FE84028FC02AAC07 /* Project object */; +} diff --git a/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads_Prefix.pch b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads_Prefix.pch new file mode 100755 index 0000000000000000000000000000000000000000..8b6324940b1440bf3d5f59ec927484fe4a2a6486 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/OpenThreads_Prefix.pch @@ -0,0 +1,5 @@ +// +// Prefix header for all source files of the 'OpenThreads' target in the 'OpenThreads' project. +// + +//#include <Carbon/Carbon.h> diff --git a/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/version.plist b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/version.plist new file mode 100755 index 0000000000000000000000000000000000000000..169b5fae845c224c489d08adbc33ad99b5832d2b --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/Xcode/OpenThreads/version.plist @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>BuildVersion</key> + <string>38</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>ProjectName</key> + <string>CarbonProjectTemplates</string> + <key>SourceVersion</key> + <string>140000</string> +</dict> +</plist> diff --git a/Utilities/otbopenthreads/OpenThreads/bin/README b/Utilities/otbopenthreads/OpenThreads/bin/README new file mode 100755 index 0000000000000000000000000000000000000000..a72608a960be88bc365f820ef9778d507af31029 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/bin/README @@ -0,0 +1,3 @@ +This is where all the binaries go. +This file exists to keep CVS from deleting +the directory. diff --git a/Utilities/otbopenthreads/OpenThreads/docs/doxyfile b/Utilities/otbopenthreads/OpenThreads/docs/doxyfile new file mode 100755 index 0000000000000000000000000000000000000000..f0bcb39cf9c4b985b97bb7f4f4c25074a49ee91f --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/docs/doxyfile @@ -0,0 +1,1213 @@ +# Doxyfile 1.4.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "OpenThread Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 1.0 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = . + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, +# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, +# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, +# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, +# Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. + +SHOW_DIRECTORIES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the progam writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../include + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm + +FILE_PATTERNS = * + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = YES + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that a graph may be further truncated if the graph's +# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH +# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), +# the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO + diff --git a/Utilities/otbopenthreads/OpenThreads/docs/doxyfile.cmake b/Utilities/otbopenthreads/OpenThreads/docs/doxyfile.cmake new file mode 100755 index 0000000000000000000000000000000000000000..842d4b2081d850ba8dbb79639bd4c77006ba21d4 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/docs/doxyfile.cmake @@ -0,0 +1,1219 @@ +# Doxyfile 1.4.2 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "OpenThread Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 1.0 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/docs + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, +# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, +# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, +# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, +# Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. + +SHOW_DIRECTORIES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the progam writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = "@CMAKE_SOURCE_DIR@/include/OpenThreads" + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm + +#FILE_PATTERNS = *.h +FILE_PATTERNS = * + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = @DOT_PATH@ + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that a graph may be further truncated if the graph's +# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH +# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), +# the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/Utilities/otbopenthreads/OpenThreads/examples/GNUmakefile b/Utilities/otbopenthreads/OpenThreads/examples/GNUmakefile new file mode 100755 index 0000000000000000000000000000000000000000..85e81df57e176bf48a6a68840402bdf11bc022ba --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/GNUmakefile @@ -0,0 +1,13 @@ +TOPDIR = .. +include $(TOPDIR)/Make/makedirdefs +include $(TOPDIR)/Make/makedefs + +DIRS = simplethreader\ + workcrew \ + $(NULL) + +include $(TOPDIR)/Make/makedirrules +include $(TOPDIR)/Make/docrules +include $(TOPDIR)/Make/instrules +include $(TOPDIR)/Make/distrules +include $(TOPDIR)/Make/helprules diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/GNUmakefile b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/GNUmakefile new file mode 100755 index 0000000000000000000000000000000000000000..5e48eec174ace4bc6a75854c0c5e0f1cc526456c --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/GNUmakefile @@ -0,0 +1,15 @@ +TOPDIR = ../../. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + ThreadObserver.cpp \ + ThreadReporter.cpp \ + SimpleThreader.cpp \ + $(NULL) + +INC += -I$(TOPDIR)/include +LIBS += -lOpenThreads + +EXEC = SimpleThreader + +include $(TOPDIR)/Make/makerules \ No newline at end of file diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/SimpleThreader.cpp b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/SimpleThreader.cpp new file mode 100755 index 0000000000000000000000000000000000000000..0812bcc95206921dd97c2ba05c176c6293a0936e --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/SimpleThreader.cpp @@ -0,0 +1,228 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include <sys/types.h> +#include <cassert> +#include <cstdio> +#include <iostream> +#include <vector> +#include <OpenThreads/Thread> +#include <OpenThreads/Mutex> +#include <OpenThreads/Barrier> +#include "ThreadObserver.h" +#include "ThreadReporter.h" + +#ifdef _WIN32 +#include <process.h> +#define getpid() _getpid() +#else +#include <unistd.h> +#endif + +OpenThreads::Barrier bar; + +int GLOBAL_NUM_THREADS; + +//----------------------------------------------------------------------------- +// Custom Thread Observer (w/finished count) +// +class MyThreadObserver : public ThreadObserver { + +public: + + MyThreadObserver() : ThreadObserver(), _finishedCount(0) {}; + + virtual ~MyThreadObserver() {}; + + void threadFinished(const int threadId) { + + ThreadObserver::threadFinished(threadId); + + ++_finishedCount; + } + + int getFinishedCount() {return _finishedCount;}; + + +private: + + volatile int _finishedCount; + +}; + +// check the working of OpenThreads::Thread::CurrentThread() +static OpenThreads::Thread* CurrentChecker(){ + return OpenThreads::Thread::CurrentThread(); +}; + +//----------------------------------------------------------------------------- +// Custom thread class - with reporting +// +class MyThread : public OpenThreads::Thread, public ThreadReporter { + +public: + + MyThread(int *dataPtr, int numElts) : OpenThreads::Thread(), + ThreadReporter(), + _dataPtr(dataPtr), _numElts(numElts), _quitflag(false) {}; + + virtual ~MyThread() {}; + + virtual void run() { + + if( CurrentChecker()!=this) + notifyObserversMessage(getThreadId(), "Thread::CurrentThread is NOT working"); + else + notifyObserversMessage(getThreadId(), "Thread::CurrentThread is working"); + + + bar.block(GLOBAL_NUM_THREADS); // Sync the threads. + + char tmp[80]; + sprintf(tmp, "StackSize: %d\n", static_cast<int>(getStackSize())); + + notifyObserversStarted(getThreadId()); + notifyObserversMessage(getThreadId(), "This is a thread message."); + notifyObserversMessage(getThreadId(), tmp); + + register int i; + for (i=0; i<_numElts; ++i) { + _dataPtr[i] = getThreadId(); + } + + notifyObserversMessage(getThreadId(), "Finished my work"); + + bar.block(GLOBAL_NUM_THREADS); // Sync the threads. + + //--------------------------------------------------------------------- + // Now that we've done our work, wait for a sign that we should quit. + // + while (true) { + + _quitmutex.lock(); + if(_quitflag == true) break; + _quitmutex.unlock(); + + OpenThreads::Thread::YieldCurrentThread(); + } + + + notifyObserversFinished(getThreadId()); + + } + + void quit() { + + _quitmutex.lock(); + _quitflag = true; + _quitmutex.unlock(); + + } + +private: + + int *_dataPtr; + + int _numElts; + + volatile bool _quitflag; + + OpenThreads::Mutex _quitmutex; +}; + + +int main(int argc, char **argv) { + + if(argc != 3) { + std::cout << "Usage: simpleThreader [NUM_ELTS] [NUM_THREADS] " + << std::endl; + return 0; + }; + + std::cout << "Root Thread ID: " << getpid() << std::endl; + + int NUM_ELTS = atoi(argv[1]); + int NUM_THREADS = atoi(argv[2]); + + GLOBAL_NUM_THREADS = NUM_THREADS + 1; + + MyThreadObserver observer; + register int i; + + int *dataArray = new int[NUM_ELTS]; + std::vector<MyThread *> threads; + + for(i=0; i<NUM_ELTS; ++i) { + + dataArray[i] = -1; + } + + OpenThreads::Thread::SetConcurrency(NUM_THREADS); + + OpenThreads::Thread::Init(); + for(i=0; i<NUM_THREADS; ++i) { + int status; + MyThread *thread = new MyThread(dataArray + (i*(NUM_ELTS/NUM_THREADS)), + NUM_ELTS/NUM_THREADS); + threads.push_back(thread); + thread->addObserver(&observer); + thread->setStackSize(1024*256); + status = thread->start(); + assert(status == 0); + } + + bar.block(GLOBAL_NUM_THREADS); // Block 'till ready + bar.block(GLOBAL_NUM_THREADS); // Block 'till finished + + char val; + std::cout << "Press any key + return to quit." << std::endl; + std::cin >> val; + + // Notify the threads to quit, wait for this to happen. + for(i=0;i<static_cast<int>(threads.size());++i) { + MyThread *thread = threads[i]; + thread->quit(); + } + + while(observer.getFinishedCount() != NUM_THREADS) { + // Spin our wheels. + } + + std::cout << "Data Array: " << std::endl; + for(i=0; i < NUM_THREADS; ++i) { + register int j; + for (j=0; j<NUM_ELTS/NUM_THREADS; ++j) { + std::cout << dataArray[(i*NUM_ELTS/NUM_THREADS)+j] << " "; + } + std::cout << std::endl; + } + std::cout << std::endl; + + // Delete all the threads. + for(i=0;i<static_cast<int>(threads.size());++i) { + MyThread *thread = threads[i]; + delete thread; + } + + threads.clear(); + + delete [] dataArray; + + return 0; +} + diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadObserver.cpp b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadObserver.cpp new file mode 100755 index 0000000000000000000000000000000000000000..1c7e01b1682040da0f05ee564ccfe1e9fb2fa3ed --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadObserver.cpp @@ -0,0 +1,45 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include <cstdio> +#include "ThreadObserver.h" + +void ThreadObserver::threadStarted(const int threadId) { + + printf("Thread %d started.\n", threadId); + +} + +void ThreadObserver::threadFinished(const int threadId) { + + printf("Thread %d finished.\n", threadId); + +} + +void ThreadObserver::threadMessage(const int threadId, const char *message) { + + printf("Thread Message (%d) : %s\n", threadId, message); + +} + +void ThreadObserver::threadError(const int threadId, + const char *errorMessage) { + + printf("Thread Message (%d) : %s\n", threadId, errorMessage); + +} diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadObserver.h b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadObserver.h new file mode 100755 index 0000000000000000000000000000000000000000..231023a37d6a01d3f4152dfa50221cf947b27fb3 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadObserver.h @@ -0,0 +1,45 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadObserver.h - provide a basic thread observer class +// ~~~~~~~~~~~~~~~~ +// + +#ifndef _THREADOBSERVER_H_ +#define _THREADOBSERVER_H_ + +class ThreadObserver { + +public: + + ThreadObserver() {}; + + virtual ~ThreadObserver() {}; + + virtual void threadStarted (const int threadId); + + virtual void threadFinished(const int threadId); + + virtual void threadMessage(const int threadId, const char *message); + + virtual void threadError(const int threadId, const char *errorMessage); + +}; + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadReporter.cpp b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadReporter.cpp new file mode 100755 index 0000000000000000000000000000000000000000..176915c25768e910cfc12f49ad942d1ae5d549fc --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadReporter.cpp @@ -0,0 +1,135 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadReporter - Basic Thread Reporter class. +// ~~~~~~~~~~~~~~~ +// + +#include "ThreadReporter.h" + +//----------------------------------------------------------------------------- +// +// Description: Constructor +// +// Use: public +// +ThreadReporter::ThreadReporter() { + _observers.clear(); +} + +//----------------------------------------------------------------------------- +// +// Description: Destructor +// +// Use: public +// +ThreadReporter::~ThreadReporter() { + _observers.clear(); +} + +//----------------------------------------------------------------------------- +// +// Description: Add an observer to the list +// +// Use: public +// +void ThreadReporter::addObserver(ThreadObserver *observer) { + + _observers.push_back(observer); + +} + +//----------------------------------------------------------------------------- +// +// Description: Remove an observer from the list +// +// Use: public +// +void ThreadReporter::removeObserver(ThreadObserver *observer) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + if(*iter == observer) { + _observers.erase(iter); + return; + } + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers the thread has started +// +// Use: protected +// +void ThreadReporter::notifyObserversStarted(const int threadId) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadStarted(threadId); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers the thread has finished +// +// Use: protected +// +void ThreadReporter::notifyObserversFinished(const int threadId) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadFinished(threadId); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers of a thread message +// +// Use: protected +// +void ThreadReporter::notifyObserversMessage(const int threadId, + const char *message) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadMessage(threadId, message); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers of a thread error +// +// Use: protected +// +void ThreadReporter::notifyObserversError(const int threadId, + const char *errorMessage) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadError(threadId, errorMessage); + } +} diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadReporter.h b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadReporter.h new file mode 100755 index 0000000000000000000000000000000000000000..cee9830cdbfe970f03cb41efb03146f66e3a6b87 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/ThreadReporter.h @@ -0,0 +1,69 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadReporter - Basic thread reporter class. +// ~~~~~~~~~~~~~~~ +// + +#ifndef _THREADREPORTER_H_ +#define _THREADREPORTER_H_ + +/* +#ifdef _WIN32 +#ifndef _WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#endif +#endif +*/ + +#include <list> +#include "ThreadObserver.h" + +using std::list; + +class ThreadReporter { + +public: + + ThreadReporter(); + + virtual ~ThreadReporter(); + + void addObserver(ThreadObserver *observer); + + void removeObserver(ThreadObserver *observer); + +protected: + + void notifyObserversStarted(const int threadId); + + void notifyObserversFinished(const int threadId); + + void notifyObserversMessage(const int threadId, const char *message); + + void notifyObserversError(const int threadId, const char *errorMessage); + +private: + + list<ThreadObserver *> _observers; + +}; + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/simplethreader.dsp b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/simplethreader.dsp new file mode 100755 index 0000000000000000000000000000000000000000..378f419d60a19e9878853fcfb18885f858782c12 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/simplethreader.dsp @@ -0,0 +1,117 @@ +# Microsoft Developer Studio Project File - Name="simplethreader" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=simplethreader - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "simplethreader.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "simplethreader.mak" CFG="simplethreader - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "simplethreader - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "simplethreader - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "simplethreader - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x41a /d "NDEBUG" +# ADD RSC /l 0x41a /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "simplethreader - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x41a /d "_DEBUG" +# ADD RSC /l 0x41a /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "simplethreader - Win32 Release" +# Name "simplethreader - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;c++" +# Begin Source File + +SOURCE=.\SimpleThreader.cpp +# End Source File +# Begin Source File + +SOURCE=.\ThreadObserver.cpp +# End Source File +# Begin Source File + +SOURCE=.\ThreadReporter.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\ThreadObserver.h +# End Source File +# Begin Source File + +SOURCE=.\ThreadReporter.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/simplethreader.plg b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/simplethreader.plg new file mode 100755 index 0000000000000000000000000000000000000000..64e0105afba32f139a94900480840590a724fddd --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/simplethreader/simplethreader.plg @@ -0,0 +1,36 @@ +<html> +<body> +<pre> +<h1>Build Log</h1> +<h3> +--------------------Configuration: simplethreader - Win32 Debug-------------------- +</h3> +<h3>Command Lines</h3> +Creating temporary file "F:\DOCUME~1\BBRALO~1.REB\LOCALS~1\Temp\RSP110.tmp" with contents +[ +/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/simplethreader.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"F:\OpenThreads\OpenThreads\examples_src\simplethreader\SimpleThreader.cpp" +] +Creating command line "cl.exe @F:\DOCUME~1\BBRALO~1.REB\LOCALS~1\Temp\RSP110.tmp" +Creating temporary file "F:\DOCUME~1\BBRALO~1.REB\LOCALS~1\Temp\RSP111.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/simplethreader.pdb" /debug /machine:I386 /out:"Debug/simplethreader.exe" /pdbtype:sept +.\Debug\ThreadReporter.obj +.\Debug\ThreadObserver.obj +.\Debug\SimpleThreader.obj +] +Creating command line "link.exe @F:\DOCUME~1\BBRALO~1.REB\LOCALS~1\Temp\RSP111.tmp" +<h3>Output Window</h3> +Compiling... +SimpleThreader.cpp +F:\OpenThreads\OpenThreads\examples_src\simplethreader\SimpleThreader.cpp(197) : warning C4018: '<' : signed/unsigned mismatch +F:\OpenThreads\OpenThreads\examples_src\simplethreader\SimpleThreader.cpp(217) : warning C4018: '<' : signed/unsigned mismatch +Linking... + + + +<h3>Results</h3> +simplethreader.exe - 0 error(s), 2 warning(s) +</pre> +</body> +</html> diff --git a/Utilities/otbopenthreads/OpenThreads/examples/workcrew/GNUmakefile b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/GNUmakefile new file mode 100755 index 0000000000000000000000000000000000000000..288c89b1b253078ff07f232c6ff841b25a1a114e --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/GNUmakefile @@ -0,0 +1,15 @@ +TOPDIR = ../../. +include $(TOPDIR)/Make/makedefs + +C++FILES =\ + ThreadObserver.c++ \ + ThreadReporter.c++ \ + WorkCrew.c++ \ + $(NULL) + +INC += -I$(TOPDIR)/include -I. +LIBS += -lOpenThreads + +EXEC = WorkCrew + +include $(TOPDIR)/Make/makerules \ No newline at end of file diff --git a/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadObserver.c++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadObserver.c++ new file mode 100755 index 0000000000000000000000000000000000000000..1c7e01b1682040da0f05ee564ccfe1e9fb2fa3ed --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadObserver.c++ @@ -0,0 +1,45 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include <cstdio> +#include "ThreadObserver.h" + +void ThreadObserver::threadStarted(const int threadId) { + + printf("Thread %d started.\n", threadId); + +} + +void ThreadObserver::threadFinished(const int threadId) { + + printf("Thread %d finished.\n", threadId); + +} + +void ThreadObserver::threadMessage(const int threadId, const char *message) { + + printf("Thread Message (%d) : %s\n", threadId, message); + +} + +void ThreadObserver::threadError(const int threadId, + const char *errorMessage) { + + printf("Thread Message (%d) : %s\n", threadId, errorMessage); + +} diff --git a/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadObserver.h b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadObserver.h new file mode 100755 index 0000000000000000000000000000000000000000..231023a37d6a01d3f4152dfa50221cf947b27fb3 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadObserver.h @@ -0,0 +1,45 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadObserver.h - provide a basic thread observer class +// ~~~~~~~~~~~~~~~~ +// + +#ifndef _THREADOBSERVER_H_ +#define _THREADOBSERVER_H_ + +class ThreadObserver { + +public: + + ThreadObserver() {}; + + virtual ~ThreadObserver() {}; + + virtual void threadStarted (const int threadId); + + virtual void threadFinished(const int threadId); + + virtual void threadMessage(const int threadId, const char *message); + + virtual void threadError(const int threadId, const char *errorMessage); + +}; + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadReporter.c++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadReporter.c++ new file mode 100755 index 0000000000000000000000000000000000000000..176915c25768e910cfc12f49ad942d1ae5d549fc --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadReporter.c++ @@ -0,0 +1,135 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadReporter - Basic Thread Reporter class. +// ~~~~~~~~~~~~~~~ +// + +#include "ThreadReporter.h" + +//----------------------------------------------------------------------------- +// +// Description: Constructor +// +// Use: public +// +ThreadReporter::ThreadReporter() { + _observers.clear(); +} + +//----------------------------------------------------------------------------- +// +// Description: Destructor +// +// Use: public +// +ThreadReporter::~ThreadReporter() { + _observers.clear(); +} + +//----------------------------------------------------------------------------- +// +// Description: Add an observer to the list +// +// Use: public +// +void ThreadReporter::addObserver(ThreadObserver *observer) { + + _observers.push_back(observer); + +} + +//----------------------------------------------------------------------------- +// +// Description: Remove an observer from the list +// +// Use: public +// +void ThreadReporter::removeObserver(ThreadObserver *observer) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + if(*iter == observer) { + _observers.erase(iter); + return; + } + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers the thread has started +// +// Use: protected +// +void ThreadReporter::notifyObserversStarted(const int threadId) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadStarted(threadId); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers the thread has finished +// +// Use: protected +// +void ThreadReporter::notifyObserversFinished(const int threadId) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadFinished(threadId); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers of a thread message +// +// Use: protected +// +void ThreadReporter::notifyObserversMessage(const int threadId, + const char *message) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadMessage(threadId, message); + } +} + +//----------------------------------------------------------------------------- +// +// Description: Notify the observers of a thread error +// +// Use: protected +// +void ThreadReporter::notifyObserversError(const int threadId, + const char *errorMessage) { + + std::list<ThreadObserver *>::iterator iter; + for(iter=_observers.begin(); iter != _observers.end(); ++iter) { + ThreadObserver *observer = static_cast<ThreadObserver *>(*iter); + observer->threadError(threadId, errorMessage); + } +} diff --git a/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadReporter.h b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadReporter.h new file mode 100755 index 0000000000000000000000000000000000000000..c66058f7651d2bf6d99ce08180254cbafb7af6be --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/ThreadReporter.h @@ -0,0 +1,58 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +// +// ThreadReporter - Basic thread reporter class. +// ~~~~~~~~~~~~~~~ +// + +#ifndef _THREADREPORTER_H_ +#define _THREADREPORTER_H_ + +#include <list> +#include "ThreadObserver.h" + +class ThreadReporter { + +public: + + ThreadReporter(); + + virtual ~ThreadReporter(); + + void addObserver(ThreadObserver *observer); + + void removeObserver(ThreadObserver *observer); + +protected: + + void notifyObserversStarted(const int threadId); + + void notifyObserversFinished(const int threadId); + + void notifyObserversMessage(const int threadId, const char *message); + + void notifyObserversError(const int threadId, const char *errorMessage); + +private: + + std::list<ThreadObserver *> _observers; + +}; + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/examples/workcrew/WorkCrew.c++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/WorkCrew.c++ new file mode 100755 index 0000000000000000000000000000000000000000..ee5ec1c3c3b104cdfcba789964f3feb28ae1f87f --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/examples/workcrew/WorkCrew.c++ @@ -0,0 +1,423 @@ +// +// OpenThread library, Copyright (C) 2002 - 2003 The Open Thread Group +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include <cstdio> +#include <sys/types.h> +#include <unistd.h> +#include <iostream> +#include <vector> +#include <cassert> +#include <cerrno> +#include "ThreadObserver.h" +#include "ThreadReporter.h" + +//----------------------------------------------------------------------------- +// For the threads +// +#include <OpenThreads/Thread> +#include <OpenThreads/Mutex> +#include <OpenThreads/Condition> +#include <OpenThreads/Barrier> + +extern int errno; + +#ifdef DEBUG +# define DPRINTF(arg) printf arg +#else +# define DPRINTF(arg) +#endif + + +//----------------------------------------------------------------------------- +// Create a data structure for the worker's to work on +// +struct WorkData { + + WorkData * next; // Next work item. + std::vector<float> datapts; // Data points. + +}; + +//----------------------------------------------------------------------------- +// Create a data structure for the crew. +// +struct Crew { + + int crewSize; // Number of workers in the crew. + long workCount; // Number of work items. + WorkData *first, *last; // First & last work items. + + OpenThreads::Mutex mutex; + OpenThreads::Condition go; + OpenThreads::Condition done; + OpenThreads::Barrier bar; + +}; + +class WorkerThread : public OpenThreads::Thread { + +public: + + WorkerThread(Crew *crew, float *workResult) : OpenThreads::Thread(), + _crew(crew), _result(workResult) { + + _bar = &_crew->bar; + _mutex = &_crew->mutex; + _go = &_crew->go; + _done = &_crew->done; + + }; + + virtual ~WorkerThread() {}; + +protected: + + virtual void run() { + + int status; + + DPRINTF(("Created Thread %d\n", getProcessId())); + + //--------------------------------------------------------------------- + // Block until all of the crew members are ready. + // + _bar->block(_crew->crewSize+1); + + DPRINTF(("Reving Thread %d\n", getProcessId())); + + //--------------------------------------------------------------------- + // Lock the crew mutex + // + status = _mutex->lock(); + DPRINTF(("Thread %d got lock\n", getProcessId())); + assert(status == 0); + + //--------------------------------------------------------------------- + // There will be no work to do when the crew members are created, + // so wait for the go signal. + // + while(_crew->workCount == 0) { + + DPRINTF(("Thread %d waiting to go\n", getProcessId())); + status = _go->wait(_mutex); + assert(status == 0); + + DPRINTF(("Thread %d going\n", getProcessId())); + } + + //--------------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + + //--------------------------------------------------------------------- + // While there's work to do, do it ! + // + while(true) { + + DPRINTF(("Thread %d entered while loop.\n", getProcessId())); + + //----------------------------------------------------------------- + // Lock the crew mutex + // + status = _mutex->lock(); + assert(status == 0); + + //----------------------------------------------------------------- + // Wait while there is nothing to do. If _crew->first == 0, + // there's no work. But if _crew->workCount == 0, we're done. + // + while(_crew->first == 0) { + + DPRINTF(("Thread %d waiting for work\n", getProcessId())); + + status = _go->wait(_mutex); + assert(status == 0); + + DPRINTF(("Thread %d woke, %#lx, %d\n", + getProcessId(), _crew->first, _crew->workCount)); + } + + //----------------------------------------------------------------- + // Remove and process a work item. + // + _work = _crew->first; + _crew->first = _work->next; + if(_crew->first == 0) { + _crew->last = 0; + }; + + DPRINTF(("Thread %d took, %#lx, leaves first %#lx, last %#lx\n", + getProcessId(), _work, _crew->first, _crew->last)); + + //----------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + //----------------------------------------------------------------- + // Okay, we have a work item, process it. + // + float proc_result = pr_processWork(); + + //----------------------------------------------------------------- + // Lock the crew mutex to decrement the work count, and + // update the result. + // + status = _mutex->lock(); + assert(status == 0); + + *(_result) += proc_result; + + --_crew->workCount; + + DPRINTF(("Thread %d decremented work count to %d\n", + getProcessId(), _crew->workCount)); + + if(_crew->workCount <= 0) { + DPRINTF(("Thread %d done.\n", getProcessId())); + + //------------------------------------------------------------- + // Signal that we have finished our job. + // + status = _done->broadcast(); + assert(status == 0); + + //------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + break; + } + + //---------------------------------------------------------------- + // unlock the crew mutex. + // + status = _mutex->unlock(); + assert(status == 0); + + } + + }; + +private: + + float pr_processWork() { + + //--------------------------------------------------------------------- + // Just take the numbers and add them + // + float result = 0; + register unsigned int i, j; + float total; + for(i=0; i<_work->datapts.size();++i) { + for(total=0, j=0; j<10000000; ++j) { +#if defined(WIN32) && !defined(__CYGWIN__) + total += double(rand()) / double(RAND_MAX); + total -= double(rand()) / double(RAND_MAX); +#else + total += drand48(); + total -= drand48(); +#endif + } + result += _work->datapts[i] + total; + result -= total; + } + + _work->next = 0; + delete _work; + _work = 0; + + return result; + + } + +private: + + WorkData *_work; + + Crew *_crew; + + OpenThreads::Mutex *_mutex; + + OpenThreads::Condition *_go; + + OpenThreads::Condition *_done; + + OpenThreads::Barrier *_bar; + + float *_result; + +}; + +int crew_create(Crew *crew, + float & result, std::vector<WorkerThread *> &workers) { + + int crew_index; + int status; + + //------------------------------------------------------------------------- + // Create the worker threads. + // + for(crew_index = 0; crew_index < crew->crewSize; ++crew_index) { + + WorkerThread *thread = new WorkerThread(crew, &result); + workers.push_back(thread); + status = thread->start(); + assert(status == 0); + + } + + crew->bar.block(crew->crewSize+1); + + return 0; +} + +int crew_start(Crew *crew) { + + + int status = 0; + + //------------------------------------------------------------------------- + // Lock the crew mutex + // + status = crew->mutex.lock(); + if(status != 0) { + DPRINTF(("Lock Error: %s\n", strerror(errno))); + } + assert(status == 0); + + DPRINTF(("Checking busy signal.\n")); + + //------------------------------------------------------------------------- + // If the crew is busy, wait 'till they're done. + // + while(crew->workCount > 0) { + + status = crew->done.wait(&(crew->mutex)); + if(status != 0) { + + status = crew->mutex.lock(); + return status; + } + } + + DPRINTF(("Crew not busy, creating some work data.\n")); + + errno = 0; + + //------------------------------------------------------------------------- + // Create some work data. + // + register int i; + for(i=0; i<4; ++i) { + WorkData *work = new WorkData; + work->datapts.push_back(10.0); + work->next = 0; + if(crew->first == 0) { + crew->first = work; + crew->last = work; + } else { + crew->last->next = work; + crew->last = work; + } + ++crew->workCount; + } + + DPRINTF(("Giving the go-ahead.\n")); + + status = crew->go.signal(); + if(status != 0) { + delete crew->first; + crew->first = NULL; + crew->workCount = 0; + status = crew->mutex.unlock(); + return status; + } + + DPRINTF(("Waiting on the crew to finish....\n")); + + while(crew->workCount > 0) { + + DPRINTF(("Work Count: %d\n", crew->workCount)); + status = crew->done.wait(&(crew->mutex)); + assert(status == 0); + } + + DPRINTF(("Crew finished.\n")); + + status = crew->mutex.unlock(); + assert(status == 0); + + return 0; +} + +int main (int argc, char **argv) { + + std::vector<WorkerThread *> workers; + + if(argc != 2) { + std::cout << "Usage: workCrew [NUM_THREADS] " << std::endl; + return 0; + }; + + const int NUM_THREADS = atoi(argv[1]); + + DPRINTF(("ROOT PID = %d\n", getpid())); + + Crew *crew = new Crew; + + crew->crewSize = NUM_THREADS; + crew->workCount = 0; + crew->first = 0; + crew->last = 0; + + float result = 0; + unsigned int status = crew_create(crew, result, workers); + assert(status == 0); + + status = crew_start(crew); + assert(status == 0); + + printf("FINAL RESULT: %f\n", result); + + for(status = 0; status < workers.size(); ++status) { + + WorkerThread *thread = workers[status]; + delete thread; + + } + workers.clear(); + + delete crew; +} + + + + + + + + + + diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Barrier b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Barrier new file mode 100755 index 0000000000000000000000000000000000000000..663d198f12fa93d3cc1eb644a756b81d6fef8283 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Barrier @@ -0,0 +1,100 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// Barrier - C++ barrier class +// ~~~~~~~ +// + +#ifndef _OPENTHREADS_BARRIER_ +#define _OPENTHREADS_BARRIER_ + +#include <OpenThreads/Exports> + +namespace OpenThreads { + + +/** + * @class Barrier + * @brief This class provides an object-oriented thread barrier interface + * + * @warning It is unwise to use the construct "Barrier barrier" in the + * global namespace on sgi's. The object "barrier" + * will confilict with the c-library sproc function "barrier" and + * unpredictable results may occur. You have been warned. + */ +class OPENTHREAD_EXPORT_DIRECTIVE Barrier { + +public: + + /** + * Constructor + */ + Barrier(int numThreads=0); + + /** + * Destructor + */ + virtual ~Barrier(); + + /** + * Reset the barrier to it's original state. + */ + virtual void reset(); + + /** + * Block until numThreads threads have entered the barrier. + */ + virtual void block(unsigned int numThreads=0); + + /** + * Release the barrier, now. + */ + virtual void release(); + + /** + * Return the number of threads currently blocked in the barrier, + * Return -1 if error. + */ + virtual int numThreadsCurrentlyBlocked(); + + + void invalidate(); + +private: + + /** + * Private copy constructor, to prevent tampering. + */ + Barrier(const Barrier &/*b*/) {}; + + /** + * Private copy assignment, to prevent tampering. + */ + Barrier &operator=(const Barrier &/*b*/) {return *(this);}; + + /** + * Implementation-specific private data. + */ + void *_prvData; + + + bool _valid; + +}; + +} + +#endif // !_OPENTHREADS_BARRIER_ + diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Block b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Block new file mode 100755 index 0000000000000000000000000000000000000000..f2ac3967884cb9e0635d1a25fdaa36e5f71e5e03 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Block @@ -0,0 +1,96 @@ +/* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef _OPENTHREADS_BLOCK_ +#define _OPENTHREADS_BLOCK_ + +#include <OpenThreads/Thread> +#include <OpenThreads/Barrier> +#include <OpenThreads/Condition> +#include <OpenThreads/ScopedLock> + +namespace OpenThreads { + +class Block +{ + public: + + Block(): + _released(false) {} + + ~Block() + { + release(); + } + + inline bool block() + { + ScopedLock<OpenThreads::Mutex> mutlock(_mut); + if( !_released ) + { + return _cond.wait(&_mut)==0; + } + else + { + return true; + } + } + + inline bool block(unsigned long timeout) + { + ScopedLock<OpenThreads::Mutex> mutlock(_mut); + if( !_released ) + { + return _cond.wait(&_mut, timeout)==0; + } + else + { + return true; + } + } + + inline void release() + { + ScopedLock<OpenThreads::Mutex> mutlock(_mut); + if (!_released) + { + _released = true; + _cond.broadcast(); + } + } + + inline void reset() + { + ScopedLock<OpenThreads::Mutex> mutlock(_mut); + _released = false; + } + + inline void set(bool doRelease) + { + if (doRelease!=_released) + { + if (doRelease) release(); + else reset(); + } + } + + protected: + + Mutex _mut; + Condition _cond; + bool _released; +}; + +} + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Condition b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Condition new file mode 100755 index 0000000000000000000000000000000000000000..454c079d3d7569d00ce352e9bd11a6d0b4048a33 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Condition @@ -0,0 +1,93 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// Condition - C++ condition class +// ~~~~~~~~~ +// + +#ifndef _OPENTHREADS_CONDITION_ +#define _OPENTHREADS_CONDITION_ + +#include <OpenThreads/Exports> +#include <OpenThreads/Mutex> + +namespace OpenThreads { + +/** + * @class Condition + * @brief This class provides an object-oriented thread condition interface. + */ +class OPENTHREAD_EXPORT_DIRECTIVE Condition { + +public: + + /** + * Constructor + */ + Condition(); + + /** + * Destructor + */ + virtual ~Condition(); + + /** + * Wait on a mutex. + */ + virtual int wait(Mutex *mutex); + + /** + * Wait on a mutex for a given amount of time (ms) + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + virtual int wait(Mutex *mutex, unsigned long int ms); + + /** + * Signal a SINGLE thread to wake if it's waiting. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + virtual int signal(); + + /** + * Wake all threads waiting on this condition. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + virtual int broadcast(); + +private: + + /** + * Private copy constructor, to prevent tampering. + */ + Condition(const Condition &/*c*/) {}; + + /** + * Private copy assignment, to prevent tampering. + */ + Condition &operator=(const Condition &/*c*/) {return *(this);}; + + /** + * Implementation-specific data + */ + void *_prvData; + +}; + +} + +#endif // !_OPENTHREADS_CONDITION_ diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Exports b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Exports new file mode 100755 index 0000000000000000000000000000000000000000..b388ee0799c77a8081b84f4e84c3b4576aa13fad --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Exports @@ -0,0 +1,43 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef _OPENTHREAD_EXPORTS_H_ +#define _OPENTHREAD_EXPORTS_H_ + + +#ifndef WIN32 + #define OPENTHREAD_EXPORT_DIRECTIVE +#else + #if defined( OT_LIBRARY_STATIC ) + #define OPENTHREAD_EXPORT_DIRECTIVE + #elif defined( OPENTHREADS_EXPORTS ) + #define OPENTHREAD_EXPORT_DIRECTIVE __declspec(dllexport) + #else + #define OPENTHREAD_EXPORT_DIRECTIVE __declspec(dllimport) + + #if 0 // Commented out for now + + #ifdef _MSC_VER + #ifdef _DEBUG + #pragma comment(lib ,"OpenThreadsWin32d") + #else + #pragma comment(lib, "OpenThreadsWin32") + #endif + #endif + #endif + #endif +#endif + +#endif + + diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Mutex b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Mutex new file mode 100755 index 0000000000000000000000000000000000000000..df8c4abf19017239510e61970e23e8201025dbc2 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Mutex @@ -0,0 +1,89 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// Mutex - C++ mutex class +// ~~~~~ +// + +#ifndef _OPENTHREADS_MUTEX_ +#define _OPENTHREADS_MUTEX_ + +#include <OpenThreads/Exports> + +namespace OpenThreads { + +/** + * @class Mutex + * @brief This class provides an object-oriented thread mutex interface. + */ +class OPENTHREAD_EXPORT_DIRECTIVE Mutex { + + friend class Condition; + +public: + + /** + * Constructor + */ + Mutex(); + + /** + * Destructor + */ + virtual ~Mutex(); + + /** + * Lock the mutex + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + virtual int lock(); + + /** + * Unlock the mutex + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + virtual int unlock(); + + /** + * Test if mutex can be locked. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + virtual int trylock(); + +private: + + /** + * Private copy constructor, to prevent tampering. + */ + Mutex(const Mutex &/*m*/) {}; + + /** + * Private copy assignment, to prevent tampering. + */ + Mutex &operator=(const Mutex &/*m*/) {return *(this);}; + + /** + * Implementation-specific private data. + */ + void *_prvData; + +}; + +} + +#endif // _OPENTHREADS_MUTEX_ diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ReadWriteMutex b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ReadWriteMutex new file mode 100755 index 0000000000000000000000000000000000000000..83bc75ddb97a67a36d3ec4732d580013a6d72ff9 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ReadWriteMutex @@ -0,0 +1,110 @@ +/* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef _OPENTHREADS_READWRITEMUTEX_ +#define _OPENTHREADS_READWRITEMUTEX_ + +#include <OpenThreads/Thread> +#include <OpenThreads/ReentrantMutex> + +namespace OpenThreads { + +class ReadWriteMutex +{ + public: + + ReadWriteMutex(): + _readCount(0) {} + + virtual ~ReadWriteMutex() {} + + virtual int readLock() + { + OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_readCountMutex); + int result = 0; + if (_readCount==0) + { + result = _readWriteMutex.lock(); + } + ++_readCount; + return result; + } + + + virtual int readUnlock() + { + OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_readCountMutex); + int result = 0; + if (_readCount>0) + { + --_readCount; + if (_readCount==0) + { + result = _readWriteMutex.unlock(); + } + } + return result; + } + + virtual int writeLock() + { + return _readWriteMutex.lock(); + } + + virtual int writeUnlock() + { + return _readWriteMutex.unlock(); + } + + protected: + + ReadWriteMutex(const ReadWriteMutex&) {} + ReadWriteMutex& operator = (const ReadWriteMutex&) { return *(this); } + +#if 0 + ReentrantMutex _readWriteMutex; + ReentrantMutex _readCountMutex; +#else + OpenThreads::Mutex _readWriteMutex; + OpenThreads::Mutex _readCountMutex; +#endif + unsigned int _readCount; + +}; + +class ScopedReadLock +{ + public: + + ScopedReadLock(ReadWriteMutex& mutex):_mutex(mutex) { _mutex.readLock(); } + ~ScopedReadLock() { _mutex.readUnlock(); } + + protected: + ReadWriteMutex& _mutex; +}; + + +class ScopedWriteLock +{ + public: + + ScopedWriteLock(ReadWriteMutex& mutex):_mutex(mutex) { _mutex.writeLock(); } + ~ScopedWriteLock() { _mutex.writeUnlock(); } + + protected: + ReadWriteMutex& _mutex; +}; + +} + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ReentrantMutex b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ReentrantMutex new file mode 100755 index 0000000000000000000000000000000000000000..8dae6a7aa774b078e1146aeaf46ceb9becd81692 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ReentrantMutex @@ -0,0 +1,125 @@ +/* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef _OPENTHREADS_REENTRANTMUTEX_ +#define _OPENTHREADS_REENTRANTMUTEX_ + +#include <OpenThreads/Thread> +#include <OpenThreads/Mutex> +#include <OpenThreads/ScopedLock> + +namespace OpenThreads { + +class ReentrantMutex : public OpenThreads::Mutex +{ + public: + + ReentrantMutex(): + _threadHoldingMutex(0), + _lockCount(0) {} + + virtual ~ReentrantMutex() {} + + virtual int lock() + { + if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread() && _lockCount>0) + { + OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_lockCountMutex); + ++_lockCount; + return 0; + } + else + { + int result = Mutex::lock(); + if (result==0) + { + OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_lockCountMutex); + + _threadHoldingMutex = OpenThreads::Thread::CurrentThread(); + _lockCount = 1; + } + return result; + } + } + + + virtual int unlock() + { + OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_lockCountMutex); + #if 0 + if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread() && _lockCount>0) + { + --_lockCount; + if (_lockCount<=0) + { + _threadHoldingMutex = 0; + return Mutex::unlock(); + } + } + else + { + osg::notify(osg::NOTICE)<<"Error: ReentrantMutex::unlock() - unlocking from the wrong thread."<<std::endl; + } + #else + if (_lockCount>0) + { + --_lockCount; + if (_lockCount<=0) + { + _threadHoldingMutex = 0; + return Mutex::unlock(); + } + } + #endif + return 0; + } + + + virtual int trylock() + { + if (_threadHoldingMutex==OpenThreads::Thread::CurrentThread() && _lockCount>0) + { + OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_lockCountMutex); + ++_lockCount; + return 0; + } + else + { + int result = Mutex::trylock(); + if (result==0) + { + OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_lockCountMutex); + + _threadHoldingMutex = OpenThreads::Thread::CurrentThread(); + _lockCount = 1; + } + return result; + } + } + + private: + + ReentrantMutex(const ReentrantMutex&):OpenThreads::Mutex() {} + + ReentrantMutex& operator =(const ReentrantMutex&) { return *(this); } + + OpenThreads::Thread* _threadHoldingMutex; + + OpenThreads::Mutex _lockCountMutex; + unsigned int _lockCount; + +}; + +} + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ScopedLock b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ScopedLock new file mode 100755 index 0000000000000000000000000000000000000000..fe84efa40ea24b2e523d1ce9de14c478e46645a4 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/ScopedLock @@ -0,0 +1,47 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// ScopedLock and ReverseScopedLock templates +// ~~~~~~~ +// +#ifndef _ScopedLock_ +#define _ScopedLock_ + +namespace OpenThreads{ + +template <class M> class ScopedLock +{ + private: + M& m_lock; + ScopedLock(const ScopedLock&); // prevent copy + ScopedLock& operator=(const ScopedLock&); // prevent assign + public: + explicit ScopedLock(M& m):m_lock(m) {m_lock.lock();} + ~ScopedLock(){m_lock.unlock();} +}; + +template <class M> class ReverseScopedLock +{ + private: + M& m_lock; + ReverseScopedLock(const ReverseScopedLock&); // prevent copy + ReverseScopedLock& operator=(const ReverseScopedLock&); // prevent assign + public: + explicit ReverseScopedLock(M& m):m_lock(m) {m_lock.unlock();} + ~ReverseScopedLock(){m_lock.lock();} +}; + +} +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Thread b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Thread new file mode 100755 index 0000000000000000000000000000000000000000..fc7548e9c48e1e5e62d66751f78f942cc17002b1 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/include/OpenThreads/Thread @@ -0,0 +1,389 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// Thread - C++ Thread class +// ~~~~~~~~ +// + +#ifndef _OPENTHREADS_THREAD_ +#define _OPENTHREADS_THREAD_ + +#include <sys/types.h> + +#include <OpenThreads/Exports> + +namespace OpenThreads { + +/** + * Get the number of processors. + * + * Note, systems where no support exists for querrying the number of processors, 1 is returned. + * + */ +extern OPENTHREAD_EXPORT_DIRECTIVE int GetNumberOfProcessors(); + +/** + * Set the processor affinity of current thread. + * + * Note, systems where no support exists no affinity will be set, and -1 will be returned. + * + */ +extern OPENTHREAD_EXPORT_DIRECTIVE int SetProcessorAffinityOfCurrentThread(unsigned int cpunum); + +/** + * @class Thread + * @brief This class provides an object-oriented thread interface. + */ +class OPENTHREAD_EXPORT_DIRECTIVE Thread { + +public: + + /** + * Set the concurrency level for a running application. This method + * only has effect if the pthreads thread model is being used, and + * then only when that model is many-to-one (eg. irix). + * in other cases it is ignored. The concurrency level is only a + * *hint* as to the number of execution vehicles to use, the actual + * implementation may do anything it wants. Setting the value + * to 0 returns things to their default state. + * + * @return previous concurrency level, -1 indicates no-op. + */ + static int SetConcurrency(int concurrencyLevel); + + /** + * Get the concurrency level for a running application. In this + * case, a return code of 0 means that the application is in default + * mode. A return code of -1 means that the application is incapable + * of setting an arbitrary concurrency, because it is a one-to-one + * execution model (sprocs, linuxThreads) + */ + static int GetConcurrency(); + + /** + * Enumerated Type for thread priority + */ + enum ThreadPriority { + + THREAD_PRIORITY_MAX, /**< The maximum possible priority */ + THREAD_PRIORITY_HIGH, /**< A high (but not max) setting */ + THREAD_PRIORITY_NOMINAL, /**< An average priority */ + THREAD_PRIORITY_LOW, /**< A low (but not min) setting */ + THREAD_PRIORITY_MIN, /**< The miniumum possible priority */ + THREAD_PRIORITY_DEFAULT /**< Priority scheduling default */ + + }; + + /** + * Enumerated Type for thread scheduling policy + */ + enum ThreadPolicy { + + THREAD_SCHEDULE_FIFO, /**< First in, First out scheduling */ + THREAD_SCHEDULE_ROUND_ROBIN, /**< Round-robin scheduling (LINUX_DEFAULT) */ + THREAD_SCHEDULE_TIME_SHARE, /**< Time-share scheduling (IRIX DEFAULT) */ + THREAD_SCHEDULE_DEFAULT /**< Default scheduling */ + + }; + + /** + * Constructor + */ + Thread(); + + /** + * Destructor + */ + virtual ~Thread(); + + + /** + * Return a pointer to the current running thread + */ + static Thread *CurrentThread(); + + + /** + * Initialize Threading in a program. This method must be called before + * you can do any threading in a program. + */ + static void Init(); + + /** + * Yield the processor. + * + * @note This method operates on the calling process. And is + * equivalent to calling sched_yield(). + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + static int YieldCurrentThread(); + + /** + * This method will return the ThreadPriority of the master process. + * (ie, the one calling the thread->start() methods for the first time) + * The method will almost certainly return + * Thread::THREAD_PRIORITY_DEFAULT if + * Init() has not been called. + * + * @return the Thread::ThreadPriority of the master thread. + */ + static ThreadPriority GetMasterPriority() {return s_masterThreadPriority;}; + + + /** + * Get a unique thread id. This id is monotonically increasing. + * + * @return a unique thread identifier + */ + int getThreadId(); + + /** + * Get the thread's process id. This is the pthread_t or pid_t value + * depending on the threading model being used. + * + * @return thread process id. + */ + size_t getProcessId(); + + /** + * Start the thread. This method will configure the thread, set + * it's priority, and spawn it. + * + * @note if the stack size specified setStackSize is smaller than the + * smallest allowable stack size, the threads stack size will be set to + * the minimum allowed, and may be retrieved via the getStackSize() + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int start(); + int startThread(); + + /** + * Test the cancel state of the thread. If the thread has been canceled + * this method will cause the thread to exit now. This method operates + * on the calling thread. + * + * Returns 0 if normal, -1 if called from a thread other that this. + */ + int testCancel(); + + + /** + * Cancel the thread. Equivalent to SIGKILL. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + virtual int cancel(); + + /** + * Set the thread's schedule priority. This is a complex method. + * Beware of thread priorities when using a many-to-many kernel + * entity implemenation (such as IRIX pthreads). If one is not carefull + * to manage the thread priorities, a priority inversion deadlock can + * easily occur (Although the OpenThreads::Mutex & OpenThreads::Barrier + * constructs have been designed with this senario in mind). Unless + * you have explicit need to set the schedule pirorites for a given + * task, it is best to leave them alone. + * + * @note some implementations (notably LinuxThreads and IRIX Sprocs) + * only alow you to decrease thread priorities dynamically. Thus, + * a lower priority thread will not allow it's priority to be raised + * on the fly. + * + * @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO + * will output scheduling information for each thread to stdout. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int setSchedulePriority(ThreadPriority priority); + + /** + * Get the thread's schedule priority (if able) + * + * @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO + * will output scheduling information for each thread to stdout. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int getSchedulePriority(); + + /** + * Set the thread's scheduling policy (if able) + * + * @note On some implementations (notably IRIX Sprocs & LinuxThreads) + * The policy may prohibit the use of SCHEDULE_ROUND_ROBIN and + * SCHEDULE_FIFO policies - due to their real-time nature, and + * the danger of deadlocking the machine when used as super-user. + * In such cases, the command is a no-op. + * + * @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO + * will output scheduling information for each thread to stdout. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int setSchedulePolicy(ThreadPolicy policy); + + /** + * Get the thread's policy (if able) + * + * @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO + * will output scheduling information for each thread to stdout. + * + * @return policy if normal, -1 if errno set, errno code otherwise. + */ + int getSchedulePolicy(); + + /** + * Set the thread's desired stack size (in bytes). + * This method is an attribute of the thread and must be called + * *before* the start() method is invoked. + * + * @note a return code of 13 (EACESS) means that the thread stack + * size can no longer be changed. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int setStackSize(size_t size); + + /** + * Get the thread's desired stack size. + * + * @return the thread's stack size. 0 indicates that the stack size + * has either not yet been initialized, or not yet been specified by + * the application. + */ + size_t getStackSize(); + + /** + * Print the thread's scheduling information to stdout. + */ + void printSchedulingInfo(); + + /** + * Detach the thread from the calling process. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int detach(); + + /** + * Join the calling process with the thread + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int join(); + + /** + * Disable thread cancelation altogether. Thread::cancel() has no effect. + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int setCancelModeDisable(); + + /** + * Mark the thread to cancel aysncronously on Thread::cancel(). + * (May not be available with process-level implementations). + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int setCancelModeAsynchronous(); + + /** + * Mark the thread to cancel at the earliest convenience on + * Thread::cancel() (This is the default) + * + * @return 0 if normal, -1 if errno set, errno code otherwise. + */ + int setCancelModeDeferred(); + + /** + * Query the thread's running status + * + * @return true if running, false if not. + */ + bool isRunning(); + + /** + * Thread's run method. Must be implemented by derived classes. + * This is where the action happens. + */ + virtual void run() = 0; + + /** + * Thread's cancel cleanup routine, called upon cancel(), after the + * cancelation has taken place, but before the thread exits completely. + * This method should be used to repair parts of the thread's data + * that may have been damaged by a pre-mature cancel. No-op by default. + */ + virtual void cancelCleanup() {}; + + void* getImplementation(){ return _prvData; }; + + /** Thread's processor affinity method. This binds a thread to a + * processor whenever possible. This call must be made before + * start() or startThread() and has no effect after the thread + * has been running. In the pthreads implementation, this is only + * implemented on sgi, through a pthread extension. On other pthread + * platforms this is ignored. Returns 0 on success, implementation's + * error on failure, or -1 if ignored. + */ + int setProcessorAffinity( unsigned int cpunum ); + + /** microSleep method, equivilant to the posix usleep(microsec). + * This is not strictly thread API but is used + * so often with threads. It's basically UNIX usleep. Parameter is + * number of microseconds we current thread to sleep. Returns 0 on + * succes, non-zero on failure (UNIX errno or GetLastError() will give + * detailed description. + */ + static int microSleep( unsigned int microsec); + +private: + + /** + * The Private Actions class is allowed to operate on private data. + */ + friend class ThreadPrivateActions; + + /** + * Private copy constructor, to prevent tampering. + */ + Thread(const Thread &/*t*/) {}; + + /** + * Private copy assignment, to prevent tampering. + */ + Thread &operator=(const Thread &/*t*/) {return *(this);}; + + /** + * Implementation-specific data + */ + void * _prvData; + + /** + * Master thread's priority, set by Thread::Init. + */ + static ThreadPriority s_masterThreadPriority; + + /** + * Is initialized flag + */ + static bool s_isInitialized; +}; + +} + +#endif // !_OPENTHREADS_THREAD_ diff --git a/Utilities/otbopenthreads/OpenThreads/lib/README b/Utilities/otbopenthreads/OpenThreads/lib/README new file mode 100755 index 0000000000000000000000000000000000000000..653670eb4955f83046caf0b5889c9a1949131ba3 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/lib/README @@ -0,0 +1,3 @@ +This is where all the libraries go. +This file exists to keep CVS from deleting +the directory. diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/CMakeLists.txt b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..2ef5e01df273ae3442f81f73b29284517af8535d --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/CMakeLists.txt @@ -0,0 +1,77 @@ +# This is mainly for Windows declspec, but other platforms know +# what to do with it. +ADD_DEFINITIONS(-DOPENTHREADS_EXPORTS) + +SET(OPENTHREADS_MAJOR_VERSION 1) +SET(OPENTHREADS_MINOR_VERSION 9) +SET(OPENTHREADS_PATCH_VERSION 5) +SET(OPENTHREADS_SOVERSION 7) + +SET(OPENTHREADS_VERSION ${OPENTHREADS_MAJOR_VERSION}.${OPENTHREADS_MINOR_VERSION}.${OPENTHREADS_PATCH_VERSION}) + +SET(HEADER_PATH ${OpenThreads_SOURCE_DIR}/include/OpenThreads) +SET(OpenThreads_PUBLIC_HEADERS + ${HEADER_PATH}/Barrier + ${HEADER_PATH}/Block + ${HEADER_PATH}/Condition + ${HEADER_PATH}/Exports + ${HEADER_PATH}/Mutex + ${HEADER_PATH}/ReadWriteMutex + ${HEADER_PATH}/ReentrantMutex + ${HEADER_PATH}/ScopedLock + ${HEADER_PATH}/Thread +) + +# User Options +# OTB modifications +#OPTION(DYNAMIC_OPENTHREADS "Set to ON to build OpenThreads for dynamic linking. Use OFF for static." ON) +#IF (DYNAMIC_OPENTHREADS) +# SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED") +#ELSE (DYNAMIC_OPENTHREADS) +# SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC") +#ENDIF(DYNAMIC_OPENTHREADS) +IF( OTB_BUILD_SHARED_LIBS ) + SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED") +ELSE( OTB_BUILD_SHARED_LIBS ) + SET(OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC") +ENDIF( OTB_BUILD_SHARED_LIBS ) + +# Use our modified version of FindThreads.cmake which has Sproc hacks. +FIND_PACKAGE(Threads) + +# Do we have sproc? +IF(CMAKE_SYSTEM MATCHES IRIX) + IF(CMAKE_USE_SPROC_INIT) + # In this case, only Sproc exists, so no option. + SET(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS 1) + ELSE(CMAKE_USE_SPROC_INIT) + IF(CMAKE_HAVE_SPROC_H) + OPTION(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS "Set to ON to build OpenThreads against sproc instead of pthreads" OFF) + ENDIF(CMAKE_HAVE_SPROC_H) + ENDIF(CMAKE_USE_SPROC_INIT) +ENDIF(CMAKE_SYSTEM MATCHES IRIX) + +# Maybe we should be using the FindThreads.cmake module? +IF(WIN32) + # So I think Cygwin wants to use pthreads + IF(CYGWIN) + SUBDIRS(pthreads) + ELSE(CYGWIN) + # Everybody else including Msys should probably go here + SUBDIRS(win32) + # examples) + ENDIF(CYGWIN) +ELSE(WIN32) + IF(UNIX) + IF(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS) + SUBDIRS(sproc) + ELSE(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS) + SUBDIRS(pthreads) + ENDIF(OPENTHREADS_USE_SPROC_INSTEAD_OF_PTHREADS) + ELSE(UNIX) + MESSAGE("Sorry, OpenThreads may not support your platform") + ENDIF(UNIX) +ENDIF(WIN32) + + + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/CMakeLists.txt b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..13a5a424908bfcdc49dfc10e35c05d22cf1e8722 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/CMakeLists.txt @@ -0,0 +1,55 @@ +# This file should only be included when using Pthreads + +SET(LIB_NAME OpenThreads) +SET(LIB_PUBLIC_HEADERS ${OpenThreads_PUBLIC_HEADERS}) + +ADD_LIBRARY(${LIB_NAME} + ${OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC} + ${LIB_PUBLIC_HEADERS} + PThread.c++ + PThreadBarrier.c++ + PThreadBarrierPrivateData.h + PThreadCondition.c++ + PThreadConditionPrivateData.h + PThreadMutex.c++ + PThreadMutexPrivateData.h + PThreadPrivateData.h +) + +IF(OPENTHREADS_SONAMES) + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${OPENTHREADS_VERSION} SOVERSION ${OPENTHREADS_SOVERSION}) +ENDIF(OPENTHREADS_SONAMES) + +TARGET_LINK_LIBRARIES(${LIB_NAME} + ${CMAKE_THREAD_LIBS_INIT} +) + +# Since we're building different platforms binaries in +# their respective directories, we need to set the +# link directory so it can find this location. +LINK_DIRECTORIES( + ${CMAKE_CURRENT_BINARY_DIR} +) + +# OTB Modifications +#INSTALL( +# TARGETS OpenThreads +# ARCHIVE DESTINATION lib${LIB_POSTFIX} +# LIBRARY DESTINATION lib${LIB_POSTFIX} +# RUNTIME DESTINATION bin +#) +INSTALL(TARGETS OpenThreads +RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries +LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries +ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT Development) + +#INSTALL( +# FILES ${OpenThreads_PUBLIC_HEADERS} +# DESTINATION include/OpenThreads +#) +INSTALL(FILES ${OpenThreads_PUBLIC_HEADERS} + DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbopenthreads/OpenThreads/include + COMPONENT Development) + + +#commented out# INCLUDE(ModuleInstall OPTIONAL) diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/GNUmakefile b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/GNUmakefile new file mode 100755 index 0000000000000000000000000000000000000000..a800725fd3164aaeb74005c9ed4de030602f25be --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/GNUmakefile @@ -0,0 +1,46 @@ +TOPDIR = ../. +include $(TOPDIR)/Make/makedefs + +C++FILES = \ + PThread.c++ \ + PThreadMutex.c++ \ + PThreadCondition.c++ \ + PThreadBarrier.c++ \ + $(NULL) + +INC += -I$(TOPDIR)/include -I. + +ifeq ($(OS),Linux) +DEF += -fPIC -DLinux -DGL_GLEXT_PROTOTYPES +LIBS += -lpthread +endif + +ifeq ($(OS),SunOS) +LIBS += -lpthread -lposix4 +endif + +ifeq ($(OS),IRIX) +LIBS += -lpthread +endif + +ifeq ($(OS),Darwin) +LIBS += -lpthread +endif + +ifeq ($(OS),CYGWIN) +LIBS += -lpthread +DEF += -DOPENTHREADS_EXPORTS +endif + +ifeq ($(OS),MINGW) +LIBS += -lpthread -lwinmm +DEF += -DOPENTHREADS_EXPORTS +endif + +TARGET_BASENAME = OpenThreads +LIB = $(LIB_PREFIX)$(TARGET_BASENAME) + +ifeq ($(COMPILE_USING_TWO_PARAM_sched_setaffinity),yes) +DEF += -DCOMPILE_USING_TWO_PARAM_sched_setaffinity +endif +include $(TOPDIR)/Make/makerules diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThread.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThread.c++ new file mode 100755 index 0000000000000000000000000000000000000000..4179e1cbc35abe6dd0561b4463fbbe70423d3da3 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThread.c++ @@ -0,0 +1,942 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThread.c++ - C++ Thread class built on top of posix threads. +// ~~~~~~~~~~~ + +#include <stdlib.h> +#include <stdio.h> +#include <sys/types.h> +#include <unistd.h> +#include <pthread.h> +#include <assert.h> + +#if defined __linux || defined __sun || defined __APPLE__ +#include <string.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/unistd.h> +#endif + +#if defined (__linux__) + #include <sched.h> +#endif +#if defined (__FreeBSD__) || defined (__APPLE__) || defined (__MACH__) + #include <sys/types.h> + #include <sys/sysctl.h> +#endif + +#include <OpenThreads/Thread> +#include "PThreadPrivateData.h" + +#include <iostream> + +using namespace OpenThreads; + +extern int errno; +const char *OPENTHREAD_VERSION_STRING = "OpenThreads v1.2preAlpha, Posix Threads (Public Implementation)"; + +#ifdef DEBUG +# define DPRINTF(arg) printf arg +#else +# define DPRINTF(arg) +#endif + +//----------------------------------------------------------------------------- +// Initialize the static unique ids. +// +int PThreadPrivateData::nextId = 0; + +//----------------------------------------------------------------------------- +// Initialize thread master priority level +// +Thread::ThreadPriority Thread::s_masterThreadPriority = + Thread::THREAD_PRIORITY_DEFAULT; + +bool Thread::s_isInitialized = false; +pthread_key_t PThreadPrivateData::s_tls_key; + +struct ThreadCleanupStruct { + + OpenThreads::Thread *thread; + volatile bool *runflag; + +}; + +//----------------------------------------------------------------------------- +// This cleanup handler is necessary to ensure that the thread will cleanup +// and set its isRunning flag properly. +// +void thread_cleanup_handler(void *arg) { + + ThreadCleanupStruct *tcs = static_cast<ThreadCleanupStruct *>(arg); + + tcs->thread->cancelCleanup(); + *(tcs->runflag) = false; + +} + +//----------------------------------------------------------------------------- +// Class to support some static methods necessary for pthread's to work +// correctly. +// + +namespace OpenThreads { + +class ThreadPrivateActions { + + //------------------------------------------------------------------------- + // We're friendly to Thread, so it can issue the methods. + // + friend class Thread; + +private: + + //------------------------------------------------------------------------- + // pthreads standard start routine. + // + static void *StartThread(void *data) { + + Thread *thread = static_cast<Thread *>(data); + PThreadPrivateData *pd = + static_cast<PThreadPrivateData *>(thread->_prvData); + + if (pd->cpunum>=0) + { + #ifdef __sgi + + pthread_setrunon_np( pd->cpunum ); + + #elif defined (__linux__) && defined(CPU_SET) + + cpu_set_t cpumask; + CPU_ZERO( &cpumask ); + CPU_SET( pd->cpunum, &cpumask ); + + #if defined(COMPILE_USING_TWO_PARAM_sched_setaffinity) + sched_setaffinity( 0, &cpumask ); + #else + sched_setaffinity( 0, sizeof(cpumask), &cpumask ); + #endif + + #endif + } + + + ThreadCleanupStruct tcs; + tcs.thread = thread; + tcs.runflag = &pd->isRunning; + + // Set local storage so that Thread::CurrentThread() can return the right thing + int status = pthread_setspecific(PThreadPrivateData::s_tls_key, thread); + assert(status == 0); + + pthread_cleanup_push(thread_cleanup_handler, &tcs); + +#ifdef ALLOW_PRIORITY_SCHEDULING + + //--------------------------------------------------------------------- + // Set the proper scheduling priorities + // + SetThreadSchedulingParams(thread); + +#endif // ] ALLOW_PRIORITY_SCHEDULING + + pd->isRunning = true; + thread->run(); + pd->isRunning = false; + + pthread_cleanup_pop(0); + + return 0; + + }; + + //------------------------------------------------------------------------- + // Print information related to thread schduling parameters. + // + static void PrintThreadSchedulingInfo(Thread *thread) { + +#ifdef ALLOW_PRIORITY_SCHEDULING // [ + + if(sysconf(_POSIX_THREAD_PRIORITY_SCHEDULING)) { + + int status, my_policy, min_priority, max_priority; + struct sched_param my_param; + + status = pthread_getschedparam(thread->getProcessId(), + &my_policy, + &my_param); + + if(status != 0) { + printf("THREAD INFO (%d) : Get sched: %s\n", + thread->getProcessId(), + strerror(status)); + } else { + printf( + "THREAD INFO (%d) : Thread running at %s / Priority: %d\n", + thread->getProcessId(), + (my_policy == SCHED_FIFO ? "SCHEDULE_FIFO" + : (my_policy == SCHED_RR ? "SCHEDULE_ROUND_ROBIN" + : (my_policy == SCHED_OTHER ? "SCHEDULE_OTHER" + : "UNKNOWN"))), + my_param.sched_priority); + + max_priority = sched_get_priority_max(my_policy); + min_priority = sched_get_priority_min(my_policy); + + printf( + "THREAD INFO (%d) : Max priority: %d, Min priority: %d\n", + thread->getProcessId(), + max_priority, min_priority); + + } + + } else { + printf( + "THREAD INFO (%d) POSIX Priority scheduling not available\n", + thread->getProcessId()); + } + + fflush(stdout); + +#endif // ] ALLOW_PRIORITY_SCHEDULING + + } + + //-------------------------------------------------------------------------- + // Set thread scheduling parameters. Unfortunately on Linux, there's no + // good way to set this, as pthread_setschedparam is mostly a no-op. + // + static int SetThreadSchedulingParams(Thread *thread) { + + int status = 0; + +#ifdef ALLOW_PRIORITY_SCHEDULING // [ + + if(sysconf(_POSIX_THREAD_PRIORITY_SCHEDULING)) { + + int th_policy; + int max_priority, nominal_priority, min_priority; + sched_param th_param; + pthread_getschedparam(thread->getProcessId(), + &th_policy, &th_param); + +#ifndef __linux__ + + switch(thread->getSchedulePolicy()) { + + case Thread::THREAD_SCHEDULE_FIFO: + th_policy = SCHED_FIFO; + break; + + case Thread::THREAD_SCHEDULE_ROUND_ROBIN: + th_policy = SCHED_RR; + break; + + case Thread::THREAD_SCHEDULE_TIME_SHARE: + th_policy = SCHED_OTHER; + break; + + default: +#ifdef __sgi + th_policy = SCHED_RR; +#else + th_policy = SCHED_FIFO; +#endif + break; + }; + +#else + th_policy = SCHED_OTHER; // Must protect linux from realtime. +#endif + +#ifdef __linux__ + + max_priority = 0; + min_priority = 20; + nominal_priority = (max_priority + min_priority)/2; + +#else + + max_priority = sched_get_priority_max(th_policy); + min_priority = sched_get_priority_min(th_policy); + nominal_priority = (max_priority + min_priority)/2; + +#endif + + switch(thread->getSchedulePriority()) { + + case Thread::THREAD_PRIORITY_MAX: + th_param.sched_priority = max_priority; + break; + + case Thread::THREAD_PRIORITY_HIGH: + th_param.sched_priority = (max_priority + nominal_priority)/2; + break; + + case Thread::THREAD_PRIORITY_NOMINAL: + th_param.sched_priority = nominal_priority; + break; + + case Thread::THREAD_PRIORITY_LOW: + th_param.sched_priority = (min_priority + nominal_priority)/2; + break; + + case Thread::THREAD_PRIORITY_MIN: + th_param.sched_priority = min_priority; + break; + + default: + th_param.sched_priority = max_priority; + break; + + } + + status = pthread_setschedparam(thread->getProcessId(), + th_policy, + &th_param); + + + if(getenv("OUTPUT_THREADLIB_SCHEDULING_INFO") != 0) + PrintThreadSchedulingInfo(thread); + + } + +#endif // ] ALLOW_PRIORITY_SCHEDULING + + return status; + }; +}; + +} + +//---------------------------------------------------------------------------- +// +// Description: Set the concurrency level (no-op) +// +// Use static public +// +int Thread::SetConcurrency(int concurrencyLevel) { + +#if defined (__sgi) || defined (__sun) + return pthread_setconcurrency(concurrencyLevel); +#else + return -1; +#endif + +} + +//---------------------------------------------------------------------------- +// +// Description: Get the concurrency level +// +// Use static public +// +int Thread::GetConcurrency() { + +#if defined (__sgi) || defined (__sun) + return pthread_getconcurrency(); +#else + return -1; +#endif + +} + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Thread::Thread() { + + if(!s_isInitialized) Init(); + + PThreadPrivateData *pd = new PThreadPrivateData(); + pd->stackSize = 0; + pd->stackSizeLocked = false; + pd->idSet = false; + pd->isRunning = false; + pd->isCanceled = false; + pd->uniqueId = pd->nextId; + pd->nextId++; + pd->threadPriority = Thread::THREAD_PRIORITY_DEFAULT; + pd->threadPolicy = Thread::THREAD_SCHEDULE_DEFAULT; + pd->cpunum = -1; + + _prvData = static_cast<void *>(pd); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Thread::~Thread() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *>(_prvData); + + if(pd->isRunning) { + + std::cout<<"Error: Thread "<<this<<" still running in destructor"<<std::endl; + + //--------------------------------------------------------------------- + // Kill the thread when it is destructed + // + cancel(); + } + + delete pd; + +} + +Thread *Thread::CurrentThread() { + + Thread *thread = + static_cast<Thread *>(pthread_getspecific(PThreadPrivateData::s_tls_key)); + + return thread; + +} + +//----------------------------------------------------------------------------- +// +// Description: Initialize Threading +// +// Use: public. +// +void Thread::Init() { + + if(s_isInitialized) return; + + // Allocate a key to be used to access thread local storage + int status = pthread_key_create(&PThreadPrivateData::s_tls_key, NULL); + assert(status == 0); + +#ifdef ALLOW_PRIORITY_SCHEDULING + + //-------------------------------------------------------------------------- + // If we've got priority scheduling, set things to nominal. + // + if(sysconf(_POSIX_THREAD_PRIORITY_SCHEDULING)) { + + int max_priority, nominal_priority, min_priority; + + int th_policy; + sched_param th_param; + pthread_getschedparam(pthread_self(), + &th_policy, &th_param); + + max_priority = sched_get_priority_max(th_policy); + min_priority = sched_get_priority_min(th_policy); + nominal_priority = (max_priority + min_priority)/2; + + th_param.sched_priority = nominal_priority; + + pthread_setschedparam(pthread_self(), + th_policy, + &th_param); + + s_masterThreadPriority = Thread::THREAD_PRIORITY_NOMINAL; + + } else { + + s_masterThreadPriority = Thread::THREAD_PRIORITY_DEFAULT; + + } + +#endif // ] ALLOW_PRIORITY_SCHEDULING + + s_isInitialized = true; + +} + +//----------------------------------------------------------------------------- +// +// Description: Get a unique identifier for this thread. +// +// Use: public +// +int Thread::getThreadId() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + return pd->uniqueId; +} + +//----------------------------------------------------------------------------- +// +// Description: Get the thread's process id +// +// Use: public +// +size_t Thread::getProcessId() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + if(pd->idSet == false) return (size_t)(pthread_self()); + + return (size_t)(pd->tid); +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's processor affinity +// +// Use: public +// +int Thread::setProcessorAffinity(unsigned int cpunum) +{ + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + pd->cpunum = cpunum; + if (pd->cpunum<0) return -1; + +#ifdef __sgi + + int status; + pthread_attr_t thread_attr; + + status = pthread_attr_init( &thread_attr ); + if(status != 0) { + return status; + } + + status = pthread_attr_setscope( &thread_attr, PTHREAD_SCOPE_BOUND_NP ); + return status; + +#elif defined (__linux__) && defined(CPU_SET) + + + if (pd->isRunning && Thread::CurrentThread()==this) + { + cpu_set_t cpumask; + CPU_ZERO( &cpumask ); + CPU_SET( pd->cpunum, &cpumask ); + + #if defined(COMPILE_USING_TWO_PARAM_sched_setaffinity) + return sched_setaffinity( 0, &cpumask ); + #else + return sched_setaffinity( 0, sizeof(cpumask), &cpumask ); + #endif + } + + return -1; +#else + return -1; +#endif + +} + +//----------------------------------------------------------------------------- +// +// Description: Determine if the thread is running +// +// Use: public +// +bool Thread::isRunning() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + return pd->isRunning; + +} + +//----------------------------------------------------------------------------- +// +// Description: Start the thread. +// +// Use: public +// +int Thread::start() { + + int status; + pthread_attr_t thread_attr; + + status = pthread_attr_init( &thread_attr ); + if(status != 0) { + return status; + } + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + size_t defaultStackSize; + pthread_attr_getstacksize( &thread_attr, &defaultStackSize); + if(status != 0) { + return status; + } + + if(defaultStackSize < pd->stackSize) { + + pthread_attr_setstacksize( &thread_attr, pd->stackSize); + if(status != 0) { + return status; + } + } + + //------------------------------------------------------------------------- + // Now get what we actually have... + // + pthread_attr_getstacksize( &thread_attr, &defaultStackSize); + if(status != 0) { + return status; + } + + pd->stackSize = defaultStackSize; + + //------------------------------------------------------------------------- + // Prohibit the stack size from being changed. + // + pd->stackSizeLocked = true; + +#ifdef ALLOW_PRIORITY_SCHEDULING + + status = pthread_attr_setinheritsched( &thread_attr, + PTHREAD_EXPLICIT_SCHED ); + + pthread_attr_setscope(&thread_attr, PTHREAD_SCOPE_SYSTEM); + +#endif // ] ALLOW_PRIORITY_SCHEDULING + + if(status != 0) { + return status; + } + + status = pthread_create(&(pd->tid), &thread_attr, + ThreadPrivateActions::StartThread, + static_cast<void *>(this)); + + if(status != 0) { + return status; + } + + pd->idSet = true; + + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: Alternate thread start routine. +// +// Use: public +// +int Thread::startThread() { return start(); } + +//----------------------------------------------------------------------------- +// +// Description: Join the thread. +// +// Use: public +// +int Thread::detach() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + return pthread_detach(pd->tid); + +} + +//----------------------------------------------------------------------------- +// +// Description: Join the thread. +// +// Use: public +// +int Thread::join() { + + void *threadResult = 0; // Dummy var. + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + return pthread_join(pd->tid, &threadResult); + +} + +//----------------------------------------------------------------------------- +// +// Description: test the cancel state of the thread. +// +// Use: public +// +int Thread::testCancel() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + if(pthread_self() != pd->tid) + return -1; + + pthread_testcancel(); + + return 0; + +} + + +//----------------------------------------------------------------------------- +// +// Description: Cancel the thread. +// +// Use: public +// +int Thread::cancel() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + if (pd->isRunning) + { + pd->isCanceled = true; + int status = pthread_cancel(pd->tid); + return status; + } + return 0; +} + +//----------------------------------------------------------------------------- +// +// Description: Disable cancelibility +// +// Use: public +// +int Thread::setCancelModeDisable() { + + return pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, 0 ); + +} + +//----------------------------------------------------------------------------- +// +// Description: set the thread to cancel immediately +// +// Use: public +// +int Thread::setCancelModeAsynchronous() { + + int status = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); + if(status != 0) return status; + + return pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, 0); +} + +//----------------------------------------------------------------------------- +// +// Description: set the thread to cancel at the next convienent point. +// +// Use: public +// +int Thread::setCancelModeDeferred() { + + int status = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, 0); + if(status != 0) return status; + + return pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, 0); + +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's schedule priority (if able) +// +// Use: public +// +int Thread::setSchedulePriority(ThreadPriority priority) { + +#ifdef ALLOW_PRIORITY_SCHEDULING + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + pd->threadPriority = priority; + + if(pd->isRunning) + return ThreadPrivateActions::SetThreadSchedulingParams(this); + else + return 0; + +#else + return -1; +#endif + +} + +//----------------------------------------------------------------------------- +// +// Description: Get the thread's schedule priority (if able) +// +// Use: public +// +int Thread::getSchedulePriority() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + return pd->threadPriority; + +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's scheduling policy (if able) +// +// Use: public +// +int Thread::setSchedulePolicy(ThreadPolicy policy) { + +#ifdef ALLOW_PRIORITY_SCHEDULING + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + pd->threadPolicy = policy; + + if(pd->isRunning) + return ThreadPrivateActions::SetThreadSchedulingParams(this); + else + return 0; +#else + return -1; +#endif + +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's scheduling policy (if able) +// +// Use: public +// +int Thread::getSchedulePolicy() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + return pd->threadPolicy; + +} + + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's desired stack size +// +// Use: public +// +int Thread::setStackSize(size_t stackSize) { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + if(pd->stackSizeLocked == true) return 13; // EACESS + + pd->stackSize = stackSize; + + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: Get the thread's stack size. +// +// Use: public +// +size_t Thread::getStackSize() { + + PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); + + return pd->stackSize; + +} + +//----------------------------------------------------------------------------- +// +// Description: Print the thread's scheduling information to stdout. +// +// Use: public +// +void Thread::printSchedulingInfo() { + + ThreadPrivateActions::PrintThreadSchedulingInfo(this); + +} + +//----------------------------------------------------------------------------- +// +// Description: Yield the processor +// +// Use: protected +// +int Thread::YieldCurrentThread() +{ + + return sched_yield(); + +} + +// Description: sleep +// +// Use: public +// +int Thread::microSleep(unsigned int microsec) +{ + return ::usleep(microsec); +} + + + +//----------------------------------------------------------------------------- +// +// Description: Get the number of processors +// +int OpenThreads::GetNumberOfProcessors() +{ +#if defined(__linux__) + return sysconf(_SC_NPROCESSORS_CONF); +#else + #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) + uint64_t num_cpus = 0; + size_t num_cpus_length = sizeof(num_cpus); + #if defined(__FreeBSD__) + sysctlbyname("hw.ncpu", &num_cpus, &num_cpus_length, NULL, 0); + #else + sysctlbyname("hw.activecpu", &num_cpus, &num_cpus_length, NULL, 0); + #endif + return num_cpus; + #else + return 1; + #endif +#endif +} + +int OpenThreads::SetProcessorAffinityOfCurrentThread(unsigned int cpunum) +{ + if (cpunum<0) return -1; + + Thread* thread = Thread::CurrentThread(); + if (thread) + { + return thread->setProcessorAffinity(cpunum); + } + else + { + #if defined (__linux__) && defined(CPU_SET) + + cpu_set_t cpumask; + CPU_ZERO( &cpumask ); + CPU_SET( cpunum, &cpumask ); + + #if defined(COMPILE_USING_TWO_PARAM_sched_setaffinity) + return sched_setaffinity( 0, &cpumask ); + #else + return sched_setaffinity( 0, sizeof(cpumask), &cpumask ); + #endif + + #endif + } + + return -1; +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadBarrier.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadBarrier.c++ new file mode 100755 index 0000000000000000000000000000000000000000..033ca8716e5af99f9cfe6bbddcc2b2d32f235f22 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadBarrier.c++ @@ -0,0 +1,242 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThreadBarrier.c++ - C++ Barrier class built on top of POSIX threads. +// ~~~~~~~~~~~~~~~~~~ +// + +#include <stdio.h> +#include <unistd.h> +#include <OpenThreads/Barrier> +#include "PThreadBarrierPrivateData.h" + +using namespace OpenThreads; + +//---------------------------------------------------------------------------- +// This cancel cleanup handler is necessary to ensure that the barrier's +// mutex gets unlocked on cancel. Otherwise deadlocks could occur with +// later joins. +// +void barrier_cleanup_handler(void *arg) { + + pthread_mutex_t *mutex = static_cast<pthread_mutex_t *>(arg); + + pthread_mutex_unlock(mutex); + +} + +//---------------------------------------------------------------------------- +// +// Description: Constructor +// +// Use: public. +// +Barrier::Barrier(int numThreads) { + + PThreadBarrierPrivateData *pd = new PThreadBarrierPrivateData(); + + pd->cnt = 0; + pd->phase = 0; + pd->maxcnt = numThreads; + + _valid = true; + + pthread_mutexattr_t mutex_attr; + pthread_mutexattr_init( &mutex_attr ); + +#ifndef __linux__ // (not available until NPTL) [ + pthread_mutexattr_settype( &mutex_attr, PTHREAD_MUTEX_ERRORCHECK ); +#endif // ] __linux__ + +#ifdef ALLOW_PRIORITY_SCHEDULING // [ + +#ifdef __sun // [ + pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_NONE); +#endif // ] __sun + + //------------------------------------------------------------------------- + // Initialization is a bit tricky, since we have to be able to be aware + // that on many-to-many execution vehicle systems, we may run into + // priority inversion deadlocks if a mutex is shared between threads + // of differing priorities. Systems that do this should provide the + // following protocol attributes to prevent deadlocks. Check at runtime. + // + // PRIO_INHERIT causes any thread locking the mutex to temporarily become + // the same priority as the highest thread also blocked on the mutex. + // Although more expensive, this is the prefered method. + // + // PRIO_PROTECT causes any thread locking the mutex to assume the priority + // specified by setprioceiling. pthread_mutex_lock will fail if + // the priority ceiling is lower than the thread's priority. Therefore, + // the priority ceiling must be set to the max priority in order to + // garantee no deadlocks will occur. + // +#if defined (_POSIX_THREAD_PRIO_INHERIT) || defined (_POSIX_THREAD_PRIO_PROTECT) // [ + + if(sysconf(_POSIX_THREAD_PRIO_INHERIT)) { + + pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_INHERIT); + + } else if (sysconf(_POSIX_THREAD_PRIO_PROTECT)) { + + int th_policy; + struct sched_param th_param; + pthread_getschedparam(pthread_self(), &th_policy, &th_param); + + pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_PROTECT); + pthread_mutexattr_setprioceiling(&mutex_attr, + sched_get_priority_max(th_policy)); + + } + +#endif // ] Priority sheduling + +#endif // ] ALLOW_PRIORITY_SCHEDULING + + pthread_mutex_init(&(pd->lock), &mutex_attr); + + pthread_cond_init(&(pd->cond), NULL); + + _prvData = static_cast<void *>(pd); + +} + +//---------------------------------------------------------------------------- +// +// Description: Destructor +// +// Use: public. +// +Barrier::~Barrier() { + + PThreadBarrierPrivateData *pd = + static_cast<PThreadBarrierPrivateData*>(_prvData); + + pthread_mutex_destroy(&(pd->lock)); + + pthread_cond_destroy(&(pd->cond)); + + delete pd; + +} + +//---------------------------------------------------------------------------- +// +// Description: Reset the barrier to its original state +// +// Use: public. +// +void Barrier::reset() { + + PThreadBarrierPrivateData *pd = + static_cast<PThreadBarrierPrivateData*>(_prvData); + + pd->cnt = 0; + pd->phase = 0; + +} + +//---------------------------------------------------------------------------- +// +// Description: Block until numThreads threads have entered the barrier. +// +// Use: public. +// +void Barrier::block(unsigned int numThreads) { + + PThreadBarrierPrivateData *pd = + static_cast<PThreadBarrierPrivateData*>(_prvData); + + if(numThreads != 0) pd->maxcnt = numThreads; + + int my_phase; + + pthread_mutex_lock(&(pd->lock)); + if( _valid ) + { + my_phase = pd->phase; + ++pd->cnt; + + if (pd->cnt == pd->maxcnt) { // I am the last one + pd->cnt = 0; // reset for next use + pd->phase = 1 - my_phase; // toggle phase + pthread_cond_broadcast(&(pd->cond)); + } + + while (pd->phase == my_phase) { + + pthread_cleanup_push(barrier_cleanup_handler, &(pd->lock)); + + pthread_cond_wait(&(pd->cond), &(pd->lock)); + + pthread_cleanup_pop(0); + } + } + + pthread_mutex_unlock(&(pd->lock)); + +} + +void Barrier::invalidate() +{ + PThreadBarrierPrivateData *pd = + static_cast<PThreadBarrierPrivateData*>(_prvData); + pthread_mutex_lock(&(pd->lock)); + _valid = false; + pthread_mutex_unlock(&(pd->lock)); + release(); +} + +//---------------------------------------------------------------------------- +// +// Description: Release the barrier, now. +// +// Use: public. +// +void Barrier::release() { + + PThreadBarrierPrivateData *pd = + static_cast<PThreadBarrierPrivateData*>(_prvData); + + int my_phase; + + pthread_mutex_lock(&(pd->lock)); + my_phase = pd->phase; + + pd->cnt = 0; // reset for next use + pd->phase = 1 - my_phase; // toggle phase + pthread_cond_broadcast(&(pd->cond)); + pthread_mutex_unlock(&(pd->lock)); + +} + +//---------------------------------------------------------------------------- +// +// Description: Return the number of threads currently blocked in the barrier +// +// Use: public +// +int Barrier::numThreadsCurrentlyBlocked() { + + PThreadBarrierPrivateData *pd = static_cast<PThreadBarrierPrivateData*>(_prvData); + + + int numBlocked = -1; + pthread_mutex_lock(&(pd->lock)); + numBlocked = pd->cnt; + pthread_mutex_unlock(&(pd->lock)); + + return numBlocked; +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadBarrierPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadBarrierPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..235706a2537b8f7711432f0640190465ae584fa2 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadBarrierPrivateData.h @@ -0,0 +1,52 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThreadBarrierPrivateData.h - private data structure for barrier +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// + +#ifndef _PTHREADBARRIERPRIVATEDATA_H_ +#define _PTHREADBARRIERPRIVATEDATA_H_ + +#include <pthread.h> +#include <OpenThreads/Barrier> + +namespace OpenThreads { + +class PThreadBarrierPrivateData { + + friend class Barrier; + +private: + + PThreadBarrierPrivateData() {}; + + virtual ~PThreadBarrierPrivateData() {}; + + pthread_cond_t cond; // cv for waiters at barrier + + pthread_mutex_t lock; // mutex for waiters at barrier + + volatile int maxcnt; // number of threads to wait for + + volatile int cnt; // number of waiting threads + + volatile int phase; // flag to seperate two barriers + +}; + +} + +#endif //_PTHREADBARRIERPRIVATEDATA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadCondition.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadCondition.c++ new file mode 100755 index 0000000000000000000000000000000000000000..b29a5f936b39fc0b3e5bba785ab87d716939b2c7 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadCondition.c++ @@ -0,0 +1,211 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThreadCondition.c++ - C++ Condition class built on top of posix threads. +// ~~~~~~~~~~~~~~~~~~~~ +// + +#if defined(_MSC_VER) || defined(__MINGW32__) +# include <time.h> +#else +# include <sys/time.h> +#endif + +#include <assert.h> +#include <OpenThreads/Condition> +#include "PThreadConditionPrivateData.h" +#include "PThreadMutexPrivateData.h" + +using namespace OpenThreads; + +#if defined(_MSC_VER) || defined(__MINGW32__) +int gettimeofday(struct timeval* tp, void* tzp) { + LARGE_INTEGER t; + + if(QueryPerformanceCounter(&t)) { + /* hardware supports a performance counter */ + static int been_here = 0; + static LARGE_INTEGER f; + if( !been_here ) + { + been_here = 1; + QueryPerformanceFrequency(&f); + } + tp->tv_sec = t.QuadPart/f.QuadPart; + tp->tv_usec = ((float)t.QuadPart/f.QuadPart*1000*1000) + - (tp->tv_sec*1000*1000); + } else { + /* hardware doesn't support a performance counter, so get the + time in a more traditional way. */ + DWORD t; + t = timeGetTime(); + tp->tv_sec = t / 1000; + tp->tv_usec = t % 1000; + } + + /* 0 indicates that the call succeeded. */ + return 0; +} +#endif + +//---------------------------------------------------------------------------- +// This cancel cleanup handler is necessary to ensure that the barrier's +// mutex gets unlocked on cancel. Otherwise deadlocks could occur with +// later joins. +// +void condition_cleanup_handler(void *arg) { + + pthread_mutex_t *mutex = static_cast<pthread_mutex_t *>(arg); + + pthread_mutex_unlock(mutex); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Condition::Condition() { + + PThreadConditionPrivateData *pd = + new PThreadConditionPrivateData(); + + int status = pthread_cond_init( &pd->condition, NULL ); + assert(status == 0); + + _prvData = static_cast<void *>(pd); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Condition::~Condition() { + + PThreadConditionPrivateData *pd = + static_cast<PThreadConditionPrivateData *>(_prvData); + + int status = pthread_cond_destroy( &pd->condition ); + assert(status == 0); + + delete pd; + +} + +//---------------------------------------------------------------------------- +// +// Decription: wait on a condition +// +// Use: public. +// +int Condition::wait(Mutex *mutex) { + + PThreadConditionPrivateData *pd = + static_cast<PThreadConditionPrivateData *>(_prvData); + + PThreadMutexPrivateData *mpd = + static_cast<PThreadMutexPrivateData *>(mutex->_prvData); + + int status; + + pthread_cleanup_push(condition_cleanup_handler, &mpd->mutex); + + status = pthread_cond_wait( &pd->condition, &mpd->mutex ); + + pthread_cleanup_pop(0); + + return status; + + +} + +//---------------------------------------------------------------------------- +// +// Decription: wait on a condition, for a specified period of time +// +// Use: public. +// +int Condition::wait(Mutex *mutex, unsigned long int ms) { + + PThreadConditionPrivateData *pd = + static_cast<PThreadConditionPrivateData *>(_prvData); + + PThreadMutexPrivateData *mpd = + static_cast<PThreadMutexPrivateData *>(mutex->_prvData); + + + // wait time is now in ms milliseconds, so need to convert to seconds and nanoseconds for timespec strucuture. + unsigned int sec = ms / 1000; + unsigned int nsec = (ms % 1000) * 1000000; + + // add to the current time + struct ::timeval now; + ::gettimeofday( &now, 0 ); + + sec += now.tv_sec; + nsec += now.tv_usec*1000; + + // now pass on any overflow from nsec onto seconds. + sec += nsec / 1000000000; + nsec = nsec % 1000000000; + + struct timespec abstime; + abstime.tv_sec = sec; + abstime.tv_nsec = nsec; + + int status; + + pthread_cleanup_push(condition_cleanup_handler, &mpd->mutex); + + status = pthread_cond_timedwait( &pd->condition, &mpd->mutex, &abstime ); + + pthread_cleanup_pop(0); + + return status; + +} + +//---------------------------------------------------------------------------- +// +// Decription: signal a thread to wake up. +// +// Use: public. +// +int Condition::signal() { + + PThreadConditionPrivateData *pd = + static_cast<PThreadConditionPrivateData *>(_prvData); + + return pthread_cond_signal( &pd->condition ); +} + +//---------------------------------------------------------------------------- +// +// Decription: signal many threads to wake up. +// +// Use: public. +// +int Condition::broadcast() { + + PThreadConditionPrivateData *pd = + static_cast<PThreadConditionPrivateData *>(_prvData); + + return pthread_cond_broadcast( &pd->condition ); +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadConditionPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadConditionPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..261428051ddf77090e2edbc5d9b6d54b95b377ba --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadConditionPrivateData.h @@ -0,0 +1,44 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThreadConditionPrivateData.h - Private data structure for Condition +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// + +#ifndef _PTHREADCONDITIONPRIVATEDATA_H_ +#define _PTHREADCONDITIONPRIVATEDATA_H_ + +#include <pthread.h> +#include <OpenThreads/Condition> + +namespace OpenThreads { + +class PThreadConditionPrivateData { + + friend class Condition; + +private: + + PThreadConditionPrivateData() {}; + + virtual ~PThreadConditionPrivateData() {}; + + pthread_cond_t condition; + +}; + +} + +#endif // !_PTHREADCONDITIONPRIVATEDATA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadMutex.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadMutex.c++ new file mode 100755 index 0000000000000000000000000000000000000000..733c9fcb5ceb084da9243293a199468d2a83381c --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadMutex.c++ @@ -0,0 +1,154 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThreadMutex.c++ - C++ Mutex class built on top of posix threads. +// ~~~~~~~~~~~~~~~~ +// + +#include <unistd.h> +#include <pthread.h> +#include <OpenThreads/Mutex> +#include "PThreadMutexPrivateData.h" + +using namespace OpenThreads; + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Mutex::Mutex() { + + pthread_mutexattr_t mutex_attr; + pthread_mutexattr_init( &mutex_attr ); + + PThreadMutexPrivateData *pd = new PThreadMutexPrivateData(); + +#ifndef __linux__ // (not available until NPTL) [ + pthread_mutexattr_settype( &mutex_attr, PTHREAD_MUTEX_ERRORCHECK ); +#endif // ] __linux__ + +#ifdef ALLOW_PRIORITY_SCHEDULING // [ + +#ifdef __sun // [ + pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_NONE); +#endif // ] __sun + + //------------------------------------------------------------------------- + // Initialization is a bit tricky, since we have to be able to be aware + // that on many-to-many execution vehicle systems, we may run into + // priority inversion deadlocks if a mutex is shared between threads + // of differing priorities. Systems that do this should provide the + // following protocol attributes to prevent deadlocks. Check at runtime. + // + // PRIO_INHERIT causes any thread locking the mutex to temporarily become + // the same priority as the highest thread also blocked on the mutex. + // Although more expensive, this is the prefered method. + // + // PRIO_PROTECT causes any thread locking the mutex to assume the priority + // specified by setprioceiling. pthread_mutex_lock will fail if + // the priority ceiling is lower than the thread's priority. Therefore, + // the priority ceiling must be set to the max priority in order to + // garantee no deadlocks will occur. + // +#if defined (_POSIX_THREAD_PRIO_INHERIT) || defined (_POSIX_THREAD_PRIO_PROTECT) // [ + + if(sysconf(_POSIX_THREAD_PRIO_INHERIT)) { + + pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_INHERIT); + + } else if (sysconf(_POSIX_THREAD_PRIO_PROTECT)) { + + int th_policy; + struct sched_param th_param; + pthread_getschedparam(pthread_self(), &th_policy, &th_param); + + pthread_mutexattr_setprotocol(&mutex_attr, PTHREAD_PRIO_PROTECT); + pthread_mutexattr_setprioceiling(&mutex_attr, + sched_get_priority_max(th_policy)); + + } + +#endif // ] Priority Scheduling. + +#endif // ] ALLOW_PRIORITY_SCHEDULING + + pthread_mutex_init(&pd->mutex, &mutex_attr); + _prvData = static_cast<void *>(pd); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Mutex::~Mutex() { + + PThreadMutexPrivateData *pd = + static_cast<PThreadMutexPrivateData*>(_prvData); + + pthread_mutex_destroy(&pd->mutex); + + delete pd; + +} + +//---------------------------------------------------------------------------- +// +// Decription: lock the mutex +// +// Use: public. +// +int Mutex::lock() { + + PThreadMutexPrivateData *pd = + static_cast<PThreadMutexPrivateData*>(_prvData); + + return pthread_mutex_lock(&pd->mutex); + +} + +//---------------------------------------------------------------------------- +// +// Decription: unlock the mutex +// +// Use: public. +// +int Mutex::unlock() { + + PThreadMutexPrivateData *pd = + static_cast<PThreadMutexPrivateData*>(_prvData); + + return pthread_mutex_unlock(&pd->mutex); + +} + +//---------------------------------------------------------------------------- +// +// Decription: test if the mutex may be locked +// +// Use: public. +// +int Mutex::trylock() { + + PThreadMutexPrivateData *pd = + static_cast<PThreadMutexPrivateData*>(_prvData); + + return pthread_mutex_trylock(&pd->mutex); + +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadMutexPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadMutexPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..25d967073f7f4e7f38e7752ca5295320e4dff7b1 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadMutexPrivateData.h @@ -0,0 +1,47 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThreadMutexPrivateData.h - Private data structure for Mutex +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// + +#ifndef _PTHREADMUTEXPRIVATEDATA_H_ +#define _PTHREADMUTEXPRIVATEDATA_H_ + +#include <pthread.h> +#include <OpenThreads/Mutex> + +namespace OpenThreads { + +class PThreadMutexPrivateData { + + friend class Mutex; + + friend class Condition; + +private: + + PThreadMutexPrivateData() {}; + + virtual ~PThreadMutexPrivateData() {}; + + pthread_mutex_t mutex; + +}; + +} + +#endif // !_PTHREADMUTEXPRIVATEDATA_H_ + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..26a56b936b4e80c2f238c9794506cd4ed5bfefa5 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/pthreads/PThreadPrivateData.h @@ -0,0 +1,74 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// PThreadPrivateData.h - Private data structure for Thread +// ~~~~~~~~~~~~~~~~~~~~~ + +#ifndef _PTHREADPRIVATEDATA_H_ +#define _PTHREADPRIVATEDATA_H_ + +#include <pthread.h> +#include <OpenThreads/Thread> + +namespace OpenThreads { + +class PThreadPrivateData { + + //------------------------------------------------------------------------- + // We're friendly to Thread, so it can use our data. + // + friend class Thread; + + //------------------------------------------------------------------------- + // We're friendly to PThreadPrivateActions, so it can get at some + // variables. + // + friend class ThreadPrivateActions; + +private: + + PThreadPrivateData() {}; + + virtual ~PThreadPrivateData() {}; + + volatile unsigned int stackSize; + + volatile bool stackSizeLocked; + + volatile bool isRunning; + + volatile bool isCanceled; + + volatile bool idSet; + + volatile Thread::ThreadPriority threadPriority; + + volatile Thread::ThreadPolicy threadPolicy; + + pthread_t tid; + + volatile int uniqueId; + + volatile int cpunum; + + static int nextId; + + static pthread_key_t s_tls_key; + +}; + +} + +#endif // !_PTHREADPRIVATEDATA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/CMakeLists.txt b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..5e79b5d31e83ec9bb5d2a56949211eb351e8bf37 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/CMakeLists.txt @@ -0,0 +1,58 @@ +# This file should only be included when using Sproc + +SET(LIB_NAME OpenThreads) +SET(LIB_PUBLIC_HEADERS ${OpenThreads_PUBLIC_HEADERS}) + +ADD_LIBRARY(${LIB_NAME} + ${OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC} + ${LIB_PUBLIC_HEADERS} + SharedArena.c++ + SharedArena.h + SprocBarrier.c++ + SprocBarrierPrivateData.h + SprocCondition.c++ + SprocConditionPrivateData.h + SprocMutex.c++ + SprocMutexPrivateData.h + SprocThread.c++ + SprocThreadPrivateActions.h + SprocThreadPrivateData.h +) + +IF(OPENTHREADS_SONAMES) + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${OPENTHREADS_VERSION} SOVERSION ${OPENTHREADS_SOVERSION}) +ENDIF(OPENTHREADS_SONAMES) + +# Do we need to link against anything for Sproc? +#TARGET_LINK_LIBRARIES(${LIB_NAME} +#) + +# Since we're building different platforms binaries in +# their respective directories, we need to set the +# link directory so it can find this location. +LINK_DIRECTORIES( + ${CMAKE_CURRENT_BINARY_DIR} +) + +# OTB Modifications +#INSTALL( +# TARGETS OpenThreads +# ARCHIVE DESTINATION lib${LIB_POSTFIX} +# LIBRARY DESTINATION lib${LIB_POSTFIX} +# RUNTIME DESTINATION bin +#) +INSTALL(TARGETS OpenThreads +RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries +LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries +ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT Development) + + +#INSTALL( +# FILES ${OpenThreads_PUBLIC_HEADERS} +# DESTINATION include/OpenThreads +#) +INSTALL(FILES ${OpenThreads_PUBLIC_HEADERS} + DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbopenthreads/OpenThreads/include + COMPONENT Development) + +#commented out# INCLUDE(ModuleInstall OPTIONAL) diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/GNUmakefile b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/GNUmakefile new file mode 100755 index 0000000000000000000000000000000000000000..1da6eda227dd785d596fdb11f2a0b6987ff5941a --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/GNUmakefile @@ -0,0 +1,17 @@ +TOPDIR = ../. +include $(TOPDIR)/Make/makedefs + +C++FILES = \ + SprocThread.c++ \ + SprocMutex.c++ \ + SprocBarrier.c++ \ + SprocCondition.c++ \ + SharedArena.c++ \ + $(NULL) + +INC += -I$(TOPDIR)/include -I. + +TARGET_BASENAME = OpenThreads +LIB = libOpenThreads + +include $(TOPDIR)/Make/makerules diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SharedArena.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SharedArena.c++ new file mode 100755 index 0000000000000000000000000000000000000000..7f9db7a130511886125e2afad30dda09e08bfda7 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SharedArena.c++ @@ -0,0 +1,256 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SharedArena.c++ - Facilities for creating/destroying shared arenas +// ~~~~~~~~~~~~~~~ + +#include <unistd.h> +#include <sys/types.h> +#include <poll.h> +#include <bstring.h> +#include <sys/stat.h> +#include <sys/param.h> +#include <stdlib.h> + +#include "SharedArena.h" + +using namespace OpenThreads; + +#ifdef DEBUG +# define DPRINTF(arg) printf arg +#else +# define DPRINTF(arg) +#endif + +#define MAX_PROCS 1024 + +#define SEMAPHORE_ARENA_SIZE 500000 + +//---------------------------------------------------------------------------- +// Static arena initialization +// +usptr_t *SharedArena::_arena = 0; + +int SharedArena::_numLocks = 0; + +char *SharedArena::_arenaName = 0; + + +void SharedArena::initArena() { + + _arenaName = tmpnam(0); + DPRINTF(("Creating arena: %s\n", _arenaName)); + + if (unlink(_arenaName) < 0) { + if (errno != ENOENT) { + perror("unlink"); + exit(1); + } + } + + if (usconfig(CONF_INITUSERS, MAX_PROCS) < 0) { + perror("usconfig1"); + exit(1); + } + +#ifdef OT_USESHAREDONLY + if (usconfig(CONF_ARENATYPE, US_SHAREDONLY) < 0) { + perror("usconfig2"); + exit(1); + } +#endif + + char *sema_arena_size_string = getenv("OPENTHREADS_SEMAPHORE_ARENA_SIZE"); + unsigned long int sema_arena_size; + if(sema_arena_size_string != 0L) { + sema_arena_size = atol(sema_arena_size_string); + } else { + sema_arena_size = SEMAPHORE_ARENA_SIZE; + } + + if (usconfig(CONF_INITSIZE,sema_arena_size) < 0) { + perror("usconfig3"); + exit(1); + } + + + if ((_arena = usinit(_arenaName)) == 0) { + perror("usinit"); + exit(1); + } +} + +void SharedArena::removeArena() { + + DPRINTF(("Removing arena: %s\n", _arenaName)); +#ifndef OT_USESHAREDONLY + + if (unlink(_arenaName) < 0) { + perror("unlink"); + exit(1); + } +#endif + +} + +ulock_t SharedArena::allocLock() { + + if(_numLocks == 0) initArena(); + + assert(_arena != 0); + + ulock_t lock; + if ((lock = usnewlock(_arena)) == 0) { + perror("usnewlock"); + printf("Num Locks: %d\n", _numLocks); + exit(1); + } + ++_numLocks; + return lock; +} + +barrier_t *SharedArena::allocBarrier() { + + if(_numLocks == 0) initArena(); + + assert(_arena != 0); + barrier_t *bar; + if ((bar= new_barrier(_arena)) == 0) { + perror("new_barrier"); + exit(1); + } + ++_numLocks; + return bar; + +} + +int SharedArena::lock(ulock_t lock) { + + return ussetlock(lock); +} + +int SharedArena::unlock(ulock_t lock) { + + return usunsetlock(lock); +} + +int SharedArena::trylock(ulock_t lock) { + + return ustestlock(lock); +} + +void SharedArena::deleteLock(ulock_t lock) { + + assert(_arena != 0); + usfreelock(lock, _arena); + --_numLocks; + if(_numLocks == 0) { + removeArena(); + } +} + +void SharedArena::initBarrier(barrier_t *b) { + init_barrier(b); +} + +void SharedArena::freeBarrier(barrier_t *b) { + assert(_arena != 0); + free_barrier(b); + b = 0; + --_numLocks; + if(_numLocks == 0) { + removeArena(); + } +} + +void SharedArena::block(barrier_t *b, unsigned int n) { + barrier(b, n); +} + +usema_t *SharedArena::allocSema() { + + if(_numLocks == 0) initArena(); + assert(_arena != 0); + + usema_t *sema; + sema = usnewpollsema(_arena, 0); + if(sema == 0) { + perror("usnewpollsema"); + printf("NUM SEMAS: %d\n", _numLocks); + exit(1); + } + ++_numLocks; + return sema; + +} + +int SharedArena::getSemaFd(usema_t *sema) { + + int returnval; + returnval = usopenpollsema(sema, S_IRWXU | S_IRWXG | S_IRWXO); + if(0 > returnval) { + perror("usopenpollsema"); + exit(1); + } + return returnval; + +} + + + +int SharedArena::pSema(usema_t *sema) { + + return uspsema(sema); + +} + +int SharedArena::vSema(usema_t *sema) { + + return usvsema(sema); + +} + +int SharedArena::testSema(usema_t *sema) { + + return ustestsema(sema); + +} + +int SharedArena::closeSemaFd(usema_t *sema) { + + int returnval; + returnval = usclosepollsema(sema); + if(returnval != 0) { + perror("usclosepollsema"); + exit(1); + } + + return returnval; + +} + +int SharedArena::freeSema(usema_t *sema) { + + assert(_arena != 0); + usfreepollsema(sema, _arena); + --_numLocks; + if(_numLocks == 0) { + removeArena(); + } + + return 0; +} + +#undef OT_USESHAREDONLY diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SharedArena.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SharedArena.h new file mode 100755 index 0000000000000000000000000000000000000000..df3d678f646c35f13436a528406667d120394c67 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SharedArena.h @@ -0,0 +1,87 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// SharedArena.h - Facilities for creating/destroying shared arenas +// ~~~~~~~~~~~~~ + +#ifndef _SHAREDARENA_H_ +#define _SHAREDARENA_H_ + +#include <unistd.h> +#include <ulocks.h> +#include <errno.h> +#include <assert.h> + +namespace OpenThreads { + +#define OT_USESHAREDONLY + +class SharedArena { + + friend class Mutex; + + friend class Barrier; + + friend class Condition; + +private: + + static void initArena(); + + static void removeArena(); + + static ulock_t allocLock(); + + static barrier_t *allocBarrier(); + + static usema_t *allocSema(); + + static int getSemaFd(usema_t *sema); + + static int pSema(usema_t *sema); + + static int vSema(usema_t *sema); + + static int testSema(usema_t *sema); + + static int closeSemaFd(usema_t *sema); + + static int freeSema(usema_t *sema); + + static int lock(ulock_t lock); + + static int unlock(ulock_t lock); + + static int trylock(ulock_t lock); + + static void deleteLock(ulock_t lock); + + static void initBarrier(barrier_t *b); + + static void freeBarrier(barrier_t *b); + + static void block(barrier_t *b, unsigned int n); + +private: + + static usptr_t *_arena; + + static int _numLocks; + + static char *_arenaName; +}; + +} + +#endif // !_SHAREDARENA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocBarrier.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocBarrier.c++ new file mode 100755 index 0000000000000000000000000000000000000000..2ffa4c6d81c84a91e4aa45681c0e6b9855f8e58d --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocBarrier.c++ @@ -0,0 +1,229 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SprocBarrier.c++ - C++ Barrier class built on top of IRIX process threads. +// ~~~~~~~~~~~~~~~~ + +#include <ulocks.h> +#include <OpenThreads/Barrier> +#include "SprocBarrierPrivateData.h" +#include "SharedArena.h" +#include "SprocThreadPrivateActions.h" + +#ifndef USE_IRIX_NATIVE_BARRIER + +#include <OpenThreads/Condition> +#include <OpenThreads/Mutex> + +#endif + +#ifdef DEBUG +#define DPRINTF(arg) printf arg; fflush(stdout); +#else +#define DPRINTF(arg) +#endif + +using namespace OpenThreads; + +//---------------------------------------------------------------------------- +// This cancel cleanup handler is necessary to ensure that the barrier's +// mutex gets unlocked on cancel. Otherwise deadlocks could occur with +// later joins. +// +void barrier_cleanup_handler(void *arg) { + + DPRINTF(("(SPROC BARRIER) cleanup handler called on pid %d\n", getpid())); + + Mutex *mutex = static_cast<Mutex *>(arg); + + if(mutex->trylock() == 1) + mutex->unlock(); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Barrier::Barrier(int numThreads) { + + SprocBarrierPrivateData *pd = new SprocBarrierPrivateData(); + +#ifdef USE_IRIX_NATIVE_BARRIER + + pd->barrier = SharedArena::allocBarrier(); + pd->numThreads = numThreads; + +#else + + pd->cnt = 0; + pd->phase = 0; + pd->maxcnt = numThreads; + +#endif + + _prvData = static_cast<void *>(pd); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Barrier::~Barrier() { + + SprocBarrierPrivateData *pd = + static_cast<SprocBarrierPrivateData*>(_prvData); + +#ifdef USE_IRIX_NATIVE_BARRIER + + SharedArena::freeBarrier(pd->barrier); + +#endif + + delete pd; +} + +//---------------------------------------------------------------------------- +// +// Decription: Reset the barrier to its original state +// +// Use: public. +// +void Barrier::reset() { + + SprocBarrierPrivateData *pd = + static_cast<SprocBarrierPrivateData*>(_prvData); + +#ifdef USE_IRIX_NATIVE_BARRIER + + SharedArena::initBarrier(pd->barrier); + +#else + + pd->cnt = 0; + pd->phase = 0; + +#endif + +} + +//---------------------------------------------------------------------------- +// +// Decription: Block until numThreads threads have entered the barrier. +// +// Use: public. +// +void Barrier::block(unsigned int numThreads) { + + SprocBarrierPrivateData *pd = + static_cast<SprocBarrierPrivateData*>(_prvData); + +#ifdef USE_IRIX_NATIVE_BARRIER + + if(numThreads == 0) { + SharedArena::block(pd->barrier, pd->numThreads); + } else { + SharedArena::block(pd->barrier, numThreads); + } + +#else + + pd->_mutex.lock(); + + if(numThreads != 0) pd->maxcnt = numThreads; + + int my_phase; + + my_phase = pd->phase; + ++pd->cnt; + + DPRINTF(("(SPROC BARRIER %d) block, count=%d, maxThreads=%d, phase=%d\n", + getpid(), pd->cnt, pd->maxcnt, pd->phase)); + + if(pd->cnt == pd->maxcnt) { // I am the last one + pd->cnt = 0; // reset for next use + pd->phase = 1 - my_phase; // toggle phase + pd->_cond.broadcast(); + } + + while (pd->phase == my_phase) { + ThreadPrivateActions::PushCancelFunction(barrier_cleanup_handler, + &pd->_mutex); + pd->_cond.wait(&pd->_mutex); + + ThreadPrivateActions::PopCancelFunction(); + } + + pd->_mutex.unlock(); + +#endif + +} + +//---------------------------------------------------------------------------- +// +// Description: Release the barrier, now. +// +// Use: public. +// +void Barrier::release() { + + SprocBarrierPrivateData *pd = + static_cast<SprocBarrierPrivateData*>(_prvData); + +#ifdef USE_IRIX_NATIVE_BARRIER + + printf("ERROR >>>>> Barrier::release() cannot be implemented using native IRIX Barriers !!!\n"); + +#else + + int my_phase; + pd->_mutex.lock(); + + my_phase = pd->phase; + + pd->cnt = 0; // reset for next use + pd->phase = 1 - my_phase; // toggle phase + pd->_cond.broadcast(); + + pd->_mutex.unlock(); + +#endif + +} + +//---------------------------------------------------------------------------- +// +// Description: Return the number of threads currently blocked in the barrier +// +// Use: public +// +int Barrier::numThreadsCurrentlyBlocked() { + + SprocBarrierPrivateData *pd = + static_cast<SprocBarrierPrivateData*>(_prvData); + + int numBlocked = -1; + pd->_mutex.lock(); + numBlocked = pd->cnt; + pd->_cond.broadcast(); + return numBlocked; + +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocBarrierPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocBarrierPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..02a11b4cc40dde3e7ed3a477c834242e8106ea4f --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocBarrierPrivateData.h @@ -0,0 +1,67 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// SprocBarrierPrivateData.h - private data structure for barrier +// ~~~~~~~~~~~~~~~~~~~~~~~~~ + +#ifndef _SPROCBARRIERPRIVATEDATA_H_ +#define _SPROCBARRIERPRIVATEDATA_H_ + +#include <ulocks.h> +#include <OpenThreads/Barrier> + +#ifndef USE_IRIX_NATIVE_BARRIER + +#include <OpenThreads/Condition> +#include <OpenThreads/Mutex> + +#endif + +namespace OpenThreads { + +class SprocBarrierPrivateData { + + friend class Barrier; + +private: + + SprocBarrierPrivateData() {}; + + virtual ~SprocBarrierPrivateData() {}; + +#ifdef USE_IRIX_NATIVE_BARRIER + + barrier_t *barrier; + + unsigned int numThreads; + +#else + + OpenThreads::Condition _cond; + + OpenThreads::Mutex _mutex; + + volatile int maxcnt; + + volatile int cnt; + + volatile int phase; + +#endif + +}; + +} + +#endif //_SPROCBARRIERPRIVATEDATA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocCondition.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocCondition.c++ new file mode 100755 index 0000000000000000000000000000000000000000..3b56af59b66f610dd74ff68259e8012f52370e9a --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocCondition.c++ @@ -0,0 +1,306 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SprocCondition.c++ - C++ Condition class built on sprocs. +// ~~~~~~~~~~~~~~~~~~ + +#include <OpenThreads/Condition> +#include "SprocConditionPrivateData.h" +#include <OpenThreads/Mutex> +#include "SharedArena.h" +#include "SprocThreadPrivateActions.h" +#include <errno.h> +#include <signal.h> + +using namespace OpenThreads; + +#ifdef DEBUG + +#define DPRINTF(arg) printf arg; fflush(stdout); +#define DPRINTLIST(arg) ConditionDebug::printList arg; fflush(stdout); + +namespace OpenThreads { + +class ConditionDebug { + + friend class Condition; + +private: + + static void printList(std::list<pid_t> &pid_list) { + + std::list<pid_t>::iterator iter; + int counter = 0; + printf("(SPROC CONDITION %d) ", getpid()); + for(iter=pid_list.begin(); iter!=pid_list.end();++iter) { + printf("Pid [%d]=%d, ", counter, *iter); + ++counter; + } + printf("\b\n"); + + } + +}; + +} + +#else + +#define DPRINTF(arg) +#define DPRINTLIST(arg) + +#endif + +void condition_alarm_handler(int signal) { + + //DPRINTF(("(SPROC CONDITION) signal alarm handler called.\n")); + + sigset(SIGALRM, SIG_DFL); + + unblockproc(getpid()); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Condition::Condition() { + + SprocConditionPrivateData *pd = + new SprocConditionPrivateData(); + + _prvData = static_cast<void *>(pd); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Condition::~Condition() { + + SprocConditionPrivateData *pd = + static_cast<SprocConditionPrivateData *>(_prvData); + + pd->mutex.lock(); + DPRINTF(("(SPROC CONDITION) : In destructor\n")); + DPRINTLIST((pd->pid_list)); + + //------------------------------------------------------------------------- + // Destroy all remaining in the linked-list of waiters (pids). + // + pd->pid_list.clear(); + + delete pd; + _prvData = 0; + +} + +//---------------------------------------------------------------------------- +// +// Decription: wait on a condition +// +// Use: public. +// +int Condition::wait(Mutex *mutex) { + + return wait(mutex, 0); + +} + +//---------------------------------------------------------------------------- +// +// Decription: wait on a condition +// +// Use: public. +// +int Condition::wait(Mutex *mutex, unsigned long int ms) { + + unsigned int sec; + unsigned int usec; + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + + pid_t mypid = getpid(); + + SprocConditionPrivateData *pd = + static_cast<SprocConditionPrivateData *>(_prvData); + + if(ms != 0) { + + // Wait for ms milliseconds + sec = ms / 1000; + usec = (ms % 1000) * 1000; + tv.tv_sec = sec; + tv.tv_usec = usec; + + DPRINTF(("(SPROC CONDITION) : PID %d timeout values [%d | %d]\n", + mypid, tv.tv_sec, tv.tv_usec)); + + } + + pd->mutex.lock(); + + pd->pid_list.push_front(mypid); + + pd->mutex.unlock(); + + DPRINTF(("(SPROC CONDITION) : PID %d going to blockproc\n", + mypid)); + + int status = 0; + + status = setblockproccnt(mypid, 0); + + // If we're doing a timout, setup the signal handler to deal with it. + if(tv.tv_sec != 0 || tv.tv_usec != 0) { + + DPRINTF(("(SPROC CONDITION) : PID %d setting timeout condition\n", + mypid)); + + sigset(SIGALRM, condition_alarm_handler); + + struct timeval recur; + recur.tv_sec = 0; + recur.tv_usec = 0; + + itimerval itv; + itv.it_interval = recur; + itv.it_value = tv; + + setitimer(ITIMER_REAL, &itv, NULL); + + } + + mutex->unlock(); + + ThreadPrivateActions::ThreadCancelTest(); + + status = blockproc(mypid); + + ThreadPrivateActions::ThreadCancelTest(); + + mutex->lock(); + + DPRINTF(("(SPROC CONDITION) : PID %d, returned from blockproc %d\n", + mypid, status)); + + //------------------------------------------------------------------------- + // Pull the pid from the list + // + pd->mutex.lock(); + + DPRINTLIST((pd->pid_list)); + +#ifndef DEBUG + + // KLUDGE - can optimized this by just doing -remove()- + std::list<pid_t>::iterator iter; + iter = pd->pid_list.begin(); + while(iter != pd->pid_list.end()) { + + if(*iter == mypid) { + DPRINTF(("(SPROC CONDITION) : PID %d removed itself from the list\n", + mypid)); + + pd->pid_list.remove(mypid); + iter = pd->pid_list.begin(); + } else { + ++iter; + } + + } + +#else + pd->pid_list.remove(mypid); +#endif + + DPRINTLIST((pd->pid_list)); + + pd->mutex.unlock(); + + if(status == -1) { + return status; + } + + return 0; +} + +//---------------------------------------------------------------------------- +// +// Decription: signal a thread to wake up. +// +// Use: public. +// +int Condition::signal() { + + ThreadPrivateActions::ThreadCancelTest(); + + SprocConditionPrivateData *pd = + static_cast<SprocConditionPrivateData *>(_prvData); + + pd->mutex.lock(); + if(pd->pid_list.empty()) { + DPRINTF(("(SPROC CONDITION) : No threads to signal\n")); + pd->mutex.unlock(); // Remember to release the mutex. + return 0; + } + //------------------------------------------------------------------------- + // Perform an unblockproc on the first pid in the list. + // + DPRINTF(("(SPROC CONDITION) : PID %d signaling pid %d\n", + getpid(), pd->pid_list.front())); + int status = unblockproc(pd->pid_list.front()); + pd->mutex.unlock(); + return status; +} + +//---------------------------------------------------------------------------- +// +// Decription: signal all threads to wake up. +// +// Use: public. +// +int Condition::broadcast() { + + + ThreadPrivateActions::ThreadCancelTest(); + + SprocConditionPrivateData *pd = + static_cast<SprocConditionPrivateData *>(_prvData); + + pd->mutex.lock(); + + std::list<pid_t>::iterator iter; + for(iter = pd->pid_list.begin(); + iter != pd->pid_list.end(); + ++iter) { + + DPRINTF(("(SPROC CONDITION) Broadcast to pid[%d]\n", *iter)); + unblockproc(*iter); + } + + pd->mutex.unlock(); + + return 0; +} + + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocConditionPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocConditionPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..a758412b2293171365c63a3096a4ace9ea77eb9c --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocConditionPrivateData.h @@ -0,0 +1,82 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SprocConditionPrivateData.h - Private data structure for Condition +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#ifndef _SPROCCONDITIONPRIVATEDATA_H_ +#define _SPROCCONDITIONPRIVATEDATA_H_ + +#include <unistd.h> +#include <sys/types.h> +#include <bstring.h> +#include <sys/time.h> +#include <ulocks.h> +#include <list> + +#include <OpenThreads/Mutex> +#include <OpenThreads/Condition> + +namespace OpenThreads { + +class SemaLink { + + friend class SprocConditionPrivatedata; + + friend class Condition; + + friend class ConditionDebug; + +private: + + SemaLink() {}; + + virtual ~SemaLink() {}; + + SemaLink *next; + + usema_t *sema; + + int select_cond; // 0=pre-select, 1=in-select, 2=post-select + +}; + +class SprocConditionPrivateData { + + friend class Condition; + +private: + + SprocConditionPrivateData() { + + pid_list.clear(); + + }; + + virtual ~SprocConditionPrivateData() { + + pid_list.clear(); + + }; + + std::list<pid_t> pid_list; + + Mutex mutex; + +}; + +} + +#endif // !_SPROCCONDITIONPRIVATEDATA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocMutex.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocMutex.c++ new file mode 100755 index 0000000000000000000000000000000000000000..700927c1da54c79ef19a84f445e7ab056d6d0652 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocMutex.c++ @@ -0,0 +1,126 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SprocMutex.c++ - C++ Mutex class built on top of posix threads. +// ~~~~~~~~~~~~~~ + +#include <unistd.h> +#include <ulocks.h> +#include <errno.h> +#include <assert.h> + +#include <OpenThreads/Mutex> +#include "SharedArena.h" +#include "SprocMutexPrivateData.h" +#include "SprocThreadPrivateActions.h" + +using namespace OpenThreads; + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Mutex::Mutex() { + + SprocMutexPrivateData *pd = new SprocMutexPrivateData(); + + pd->mutex = SharedArena::allocLock(); + + _prvData = static_cast<void *>(pd); + +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Mutex::~Mutex() { + + SprocMutexPrivateData *pd = + static_cast<SprocMutexPrivateData*>(_prvData); + + SharedArena::deleteLock(pd->mutex); + + delete pd; + +} + +//---------------------------------------------------------------------------- +// +// Decription: lock the mutex +// +// Use: public. +// +int Mutex::lock() { + + ThreadPrivateActions::ThreadCancelTest(); + + SprocMutexPrivateData *pd = + static_cast<SprocMutexPrivateData*>(_prvData); + + int status = SharedArena::lock(pd->mutex); + + if(status == -1) { + return status; + } + + if(status == 1) { + return 0; + } else { + return 1; + } + return 0; +} + +//---------------------------------------------------------------------------- +// +// Decription: unlock the mutex +// +// Use: public. +// +int Mutex::unlock() { + + SprocMutexPrivateData *pd = + static_cast<SprocMutexPrivateData*>(_prvData); + + int status = SharedArena::unlock(pd->mutex); + + ThreadPrivateActions::ThreadCancelTest(); + + return status; + +} + +//---------------------------------------------------------------------------- +// +// Decription: test if the mutex may be locked +// +// Use: public. +// +int Mutex::trylock() { + + SprocMutexPrivateData *pd = + static_cast<SprocMutexPrivateData*>(_prvData); + + int status = SharedArena::trylock(pd->mutex); + + return status; + +} + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocMutexPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocMutexPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..8a09318f4570da20e11333e969dd92d23833ab8a --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocMutexPrivateData.h @@ -0,0 +1,45 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SprocMutexPrivateData.h - Private data structure for Mutex +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#ifndef _SPROCMUTEXPRIVATEDATA_H_ +#define _SPROCMUTEXPRIVATEDATA_H_ + +#include <ulocks.h> +#include <OpenThreads/Mutex> + +namespace OpenThreads { + +class SprocMutexPrivateData { + + friend class SprocThreadPrivateActions; + + friend class Mutex; + +private: + + SprocMutexPrivateData() {}; + + virtual ~SprocMutexPrivateData() {}; + + ulock_t mutex; + +}; + +} + +#endif // _SPROCMUTEXPRIVATEDATA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThread.c++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThread.c++ new file mode 100755 index 0000000000000000000000000000000000000000..47cd81fe85e8884157d80a784c01c8dc9b9daa37 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThread.c++ @@ -0,0 +1,800 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SprocThread.c++ - C++ Thread class built on top of IRIX sproc. +// ~~~~~~~~~~~~~~~ + +#include <stdlib.h> +#include <stdio.h> +#include <sched.h> +#include <sys/types.h> +#include <sys/prctl.h> +#include <sys/wait.h> +#include <sys/sysmp.h> +#include <signal.h> +#include <unistd.h> +#include <list> +#include <OpenThreads/Thread> +#include "SprocMutexPrivateData.h" +#include "SprocThreadPrivateData.h" +#include "SprocThreadPrivateActions.h" + +using namespace OpenThreads; + +extern int errno; +const char *OPENTHREAD_VERSION_STRING = "Sproc Thread Model, v1.1 ("__DATE__" "__TIME__")"; + +#ifdef DEBUG +#define DPRINTF(arg) printf arg; fflush(stdout); +#else +#define DPRINTF(ARG) +#endif + +void sproc_dead_child_sig_handler(int sigid); + +//----------------------------------------------------------------------------- +// Initialize the static unique ids. +// +int SprocThreadPrivateData::nextId = 0; + +//----------------------------------------------------------------------------- +// Initialize thread master priority level +// +Thread::ThreadPriority Thread::s_masterThreadPriority = + Thread::THREAD_PRIORITY_MAX; + +bool Thread::s_isInitialized = false; + +std::list<Thread *> ThreadPrivateActions::s_threadList; + +void ThreadPrivateActions::ThreadCancelTest() { + + OpenThreads::Thread *t = GetThread(getpid()); + + if(t != 0L) { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *>(t->_prvData); + + bool *dieflag = GetDeathFlag(t); + + if(*dieflag==false) return; + + DPRINTF(("(SPROC THREAD) Thread Cancel Test Passed for %d\n", + getpid())); + + if(!pd->cancelFuncStack.empty()) + pd->cancelFuncStack.top().routine(pd->cancelFuncStack.top().arg); + + t->cancelCleanup(); + pd->isRunning = false; + + exit(1); + } +} + +bool *ThreadPrivateActions::GetDeathFlag(Thread *thread) { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *>(thread->_prvData); + + return (bool *)(&(pd->dieFlag)); +} + +Thread *ThreadPrivateActions::GetThread(pid_t thread_id) { + + std::list<Thread *>::iterator iter; + for(iter = s_threadList.begin(); + iter != s_threadList.end(); + ++iter) { + + Thread *t = *iter; + if(t->getProcessId() == thread_id) return t; + + } + + return 0L; // no thread found; + +}; + +void ThreadPrivateActions::ThreadCancelHandler(int sigid) { + + Thread *t = GetThread(getpid()); + + if(t != 0L) { + + bool * dieflag = GetDeathFlag(t); + + *dieflag = true; + + sigset(SIGINT, SIG_DFL); + unblockproc(getpid()); + } +} + +//------------------------------------------------------------------------- +// standard start routine. +// +void ThreadPrivateActions::StartThread(void *data) { + + Thread *thread = static_cast<Thread *>(data); + + AddThread(thread); + + *((Thread **)&PRDA->usr_prda) = (Thread *)thread; + + SetThreadSchedulingParams(thread); + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *>(thread->_prvData); + + sigset(SIGINT, ThreadCancelHandler); + + size_t defaultStackSize; + prctl(PR_GETSTACKSIZE, &defaultStackSize); + + if(defaultStackSize < pd->stackSize) { + prctl(PR_SETSTACKSIZE, pd->stackSize); + } + + prctl(PR_GETSTACKSIZE, &pd->stackSize); + + pd->stackSizeLocked = true; + + pd->isRunning = true; + thread->run(); + pd->isRunning = false; + + RemoveThread(thread); + + if(pd->detached == true ) { + exit(0); + } + + return; + +}; + +void ThreadPrivateActions::AddThread(Thread *thread) { + + s_threadList.push_front(thread); + + }; + +void ThreadPrivateActions::RemoveThread(Thread *thread) { + s_threadList.remove(thread); +}; + +void ThreadPrivateActions::PrintThreadSchedulingInfo(Thread *thread) { + + int status, my_policy, min_priority, max_priority; + struct sched_param my_param; + + status = sched_getparam(thread->getProcessId(), + &my_param); + + my_policy = sched_getscheduler(thread->getProcessId()); + + if(status != 0 || my_policy == -1) { + + printf("THREAD INFO (%d) : Get sched param: %s/%s\n", + thread->getProcessId(), + strerror(status), + strerror(errno)); + } else { + printf( + "THREAD INFO (%d) : Thread running at %s / Priority: %d\n", + thread->getProcessId(), + (my_policy == SCHED_FIFO ? "SCHEDULE_FIFO" + : (my_policy == SCHED_RR ? "SCHEDULE_ROUND_ROBIN" + : (my_policy == SCHED_TS ? "SCHEDULE_TIME_SHARE" + : (my_policy == SCHED_OTHER ? "SCHEDULE_OTHER" + : "UNKNOWN")))), + my_param.sched_priority); + + max_priority = sched_get_priority_max(my_policy); + min_priority = sched_get_priority_min(my_policy); + + printf( + "THREAD INFO (%d) : Max priority: %d, Min priority: %d\n", + thread->getProcessId(), + max_priority, min_priority); + + } + +} + +int ThreadPrivateActions::SetThreadSchedulingParams(Thread *thread) { + + int status; + + int th_priority; + int max_priority, nominal_priority, min_priority; + + max_priority = 0; // This is as high as we can regularly go. + min_priority = 20; + nominal_priority = (max_priority + min_priority)/2; + + switch(thread->getSchedulePriority()) { + + case Thread::THREAD_PRIORITY_MAX: + th_priority = max_priority; + break; + + case Thread::THREAD_PRIORITY_HIGH: + th_priority = (max_priority + nominal_priority)/2; + break; + + case Thread::THREAD_PRIORITY_NOMINAL: + th_priority = nominal_priority; + break; + + case Thread::THREAD_PRIORITY_LOW: + th_priority = (min_priority + nominal_priority)/2; + break; + + case Thread::THREAD_PRIORITY_MIN: + th_priority = min_priority; + break; + + default: + th_priority = max_priority; + break; + + } + + status = setpriority(PRIO_PROCESS, thread->getProcessId(), + th_priority); + + if(getenv("OUTPUT_THREADLIB_SCHEDULING_INFO") != 0) + PrintThreadSchedulingInfo(thread); + + return status; +}; + +void ThreadPrivateActions::PushCancelFunction(void (*routine)(void *), void *arg) { + + Thread *thread = GetThread(getpid()); + + if(thread != 0L) { + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *>(thread->_prvData); + + SprocThreadPrivateData::CancelFuncStruct c; + + pd->cancelFuncStack.push(c); + + SprocThreadPrivateData::CancelFuncStruct *cft = &(pd->cancelFuncStack.top()); + + cft->routine = routine; + cft->arg = arg; + } +} + +void ThreadPrivateActions::PopCancelFunction() { + + Thread *thread = GetThread(getpid()); + + if(thread != 0L) { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *>(thread->_prvData); + + if(!pd->cancelFuncStack.empty()) + pd->cancelFuncStack.pop(); + } +} + +//---------------------------------------------------------------------------- +// +// Description: Set the concurrency level (no-op) +// +// Use static public +// +int Thread::SetConcurrency(int concurrencyLevel) { + + return -1; + +}; + +//---------------------------------------------------------------------------- +// +// Description: Get the concurrency level +// +// Use static public +// +int Thread::GetConcurrency() { + + return -1; + +}; + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Thread::Thread() { + + if(!s_isInitialized) Init(); + + SprocThreadPrivateData *pd = new SprocThreadPrivateData(); + pd->stackSize = 128*1024; // Set a minimum of 128K bytes if possible. + pd->stackSizeLocked = false; + pd->isRunning = false; + pd->isCanceled = false; + pd->idSet = false; + pd->cancelActive = true; + pd->detached = false; + pd->uniqueId = pd->nextId; + pd->nextId++; + pd->threadPriority = Thread::THREAD_PRIORITY_DEFAULT; + pd->threadPolicy = Thread::THREAD_SCHEDULE_DEFAULT; + + _prvData = static_cast<void *>(pd); +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Thread::~Thread() { + + DPRINTF(("(SPROC THREAD) %s:%d, In OpenThreads::Thread destructor\n", + __FILE__, __LINE__)); + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *>(_prvData); + + if(pd->isRunning) { + + DPRINTF(("(SPROC THREAD) %s:%d, about to kill OpenThreads::Thread\n", + __FILE__, __LINE__)); + + + //------------------------------------------------------------------- + // Kill the process when the thread is destroyed. + // + cancel(); + + while (pd->isRunning == true) { + ::usleep(1); + } + + } + + + DPRINTF(("(SPROC THREAD) %s:%d, Thread destroying private data.\n", + __FILE__, __LINE__)); + + + delete pd; + +} + +//----------------------------------------------------------------------------- +// +// Description: Initialize Threading +// +// Use: public. +// +void Thread::Init() { + + if(s_isInitialized) return; + +#ifdef GP_DEBUG + fprintf(stderr, "%s\n", OPENTHREAD_VERSION_STRING); +#endif + + s_masterThreadPriority = Thread::THREAD_PRIORITY_MAX; + + s_isInitialized = true; + +} + +//----------------------------------------------------------------------------- +// +// Description: Return a pointer to the currently executing thread +// +// Use: public +// +Thread *Thread::CurrentThread() { + + return (*(Thread **)&PRDA->usr_prda); + +} + +//----------------------------------------------------------------------------- +// +// Description: Get a unique identifier for this thread. +// +// Use: public +// +int Thread::getThreadId() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + return pd->uniqueId; +} + +//----------------------------------------------------------------------------- +// +// Description: Get the thread's process id +// +// Use: public +// +size_t Thread::getProcessId() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + if(pd->idSet == false) return getpid(); + + return (size_t)(pd->pid); + +} + +//----------------------------------------------------------------------------- +// +// Description: Determine if the thread is running +// +// Use: public +// +bool Thread::isRunning() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + return pd->isRunning; + +} + +//----------------------------------------------------------------------------- +// +// Description: Start the thread. +// +// Use: public +// +int Thread::start() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + int pid = sproc(ThreadPrivateActions::StartThread, + PR_SALL, + static_cast<void *>(this)); + + // PR_SADDR | PR_SDIR | PR_SUMASK | PR_SULIMIT | PR_SID, + + if(pid < 0) { + perror("sproc encountered an error"); + return -1; + } + + //----------------------------------------------------------------- + // Make the thread runnable anywhere. + // + sysmp(MP_RUNANYWHERE_PID, pid); + + pd->pid = pid; + pd->idSet = true; + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: Alternate thread start routine. +// +// Use: public +// +int Thread::startThread() { return start(); } + +//----------------------------------------------------------------------------- +// +// Description: Join the thread. +// +// Use: public +// +int Thread::detach() { + + int status = 0; + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + pd->detached=true; + sigset(SIGCLD, sproc_dead_child_sig_handler); + + return status; + +} + +//----------------------------------------------------------------------------- +// +// Description: Join the thread. +// +// Use: public +// +int Thread::join() { + + int status; + + return waitpid((pid_t)getProcessId(), &status, NULL); + //return status; + +} + +//----------------------------------------------------------------------------- +// +// Description: test the cancel state of the thread. +// +// Use: public +// +int Thread::testCancel() { + + if(getpid() != getProcessId()) return -1; + + ThreadPrivateActions::ThreadCancelTest(); + + return 0; +} + +//----------------------------------------------------------------------------- +// +// Description: Cancel the thread. +// +// Use: public +// +int Thread::cancel() { + + int status = 0; + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + if(pd->cancelActive) { + + status = kill((pid_t)getProcessId(), SIGINT); + }; + + return status; + +} + +//----------------------------------------------------------------------------- +// +// Description: Disable cancelibility +// +// Use: public +// +int Thread::setCancelModeDisable() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + pd->cancelActive = false; + + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: set the thread to cancel immediately +// +// Use: public +// +int Thread::setCancelModeAsynchronous() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + pd->cancelActive = true; + + return 0; +} + +//----------------------------------------------------------------------------- +// +// Description: set the thread to cancel at the next convienent point. +// +// Use: public +// +int Thread::setCancelModeDeferred() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + pd->cancelActive = true; + + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's schedule priority (if able) +// +// Use: public +// +int Thread::setSchedulePriority(ThreadPriority priority) { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + pd->threadPriority = priority; + + if(pd->isRunning) + return ThreadPrivateActions::SetThreadSchedulingParams(this); + else + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: Get the thread's schedule priority (if able) +// +// Use: public +// +int Thread::getSchedulePriority() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + return pd->threadPriority; + +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's scheduling policy (if able) +// +// Use: public +// +int Thread::setSchedulePolicy(ThreadPolicy policy) { + + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's scheduling policy (if able) +// +// Use: public +// +int Thread::getSchedulePolicy() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + return pd->threadPolicy; + +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's desired stack size +// +// Use: public +// +int Thread::setStackSize(size_t stackSize) { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + if(pd->stackSizeLocked == true) return 13; // EACESS + + pd->stackSize = stackSize; + + return 0; + +} + +//----------------------------------------------------------------------------- +// +// Description: Get the thread's stack size. +// +// Use: public +// +size_t Thread::getStackSize() { + + SprocThreadPrivateData *pd = + static_cast<SprocThreadPrivateData *> (_prvData); + + return pd->stackSize; + +} + +//----------------------------------------------------------------------------- +// +// Description: Print the thread's scheduling information to stdout. +// +// Use: public +// +void Thread::printSchedulingInfo() { + + ThreadPrivateActions::PrintThreadSchedulingInfo(this); + +} + +//----------------------------------------------------------------------------- +// +// Description: Yield the processor +// +// Use: protected +// +int Thread::YieldCurrentThread() { + + return sched_yield(); + +} + +//----------------------------------------------------------------------------- +// Description: sleep +// +// Use: public +// +int Thread::microSleep(unsigned int microsec) +{ + return ::usleep(microsec); +} + +static void sproc_dead_child_sig_handler(int sigid) { + +#ifdef DEBUG + int pid, status; + pid = wait(&status); + DPRINTF(("(SPROC THREAD) Dead Child Handler Caught Signal, Reaped %d\n", + pid)); +#endif + + sigset(SIGCLD, sproc_dead_child_sig_handler); + +} + +int Thread::setProcessorAffinity( unsigned int cpunum ) +{ + return -1; +} + +//----------------------------------------------------------------------------- +// +// Description: Get the number of processors +// +int OpenThreads::GetNumberOfProcessors() +{ + return 1; +} + +int OpenThreads::SetProcessorAffinityOfCurrentThread(unsigned int cpunum) +{ + if (cpunum<0) return -1; + + Thread* thread = Thread::CurrentThread(); + if (thread) + { + return thread->setProcessorAffinity(cpunum); + } + else + { + // non op right now, needs implementation. + } +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThreadPrivateActions.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThreadPrivateActions.h new file mode 100755 index 0000000000000000000000000000000000000000..a024eb4bb31ed835c6398cd9f8d8dd69dd547b3d --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThreadPrivateActions.h @@ -0,0 +1,71 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// SprocThreadPrivateActions.c++ - Thread private actions for sprocs +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#include <OpenThreads/Thread> +#include <list> + +#ifndef SPROC_THREAD_PRIVATE_ACTIONS +#define SPROC_THREAD_PRIVATE_ACTIONS + +namespace OpenThreads { + + class ThreadPrivateActions { + + //------------------------------------------------------------------------- + // We're friendly to Thread, so it can issue the methods. + // + friend class Thread; + + public: + + static void ThreadCancelTest(); + + static void PushCancelFunction(void (*routine)(void *), void *arg); + + static void PopCancelFunction(); + + private: + + static bool *GetDeathFlag(Thread *thread); + + static Thread *GetThread(pid_t thread_id); + + static void ThreadCancelHandler(int sigid); + + //------------------------------------------------------------------------- + // standard start routine. + // + static void StartThread(void *data); + + static void AddThread(Thread *thread); + + static void RemoveThread(Thread *thread); + + static void PrintThreadSchedulingInfo(Thread *thread); + + static int SetThreadSchedulingParams(Thread *thread); + + private: + + static std::list<Thread *> s_threadList; + + }; + +} + +#endif // !SPROC_THREAD_PRIVATE_ACTIONS diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThreadPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThreadPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..f70aeacb449af8ea02ac97ba12894731438afab2 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/sproc/SprocThreadPrivateData.h @@ -0,0 +1,81 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// +// SprocThreadPrivateData.h - private data for sproc thread +// ~~~~~~~~~~~~~~~~~~~~~~~~ + +#ifndef _SPROCTHREADPRIVATEDATA_H_ +#define _SPROCTHREADPRIVATEDATA_H_ + +#include <sys/types.h> +#include <ulocks.h> +#include <stack> + +#include <OpenThreads/Thread> +#include "SprocThreadPrivateActions.h" + +namespace OpenThreads { + +class SprocThreadPrivateData { + + friend class Thread; + + friend class ThreadPrivateActions; + +private: + + struct CancelFuncStruct { + + void (*routine)(void *); + void *arg; + }; + + SprocThreadPrivateData() {}; + + virtual ~SprocThreadPrivateData() {}; + + volatile unsigned int stackSize; + + volatile bool stackSizeLocked; + + volatile bool isRunning; + + volatile bool isCanceled; + + volatile bool idSet; + + volatile bool cancelActive; + + volatile bool detached; + + volatile bool dieFlag; + + volatile Thread::ThreadPriority threadPriority; + + volatile Thread::ThreadPolicy threadPolicy; + + volatile pid_t pid; + + volatile int uniqueId; + + std::stack<CancelFuncStruct> cancelFuncStack; + + static int nextId; + +}; + +} + +#endif // !_SPROCTHREADPRIVATEDATA_H_ diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/CMakeLists.txt b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..f023e63bd72db68ef417b068ef8c13f8ab63e0ef --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/CMakeLists.txt @@ -0,0 +1,58 @@ +# This file should only be included when WIN32 + +SET(LIB_NAME OpenThreads) +SET(LIB_PUBLIC_HEADERS ${OpenThreads_PUBLIC_HEADERS}) + +SOURCE_GROUP("Header Files" FILES ${LIB_PUBLIC_HEADERS}) +SET_SOURCE_FILES_PROPERTIES(${LIB_PUBLIC_HEADERS} PROPERTIES HEADER_FILE_ONLY ON) + +ADD_LIBRARY(${LIB_NAME} + ${OPENTHREADS_USER_DEFINED_DYNAMIC_OR_STATIC} + ${LIB_PUBLIC_HEADERS} + HandleHolder.h + Win32BarrierPrivateData.h + WIN32Condition.cpp + Win32Condition.h + Win32ConditionPrivateData.h + Win32Mutex.cpp + Win32MutexPrivateData.h + Win32Thread.cpp + Win32ThreadBarrier.cpp + Win32ThreadPrivateData.h +) + + +IF(OPENTHREADS_SONAMES) + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${OPENTHREADS_VERSION} SOVERSION ${OPENTHREADS_SOVERSION}) +ENDIF(OPENTHREADS_SONAMES) + +# Since we're building different platforms binaries in +# their respective directories, we need to set the +# link directory so it can find this location. +LINK_DIRECTORIES( + ${CMAKE_CURRENT_BINARY_DIR} +) + +# OTB Modifications +#INSTALL( +# TARGETS OpenThreads +# ARCHIVE DESTINATION lib +# LIBRARY DESTINATION lib +# RUNTIME DESTINATION bin +#) +INSTALL(TARGETS OpenThreads +RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries +LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries +ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT Development) + + +#INSTALL( +# FILES ${OpenThreads_PUBLIC_HEADERS} +# DESTINATION include/OpenThreads +#) +INSTALL(FILES ${OpenThreads_PUBLIC_HEADERS} + DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbopenthreads/OpenThreads/include + COMPONENT Development) + + +#commented out# INCLUDE(ModuleInstall OPTIONAL) diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/GNUmakefile b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/GNUmakefile new file mode 100755 index 0000000000000000000000000000000000000000..163b0cc8b4d235909955aa5b0467c77e91d3a112 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/GNUmakefile @@ -0,0 +1,38 @@ +TOPDIR = ../. +include $(TOPDIR)/Make/makedefs + +CXXFILES = \ + WIN32Condition.cpp \ + Win32Mutex.cpp \ + Win32Thread.cpp \ + Win32ThreadBarrier.cpp \ + $(NULL) + +INC += -I$(TOPDIR)/include -I. + +ifeq ($(OS),Linux) +DEF += -fPIC -DLinux -DGL_GLEXT_PROTOTYPES +LIBS += -lpthread +endif + +ifeq ($(OS),SunOS) +LIBS += -lpthread -lposix4 +endif + +ifeq ($(OS),IRIX) +LIBS += -lpthread +endif + +ifeq ($(OS),Darwin) +LIBS += -lpthread +endif + +ifeq ($(OS),MINGW) +LIBS += +DEF += -DOPENTHREADS_EXPORTS +endif + +TARGET_BASENAME = OpenThreads +LIB = $(LIB_PREFIX)$(TARGET_BASENAME) + +include $(TOPDIR)/Make/makerules diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/HandleHolder.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/HandleHolder.h new file mode 100755 index 0000000000000000000000000000000000000000..026ab9d44f02409291f5e98e31cff1a6d3052f4d --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/HandleHolder.h @@ -0,0 +1,89 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// +// Win32BarrierPrivateData.h - private data structure for barrier +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +#ifndef _HandleHolder_H_ +#define _HandleHolder_H_ + +#ifndef _WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#endif + +/************************************************************************/ +/* Class that holds HANDLES ensuring proper destruction */ +/* It is design decision to make this class noncopyable. */ +/* It makes design much cleaner. If one wants to copy handle than one */ +/* can do hv.set(DuplicateHandle(....)) */ +/************************************************************************/ +namespace OpenThreads { + + class HandleHolder{ + private: + HANDLE _handle; + + inline void close(){ + if( _handle != INVALID_HANDLE_VALUE) CloseHandle(_handle); + _handle = INVALID_HANDLE_VALUE; + }; + + // copy constructor - disallow + HandleHolder(const HandleHolder& rhs); + + // assignment operator - disallow + HandleHolder& operator=(const HandleHolder& rhs ); + + public: + // constructor + HandleHolder() + :_handle(INVALID_HANDLE_VALUE) + {}; + + // constructor from HANDLE + explicit HandleHolder(HANDLE h) + :_handle(h) + {}; + + // destructor - CloseHandle() + ~HandleHolder() + { + close(); + }; + + // accessor + const HANDLE& get() const { + return _handle; + } + + // mutator + void set (HANDLE h) { + if( _handle != INVALID_HANDLE_VALUE ) close(); + _handle = h; + } + + operator bool (){ + return _handle != INVALID_HANDLE_VALUE && _handle != NULL; + }; + + }; + +} // namespace + + + + +#endif diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Makefile b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Makefile new file mode 100755 index 0000000000000000000000000000000000000000..a3abb4de9f12464fbb491ed9d2e1b6c4339aab14 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Makefile @@ -0,0 +1,18 @@ +# Makefile - OpenThreads.dsw + +.PHONY: all +all: \ + OpenThreads + +.PHONY: OpenThreads +OpenThreads: + $(MAKE) -f OpenThreads.mak + +.PHONY: clean +clean: + $(MAKE) -f OpenThreads.mak clean + +.PHONY: depends +depends: + $(MAKE) -f OpenThreads.mak depends + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.dsp b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.dsp new file mode 100755 index 0000000000000000000000000000000000000000..7e40f281c6aa2058ff6150b455925366f1df1bb2 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.dsp @@ -0,0 +1,231 @@ +# Microsoft Developer Studio Project File - Name="OpenThreads" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=OpenThreads - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "OpenThreads.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "OpenThreads.mak" CFG="OpenThreads - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "OpenThreads - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "OpenThreads - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "OpenThreads - Win32 Release Static" (based on "Win32 (x86) Static Library") +!MESSAGE "OpenThreads - Win32 Debug Static" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "OpenThreads - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPENTHREADS_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPENTHREADS_EXPORTS" /YX /FD /c +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /opt:ref /opt:icf /out:"$(OutDir)/OpenThreadsWin32.dll" /implib:"../lib/$(PlatformName)/OpenThreadsWin32.lib" + +!ELSEIF "$(CFG)" == "OpenThreads - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +CPP=cl.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPENTHREADS_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPENTHREADS_EXPORTS" /YX /FD /GZ /c +MTL=midl.exe +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /out:"$(OutDir)/OpenThreadsWin32d.dll" /implib:"../lib/$(PlatformName)/OpenThreadsWin32d.lib" + +!ELSEIF "$(CFG)" == "OpenThreads - Win32 Release Static" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_Static" +# PROP BASE Intermediate_Dir "Release_Static" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../lib/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +CPP=cl.exe +# ADD BASE CPP /nologo /MT /W3 /GR /GX /O2 /I "../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "OT_LIBRARY_STATIC" /D "OPENTHREADS_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "OT_LIBRARY_STATIC" /YX /FD /c +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"../lib/$(PlatformName)/OpenThreadsWin32_s.lib" + +!ELSEIF "$(CFG)" == "OpenThreads - Win32 Debug Static" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_Static" +# PROP BASE Intermediate_Dir "Debug_Static" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../lib/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +CPP=cl.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GR /GX /Z7 /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "OT_LIBRARY_STATIC" /D "OPENTHREADS_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /Z7 /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "OT_LIBRARY_STATIC" /YX /FD /GZ /c +RSC=rc.exe +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"../lib/$(PlatformName)/OpenThreadsWin32d_s.lib" + +!ENDIF + +# Begin Target + +# Name "OpenThreads - Win32 Release" +# Name "OpenThreads - Win32 Debug" +# Name "OpenThreads - Win32 Release Static" +# Name "OpenThreads - Win32 Debug Static" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\WIN32Condition.cpp +# End Source File +# Begin Source File + +SOURCE=.\Win32Mutex.cpp +# End Source File +# Begin Source File + +SOURCE=.\Win32Thread.cpp +# End Source File +# Begin Source File + +SOURCE=.\Win32ThreadBarrier.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\include\OpenThreads\Barrier +# End Source File +# Begin Source File + +SOURCE=..\include\OpenThreads\Condition +# End Source File +# Begin Source File + +SOURCE=..\include\OpenThreads\Exports +# End Source File +# Begin Source File + +SOURCE=.\HandleHolder.h +# End Source File +# Begin Source File + +SOURCE=..\include\OpenThreads\Mutex +# End Source File +# Begin Source File + +SOURCE=..\include\OpenThreads\ScopedLock +# End Source File +# Begin Source File + +SOURCE=..\include\OpenThreads\Thread +# End Source File +# Begin Source File + +SOURCE=.\Win32BarrierPrivateData.h +# End Source File +# Begin Source File + +SOURCE=.\Win32ConditionPrivateData.h +# End Source File +# Begin Source File + +SOURCE=.\Win32MutexPrivateData.h +# End Source File +# Begin Source File + +SOURCE=.\Win32ThreadPrivateData.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.dsw b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.dsw new file mode 100755 index 0000000000000000000000000000000000000000..be8b59a23d186409f97b9061efd558ae8dd7c256 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "OpenThreads"=.\OpenThreads.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.mak b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.mak new file mode 100755 index 0000000000000000000000000000000000000000..6880e1dc1b60d4d1548e5e120c8cc441540f4aea --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/OpenThreads.mak @@ -0,0 +1,89 @@ +# Makefile - OpenThreads.dsp + +ifndef CFG +CFG=OpenThreads - Win32 Release +endif +CC=gcc +CFLAGS= +CXX=g++ +CXXFLAGS=$(CFLAGS) +RC=windres -O COFF +ifeq "$(CFG)" "OpenThreads - Win32 Release" +CFLAGS+=-W -fexceptions -O2 -I../include -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DOPENTHREADS_EXPORTS +LD=g++ +LDFLAGS=-shared -Wl,--out-implib,../bin/Win32/OpenThreadsWin32.dll.a -Wl,--export-all-symbols +TARGET=../bin/Win32/OpenThreadsWin32.dll +LDFLAGS+= +LIBS+=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 +else +ifeq "$(CFG)" "OpenThreads - Win32 Debug" +CFLAGS+=-W -fexceptions -g -O0 -I../include -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DOPENTHREADS_EXPORTS +LD=g++ +LDFLAGS=-shared -Wl,--out-implib,../bin/Win32/OpenThreadsWin32d.dll.a -Wl,--export-all-symbols +TARGET=../bin/Win32/OpenThreadsWin32d.dll +LDFLAGS+= +LIBS+=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 +endif +endif + +ifndef TARGET +TARGET=OpenThreads.dll +endif + +.PHONY: all +all: $(TARGET) + +%.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< + +%.o: %.cc + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< + +%.o: %.cxx + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< + +%.res: %.rc + $(RC) $(CPPFLAGS) -o $@ -i $< + +SOURCE_FILES= \ + WIN32Condition.cpp \ + Win32Mutex.cpp \ + Win32Thread.cpp \ + Win32ThreadBarrier.cpp + +HEADER_FILES= \ + ../include/OpenThreads/Barrier \ + ../include/OpenThreads/Condition \ + ../include/OpenThreads/Exports \ + ../include/OpenThreads/Mutex \ + ../include/OpenThreads/ScopedLock \ + ../include/OpenThreads/Thread \ + Win32BarrierPrivateData.h \ + Win32Condition.h \ + Win32ConditionPrivateData.h \ + Win32MutexPrivateData.h \ + Win32ThreadPrivateData.h \ + HandleHolder.h + +RESOURCE_FILES= + +SRCS=$(SOURCE_FILES) $(HEADER_FILES) $(RESOURCE_FILES) + +OBJS=$(patsubst %.rc,%.res,$(patsubst %.cxx,%.o,$(patsubst %.cpp,%.o,$(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(filter %.c %.cc %.cpp %.cxx %.rc,$(SRCS))))))) + +$(TARGET): $(OBJS) + $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + +.PHONY: clean +clean: + -rm -f $(OBJS) $(TARGET) OpenThreads.dep + +.PHONY: depends +depends: + -$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MM $(filter %.c %.cc %.cpp %.cxx,$(SRCS)) > OpenThreads.dep + +-include OpenThreads.dep + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/WIN32Condition.cpp b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/WIN32Condition.cpp new file mode 100755 index 0000000000000000000000000000000000000000..4f2471eeb517d1dfb97dcef78d3d53682f09d86e --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/WIN32Condition.cpp @@ -0,0 +1,100 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// Win32Condition.c++ - C++ Condition class built on top of posix threads. +// ~~~~~~~~~~~~~~~~~~~~ +// +#include <OpenThreads/Condition> +#include <OpenThreads/Thread> +#include "Win32ConditionPrivateData.h" + +using namespace OpenThreads; +Win32ConditionPrivateData::~Win32ConditionPrivateData() +{ +} + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Condition::Condition() { + Win32ConditionPrivateData *pd = + new Win32ConditionPrivateData(); + _prvData = static_cast<void *>(pd); +} +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Condition::~Condition() { + Win32ConditionPrivateData *pd = + static_cast<Win32ConditionPrivateData *>(_prvData); + + delete pd; +} + +//---------------------------------------------------------------------------- +// +// Decription: wait on a condition +// +// Use: public. +// +int Condition::wait(Mutex *mutex) { + + Win32ConditionPrivateData *pd = + static_cast<Win32ConditionPrivateData *>(_prvData); + + return pd->wait(*mutex, INFINITE); +} +//---------------------------------------------------------------------------- +// +// Decription: wait on a condition, for a specified period of time +// +// Use: public. +// +int Condition::wait(Mutex *mutex, unsigned long ms) { + + Win32ConditionPrivateData *pd = + static_cast<Win32ConditionPrivateData *>(_prvData); + + return pd->wait(*mutex, ms); +} +//---------------------------------------------------------------------------- +// +// Decription: signal a thread to wake up. +// +// Use: public. +// +int Condition::signal() { + + Win32ConditionPrivateData *pd = + static_cast<Win32ConditionPrivateData *>(_prvData); + return pd->signal(); +} +//---------------------------------------------------------------------------- +// +// Decription: signal many threads to wake up. +// +// Use: public. +// +int Condition::broadcast() { + + Win32ConditionPrivateData *pd = + static_cast<Win32ConditionPrivateData *>(_prvData); + return pd->broadcast(); +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32BarrierPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32BarrierPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..d474e9cf4219694cc4580ddf4aa591f92e54992b --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32BarrierPrivateData.h @@ -0,0 +1,69 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// Win32BarrierPrivateData.h - private data structure for barrier +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +#ifndef _Win32BARRIERPRIVATEDATA_H_ +#define _Win32BARRIERPRIVATEDATA_H_ + +#ifndef _WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#endif + +#include <OpenThreads/Mutex> +#include <OpenThreads/Condition> + +namespace OpenThreads { + +class Barrier; + +class Win32BarrierPrivateData { + friend class Barrier; +private: + Win32BarrierPrivateData() {}; + ~Win32BarrierPrivateData(); + + Condition cond; // cv for waiters at barrier + + Mutex lock; // mutex for waiters at barrier + + volatile int maxcnt; // number of threads to wait for + + volatile int cnt; // number of waiting threads + + volatile int phase; // flag to seperate two barriers + + +}; + + + + + + + +} + + + + + + + +#endif //_Win32BARRIERPRIVATEDATA_H_ + + + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Condition.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Condition.h new file mode 100755 index 0000000000000000000000000000000000000000..23b34207f595d6464305b75ac5339e6f7fd91011 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Condition.h @@ -0,0 +1,159 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef _WIN32VODITIONPRODUCER_CONDITION +#define PRODUCER_CONDITION + +#ifdef WIN32 + +#include "Mutex.h" + +namespace OpenThreads { + +class Win32ConditionImpl +{ +public: + /// number of waiters. + long waiters_; + + Condition(long max = 0L) + { + waiters_ = 0; + sema_ = CreateSemaphore(NULL,0,0x7fffffff,NULL); + waiters_done_ = CreateEvent(NULL,FALSE,FALSE,NULL); + } + + ~Condition() + { + // CloseHandle(sema_); + // CloseHandle(waiters_done_); + } + + inline int broadcast () + { + waiters_lock_.lock(); + int have_waiters = 0; + + if (waiters_ > 0) + { + // We are broadcasting, even if there is just one waiter... + // Record the fact that we are broadcasting. This helps the + // wait() method know how to optimize itself. Be sure to + // set this with the <waiters_lock_> held. + was_broadcast_ = 1; + have_waiters = 1; + } + waiters_lock_.unlock(); + + int result = 0; + if (have_waiters) + { + // Wake up all the waiters. + ReleaseSemaphore(sema_,waiters_,NULL); + WaitForSingleObject(waiters_done_,INFINITE) ; + // This is okay, even without the <waiters_lock_> held because + // no other waiter threads can wake up to access it. + was_broadcast_ = 0; + } + return result; + } + + inline int wait (Mutex& external_mutex) + { + // Prevent race conditions on the <waiters_> count. + waiters_lock_.lock(); + waiters_++; + waiters_lock_.unlock(); + + int result = 0; + + external_mutex.unlock(); + + DWORD dwResult = WaitForSingleObject(sema_,INFINITE); + if(dwResult != WAIT_OBJECT_0) + result = (int)dwResult; + + // Reacquire lock to avoid race conditions on the <waiters_> count. + waiters_lock_.lock(); + + // We're ready to return, so there's one less waiter. + waiters_--; + + int last_waiter = was_broadcast_ && waiters_ == 0; + + // Release the lock so that other collaborating threads can make + // progress. + waiters_lock_.unlock(); + + if (result != -1 && last_waiter) + SetEvent(waiters_done_); + + external_mutex.lock(); + + return result; + } + + +protected: + + /// Serialize access to the waiters count. + Mutex waiters_lock_; + + /// Queue up threads waiting for the condition to become signaled. + HANDLE sema_; + /** + * An auto reset event used by the broadcast/signal thread to wait + * for the waiting thread(s) to wake up and get a chance at the + * semaphore. + */ + HANDLE waiters_done_; + + /// Keeps track of whether we were broadcasting or just signaling. + size_t was_broadcast_; + +}; +#else +#include <pthread.h> + +namespace Producer { + +class PR_EXPORT Condition +{ +public: + /// number of waiters. + Condition(long max) + { + pthread_cond_init( &_cond, 0L ); + } + + ~Condition() + { + } + + inline int broadcast () + { + return pthread_cond_broadcast(&_cond); + } + + inline int wait (Mutex& external_mutex) + { + return pthread_cond_wait(&_cond); + } + + +protected: + pthread_cond_t _cond; +}; +#endif +} +#endif \ No newline at end of file diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ConditionPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ConditionPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..0c2ec6bf054abc4ba0a0f46dc908f703a470c807 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ConditionPrivateData.h @@ -0,0 +1,163 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// +// WIN32ConditionPrivateData.h - Private data structure for Condition +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +#ifndef _WIN32CONDITIONPRIVATEDATA_H_ +#define _WIN32CONDITIONPRIVATEDATA_H_ + +#ifndef _WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#endif + +#include <OpenThreads/ScopedLock> + +#include "Win32ThreadPrivateData.h" +#include "HandleHolder.h" + +#define InterlockedGet(x) InterlockedExchangeAdd(x,0) + +namespace OpenThreads { + +class Condition; + +class Win32ConditionPrivateData { +public: + friend class Condition; + /// number of waiters. + long waiters_; + + Win32ConditionPrivateData () + :waiters_(0), + sema_(CreateSemaphore(NULL,0,0x7fffffff,NULL)), + waiters_done_(CreateEvent(NULL,FALSE,FALSE,NULL)) + { + } + + ~Win32ConditionPrivateData (); + + inline int broadcast () + { + int have_waiters = 0; + long w = InterlockedGet(&waiters_); + + if (w > 0) + { + // we are broadcasting. + was_broadcast_ = 1; + have_waiters = 1; + } + + int result = 0; + if (have_waiters) + { + // Wake up all the waiters. + ReleaseSemaphore(sema_.get(),waiters_,NULL); + + cooperativeWait(waiters_done_.get(), INFINITE); + + //end of broadcasting + was_broadcast_ = 0; + } + return result; + } + + inline int signal() + { + long w = InterlockedGet(&waiters_); + int have_waiters = w > 0; + + int result = 0; + + if (have_waiters) + { + if( !ReleaseSemaphore(sema_.get(),1,NULL) ) + result = -1; + } + return result; + } + + inline int wait (Mutex& external_mutex, long timeout_ms) + { + + // Prevent race conditions on the <waiters_> count. + InterlockedIncrement(&waiters_); + + int result = 0; + + ReverseScopedLock<Mutex> lock(external_mutex); + + // wait in timeslices, giving testCancel() a change to + // exit the thread if requested. + try { + DWORD dwResult = cooperativeWait(sema_.get(), timeout_ms); + if(dwResult != WAIT_OBJECT_0) + result = (int)dwResult; + } + catch(...){ + // thread is canceled in cooperative wait , do cleanup + InterlockedDecrement(&waiters_); + long w = InterlockedGet(&waiters_); + int last_waiter = was_broadcast_ && w == 0; + + if (last_waiter) SetEvent(waiters_done_.get()); + // rethrow + throw; + } + + + // We're ready to return, so there's one less waiter. + InterlockedDecrement(&waiters_); + long w = InterlockedGet(&waiters_); + int last_waiter = was_broadcast_ && w == 0; + + if (result != -1 && last_waiter) + SetEvent(waiters_done_.get()); + + return result; + } + +protected: + + /// Serialize access to the waiters count. + /// Mutex waiters_lock_; + /// Queue up threads waiting for the condition to become signaled. + HandleHolder sema_; + /** + * An auto reset event used by the broadcast/signal thread to wait + * for the waiting thread(s) to wake up and get a chance at the + * semaphore. + */ + HandleHolder waiters_done_; + /// Keeps track of whether we were broadcasting or just signaling. + size_t was_broadcast_; +}; + +#undef InterlockedGet + +} + + + + + + + +#endif // !_WIN32CONDITIONPRIVATEDATA_H_ + + + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Mutex.cpp b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Mutex.cpp new file mode 100755 index 0000000000000000000000000000000000000000..13ef5fbd2043756baaeacf62ea77e9130e39c077 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Mutex.cpp @@ -0,0 +1,222 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// +// Win32Mutex.c++ - C++ Mutex class . +// The idea for it is borrowed from SGI STL +// It looks like it's hard to use win32 CRITICALL_SECTIONS withour introducing race +// conditions on InitializeCriticalSection() . So we use spin mutex here. +// ~~~~~~~~~~~~~~~~ +// + +#include <OpenThreads/Mutex> +#include "Win32MutexPrivateData.h" +using namespace OpenThreads; + +Win32MutexPrivateData::Win32MutexPrivateData() +{ +#ifdef USE_CRITICAL_SECTION + InitializeCriticalSection( &_cs ); +#else + mutex = 0; +#endif +} +Win32MutexPrivateData::~Win32MutexPrivateData() +{ +#ifdef USE_CRITICAL_SECTION + DeleteCriticalSection( &_cs ); +#endif +} + + +#ifndef USE_CRITICAL_SECTION + +template <int instance> +struct WIN32MutexSpin { + + enum { __low_max = 30, __high_max = 1000 }; + // Low if we suspect uniprocessor, high for multiprocessor. + static unsigned __max; + static unsigned __last; +}; + +template <int instance> +unsigned WIN32MutexSpin <instance>::__max = WIN32MutexSpin <instance>::__low_max; + +template <int instance> +unsigned WIN32MutexSpin <instance>::__last = 0; + + + +static void _S_nsec_sleep(int __log_nsec) { + + if (__log_nsec <= 20) { + SwitchToThread(); //Sleep(0); // adegli replaced it Sleep by SwitchToThread + } else { + Sleep(1 << (__log_nsec - 20)); + } +} + + +#if defined(_MSC_VER) && _MSC_VER <= 1300 + template WIN32MutexSpin <0>; +#endif + +#endif // USE_CRITICAL_SECTION + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Mutex::Mutex() { + Win32MutexPrivateData *pd = new Win32MutexPrivateData(); + _prvData = static_cast<void *>(pd); +} + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Mutex::~Mutex() { + unlock(); + delete static_cast<Win32MutexPrivateData*>(_prvData); +} +//---------------------------------------------------------------------------- +// +// Decription: lock the mutex +// +// Use: public. +// +int Mutex::lock() { + Win32MutexPrivateData *pd = + static_cast<Win32MutexPrivateData*>(_prvData); + +#ifdef USE_CRITICAL_SECTION + + // Block until we can take this lock. + EnterCriticalSection( &(pd->_cs) ); + + return 0; + +#else + + volatile unsigned long* lock = &pd->mutex; + // InterlockedExchange returns old value + // if old_value == 0 mutex wasn't locked , now it is + if( !InterlockedExchange((long*)lock, 1L)) { + return 0; + } + + unsigned my_spin_max = WIN32MutexSpin<0>::__max; + unsigned my_last_spins = WIN32MutexSpin<0>::__last; + volatile unsigned junk = 17; + unsigned i; + + for (i = 0; i < my_spin_max; i++) { + if (i < my_last_spins/2 || *lock) { + junk *= junk; junk *= junk; + junk *= junk; junk *= junk; + continue; + } + + if (!InterlockedExchange((long*)lock, 1L)) { + // got it! + // Spinning worked. Thus we're probably not being scheduled + // against the other process with which we were contending. + // Thus it makes sense to spin longer the next time. + WIN32MutexSpin<0>::__last = i; + WIN32MutexSpin<0>::__max = WIN32MutexSpin<0>::__high_max; + return 0; + } + } + // We are probably being scheduled against the other process. Sleep. + WIN32MutexSpin<0>::__max = WIN32MutexSpin<0>::__low_max; + for (i = 0 ;; ++i) { + int __log_nsec = i + 6; + if (__log_nsec > 27) __log_nsec = 27; + if (!InterlockedExchange((long*)lock, 1L)) { + return 0; + } + _S_nsec_sleep(__log_nsec); + } + return -1; + +#endif // USE_CRITICAL_SECTION +} + +//---------------------------------------------------------------------------- +// +// Decription: unlock the mutex +// +// Use: public. +// +int Mutex::unlock() { + Win32MutexPrivateData *pd = + static_cast<Win32MutexPrivateData*>(_prvData); + +#ifdef USE_CRITICAL_SECTION + + // Release this lock. CRITICAL_SECTION is nested, thus + // unlock() calls must be paired with lock() calls. + LeaveCriticalSection( &(pd->_cs) ); + + return 0; + +#else + + volatile unsigned long* lock = &pd->mutex; + *lock = 0; + // This is not sufficient on many multiprocessors, since + // writes to protected variables and the lock may be reordered. + return 0; + +#endif // USE_CRITICAL_SECTION +} + +//---------------------------------------------------------------------------- +// +// Decription: test if the mutex may be locked +// +// Use: public. +// +int Mutex::trylock() { + Win32MutexPrivateData *pd = + static_cast<Win32MutexPrivateData*>(_prvData); + +#ifdef USE_CRITICAL_SECTION + + // Take the lock if we can; regardless don't block. + // 'result' is FALSE if we took the lock or already held + // it amd TRUE if another thread already owns the lock. + BOOL result = TryEnterCriticalSection( &(pd->_cs) ); + + return( (result==TRUE) ? 0 : 1 ); + +#else + + volatile unsigned long* lock = &pd->mutex; + + if( !InterlockedExchange((long*)lock, 1L)) { + return 1; // TRUE + } + + return 0; // FALSE + +#endif // USE_CRITICAL_SECTION +} + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32MutexPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32MutexPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..dd196dcc7ac98071f371a9521cb5c7127331fd19 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32MutexPrivateData.h @@ -0,0 +1,55 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// Win32MutexPrivateData.h - Private data structure for Mutex +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// + +#ifndef _Win32MUTEXPRIVATEDATA_H_ +#define _Win32MUTEXPRIVATEDATA_H_ + + +#ifndef _WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#define _WIN32_WINNT 0x0400 // was missing : adegli +#include <windows.h> +#endif +namespace OpenThreads { + +class Win32MutexPrivateData { + friend class Mutex; + friend class Condition; + +private: + + Win32MutexPrivateData(); + + ~Win32MutexPrivateData(); +#define USE_CRITICAL_SECTION +#ifdef USE_CRITICAL_SECTION + CRITICAL_SECTION _cs; +#else + volatile unsigned long mutex; +#endif + +}; + +} + +#endif // !_Win32MUTEXPRIVATEDATA_H_ + + + + + diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Thread.cpp b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Thread.cpp new file mode 100755 index 0000000000000000000000000000000000000000..aa1c3bab8735977ee0325bb15360685578670232 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32Thread.cpp @@ -0,0 +1,659 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + + +// +// Win32Thread.c++ +// ~~~~~~~~~~~ +#include <memory> +#include <string> +#include <iostream> + +#if defined(_MSC_VER) && (_MSC_VER < 1300) +#ifdef __SGI_STL +using std::size_t; +#endif +#else +using std::size_t; +#endif + +#if defined(_MSC_VER) + #pragma warning( disable : 4996 ) +#endif + +#include "Win32ThreadPrivateData.h" + +struct Win32ThreadCanceled{}; + +using namespace OpenThreads; + +DWORD OpenThreads::cooperativeWait(HANDLE waitHandle, unsigned long timeout){ + Thread* current = Thread::CurrentThread(); + DWORD dwResult ; + if(current) + { + HANDLE cancelHandle = static_cast<Win32ThreadPrivateData*>(current->getImplementation())->cancelEvent.get(); + HANDLE handleSet[2] = {waitHandle, cancelHandle}; + + dwResult = WaitForMultipleObjects(2,handleSet,FALSE,timeout); + if(dwResult == WAIT_OBJECT_0 + 1 ) throw Win32ThreadCanceled(); + } + else + { + dwResult = WaitForSingleObject(waitHandle,timeout); + } + + return dwResult; +} + +Win32ThreadPrivateData::TlsHolder Win32ThreadPrivateData::TLS; + +Win32ThreadPrivateData::~Win32ThreadPrivateData() +{ +} + +const std::string OPENTHREAD_VERSION_STRING = "OpenThread v1.2preAlpha, WindowThreads (Public Implementation)"; + + +//----------------------------------------------------------------------------- +// Initialize thread master priority level +// +Thread::ThreadPriority Thread::s_masterThreadPriority = Thread::THREAD_PRIORITY_DEFAULT; + +bool Thread::s_isInitialized = false; +//----------------------------------------------------------------------------- +// Class to support some static methods necessary for pthread's to work +// correctly. +// +namespace OpenThreads { + + class ThreadPrivateActions { + //------------------------------------------------------------------------- + // We're friendly to Thread, so it can issue the methods. + // + friend class Thread; + private: + + //------------------------------------------------------------------------- + // Win32Threads standard start routine. + // + static unsigned long __stdcall StartThread(void *data) { + + Thread *thread = static_cast<Thread *>(data); + Win32ThreadPrivateData *pd = + static_cast<Win32ThreadPrivateData *>(thread->_prvData); + + TlsSetValue(Win32ThreadPrivateData::TLS.ID ,data); + //--------------------------------------------------------------------- + // Set the proper scheduling priorities + // + SetThreadSchedulingParams(thread); + + pd->isRunning = true; + + try{ + thread->run(); + } + catch(Win32ThreadCanceled&) + { + // thread is canceled do cleanup + try { + thread->cancelCleanup(); + } catch(...) { } + } + catch(...) + { + // abnormal termination but must be caught in win32 anyway + } + + pd->isRunning = false; + + return 0; + }; + + //------------------------------------------------------------------------- + // Print information related to thread schduling parameters. + // + static void PrintThreadSchedulingInfo(Thread *thread) { + Win32ThreadPrivateData *pd = + static_cast<Win32ThreadPrivateData *>(thread->_prvData); + + std::cout<<"Thread "<< thread <<" priority : "; + + switch(thread->getSchedulePriority()) { + case Thread::THREAD_PRIORITY_MAX: + std::cout<<"MAXIMAL"<<std::endl; + break; + case Thread::THREAD_PRIORITY_HIGH: + std::cout<<"HIGH"<<std::endl; + break; + case Thread::THREAD_PRIORITY_DEFAULT: + case Thread::THREAD_PRIORITY_NOMINAL: + std::cout<<"NORMAL"<<std::endl; + break; + case Thread::THREAD_PRIORITY_LOW: + std::cout<<"LOW"<<std::endl; + break; + case Thread::THREAD_PRIORITY_MIN: + std::cout<<"MINIMAL"<<std::endl; + break; + } + } + + //-------------------------------------------------------------------------- + // Set thread scheduling parameters. + // Note that time-critical priority is ommited : + // 1) It's not sensible thing to do + // 2) there's no enum for that in Thread interface + // Also, on Windows, effective thread priority is : + // process priority (manipulated with Get/SetProrityClass) + thread priority (here). + // + // + static int SetThreadSchedulingParams(Thread *thread) { + + Win32ThreadPrivateData *pd = + static_cast<Win32ThreadPrivateData *>(thread->_prvData); + + int prio = THREAD_PRIORITY_NORMAL; + + switch(thread->getSchedulePriority()) { + case Thread::THREAD_PRIORITY_MAX: + prio = THREAD_PRIORITY_HIGHEST; + break; + case Thread::THREAD_PRIORITY_HIGH: + prio = THREAD_PRIORITY_ABOVE_NORMAL; + break; + case Thread::THREAD_PRIORITY_NOMINAL: + prio = THREAD_PRIORITY_NORMAL; + break; + case Thread::THREAD_PRIORITY_LOW: + prio = THREAD_PRIORITY_BELOW_NORMAL; + break; + case Thread::THREAD_PRIORITY_MIN: + prio = THREAD_PRIORITY_IDLE; + break; + } + + int status = SetThreadPriority( pd->tid.get(), prio); + + if(getenv("OUTPUT_THREADLIB_SCHEDULING_INFO") != 0) + PrintThreadSchedulingInfo(thread); + + return status!=0; + }; + }; +}; + +Thread* Thread::CurrentThread() +{ + return (Thread* )TlsGetValue(Win32ThreadPrivateData::TLS.ID); +}; + +//---------------------------------------------------------------------------- +// +// Description: Set the concurrency level (no-op) +// +// Use static public +// +int Thread::SetConcurrency(int) { + return -1; +}; + +//---------------------------------------------------------------------------- +// +// Description: Get the concurrency level +// +// Use static public +// +int Thread::GetConcurrency() { + return -1; +}; + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Thread::Thread() { + + // there's no need for this + // if(!s_isInitialized) Init(); + + Win32ThreadPrivateData *pd = new Win32ThreadPrivateData(); + + pd->stackSize = 0; + pd->isRunning = false; + pd->cancelMode = 0; + pd->uniqueId = 0; + pd->threadPriority = Thread::THREAD_PRIORITY_DEFAULT; + pd->threadPolicy = Thread::THREAD_SCHEDULE_DEFAULT; + pd->detached = false; + pd->cancelEvent.set(CreateEvent(NULL,TRUE,FALSE,NULL)); + + _prvData = static_cast<void *>(pd); +} + + +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Thread::~Thread() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *>(_prvData); + if(pd->isRunning) { + std::cout<<"Error: Thread "<<this<<" still running in destructor"<<std::endl; + pd->cancelMode = 0; + cancel(); + } + delete pd; +} +//----------------------------------------------------------------------------- +// +// Description: Initialize Threading +// +// Use: public. +// +void Thread::Init() { +// if(s_isInitialized) return; +// s_masterThreadPriority = Thread::THREAD_PRIORITY_DEFAULT; + s_isInitialized = true; +} + +//----------------------------------------------------------------------------- +// +// Description: Get a unique identifier for this thread. +// +// Use: public +// +int Thread::getThreadId() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + return pd->uniqueId; +} +//----------------------------------------------------------------------------- +// +// Description: Get the thread's process id +// +// Use: public +// +size_t Thread::getProcessId() { + + return (size_t) GetCurrentProcessId(); + +} +//----------------------------------------------------------------------------- +// +// Description: Determine if the thread is running +// +// Use: public +// +bool Thread::isRunning() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + return pd->isRunning; +} +//----------------------------------------------------------------------------- +// +// Description: Start the thread. +// +// Use: public +// +int Thread::start() { + + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + //------------------------------------------------------------------------- + // Prohibit the stack size from being changed. + // (bb 5/13/2005) it acctualy doesn't matter. + // 1) usually setStackSize()/start() sequence iz serialized. + // 2) if not than we're in trouble anyway - nothing is protected + // pd->stackSizeLocked = true; + unsigned long ID; + + pd->tid.set( CreateThread(NULL,pd->stackSize,ThreadPrivateActions::StartThread,static_cast<void *>(this),0,&ID)); + + pd->uniqueId = (int)ID; + + if(!pd->tid) { + return -1; + } + + return 0; + +} + +int Thread::startThread() +{ return start(); } + +//----------------------------------------------------------------------------- +// +// Description: Join the thread. +// +// Use: public +// +int Thread::join() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + if( pd->detached ) + return -1; // cannot wait for detached ; + + if( WaitForSingleObject(pd->tid.get(),INFINITE) != WAIT_OBJECT_0) + return -1 ; + + return 0; +} + + + +int Thread::detach() +{ + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + pd->detached = true; + return 0; +} + + +//----------------------------------------------------------------------------- +// +// Description: Cancel the thread. +// +// Use: public +// +int Thread::cancel() +{ + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + + if (pd->isRunning) + { + if( pd->cancelMode == 2 ) + return -1; + + // signal all interested parties that we are going to exit + SetEvent(pd->cancelEvent.get()); + + // cancelMode == 1 (asynch)-> kill em + // cancelMode == 0 (deffered) -> wait a little then kill em + + // if( (pd->cancelMode == 1) || (WaitForSingleObject(pd->tid,INFINITE)!=WAIT_OBJECT_0) ) + if( pd->cancelMode == 1 ) + { + // did not terminate cleanly force termination + pd->isRunning = false; + return TerminateThread(pd->tid.get(),(DWORD)-1); + } + } + + return 0; +} + + + +int Thread::testCancel() +{ + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + + if(WaitForSingleObject(pd->cancelEvent.get(),0) != WAIT_OBJECT_0) return 0; + + if(pd->cancelMode == 2) + return 0; + + DWORD curr = GetCurrentThreadId(); + + if( pd->uniqueId != (int)curr ) + return -1; + +// pd->isRunning = false; +// ExitThread(0); + throw Win32ThreadCanceled(); + + return 0; + +} + + + +//----------------------------------------------------------------------------- +// +// Description: Disable cancelibility +// +// Use: public +// +int Thread::setCancelModeDisable() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + pd->cancelMode = 2; + return 0; +} + +//----------------------------------------------------------------------------- +// +// Description: set the thread to cancel immediately +// +// Use: public +// +int Thread::setCancelModeAsynchronous() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + pd->cancelMode = 1; + return 0; +} + +//----------------------------------------------------------------------------- +// +// Description: set the thread to cancel at the next convienent point. +// +// Use: public +// +int Thread::setCancelModeDeferred() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + pd->cancelMode = 0; + return 0; +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's schedule priority (if able) +// +// Use: public +// +int Thread::setSchedulePriority(ThreadPriority priority) { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + + pd->threadPriority = priority; + + if(pd->isRunning) + return ThreadPrivateActions::SetThreadSchedulingParams(this); + else + return 0; +} + + +//----------------------------------------------------------------------------- +// +// Description: Get the thread's schedule priority (if able) +// +// Use: public +// +int Thread::getSchedulePriority() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + return pd->threadPriority; +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's scheduling policy (if able) +// +// Use: public +// +int Thread::setSchedulePolicy(ThreadPolicy policy) { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + + pd->threadPolicy = policy; + + if(pd->isRunning) + return ThreadPrivateActions::SetThreadSchedulingParams(this); + else + return 0; +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's scheduling policy (if able) +// +// Use: public +// +int Thread::getSchedulePolicy() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + return pd->threadPolicy; +} + +//----------------------------------------------------------------------------- +// +// Description: Set the thread's desired stack size +// +// Use: public +// +int Thread::setStackSize(size_t stackSize) { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + if(pd->isRunning) return 13; // cannot set stack size of running thread return EACESS + pd->stackSize = stackSize; + return 0; +} +//----------------------------------------------------------------------------- +// +// Description: Get the thread's stack size. +// +// Use: public +// +size_t Thread::getStackSize() { + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + return pd->stackSize; +} + +//----------------------------------------------------------------------------- +// +// Description: set processor affinity for the thread +// +// Use: public +// +int Thread::setProcessorAffinity( unsigned int cpunum ) +{ + Win32ThreadPrivateData *pd = static_cast<Win32ThreadPrivateData *> (_prvData); + DWORD affinityMask = 0x1 << cpunum ; // thread affinity mask + DWORD_PTR res = + SetThreadAffinityMask + ( + pd->tid.get(), // handle to thread + affinityMask // thread affinity mask + ); +/* + This one is funny. + This is "non-mandatory" affinity , winows will try to use dwIdealProcessor + whenever possible ( when Bill's account is over 50B, maybe :-) ). + + DWORD SetThreadIdealProcessor( + HANDLE hThread, // handle to the thread + DWORD dwIdealProcessor // ideal processor number + ); +*/ + // return value 1 means call is ignored ( 9x/ME/SE ) + if( res == 1 ) return -1; + // return value 0 is failure + return (res == 0) ? GetLastError() : 0 ; +} + +//----------------------------------------------------------------------------- +// +// Description: Print the thread's scheduling information to stdout. +// +// Use: public +// +void Thread::printSchedulingInfo() { + ThreadPrivateActions::PrintThreadSchedulingInfo(this); +} + + +//----------------------------------------------------------------------------- +// +// Description: Yield the processor +// +// Use: protected +// +#if _WIN32_WINNT < 0x0400 // simulate +int SwitchToThread (void) +{ + ::Sleep(10); + return 0; +}; +#endif + +int Thread::YieldCurrentThread() +{ + return SwitchToThread(); +} + +int Thread::microSleep(unsigned int microsec) +{ +#if _WIN32_WINNT < 0x0400 // simulate + ::Sleep(microsec/1000); + return 0; +#else + HandleHolder sleepTimer(CreateWaitableTimer(NULL, TRUE, NULL)); + + if( !sleepTimer ) + return -1; + + LARGE_INTEGER t; + + t.QuadPart= -(LONGLONG)microsec*10; // in 100ns units + // negative sign means relative, + + if (!SetWaitableTimer(sleepTimer.get(), &t, 0, NULL, NULL, 0)) + { + return -1; + } + + // Wait for the timer. + if (WaitForSingleObject(sleepTimer.get(), INFINITE) != WAIT_OBJECT_0) + { + return -1; + } + return 0; +#endif +} + + +//----------------------------------------------------------------------------- +// +// Description: Get the number of processors +// +int OpenThreads::GetNumberOfProcessors() +{ + SYSTEM_INFO sysInfo; + GetSystemInfo(&sysInfo); + + return sysInfo.dwNumberOfProcessors; +} + +int OpenThreads::SetProcessorAffinityOfCurrentThread(unsigned int cpunum) +{ + if (cpunum<0) return -1; + + Thread* thread = Thread::CurrentThread(); + if (thread) + { + return thread->setProcessorAffinity(cpunum); + } + else + { + // non op right now, needs implementation. + return -1; + } +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ThreadBarrier.cpp b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ThreadBarrier.cpp new file mode 100755 index 0000000000000000000000000000000000000000..af5d173931a5d2f729a5020dbd8876421e30ab55 --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ThreadBarrier.cpp @@ -0,0 +1,149 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// Win32Barrier.c++ - C++ Barrier class built on top of POSIX threads. +// ~~~~~~~~~~~~~~~~~~ +// + +#include <OpenThreads/Barrier> +#include <OpenThreads/Thread> +#include <OpenThreads/ScopedLock> +#include "Win32BarrierPrivateData.h" +using namespace OpenThreads; + +// so compiler can place it somewhere +Win32BarrierPrivateData::~Win32BarrierPrivateData() +{ +}; + +//---------------------------------------------------------------------------- +// +// Decription: Constructor +// +// Use: public. +// +Barrier::Barrier(int numThreads) { + Win32BarrierPrivateData *pd = new Win32BarrierPrivateData(); + pd->cnt = 0; + pd->phase = 0; + pd->maxcnt = numThreads; + _valid = true; + _prvData = static_cast<void *>(pd); +} +//---------------------------------------------------------------------------- +// +// Decription: Destructor +// +// Use: public. +// +Barrier::~Barrier() { + Win32BarrierPrivateData *pd = + static_cast<Win32BarrierPrivateData*>(_prvData); + delete pd; +} +//---------------------------------------------------------------------------- +// +// Decription: Reset the barrier to its original state +// +// Use: public. +// +void Barrier::reset() { + Win32BarrierPrivateData *pd = + static_cast<Win32BarrierPrivateData*>(_prvData); + pd->cnt = 0; + pd->phase = 0; +} +//---------------------------------------------------------------------------- +// +// Decription: Block until numThreads threads have entered the barrier. +// +// Use: public. +// +void Barrier::block(unsigned int numThreads) { + + Win32BarrierPrivateData *pd = + static_cast<Win32BarrierPrivateData*>(_prvData); + + if(numThreads != 0) pd->maxcnt = numThreads; + int my_phase; + + ScopedLock<Mutex> lock(pd->lock); + if( _valid ) + { + my_phase = pd->phase; + ++pd->cnt; + + if (pd->cnt == pd->maxcnt) { // I am the last one + pd->cnt = 0; // reset for next use + pd->phase = 1 - my_phase; // toggle phase + pd->cond.broadcast(); + }else{ + while (pd->phase == my_phase ) { + pd->cond.wait(&pd->lock); + } + } + } +} + +void Barrier::invalidate() +{ + Win32BarrierPrivateData *pd = + static_cast<Win32BarrierPrivateData*>(_prvData); + + pd->lock.lock(); + _valid = false; + pd->lock.unlock(); + release(); +} + + +//---------------------------------------------------------------------------- +// +// Description: Release the barrier, now. +// +// Use: public. +// +void Barrier::release() { + + Win32BarrierPrivateData *pd = + static_cast<Win32BarrierPrivateData*>(_prvData); + + int my_phase; + + ScopedLock<Mutex> lock(pd->lock); + my_phase = pd->phase; + + pd->cnt = 0; // reset for next use + pd->phase = 1 - my_phase; // toggle phase + pd->cond.broadcast(); + +} + +//---------------------------------------------------------------------------- +// +// Description: Return the number of threads currently blocked in the barrier +// +// Use: public +// +int Barrier::numThreadsCurrentlyBlocked() { + + Win32BarrierPrivateData *pd = + static_cast<Win32BarrierPrivateData*>(_prvData); + + int numBlocked = -1; + ScopedLock<Mutex> lock(pd->lock); + numBlocked = pd->cnt; + return numBlocked; + +} diff --git a/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ThreadPrivateData.h b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ThreadPrivateData.h new file mode 100755 index 0000000000000000000000000000000000000000..a3de0e0360a6b2355ef6656d61611da4cfb3eebb --- /dev/null +++ b/Utilities/otbopenthreads/OpenThreads/src/OpenThreads/win32/Win32ThreadPrivateData.h @@ -0,0 +1,92 @@ +/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +// +// Win32PrivateData.h - Private data structure for Thread +// ~~~~~~~~~~~~~~~~~~~~~ +#ifndef _Win32PRIVATEDATA_H_ +#define _Win32PRIVATEDATA_H_ + +#ifndef _WINDOWS_ +#define WIN32_LEAN_AND_MEAN +#define _WIN32_WINNT 0x0400 +#include <windows.h> +#endif + +#include <OpenThreads/Thread> +#include "HandleHolder.h" + +namespace OpenThreads { + + class Win32ThreadPrivateData { + //------------------------------------------------------------------------- + // We're friendly to Thread, so it can use our data. + // + friend class Thread; + //------------------------------------------------------------------------- + // We're friendly to Win32PrivateActions, so it can get at some + // variables. + // + friend class ThreadPrivateActions; + +private: + + Win32ThreadPrivateData() {}; + ~Win32ThreadPrivateData(); + + size_t stackSize; + bool isRunning; + + int cancelMode; // 0 - deffered (default) 1-asynch 2-disabled + + bool detached; + + Thread::ThreadPriority threadPriority; + + Thread::ThreadPolicy threadPolicy; + + HandleHolder tid; + + int uniqueId; + +public: + + HandleHolder cancelEvent; + + struct TlsHolder{ // thread local storage slot + DWORD ID; + TlsHolder(): ID(TlsAlloc()){ + } + ~TlsHolder(){ + TlsFree(ID); + } + }; + + static TlsHolder TLS; + +}; + +DWORD cooperativeWait(HANDLE waitHandle, unsigned long timeout); + + +} + + + + + + +#endif // !_PTHREADPRIVATEDATA_H_ + + + diff --git a/otbIncludeDirectories.cmake b/otbIncludeDirectories.cmake index b52a70d11da4be0d9429cf9d42540ede03329097..10f5f0c66c7e0fce243f76c5623143c1c524b51d 100644 --- a/otbIncludeDirectories.cmake +++ b/otbIncludeDirectories.cmake @@ -143,7 +143,12 @@ ELSE(OTB_USE_EXTERNAL_EXPAT) ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbexpat ) ENDIF(OTB_USE_EXTERNAL_EXPAT) - +# For OpenThreads +IF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + SET(OTB_INCLUDE_DIRS_BUILD_TREE_CXX ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX} + ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbopenthreads/OpenThreads/include + ) +ENDIF(NOT OTB_USE_EXTERNAL_OPENTHREADS) #For ITK header file IF(OTB_USE_EXTERNAL_ITK) @@ -223,6 +228,12 @@ IF(OTB_USE_CURL) ${CURL_INCLUDE_DIR} ) ENDIF(OTB_USE_CURL) +# For OpentTreads header file +IF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + SET(OTB_INCLUDE_DIRS_INSTALL_TREE ${OTB_INCLUDE_DIRS_INSTALL_TREE} + ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbopenthreads/OpenThreads/include) +ENDIF(NOT OTB_USE_EXTERNAL_OPENTHREADS) + #For FLTK header file IF(OTB_USE_EXTERNAL_FLTK) SET(OTB_INCLUDE_DIRS_INSTALL_TREE ${OTB_INCLUDE_DIRS_INSTALL_TREE}