fix missing __PTHREAD__

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8109 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-12-28 08:46:45 +00:00
commit 62ecf24b23
2 changed files with 29 additions and 11 deletions

View file

@ -463,7 +463,9 @@ namespace Swig {
private: private:
typedef std::map<void*, GCItem_var> ownership_map; typedef std::map<void*, GCItem_var> ownership_map;
mutable ownership_map owner; mutable ownership_map owner;
#ifdef __PTHREAD__
static pthread_mutex_t swig_mutex_own; static pthread_mutex_t swig_mutex_own;
#endif
public: public:
template <typename Type> template <typename Type>

View file

@ -244,19 +244,33 @@ namespace Swig {
/* Simple thread abstraction for pthreads on win32 */ /* Simple thread abstraction for pthreads on win32 */
#ifdef __THREAD__ #ifdef __THREAD__
#define __PTHREAD__ # define __PTHREAD__
#if defined(_WIN32) || defined(__WIN32__) # if defined(_WIN32) || defined(__WIN32__)
#define pthread_mutex_lock EnterCriticalSection # define pthread_mutex_lock EnterCriticalSection
#define pthread_mutex_unlock LeaveCriticalSection # define pthread_mutex_unlock LeaveCriticalSection
#define pthread_mutex_t CRITICAL_SECTION # define pthread_mutex_t CRITICAL_SECTION
#define MUTEX_INIT(var) CRITICAL_SECTION var # define SWIG_MUTEX_INIT(var) var
#else # else
#include <pthread.h> # include <pthread.h>
#define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER # define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER
#endif # endif
#endif #endif
#ifdef __PTHREAD__ #ifdef __PTHREAD__
struct Guard
{
pthread_mutex_t *_mutex;
Guard(pthread_mutex_t &mutex) : _mutex(&mutex)
{
pthread_mutex_lock(_mutex);
}
~Guard()
{
pthread_mutex_unlock(_mutex);
}
};
# define SWIG_GUARD(mutex) Guard _guard(mutex) # define SWIG_GUARD(mutex) Guard _guard(mutex)
#else #else
# define SWIG_GUARD(mutex) # define SWIG_GUARD(mutex)
@ -371,7 +385,9 @@ namespace Swig {
private: private:
typedef std::map<void*, GCItem_var> ownership_map; typedef std::map<void*, GCItem_var> ownership_map;
mutable ownership_map owner; mutable ownership_map owner;
mutable pthread_mutex_t swig_mutex_own; #ifdef __PTHREAD__
static pthread_mutex_t swig_mutex_own;
#endif
public: public: