mirror of https://github.com/PCSX2/pcsx2.git
w32pthreads:
* Implemented a combination static link and dynamic link system; threads still benefit from DLL-level thread management, but speed-critical actions (semaphore and mutex locks) can now inline their "accelerated" interlocks properly. Should be a nice speedup. * Implemented a highly optimized pthread_testcancel(), that typically performs its test in a single cycle. :) * Disabled static mutexes. They aren't needed in C++ code, and reduce mutex locking overhead nicely. * Use intrin.h for Interlocked functions, instead of pthreads' built in ones. * Reverted my previous commit, since TLS isn't safe in DLLs. (oops!) * Disabled pthread_spin API, it's not entirely cross-platform and shouldn't be used anyway (bad threading model for modern computing) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1925 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
6c0afe7c48
commit
a628c163d5
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* attr.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit agregates operations on thread attribute objects.
|
||||
* It is used for inline optimisation.
|
||||
*
|
||||
* The included modules are used separately when static executable sizes
|
||||
* must be minimised.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#include "pthread_attr_init.c"
|
||||
#include "pthread_attr_destroy.c"
|
||||
#include "pthread_attr_getdetachstate.c"
|
||||
#include "pthread_attr_setdetachstate.c"
|
||||
#include "pthread_attr_getstackaddr.c"
|
||||
#include "pthread_attr_setstackaddr.c"
|
||||
#include "pthread_attr_getstacksize.c"
|
||||
#include "pthread_attr_setstacksize.c"
|
||||
#include "pthread_attr_getscope.c"
|
||||
#include "pthread_attr_setscope.c"
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* barrier.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit implements barrier primitives.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#include "pthread_barrier_init.c"
|
||||
#include "pthread_barrier_destroy.c"
|
||||
#include "pthread_barrier_wait.c"
|
||||
#include "pthread_barrierattr_init.c"
|
||||
#include "pthread_barrierattr_destroy.c"
|
||||
#include "pthread_barrierattr_getpshared.c"
|
||||
#include "pthread_barrierattr_setpshared.c"
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* cancel.c
|
||||
*
|
||||
* Description:
|
||||
* POSIX thread functions related to thread cancellation.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#include "pthread_setcancelstate.c"
|
||||
#include "pthread_setcanceltype.c"
|
||||
#include "pthread_testcancel.c"
|
||||
#include "pthread_cancel.c"
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* condvar.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit implements condition variables and their primitives.
|
||||
*
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#include "ptw32_cond_check_need_init.c"
|
||||
#include "pthread_condattr_init.c"
|
||||
#include "pthread_condattr_destroy.c"
|
||||
#include "pthread_condattr_getpshared.c"
|
||||
#include "pthread_condattr_setpshared.c"
|
||||
#include "pthread_cond_init.c"
|
||||
#include "pthread_cond_destroy.c"
|
||||
#include "pthread_cond_wait.c"
|
||||
#include "pthread_cond_signal.c"
|
|
@ -34,10 +34,9 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifndef PTW32_STATIC_LIB
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#ifndef PTW32_STATIC_LIB
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* fork.c
|
||||
*
|
||||
* Description:
|
||||
* Implementation of fork() for POSIX threads.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
|
||||
#include "ptw32pch.h"
|
|
@ -37,22 +37,22 @@
|
|||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
__declspec(thread) ptw32_thread_t* ptw32_selfThread = NULL;
|
||||
|
||||
int ptw32_processInitialized = PTW32_FALSE;
|
||||
ptw32_thread_t * ptw32_threadReuseTop = PTW32_THREAD_REUSE_EMPTY;
|
||||
ptw32_thread_t * ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY;
|
||||
pthread_key_t ptw32_selfThreadKey = NULL;
|
||||
pthread_key_t ptw32_cleanupKey = NULL;
|
||||
pthread_cond_t ptw32_cond_list_head = NULL;
|
||||
pthread_cond_t ptw32_cond_list_tail = NULL;
|
||||
|
||||
long ptw32_testcancel_enable = 0;
|
||||
|
||||
int ptw32_concurrency = 0;
|
||||
|
||||
/* What features have been auto-detected */
|
||||
/* What features have been auto-detaected */
|
||||
int ptw32_features = 0;
|
||||
|
||||
BOOL ptw32_smp_system = PTW32_TRUE; /* Safer if assumed true initially. */
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Function pointer to InterlockedCompareExchange if it exists, otherwise
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#define _WIN32_WINNT 0x400
|
||||
|
||||
#include <windows.h>
|
||||
#include <intrin.h>
|
||||
|
||||
/*
|
||||
* In case windows.h doesn't define it (e.g. WinCE perhaps)
|
||||
|
@ -136,7 +137,7 @@ struct ptw32_thread_t_
|
|||
void *parms;
|
||||
int ptErrno;
|
||||
int detachState;
|
||||
pthread_mutex_t threadLock; /* Used for serialized access to public thread state */
|
||||
pthread_mutex_t threadLock; /* Used for serialised access to public thread state */
|
||||
int sched_priority; /* As set, not as currently is */
|
||||
pthread_mutex_t cancelLock; /* Used for async-cancel safety */
|
||||
int cancelState;
|
||||
|
@ -182,6 +183,12 @@ struct pthread_attr_t_
|
|||
* ====================
|
||||
*/
|
||||
|
||||
#ifdef PTW32_STATIC_MUTEXS
|
||||
# define ptw32_static_mutex_enable (1)
|
||||
#else
|
||||
# define ptw32_static_mutex_enable (0)
|
||||
#endif
|
||||
|
||||
struct sem_t_
|
||||
{
|
||||
int value;
|
||||
|
@ -528,7 +535,8 @@ extern "C"
|
|||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern __declspec(thread) ptw32_thread_t* ptw32_selfThread;
|
||||
PTW32_DLLPORT long ptw32_testcancel_enable;
|
||||
PTW32_DLLPORT pthread_key_t ptw32_selfThreadKey;
|
||||
|
||||
extern int ptw32_processInitialized;
|
||||
extern ptw32_thread_t * ptw32_threadReuseTop;
|
||||
|
@ -543,8 +551,6 @@ extern int ptw32_concurrency;
|
|||
|
||||
extern int ptw32_features;
|
||||
|
||||
extern BOOL ptw32_smp_system; /* True: SMP system, False: Uni-processor system */
|
||||
|
||||
extern CRITICAL_SECTION ptw32_thread_reuse_lock;
|
||||
extern CRITICAL_SECTION ptw32_mutex_test_init_lock;
|
||||
extern CRITICAL_SECTION ptw32_cond_list_lock;
|
||||
|
@ -568,22 +574,15 @@ extern int pthread_count;
|
|||
int ptw32_is_attr (const pthread_attr_t * attr);
|
||||
|
||||
int ptw32_cond_check_need_init (pthread_cond_t * cond);
|
||||
int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
|
||||
PTW32_DLLPORT int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
|
||||
int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
|
||||
|
||||
PTW32_INTERLOCKED_LONG WINAPI
|
||||
ptw32_InterlockedCompareExchange (volatile PTW32_INTERLOCKED_LPLONG location,
|
||||
PTW32_INTERLOCKED_LONG value,
|
||||
PTW32_INTERLOCKED_LONG comparand);
|
||||
|
||||
LONG WINAPI
|
||||
ptw32_InterlockedExchange (volatile PTW32_INTERLOCKED_LPLONG location,
|
||||
LONG value);
|
||||
|
||||
DWORD
|
||||
ptw32_RegisterCancelation (PAPCFUNC callback,
|
||||
HANDLE threadH, DWORD callback_arg);
|
||||
|
||||
PTW32_DLLPORT void ptw32_PrepCancel( ptw32_thread_t* tp );
|
||||
|
||||
int ptw32_processInitialize (void);
|
||||
|
||||
void ptw32_processTerminate (void);
|
||||
|
@ -640,7 +639,7 @@ extern int pthread_count;
|
|||
#endif
|
||||
|
||||
/* Declared in private.c */
|
||||
void ptw32_throw (DWORD exception);
|
||||
PTW32_DLLPORT void ptw32_throw (DWORD exception);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -675,11 +674,11 @@ extern "C"
|
|||
*/
|
||||
// Default to inlining the pthreads versions... (air)
|
||||
#ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE
|
||||
#define PTW32_INTERLOCKED_COMPARE_EXCHANGE ptw32_InterlockedCompareExchange
|
||||
#define PTW32_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
|
||||
#endif
|
||||
|
||||
#ifndef PTW32_INTERLOCKED_EXCHANGE
|
||||
#define PTW32_INTERLOCKED_EXCHANGE ptw32_InterlockedExchange
|
||||
#define PTW32_INTERLOCKED_EXCHANGE _InterlockedExchange
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -685,6 +685,10 @@ struct pthread_once_t_
|
|||
* ====================
|
||||
* ====================
|
||||
*/
|
||||
|
||||
// Note: Static mutexes are useful in C but a bad idea in C++, and add overhead to all
|
||||
// mutex lockers (bad!), so C++ code should idisable them and use C++ initializers instead.
|
||||
|
||||
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1)
|
||||
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2)
|
||||
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3)
|
||||
|
@ -951,7 +955,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread,
|
|||
|
||||
PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread);
|
||||
extern int PTW32_CDECL pthread_cancel (pthread_t thread);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state,
|
||||
int *oldstate);
|
||||
|
@ -959,7 +963,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state,
|
|||
PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type,
|
||||
int *oldtype);
|
||||
|
||||
PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void);
|
||||
extern void PTW32_CDECL pthread_testcancel (void);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control,
|
||||
void (*init_routine) (void));
|
||||
|
@ -1025,17 +1029,22 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex,
|
|||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex);
|
||||
extern int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t *mutex,
|
||||
const struct timespec *abstime);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex);
|
||||
extern int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex);
|
||||
extern int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex);
|
||||
|
||||
#ifdef PTW32_ALLOW_SPIN
|
||||
/*
|
||||
* Spinlock Functions
|
||||
*
|
||||
* These are disabled by default; they are not part of the "required" portion of pthreads
|
||||
* implementations, and they are generally a bad idea for anything except the most controlled
|
||||
* of threaded environments (which hardly exist in modern computing).
|
||||
*/
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared);
|
||||
|
||||
|
@ -1046,6 +1055,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock);
|
|||
PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock);
|
||||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Barrier Functions
|
||||
|
@ -1058,6 +1068,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barri
|
|||
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier);
|
||||
|
||||
#ifdef PTW32_ALLOW_COND
|
||||
/*
|
||||
* Condition Variable Attribute Functions
|
||||
*/
|
||||
|
@ -1074,7 +1085,6 @@ PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t *
|
|||
/*
|
||||
* Condition Variable Functions
|
||||
*/
|
||||
#ifdef PCSX2_ALLOW_COND
|
||||
PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond,
|
||||
const pthread_condattr_t * attr);
|
||||
|
||||
|
|
|
@ -132,9 +132,9 @@ PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
|
|||
|
||||
PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
|
||||
extern int __cdecl sem_trywait (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
|
||||
extern int __cdecl sem_wait (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
|
||||
const struct timespec * abstime);
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* misc.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit implements miscellaneous thread functions.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
#include "pthread_kill.c"
|
||||
#include "pthread_once.c"
|
||||
#include "pthread_self.c"
|
||||
#include "pthread_equal.c"
|
||||
#include "pthread_setconcurrency.c"
|
||||
#include "pthread_getconcurrency.c"
|
||||
#include "ptw32_new.c"
|
||||
#include "ptw32_calloc.c"
|
||||
#include "ptw32_reuse.c"
|
||||
#include "w32_CancelableWait.c"
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* mutex.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit implements mutual exclusion (mutex) primitives.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#ifndef _UWIN
|
||||
# include <process.h>
|
||||
#endif
|
||||
#ifndef NEED_FTIME
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "ptw32_mutex_check_need_init.c"
|
||||
#include "pthread_mutex_init.c"
|
||||
#include "pthread_mutex_destroy.c"
|
||||
#include "pthread_mutexattr_init.c"
|
||||
#include "pthread_mutexattr_destroy.c"
|
||||
#include "pthread_mutexattr_getpshared.c"
|
||||
#include "pthread_mutexattr_setpshared.c"
|
||||
#include "pthread_mutexattr_settype.c"
|
||||
#include "pthread_mutexattr_gettype.c"
|
||||
#include "pthread_mutex_lock.c"
|
||||
#include "pthread_mutex_timedlock.c"
|
||||
#include "pthread_mutex_unlock.c"
|
||||
#include "pthread_mutex_trylock.c"
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* nonportable.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit implements non-portable thread functions.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#include "pthread_mutexattr_setkind_np.c"
|
||||
#include "pthread_mutexattr_getkind_np.c"
|
||||
#include "pthread_getw32threadhandle_np.c"
|
||||
#include "pthread_delay_np.c"
|
||||
#include "pthread_num_processors_np.c"
|
||||
#include "pthread_win32_attach_detach_np.c"
|
||||
|
||||
// Removed due to pthread_cond reference - air
|
||||
//#include "pthread_timechange_handler_np.c"
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* private.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit implements routines which are private to
|
||||
* the implementation and may be used throughout it.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/* Must be first to define HAVE_INLINABLE_INTERLOCKED_CMPXCHG */
|
||||
#include "ptw32_InterlockedCompareExchange.c"
|
||||
|
||||
#include "ptw32_MCS_lock.c"
|
||||
#include "ptw32_is_attr.c"
|
||||
#include "ptw32_processInitialize.c"
|
||||
#include "ptw32_processTerminate.c"
|
||||
#include "ptw32_threadStart.c"
|
||||
#include "ptw32_threadDestroy.c"
|
||||
#include "ptw32_tkAssocCreate.c"
|
||||
#include "ptw32_tkAssocDestroy.c"
|
||||
#include "ptw32_callUserDestroyRoutines.c"
|
||||
#include "ptw32_semwait.c"
|
||||
#include "ptw32_timespec.c"
|
||||
#include "ptw32_relmillisecs.c"
|
||||
#include "ptw32_throw.c"
|
||||
#include "ptw32_getprocessors.c"
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/* ignore warning "unreferenced formal parameter" */
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/* ignore warning "unreferenced formal parameter" */
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/* ignore warning "unreferenced formal parameter" */
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/* ignore warning "unreferenced formal parameter" */
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,69 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
|
||||
#if defined(_M_IX86) || defined(_X86_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Eip)
|
||||
#endif
|
||||
|
||||
#if defined (_M_IA64)
|
||||
#define PTW32_PROGCTR(Context) ((Context).StIIP)
|
||||
#endif
|
||||
|
||||
#if defined(_MIPS_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Fir)
|
||||
#endif
|
||||
|
||||
#if defined(_ALPHA_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Fir)
|
||||
#endif
|
||||
|
||||
#if defined(_PPC_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Iar)
|
||||
#endif
|
||||
|
||||
#if defined(_AMD64_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Rip)
|
||||
#endif
|
||||
|
||||
#if !defined(PTW32_PROGCTR)
|
||||
#error Module contains CPU-specific code; modify and recompile.
|
||||
#endif
|
||||
|
||||
static void
|
||||
ptw32_cancel_self (void)
|
||||
{
|
||||
ptw32_throw (PTW32_EPS_CANCEL);
|
||||
|
||||
/* Never reached */
|
||||
}
|
||||
|
||||
static void CALLBACK
|
||||
ptw32_cancel_callback (DWORD unused)
|
||||
{
|
||||
ptw32_throw (PTW32_EPS_CANCEL);
|
||||
|
||||
/* Never reached */
|
||||
}
|
||||
|
||||
/*
|
||||
* ptw32_RegisterCancelation() -
|
||||
* Must have args of same type as QueueUserAPCEx because this function
|
||||
* is a substitute for QueueUserAPCEx if it's not available.
|
||||
*/
|
||||
DWORD
|
||||
ptw32_RegisterCancelation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
|
||||
{
|
||||
CONTEXT context;
|
||||
|
||||
context.ContextFlags = CONTEXT_CONTROL;
|
||||
GetThreadContext (threadH, &context);
|
||||
PTW32_PROGCTR (context) = (DWORD_PTR) ptw32_cancel_self;
|
||||
SetThreadContext (threadH, &context);
|
||||
return 0;
|
||||
}
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
pthread_cancel (pthread_t thread)
|
||||
|
@ -137,7 +75,7 @@ pthread_cancel (pthread_t thread)
|
|||
if ((self = pthread_self ()).p == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME!!
|
||||
|
@ -149,14 +87,17 @@ pthread_cancel (pthread_t thread)
|
|||
* thread is itself.
|
||||
*
|
||||
* If it may, then we need to ensure that a thread can't
|
||||
* deadlock itself trying to cancel itself asyncronously
|
||||
* deadlock itself trying to cancel itself asynchronously
|
||||
* (pthread_cancel is required to be an async-cancel
|
||||
* safe function).
|
||||
*/
|
||||
cancel_self = pthread_equal (thread, self);
|
||||
|
||||
tp = (ptw32_thread_t *) thread.p;
|
||||
|
||||
// enables full cancel testing in pthread_testcancel, which is normally
|
||||
// disabled because
|
||||
_InterlockedIncrement( &ptw32_testcancel_enable );
|
||||
|
||||
/*
|
||||
* Lock for async-cancel safety.
|
||||
*/
|
||||
|
@ -178,24 +119,7 @@ pthread_cancel (pthread_t thread)
|
|||
}
|
||||
else
|
||||
{
|
||||
HANDLE threadH = tp->threadH;
|
||||
|
||||
SuspendThread (threadH);
|
||||
|
||||
if (WaitForSingleObject (threadH, 0) == WAIT_TIMEOUT)
|
||||
{
|
||||
tp->state = PThreadStateCanceling;
|
||||
tp->cancelState = PTHREAD_CANCEL_DISABLE;
|
||||
/*
|
||||
* If alertdrv and QueueUserAPCEx is available then the following
|
||||
* will result in a call to QueueUserAPCEx with the args given, otherwise
|
||||
* this will result in a call to ptw32_RegisterCancelation and only
|
||||
* the threadH arg will be used.
|
||||
*/
|
||||
ptw32_register_cancelation (ptw32_cancel_callback, threadH, 0);
|
||||
(void) pthread_mutex_unlock (&tp->cancelLock);
|
||||
ResumeThread (threadH);
|
||||
}
|
||||
ptw32_PrepCancel( tp );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* pthread_delay_np
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* Not needed yet, but defining it should indicate clashes with build target
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#ifndef _UWIN
|
||||
//# include <process.h>
|
||||
#endif
|
||||
|
@ -65,7 +64,13 @@ pthread_exit (void *value_ptr)
|
|||
* ------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
ptw32_thread_t * sp = ptw32_selfThread;
|
||||
ptw32_thread_t * sp;
|
||||
|
||||
/*
|
||||
* Don't use pthread_self() to avoid creating an implicit POSIX thread handle
|
||||
* unnecessarily.
|
||||
*/
|
||||
sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
|
||||
|
||||
#ifdef _UWIN
|
||||
if (--pthread_count <= 0)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
void *
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* pthread_getw32threadhandle_np()
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* Not needed yet, but defining it should indicate clashes with build target
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
/* TLS_OUT_OF_INDEXES not defined on WinCE */
|
||||
|
@ -98,7 +97,11 @@ pthread_key_create (pthread_key_t * key, void (*destructor) (void *))
|
|||
*
|
||||
* The mutex will only be created when it is first locked.
|
||||
*/
|
||||
newkey->keyLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#ifdef PTW32_STATIC_MUTEXS
|
||||
newkey->keyLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#else
|
||||
pthread_mutex_init (&newkey->keyLock, NULL);
|
||||
#endif
|
||||
newkey->destructor = destructor;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* Not needed yet, but defining it should indicate clashes with build target
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
@ -51,7 +50,7 @@ pthread_mutex_destroy (pthread_mutex_t * mutex)
|
|||
/*
|
||||
* Check to see if we have something to delete.
|
||||
*/
|
||||
if (*mutex < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
|
||||
if (!ptw32_static_mutex_enable || (*mutex < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER))
|
||||
{
|
||||
mx = *mutex;
|
||||
|
||||
|
@ -120,7 +119,7 @@ pthread_mutex_destroy (pthread_mutex_t * mutex)
|
|||
/*
|
||||
* Check again.
|
||||
*/
|
||||
if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
|
||||
if (ptw32_static_mutex_enable && (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER))
|
||||
{
|
||||
/*
|
||||
* This is all we need to do to destroy a statically
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
|
||||
|
|
|
@ -34,13 +34,9 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifndef _UWIN
|
||||
//# include <process.h>
|
||||
#endif
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
INLINE int
|
||||
pthread_mutex_lock (pthread_mutex_t * mutex)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -60,7 +56,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
|
|||
* again inside the guarded section of ptw32_mutex_check_need_init()
|
||||
* to avoid race conditions.
|
||||
*/
|
||||
if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
|
||||
if (ptw32_static_mutex_enable && (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER))
|
||||
{
|
||||
if ((result = ptw32_mutex_check_need_init (mutex)) != 0)
|
||||
{
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
static INLINE int
|
||||
|
@ -122,7 +121,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
|
|||
* again inside the guarded section of ptw32_mutex_check_need_init()
|
||||
* to avoid race conditions.
|
||||
*/
|
||||
if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
|
||||
if (ptw32_static_mutex_enable && (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER))
|
||||
{
|
||||
if ((result = ptw32_mutex_check_need_init (mutex)) != 0)
|
||||
{
|
||||
|
|
|
@ -34,11 +34,10 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
INLINE int
|
||||
pthread_mutex_trylock (pthread_mutex_t * mutex)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -54,7 +53,7 @@ pthread_mutex_trylock (pthread_mutex_t * mutex)
|
|||
* again inside the guarded section of ptw32_mutex_check_need_init()
|
||||
* to avoid race conditions.
|
||||
*/
|
||||
if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
|
||||
if (ptw32_static_mutex_enable && (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER))
|
||||
{
|
||||
if ((result = ptw32_mutex_check_need_init (mutex)) != 0)
|
||||
{
|
||||
|
|
|
@ -34,11 +34,10 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
INLINE int
|
||||
pthread_mutex_unlock (pthread_mutex_t * mutex)
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -55,7 +54,7 @@ pthread_mutex_unlock (pthread_mutex_t * mutex)
|
|||
* race condition. If another thread holds the
|
||||
* lock then we shouldn't be in here.
|
||||
*/
|
||||
if (mx < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER)
|
||||
if (!ptw32_static_mutex_enable || (mx < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER))
|
||||
{
|
||||
if (mx->kind == PTHREAD_MUTEX_NORMAL)
|
||||
{
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
pthread_mutexattr_getkind_np (pthread_mutexattr_t * attr, int *kind)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
pthread_mutexattr_setkind_np (pthread_mutexattr_t * attr, int kind)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* pthread_num_processors_np()
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
static void PTW32_CDECL
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
pthread_t
|
||||
pthread_self (void)
|
||||
|
@ -61,7 +60,14 @@ pthread_self (void)
|
|||
{
|
||||
pthread_t self;
|
||||
pthread_t nil = {NULL, 0};
|
||||
ptw32_thread_t * sp = ptw32_selfThread;
|
||||
ptw32_thread_t * sp;
|
||||
|
||||
#ifdef _UWIN
|
||||
if (!ptw32_selfThreadKey)
|
||||
return nil;
|
||||
#endif
|
||||
|
||||
sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
|
||||
|
||||
if (sp != NULL)
|
||||
{
|
||||
|
@ -121,7 +127,8 @@ pthread_self (void)
|
|||
* because the new handle is not yet public.
|
||||
*/
|
||||
sp->sched_priority = GetThreadPriority (sp->threadH);
|
||||
ptw32_selfThread = ptw32_new().p;
|
||||
|
||||
pthread_setspecific (ptw32_selfThreadKey, (void *) sp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
pthread_setcanceltype (int type, int *oldtype)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include "sched.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
@ -68,16 +67,40 @@ pthread_setspecific (pthread_key_t key, const void *value)
|
|||
pthread_t self;
|
||||
int result = 0;
|
||||
|
||||
/*
|
||||
* Using pthread_self will implicitly create
|
||||
* an instance of pthread_t for the current
|
||||
* thread if one wasn't explicitly created
|
||||
*/
|
||||
self = pthread_self ();
|
||||
if (self.p == NULL)
|
||||
{
|
||||
return ENOENT;
|
||||
}
|
||||
if (key != ptw32_selfThreadKey)
|
||||
{
|
||||
/*
|
||||
* Using pthread_self will implicitly create
|
||||
* an instance of pthread_t for the current
|
||||
* thread if one wasn't explicitly created
|
||||
*/
|
||||
self = pthread_self ();
|
||||
if (self.p == NULL)
|
||||
{
|
||||
return ENOENT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Resolve catch-22 of registering thread with selfThread
|
||||
* key
|
||||
*/
|
||||
ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
|
||||
|
||||
if (sp == NULL)
|
||||
{
|
||||
if (value == NULL)
|
||||
{
|
||||
return ENOENT;
|
||||
}
|
||||
self = *((pthread_t *) value);
|
||||
}
|
||||
else
|
||||
{
|
||||
self = sp->ptHandle;
|
||||
}
|
||||
}
|
||||
|
||||
result = 0;
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,11 +34,9 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
void
|
||||
INLINE void
|
||||
pthread_testcancel (void)
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
|
@ -68,8 +66,14 @@ pthread_testcancel (void)
|
|||
* ------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
pthread_t self = pthread_self ();
|
||||
ptw32_thread_t * sp = (ptw32_thread_t *) self.p;
|
||||
ptw32_thread_t * sp;
|
||||
if( ptw32_testcancel_enable == 0 ) return;
|
||||
|
||||
// Don't use pthread_self here, to avoid unnecessary object query or creation.
|
||||
// If ptw32_selfThread is NULL, then it's a sure bet no one's tried to cancel
|
||||
// this thread, since that would have spawned a selfThread object! -- air
|
||||
|
||||
sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
|
||||
|
||||
if (sp == NULL)
|
||||
{
|
||||
|
@ -86,6 +90,8 @@ pthread_testcancel (void)
|
|||
return;
|
||||
}
|
||||
|
||||
_InterlockedDecrement( &ptw32_testcancel_enable );
|
||||
|
||||
(void) pthread_mutex_lock (&sp->cancelLock);
|
||||
|
||||
if (sp->cancelState != PTHREAD_CANCEL_DISABLE)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* Notes on handling system time adjustments (especially negative ones).
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* Handle to kernel32.dll
|
||||
|
@ -51,8 +50,6 @@ BOOL
|
|||
pthread_win32_process_attach_np ()
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
DWORD_PTR vProcessCPUs;
|
||||
DWORD_PTR vSystemCPUs;
|
||||
|
||||
if( ptw32_processInitialized ) return TRUE;
|
||||
|
||||
|
@ -65,92 +62,6 @@ pthread_win32_process_attach_np ()
|
|||
ptw32_features = 0;
|
||||
|
||||
|
||||
#if defined(NEED_PROCESS_AFFINITY_MASK)
|
||||
|
||||
ptw32_smp_system = PTW32_FALSE;
|
||||
|
||||
#else
|
||||
|
||||
if (GetProcessAffinityMask (GetCurrentProcess (),
|
||||
&vProcessCPUs, &vSystemCPUs))
|
||||
{
|
||||
int CPUs = 0;
|
||||
DWORD_PTR bit;
|
||||
|
||||
for (bit = 1; bit != 0; bit <<= 1)
|
||||
{
|
||||
if (vSystemCPUs & bit)
|
||||
{
|
||||
CPUs++;
|
||||
}
|
||||
}
|
||||
ptw32_smp_system = (CPUs > 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptw32_smp_system = PTW32_FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
#ifdef WINCE
|
||||
|
||||
/*
|
||||
* Load COREDLL and try to get address of InterlockedCompareExchange
|
||||
*/
|
||||
ptw32_h_kernel32 = LoadLibrary (TEXT ("COREDLL.DLL"));
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Load KERNEL32 and try to get address of InterlockedCompareExchange
|
||||
*/
|
||||
ptw32_h_kernel32 = LoadLibrary (TEXT ("KERNEL32.DLL"));
|
||||
|
||||
#endif
|
||||
|
||||
// We're only using pthreads' inline version of InterlockedExchange
|
||||
ptw32_interlocked_compare_exchange =
|
||||
(PTW32_INTERLOCKED_LONG (WINAPI *)
|
||||
(PTW32_INTERLOCKED_LPLONG, PTW32_INTERLOCKED_LONG,
|
||||
PTW32_INTERLOCKED_LONG))
|
||||
#if defined(NEED_UNICODE_CONSTS)
|
||||
GetProcAddress (ptw32_h_kernel32,
|
||||
(const TCHAR *) TEXT ("InterlockedCompareExchange"));
|
||||
#else
|
||||
GetProcAddress (ptw32_h_kernel32, (LPCSTR) "InterlockedCompareExchange");
|
||||
#endif
|
||||
|
||||
if (ptw32_interlocked_compare_exchange == NULL)
|
||||
{
|
||||
ptw32_interlocked_compare_exchange = ptw32_InterlockedCompareExchange;
|
||||
|
||||
/*
|
||||
* If InterlockedCompareExchange is not being used, then free
|
||||
* the kernel32.dll handle now, rather than leaving it until
|
||||
* DLL_PROCESS_DETACH.
|
||||
*
|
||||
* Note: this is not a pedantic exercise in freeing unused
|
||||
* resources! It is a work-around for a bug in Windows 95
|
||||
* (see microsoft knowledge base article, Q187684) which
|
||||
* does Bad Things when FreeLibrary is called within
|
||||
* the DLL_PROCESS_DETACH code, in certain situations.
|
||||
* Since w95 just happens to be a platform which does not
|
||||
* provide InterlockedCompareExchange, the bug will be
|
||||
* effortlessly avoided.
|
||||
*/
|
||||
(void) FreeLibrary (ptw32_h_kernel32);
|
||||
ptw32_h_kernel32 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptw32_features |= PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Load QUSEREX.DLL and try to get address of QueueUserAPCEx
|
||||
*/
|
||||
|
@ -213,7 +124,7 @@ pthread_win32_process_detach_np ()
|
|||
{
|
||||
if (ptw32_processInitialized)
|
||||
{
|
||||
ptw32_thread_t * sp = ptw32_selfThread;
|
||||
ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
|
||||
|
||||
if (sp != NULL)
|
||||
{
|
||||
|
@ -224,8 +135,7 @@ pthread_win32_process_detach_np ()
|
|||
if (sp->detachState == PTHREAD_CREATE_DETACHED)
|
||||
{
|
||||
ptw32_threadDestroy (sp->ptHandle);
|
||||
free(ptw32_selfThread);
|
||||
ptw32_selfThread = NULL;
|
||||
TlsSetValue (ptw32_selfThreadKey->key, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -278,7 +188,7 @@ pthread_win32_thread_detach_np ()
|
|||
* Don't use pthread_self() - to avoid creating an implicit POSIX thread handle
|
||||
* unnecessarily.
|
||||
*/
|
||||
ptw32_thread_t * sp = ptw32_selfThread;
|
||||
ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
|
||||
|
||||
if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle.
|
||||
{
|
||||
|
@ -295,8 +205,8 @@ pthread_win32_thread_detach_np ()
|
|||
if (sp->detachState == PTHREAD_CREATE_DETACHED)
|
||||
{
|
||||
ptw32_threadDestroy (sp->ptHandle);
|
||||
free(ptw32_selfThread);
|
||||
ptw32_selfThread = NULL;
|
||||
|
||||
TlsSetValue (ptw32_selfThreadKey->key, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,300 +0,0 @@
|
|||
/*
|
||||
* ptw32_InterlockedCompareExchange.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit implements routines which are private to
|
||||
* the implementation and may be used throughout it.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
|
||||
|
||||
/*
|
||||
* ptw32_InterlockedCompareExchange --
|
||||
*
|
||||
* Originally needed because W9x doesn't support InterlockedCompareExchange.
|
||||
* We now use this version wherever possible so we can inline it.
|
||||
*/
|
||||
|
||||
INLINE PTW32_INTERLOCKED_LONG WINAPI
|
||||
ptw32_InterlockedCompareExchange (volatile PTW32_INTERLOCKED_LPLONG location,
|
||||
PTW32_INTERLOCKED_LONG value,
|
||||
PTW32_INTERLOCKED_LONG comparand)
|
||||
{
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
/* Don't report that result is not assigned a value before being referenced */
|
||||
#pragma disable_message (200)
|
||||
#endif
|
||||
|
||||
PTW32_INTERLOCKED_LONG result;
|
||||
|
||||
/*
|
||||
* Using the LOCK prefix on uni-processor machines is significantly slower
|
||||
* and it is not necessary. The overhead of the conditional below is
|
||||
* negligible in comparison. Since an optimised DLL will inline this
|
||||
* routine, this will be faster than calling the system supplied
|
||||
* Interlocked routine, which appears to avoid the LOCK prefix on
|
||||
* uniprocessor systems. So one DLL works for all systems.
|
||||
*/
|
||||
if (1) //ptw32_smp_system)
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#if defined(_M_IX86) || defined(_X86_)
|
||||
|
||||
#if defined(_MSC_VER) || defined(__WATCOMC__) || (defined(__BORLANDC__) && defined(HAVE_TASM32))
|
||||
#define HAVE_INLINABLE_INTERLOCKED_CMPXCHG
|
||||
{
|
||||
_asm {
|
||||
//PUSH ecx
|
||||
//PUSH edx
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV edx,dword ptr [value]
|
||||
MOV eax,dword ptr [comparand]
|
||||
LOCK CMPXCHG dword ptr [ecx],edx
|
||||
MOV dword ptr [result], eax
|
||||
//POP edx
|
||||
//POP ecx
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_asm {
|
||||
//PUSH ecx
|
||||
//PUSH edx
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV edx,dword ptr [value]
|
||||
MOV eax,dword ptr [comparand]
|
||||
CMPXCHG dword ptr [ecx],edx
|
||||
MOV dword ptr [result], eax
|
||||
//POP edx
|
||||
//POP ecx
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
#define HAVE_INLINABLE_INTERLOCKED_CMPXCHG
|
||||
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"lock\n\t"
|
||||
"cmpxchgl %2,%1" /* if (EAX == [location]) */
|
||||
/* [location] = value */
|
||||
/* else */
|
||||
/* EAX = [location] */
|
||||
:"=a" (result)
|
||||
:"m" (*location), "r" (value), "a" (comparand));
|
||||
}
|
||||
else
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"cmpxchgl %2,%1" /* if (EAX == [location]) */
|
||||
/* [location] = value */
|
||||
/* else */
|
||||
/* EAX = [location] */
|
||||
:"=a" (result)
|
||||
:"m" (*location), "r" (value), "a" (comparand));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* If execution gets to here then we're running on a currently
|
||||
* unsupported processor or compiler.
|
||||
*/
|
||||
|
||||
result = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
return result;
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
#pragma enable_message (200)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* ptw32_InterlockedExchange --
|
||||
*
|
||||
* We now use this version wherever possible so we can inline it.
|
||||
*/
|
||||
|
||||
INLINE LONG WINAPI
|
||||
ptw32_InterlockedExchange (volatile PTW32_INTERLOCKED_LPLONG location,
|
||||
LONG value)
|
||||
{
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
/* Don't report that result is not assigned a value before being referenced */
|
||||
#pragma disable_message (200)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The XCHG instruction always locks the bus with or without the
|
||||
* LOCKED prefix. This makes it significantly slower than CMPXCHG on
|
||||
* uni-processor machines. The Windows InterlockedExchange function
|
||||
* is nearly 3 times faster than the XCHG instruction, so this routine
|
||||
* is not yet very useful for speeding up pthreads.
|
||||
*/
|
||||
if (1) //ptw32_smp_system)
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#if defined(_M_IX86) || defined(_X86_)
|
||||
|
||||
#if defined(_MSC_VER) || defined(__WATCOMC__) || (defined(__BORLANDC__) && defined(HAVE_TASM32))
|
||||
#define HAVE_INLINABLE_INTERLOCKED_XCHG
|
||||
|
||||
// pcsx2: Optimized this slightly for MSVC, which automatically knowns when to
|
||||
// push/pop registers and how to return eax as a result without using a temp var.
|
||||
|
||||
{
|
||||
_asm {
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV eax,dword ptr [value]
|
||||
XCHG dword ptr [ecx],eax
|
||||
//MOV dword ptr [result], eax
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Faster version of XCHG for uni-processor systems because
|
||||
* it doesn't lock the bus. If an interrupt or context switch
|
||||
* occurs between the MOV and the CMPXCHG then the value in
|
||||
* 'location' may have changed, in which case we will loop
|
||||
* back to do the MOV again.
|
||||
*
|
||||
* FIXME! Need memory barriers for the MOV+CMPXCHG combo?
|
||||
*
|
||||
* Tests show that this routine has almost identical timing
|
||||
* to Win32's InterlockedExchange(), which is much faster than
|
||||
* using the inlined 'xchg' instruction above, so it's probably
|
||||
* doing something similar to this (on UP systems).
|
||||
*
|
||||
* Can we do without the PUSH/POP instructions?
|
||||
*/
|
||||
_asm {
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV edx,dword ptr [value]
|
||||
L1: MOV eax,dword ptr [ecx]
|
||||
CMPXCHG dword ptr [ecx],edx
|
||||
JNZ L1
|
||||
//MOV dword ptr [result], eax
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
#define HAVE_INLINABLE_INTERLOCKED_XCHG
|
||||
|
||||
LONG result;
|
||||
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"xchgl %2,%1"
|
||||
:"=r" (result)
|
||||
:"m" (*location), "0" (value));
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Faster version of XCHG for uni-processor systems because
|
||||
* it doesn't lock the bus. If an interrupt or context switch
|
||||
* occurs between the movl and the cmpxchgl then the value in
|
||||
* 'location' may have changed, in which case we will loop
|
||||
* back to do the movl again.
|
||||
*
|
||||
* FIXME! Need memory barriers for the MOV+CMPXCHG combo?
|
||||
*
|
||||
* Tests show that this routine has almost identical timing
|
||||
* to Win32's InterlockedExchange(), which is much faster than
|
||||
* using the an inlined 'xchg' instruction, so it's probably
|
||||
* doing something similar to this (on UP systems).
|
||||
*/
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"0:\n\t"
|
||||
"movl %1,%%eax\n\t"
|
||||
"cmpxchgl %2,%1\n\t"
|
||||
"jnz 0b"
|
||||
:"=&a" (result)
|
||||
:"m" (*location), "r" (value));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* If execution gets to here then we're running on a currently
|
||||
* unsupported processor or compiler.
|
||||
*/
|
||||
|
||||
result = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
#pragma enable_message (200)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
|
||||
#if defined(PTW32_BUILD_INLINED) && defined(HAVE_INLINABLE_INTERLOCKED_CMPXCHG)
|
||||
#undef PTW32_INTERLOCKED_COMPARE_EXCHANGE
|
||||
#define PTW32_INTERLOCKED_COMPARE_EXCHANGE ptw32_InterlockedCompareExchange
|
||||
#endif
|
||||
|
||||
#if defined(PTW32_BUILD_INLINED) && defined(HAVE_INLINABLE_INTERLOCKED_XCHG)
|
||||
#undef PTW32_INTERLOCKED_EXCHANGE
|
||||
#define PTW32_INTERLOCKED_EXCHANGE ptw32_InterlockedExchange
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -89,8 +89,7 @@
|
|||
* }
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
/*
|
||||
* ptw32_mcs_flag_set -- notify another thread about an event.
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
# if ! defined (_MSC_VER) && ! (defined(__GNUC__) && __GNUC__ < 3) && ! defined(__WATCOMC__)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
#ifdef NEED_CALLOC
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* ptw32_new.c
|
||||
*
|
||||
* Description:
|
||||
* This translation unit provides platform-specific cancelation functionality.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* 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 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 in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
#if defined(_M_IX86) || defined(_X86_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Eip)
|
||||
#endif
|
||||
|
||||
#if defined (_M_IA64)
|
||||
#define PTW32_PROGCTR(Context) ((Context).StIIP)
|
||||
#endif
|
||||
|
||||
#if defined(_MIPS_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Fir)
|
||||
#endif
|
||||
|
||||
#if defined(_ALPHA_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Fir)
|
||||
#endif
|
||||
|
||||
#if defined(_PPC_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Iar)
|
||||
#endif
|
||||
|
||||
#if defined(_AMD64_)
|
||||
#define PTW32_PROGCTR(Context) ((Context).Rip)
|
||||
#endif
|
||||
|
||||
#if !defined(PTW32_PROGCTR)
|
||||
#error Module contains CPU-specific code; modify and recompile.
|
||||
#endif
|
||||
|
||||
static void
|
||||
ptw32_cancel_self (void)
|
||||
{
|
||||
ptw32_throw (PTW32_EPS_CANCEL);
|
||||
|
||||
/* Never reached */
|
||||
}
|
||||
|
||||
static void CALLBACK
|
||||
ptw32_cancel_callback (DWORD unused)
|
||||
{
|
||||
ptw32_throw (PTW32_EPS_CANCEL);
|
||||
|
||||
/* Never reached */
|
||||
}
|
||||
|
||||
/*
|
||||
* ptw32_RegisterCancelation() -
|
||||
* Must have args of same type as QueueUserAPCEx because this function
|
||||
* is a substitute for QueueUserAPCEx if it's not available.
|
||||
*/
|
||||
DWORD
|
||||
ptw32_RegisterCancelation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
|
||||
{
|
||||
CONTEXT context;
|
||||
|
||||
context.ContextFlags = CONTEXT_CONTROL;
|
||||
GetThreadContext (threadH, &context);
|
||||
PTW32_PROGCTR (context) = (DWORD_PTR) ptw32_cancel_self;
|
||||
SetThreadContext (threadH, &context);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ptw32_PrepCancel( ptw32_thread_t* tp )
|
||||
{
|
||||
HANDLE threadH = tp->threadH;
|
||||
|
||||
SuspendThread (threadH);
|
||||
|
||||
if (WaitForSingleObject (threadH, 0) == WAIT_TIMEOUT)
|
||||
{
|
||||
tp->state = PThreadStateCanceling;
|
||||
tp->cancelState = PTHREAD_CANCEL_DISABLE;
|
||||
/*
|
||||
* If alertdrv and QueueUserAPCEx is available then the following
|
||||
* will result in a call to QueueUserAPCEx with the args given, otherwise
|
||||
* this will result in a call to ptw32_RegisterCancelation and only
|
||||
* the threadH arg will be used.
|
||||
*/
|
||||
ptw32_register_cancelation (ptw32_cancel_callback, threadH, 0);
|
||||
(void) pthread_mutex_unlock (&tp->cancelLock);
|
||||
ResumeThread (threadH);
|
||||
}
|
||||
}
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
INLINE int
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
int
|
||||
ptw32_is_attr (const pthread_attr_t * attr)
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#include <assert.h>
|
||||
|
||||
static struct pthread_mutexattr_t_ ptw32_recursive_mutexattr_s =
|
||||
{PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE};
|
||||
|
@ -51,6 +51,9 @@ ptw32_mutex_check_need_init (pthread_mutex_t * mutex)
|
|||
register int result = 0;
|
||||
register pthread_mutex_t mtx;
|
||||
|
||||
// Make sure static mutexes are enabled.
|
||||
assert( ptw32_static_mutex_enable );
|
||||
|
||||
/*
|
||||
* The following guarded test is specifically for statically
|
||||
* initialised mutexes (via PTHREAD_MUTEX_INITIALIZER).
|
||||
|
@ -72,6 +75,7 @@ ptw32_mutex_check_need_init (pthread_mutex_t * mutex)
|
|||
* the number of processors + 1.
|
||||
*
|
||||
*/
|
||||
|
||||
EnterCriticalSection (&ptw32_mutex_test_init_lock);
|
||||
|
||||
/*
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
pthread_t
|
||||
ptw32_new (void)
|
||||
|
@ -74,8 +72,15 @@ ptw32_new (void)
|
|||
tp->detachState = PTHREAD_CREATE_JOINABLE;
|
||||
tp->cancelState = PTHREAD_CANCEL_ENABLE;
|
||||
tp->cancelType = PTHREAD_CANCEL_DEFERRED;
|
||||
|
||||
#ifdef PTW32_STATIC_MUTEXS
|
||||
tp->cancelLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
tp->threadLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#else
|
||||
pthread_mutex_init (&tp->cancelLock, NULL);
|
||||
pthread_mutex_init (&tp->threadLock, NULL);
|
||||
#endif
|
||||
|
||||
tp->cancelEvent = CreateEvent (0, (int) PTW32_TRUE, /* manualReset */
|
||||
(int) PTW32_FALSE, /* setSignaled */
|
||||
NULL);
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
@ -80,8 +79,10 @@ ptw32_processInitialize (void)
|
|||
/*
|
||||
* Initialize Keys
|
||||
*/
|
||||
if (pthread_key_create (&ptw32_cleanupKey, NULL) != 0)
|
||||
if ((pthread_key_create (&ptw32_selfThreadKey, NULL) != 0) ||
|
||||
(pthread_key_create (&ptw32_cleanupKey, NULL) != 0))
|
||||
{
|
||||
|
||||
ptw32_processTerminate ();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
|
||||
#include "ptw32pch.h"
|
||||
|
||||
void
|
||||
ptw32_processTerminate (void)
|
||||
|
@ -66,9 +64,23 @@ ptw32_processTerminate (void)
|
|||
{
|
||||
ptw32_thread_t * tp, * tpNext;
|
||||
|
||||
if (ptw32_selfThreadKey != NULL)
|
||||
{
|
||||
/*
|
||||
* Release ptw32_selfThreadKey
|
||||
*/
|
||||
pthread_key_delete (ptw32_selfThreadKey);
|
||||
|
||||
ptw32_selfThreadKey = NULL;
|
||||
}
|
||||
|
||||
if (ptw32_cleanupKey != NULL)
|
||||
{
|
||||
/*
|
||||
* Release ptw32_cleanupKey
|
||||
*/
|
||||
pthread_key_delete (ptw32_cleanupKey);
|
||||
|
||||
ptw32_cleanupKey = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifndef _UWIN
|
||||
//#include <process.h>
|
||||
#endif
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
#ifndef NEED_FTIME
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
void
|
||||
ptw32_rwlock_cancelwrwait (void *arg)
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
INLINE int
|
||||
ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock)
|
||||
|
|
|
@ -34,11 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifndef _UWIN
|
||||
//# include <process.h>
|
||||
#endif
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
INLINE int
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include "pthread.h"
|
||||
#include "implement.h"
|
||||
#include "ptw32pch.h"
|
||||
|
||||
|
||||
void
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue