fix missing __PTHREAD__

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

View file

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

View file

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