gthr-dce.h: Uglify function parameter and local variable names.
* gthr-dce.h: Uglify function parameter and local variable names. * gthr-gnat.h: Likewise. * gthr-mipssde.h: Likewise. * gthr-nks.h: Likewise. * gthr-posix95.h: Likewise. * gthr-posix.h: Likewise. * gthr-rtems.h: Likewise. * gthr-single.h: Likewise. * gthr-solaris.h: Likewise. * gthr-tpf.h: Likewise. * gthr-vxworks.h: Likewise. * gthr-win32.h: Likewise. From-SVN: r144201
This commit is contained in:
parent
70f5fc7c74
commit
09e361bbde
13 changed files with 520 additions and 499 deletions
|
@ -1,3 +1,18 @@
|
|||
2009-02-16 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* gthr-dce.h: Uglify function parameter and local variable names.
|
||||
* gthr-gnat.h: Likewise.
|
||||
* gthr-mipssde.h: Likewise.
|
||||
* gthr-nks.h: Likewise.
|
||||
* gthr-posix95.h: Likewise.
|
||||
* gthr-posix.h: Likewise.
|
||||
* gthr-rtems.h: Likewise.
|
||||
* gthr-single.h: Likewise.
|
||||
* gthr-solaris.h: Likewise.
|
||||
* gthr-tpf.h: Likewise.
|
||||
* gthr-vxworks.h: Likewise.
|
||||
* gthr-win32.h: Likewise.
|
||||
|
||||
2009-02-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/39196
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 1997, 1999, 2000, 2001, 2004, 2005
|
||||
/* Copyright (C) 1997, 1999, 2000, 2001, 2004, 2005, 2008, 2009
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
@ -431,122 +431,123 @@ __gthread_objc_condition_signal (objc_condition_t condition
|
|||
#else /* _LIBOBJC */
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_once) (once, func);
|
||||
return __gthrw_(pthread_once) (__once, __func);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
return __gthrw_(pthread_keycreate) (key, dtor);
|
||||
return __gthrw_(pthread_keycreate) (__key, __dtor);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key __attribute__ ((__unused__)))
|
||||
__gthread_key_delete (__gthread_key_t __key __attribute__ ((__unused__)))
|
||||
{
|
||||
/* Operation is not supported. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
void *ptr;
|
||||
if (__gthrw_(pthread_getspecific) (key, &ptr) == 0)
|
||||
return ptr;
|
||||
void *__ptr;
|
||||
if (__gthrw_(pthread_getspecific) (__key, &__ptr) == 0)
|
||||
return __ptr;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return __gthrw_(pthread_setspecific) (key, (void *) ptr);
|
||||
return __gthrw_(pthread_setspecific) (__key, (void *) __ptr);
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
__gthrw_(pthread_mutex_init) (mutex, pthread_mutexattr_default);
|
||||
__gthrw_(pthread_mutex_init) (__mutex, pthread_mutexattr_default);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutx_destroy (__gthread_mutex_t *mutex)
|
||||
__gthread_mutx_destroy (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_destroy) (mutex);
|
||||
return __gthrw_(pthread_mutex_destroy) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_lock) (mutex);
|
||||
return __gthrw_(pthread_mutex_lock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_trylock) (mutex);
|
||||
return __gthrw_(pthread_mutex_trylock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_unlock) (mutex);
|
||||
return __gthrw_(pthread_mutex_unlock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int r;
|
||||
pthread_mutexattr_t __attr;
|
||||
int __r;
|
||||
|
||||
r = __gthrw_(pthread_mutexattr_create) (&attr);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutexattr_setkind_np) (&attr, MUTEX_RECURSIVE_NP);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutex_init) (mutex, attr);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutexattr_delete) (&attr);
|
||||
return r;
|
||||
__r = __gthrw_(pthread_mutexattr_create) (&__attr);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutexattr_setkind_np) (&__attr,
|
||||
MUTEX_RECURSIVE_NP);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutex_init) (__mutex, __attr);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutexattr_delete) (&__attr);
|
||||
return __r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_lock (mutex);
|
||||
return __gthread_mutex_lock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_trylock (mutex);
|
||||
return __gthread_mutex_trylock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_unlock (mutex);
|
||||
return __gthread_mutex_unlock (__mutex);
|
||||
}
|
||||
|
||||
#endif /* _LIBOBJC */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Threads compatibility routines for libgcc2. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2003, 2004, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
|
@ -38,7 +38,7 @@ typedef int __gthread_mutex_t;
|
|||
|
||||
#define __GTHREAD_MUTEX_INIT 0
|
||||
|
||||
extern void __gnat_install_locks (void (*lock) (void), void (*unlock) (void));
|
||||
extern void __gnat_install_locks (void (*) (void), void (*) (void));
|
||||
extern int __gthread_active_p (void);
|
||||
extern int __gthread_mutex_lock (__gthread_mutex_t *);
|
||||
extern int __gthread_mutex_unlock (__gthread_mutex_t *);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* MIPS SDE threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
Contributed by Nigel Stephens <nigel@mips.com>
|
||||
|
||||
This file is part of GCC.
|
||||
|
@ -55,7 +55,7 @@ typedef struct {
|
|||
#define __GTHREAD_MUTEX_INIT __SDETHREAD_MUTEX_INITIALIZER("gthr")
|
||||
#define __GTHREAD_ONCE_INIT __SDETHREAD_ONCE_INIT
|
||||
static inline int
|
||||
__gthread_recursive_mutex_init_function(__gthread_recursive_mutex_t *mutex);
|
||||
__gthread_recursive_mutex_init_function(__gthread_recursive_mutex_t *__mutex);
|
||||
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
||||
|
||||
#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
|
||||
|
@ -102,125 +102,125 @@ __gthread_active_p (void)
|
|||
#endif /* SUPPORTS_WEAK */
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(__sdethread_once) (once, func);
|
||||
return __gthrw_(__sdethread_once) (__once, __func);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
return __gthrw_(__sdethread_key_create) (key, dtor);
|
||||
return __gthrw_(__sdethread_key_create) (__key, __dtor);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
return __gthrw_(__sdethread_key_delete) (key);
|
||||
return __gthrw_(__sdethread_key_delete) (__key);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
return __gthrw_(__sdethread_getspecific) (key);
|
||||
return __gthrw_(__sdethread_getspecific) (__key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return __gthrw_(__sdethread_setspecific) (key, ptr);
|
||||
return __gthrw_(__sdethread_setspecific) (__key, __ptr);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(mutex))
|
||||
__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(__mutex))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(__sdethread_mutex_lock) (mutex);
|
||||
return __gthrw_(__sdethread_mutex_lock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(__sdethread_mutex_trylock) (mutex);
|
||||
return __gthrw_(__sdethread_mutex_trylock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(__sdethread_mutex_unlock) (mutex);
|
||||
return __gthrw_(__sdethread_mutex_unlock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
mutex->depth = 0;
|
||||
mutex->owner = __gthrw_(__sdethread_self) ();
|
||||
return __gthrw_(__sdethread_mutex_init) (&mutex->actual, NULL);
|
||||
__mutex->depth = 0;
|
||||
__mutex->owner = __gthrw_(__sdethread_self) ();
|
||||
return __gthrw_(__sdethread_mutex_init) (&__mutex->actual, NULL);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
__sdethread_t me = __gthrw_(__sdethread_self) ();
|
||||
__sdethread_t __me = __gthrw_(__sdethread_self) ();
|
||||
|
||||
if (mutex->owner != me)
|
||||
if (__mutex->owner != __me)
|
||||
{
|
||||
__gthrw_(__sdethread_mutex_lock) (&mutex->actual);
|
||||
mutex->owner = me;
|
||||
__gthrw_(__sdethread_mutex_lock) (&__mutex->actual);
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
|
||||
mutex->depth++;
|
||||
__mutex->depth++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
__sdethread_t me = __gthrw_(__sdethread_self) ();
|
||||
__sdethread_t __me = __gthrw_(__sdethread_self) ();
|
||||
|
||||
if (mutex->owner != me)
|
||||
if (__mutex->owner != __me)
|
||||
{
|
||||
if (__gthrw_(__sdethread_mutex_trylock) (&mutex->actual))
|
||||
if (__gthrw_(__sdethread_mutex_trylock) (&__mutex->actual))
|
||||
return 1;
|
||||
mutex->owner = me;
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
|
||||
mutex->depth++;
|
||||
__mutex->depth++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
if (--mutex->depth == 0)
|
||||
if (--__mutex->depth == 0)
|
||||
{
|
||||
mutex->owner = (__sdethread_t) 0;
|
||||
__gthrw_(__sdethread_mutex_unlock) (&mutex->actual);
|
||||
__mutex->owner = (__sdethread_t) 0;
|
||||
__gthrw_(__sdethread_mutex_unlock) (&__mutex->actual);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2002, 2003, 2004, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
|
@ -281,118 +281,118 @@ typedef volatile long __gthread_once_t;
|
|||
#define __GTHREAD_ONCE_INIT 0
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (__compare_and_swap (once, 0, 1))
|
||||
if (__compare_and_swap (__once, 0, 1))
|
||||
{
|
||||
func();
|
||||
*once |= 2;
|
||||
__func ();
|
||||
*__once |= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!(*once & 2))
|
||||
while (!(*__once & 2))
|
||||
NXThreadYield ();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
return NXKeyCreate (dtor, NULL, key);
|
||||
return NXKeyCreate (__dtor, NULL, __key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_dtor (__gthread_key_t key, void *ptr)
|
||||
__gthread_key_dtor (__gthread_key_t __key, void *__ptr)
|
||||
{
|
||||
/* Just reset the key value to zero. */
|
||||
if (ptr)
|
||||
return NXKeySetValue (key, NULL);
|
||||
if (__ptr)
|
||||
return NXKeySetValue (__key, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
return NXKeyDelete (key);
|
||||
return NXKeyDelete (__key);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
void *value;
|
||||
void *__value;
|
||||
|
||||
if (NXKeyGetValue (key, &value) == 0)
|
||||
return value;
|
||||
if (NXKeyGetValue (__key, &__value) == 0)
|
||||
return __value;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return NXKeySetValue (key, (void *)ptr);
|
||||
return NXKeySetValue (__key, (void *)__ptr);
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
static const NX_LOCK_INFO_ALLOC (info, "GTHREADS", 0);
|
||||
static const NX_LOCK_INFO_ALLOC (__info, "GTHREADS", 0);
|
||||
|
||||
*mutex = NXMutexAlloc (0, 0, &info);
|
||||
*__mutex = NXMutexAlloc (0, 0, &__info);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(mutex))
|
||||
__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(__mutex))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
return NXLock (*mutex);
|
||||
return NXLock (*__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (NXTryLock (*mutex))
|
||||
if (NXTryLock (*__mutex))
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
return NXUnlock (*mutex);
|
||||
return NXUnlock (*__mutex);
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
static const NX_LOCK_INFO_ALLOC (info, "GTHREADS", 0);
|
||||
static const NX_LOCK_INFO_ALLOC (__info, "GTHREADS", 0);
|
||||
|
||||
*mutex = NXMutexAlloc (NX_MUTEX_RECURSIVE, 0, &info);
|
||||
*__mutex = NXMutexAlloc (NX_MUTEX_RECURSIVE, 0, &__info);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return NXLock (*mutex);
|
||||
return NXLock (*__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (NXTryLock (*mutex))
|
||||
if (NXTryLock (*__mutex))
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return NXUnlock (*mutex);
|
||||
return NXUnlock (*__mutex);
|
||||
}
|
||||
|
||||
#endif /* _LIBOBJC */
|
||||
|
|
158
gcc/gthr-posix.h
158
gcc/gthr-posix.h
|
@ -1,7 +1,7 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
|
@ -267,7 +267,7 @@ __gthread_active_p (void)
|
|||
static volatile int __gthread_active = -1;
|
||||
|
||||
static void *
|
||||
__gthread_start (void *arg __attribute__((unused)))
|
||||
__gthread_start (void *__arg __attribute__((unused)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -277,21 +277,21 @@ static void
|
|||
__gthread_active_init (void)
|
||||
{
|
||||
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_t t;
|
||||
pthread_attr_t a;
|
||||
int result;
|
||||
pthread_t __t;
|
||||
pthread_attr_t __a;
|
||||
int __result;
|
||||
|
||||
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
|
||||
if (__gthread_active < 0)
|
||||
{
|
||||
__gthrw_(pthread_attr_init) (&a);
|
||||
__gthrw_(pthread_attr_setdetachstate) (&a, PTHREAD_CREATE_DETACHED);
|
||||
result = __gthrw_(pthread_create) (&t, &a, __gthread_start, NULL);
|
||||
if (result != ENOSYS)
|
||||
__gthrw_(pthread_attr_init) (&__a);
|
||||
__gthrw_(pthread_attr_setdetachstate) (&__a, PTHREAD_CREATE_DETACHED);
|
||||
__result = __gthrw_(pthread_create) (&__t, &__a, __gthread_start, NULL);
|
||||
if (__result != ENOSYS)
|
||||
__gthread_active = 1;
|
||||
else
|
||||
__gthread_active = 0;
|
||||
__gthrw_(pthread_attr_destroy) (&a);
|
||||
__gthrw_(pthread_attr_destroy) (&__a);
|
||||
}
|
||||
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
|
||||
}
|
||||
|
@ -676,27 +676,28 @@ __gthread_objc_condition_signal (objc_condition_t condition)
|
|||
#else /* _LIBOBJC */
|
||||
|
||||
static inline int
|
||||
__gthread_create (__gthread_t *thread, void *(*func) (void*), void *args)
|
||||
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
|
||||
void *__args)
|
||||
{
|
||||
return __gthrw_(pthread_create) (thread, NULL, func, args);
|
||||
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_join (__gthread_t thread, void **value_ptr)
|
||||
__gthread_join (__gthread_t __threadid, void **__value_ptr)
|
||||
{
|
||||
return __gthrw_(pthread_join) (thread, value_ptr);
|
||||
return __gthrw_(pthread_join) (__threadid, __value_ptr);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_detach (__gthread_t thread)
|
||||
__gthread_detach (__gthread_t __threadid)
|
||||
{
|
||||
return __gthrw_(pthread_detach) (thread);
|
||||
return __gthrw_(pthread_detach) (__threadid);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_equal (__gthread_t t1, __gthread_t t2)
|
||||
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
|
||||
{
|
||||
return __gthrw_(pthread_equal) (t1, t2);
|
||||
return __gthrw_(pthread_equal) (__t1, __t2);
|
||||
}
|
||||
|
||||
static inline __gthread_t
|
||||
|
@ -712,61 +713,61 @@ __gthread_yield (void)
|
|||
}
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_once) (once, func);
|
||||
return __gthrw_(pthread_once) (__once, __func);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
return __gthrw_(pthread_key_create) (key, dtor);
|
||||
return __gthrw_(pthread_key_create) (__key, __dtor);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
return __gthrw_(pthread_key_delete) (key);
|
||||
return __gthrw_(pthread_key_delete) (__key);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
return __gthrw_(pthread_getspecific) (key);
|
||||
return __gthrw_(pthread_getspecific) (__key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return __gthrw_(pthread_setspecific) (key, ptr);
|
||||
return __gthrw_(pthread_setspecific) (__key, __ptr);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_destroy) (mutex);
|
||||
return __gthrw_(pthread_mutex_destroy) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_lock) (mutex);
|
||||
return __gthrw_(pthread_mutex_lock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_trylock) (mutex);
|
||||
return __gthrw_(pthread_mutex_trylock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -774,11 +775,11 @@ __gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
|||
#ifdef _POSIX_TIMEOUTS
|
||||
#if _POSIX_TIMEOUTS >= 0
|
||||
static inline int
|
||||
__gthread_mutex_timedlock (__gthread_mutex_t *mutex,
|
||||
const __gthread_time_t *abs_timeout)
|
||||
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
|
||||
const __gthread_time_t *__abs_timeout)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_timedlock) (mutex, abs_timeout);
|
||||
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -786,109 +787,110 @@ __gthread_mutex_timedlock (__gthread_mutex_t *mutex,
|
|||
#endif
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_unlock) (mutex);
|
||||
return __gthrw_(pthread_mutex_unlock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
static inline int
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int r;
|
||||
pthread_mutexattr_t __attr;
|
||||
int __r;
|
||||
|
||||
r = __gthrw_(pthread_mutexattr_init) (&attr);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutexattr_settype) (&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutex_init) (mutex, &attr);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutexattr_destroy) (&attr);
|
||||
return r;
|
||||
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
|
||||
PTHREAD_MUTEX_RECURSIVE);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
|
||||
return __r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_lock (mutex);
|
||||
return __gthread_mutex_lock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_trylock (mutex);
|
||||
return __gthread_mutex_trylock (__mutex);
|
||||
}
|
||||
|
||||
#ifdef _POSIX_TIMEOUTS
|
||||
#if _POSIX_TIMEOUTS >= 0
|
||||
static inline int
|
||||
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *mutex,
|
||||
const __gthread_time_t *abs_timeout)
|
||||
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
|
||||
const __gthread_time_t *__abs_timeout)
|
||||
{
|
||||
return __gthread_mutex_timedlock (mutex, abs_timeout);
|
||||
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_unlock (mutex);
|
||||
return __gthread_mutex_unlock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_broadcast (__gthread_cond_t *cond)
|
||||
__gthread_cond_broadcast (__gthread_cond_t *__cond)
|
||||
{
|
||||
return __gthrw_(pthread_cond_broadcast) (cond);
|
||||
return __gthrw_(pthread_cond_broadcast) (__cond);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_signal (__gthread_cond_t *cond)
|
||||
__gthread_cond_signal (__gthread_cond_t *__cond)
|
||||
{
|
||||
return __gthrw_(pthread_cond_signal) (cond);
|
||||
return __gthrw_(pthread_cond_signal) (__cond);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex)
|
||||
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
|
||||
{
|
||||
return __gthrw_(pthread_cond_wait) (cond, mutex);
|
||||
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_timedwait (__gthread_cond_t *cond, __gthread_mutex_t *mutex,
|
||||
const __gthread_time_t *abs_timeout)
|
||||
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
|
||||
const __gthread_time_t *__abs_timeout)
|
||||
{
|
||||
return __gthrw_(pthread_cond_timedwait) (cond, mutex, abs_timeout);
|
||||
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_wait_recursive (__gthread_cond_t *cond,
|
||||
__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
|
||||
__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_cond_wait (cond, mutex);
|
||||
return __gthread_cond_wait (__cond, __mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_timedwait_recursive (__gthread_cond_t *cond,
|
||||
__gthread_recursive_mutex_t *mutex,
|
||||
const __gthread_time_t *abs_timeout)
|
||||
__gthread_cond_timedwait_recursive (__gthread_cond_t *__cond,
|
||||
__gthread_recursive_mutex_t *__mutex,
|
||||
const __gthread_time_t *__abs_timeout)
|
||||
{
|
||||
return __gthread_cond_timedwait (cond, mutex, abs_timeout);
|
||||
return __gthread_cond_timedwait (__cond, __mutex, __abs_timeout);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_destroy (__gthread_cond_t* cond)
|
||||
__gthread_cond_destroy (__gthread_cond_t* __cond)
|
||||
{
|
||||
return __gthrw_(pthread_cond_destroy) (cond);
|
||||
return __gthrw_(pthread_cond_destroy) (__cond);
|
||||
}
|
||||
|
||||
#endif /* _LIBOBJC */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
|
@ -610,150 +610,150 @@ __gthread_objc_condition_signal (objc_condition_t condition)
|
|||
#else /* _LIBOBJC */
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_once) (once, func);
|
||||
return __gthrw_(pthread_once) (__once, __func);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
return __gthrw_(pthread_key_create) (key, dtor);
|
||||
return __gthrw_(pthread_key_create) (__key, __dtor);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
return __gthrw_(pthread_key_delete) (key);
|
||||
return __gthrw_(pthread_key_delete) (__key);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
return __gthrw_(pthread_getspecific) (key);
|
||||
return __gthrw_(pthread_getspecific) (__key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return __gthrw_(pthread_setspecific) (key, ptr);
|
||||
return __gthrw_(pthread_setspecific) (__key, __ptr);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_destroy) (mutex);
|
||||
return __gthrw_(pthread_mutex_destroy) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_lock) (mutex);
|
||||
return __gthrw_(pthread_mutex_lock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_trylock) (mutex);
|
||||
return __gthrw_(pthread_mutex_trylock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(pthread_mutex_unlock) (mutex);
|
||||
return __gthrw_(pthread_mutex_unlock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
mutex->depth = 0;
|
||||
mutex->owner = (pthread_t) 0;
|
||||
return __gthrw_(pthread_mutex_init) (&mutex->actual, NULL);
|
||||
__mutex->depth = 0;
|
||||
__mutex->owner = (pthread_t) 0;
|
||||
return __gthrw_(pthread_mutex_init) (&__mutex->actual, NULL);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
pthread_t me = __gthrw_(pthread_self) ();
|
||||
pthread_t __me = __gthrw_(pthread_self) ();
|
||||
|
||||
if (mutex->owner != me)
|
||||
if (__mutex->owner != __me)
|
||||
{
|
||||
__gthrw_(pthread_mutex_lock) (&mutex->actual);
|
||||
mutex->owner = me;
|
||||
__gthrw_(pthread_mutex_lock) (&__mutex->actual);
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
|
||||
mutex->depth++;
|
||||
__mutex->depth++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
pthread_t me = __gthrw_(pthread_self) ();
|
||||
pthread_t __me = __gthrw_(pthread_self) ();
|
||||
|
||||
if (mutex->owner != me)
|
||||
if (__mutex->owner != __me)
|
||||
{
|
||||
if (__gthrw_(pthread_mutex_trylock) (&mutex->actual))
|
||||
if (__gthrw_(pthread_mutex_trylock) (&__mutex->actual))
|
||||
return 1;
|
||||
mutex->owner = me;
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
|
||||
mutex->depth++;
|
||||
__mutex->depth++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
if (--mutex->depth == 0)
|
||||
if (--__mutex->depth == 0)
|
||||
{
|
||||
mutex->owner = (pthread_t) 0;
|
||||
__gthrw_(pthread_mutex_unlock) (&mutex->actual);
|
||||
__mutex->owner = (pthread_t) 0;
|
||||
__gthrw_(pthread_mutex_unlock) (&__mutex->actual);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_broadcast (__gthread_cond_t *cond)
|
||||
__gthread_cond_broadcast (__gthread_cond_t *__cond)
|
||||
{
|
||||
return __gthrw_(pthread_cond_broadcast) (cond);
|
||||
return __gthrw_(pthread_cond_broadcast) (__cond);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex)
|
||||
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
|
||||
{
|
||||
return __gthrw_(pthread_cond_wait) (cond, mutex);
|
||||
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_cond_wait_recursive (__gthread_cond_t *cond,
|
||||
__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
|
||||
__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthrw_(pthread_cond_wait) (cond, &mutex->actual);
|
||||
return __gthrw_(pthread_cond_wait) (__cond, &__mutex->actual);
|
||||
}
|
||||
|
||||
#endif /* _LIBOBJC */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* RTEMS threads compatibility routines for libgcc2 and libobjc.
|
||||
by: Rosimildo da Silva( rdasilva@connecttel.com ) */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 1997, 1999, 2000, 2002, 2003, 2005
|
||||
/* Copyright (C) 1997, 1999, 2000, 2002, 2003, 2005, 2008, 2009
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
@ -54,24 +54,24 @@ typedef void *__gthread_recursive_mutex_t;
|
|||
*/
|
||||
|
||||
/* generic per task variables */
|
||||
extern int rtems_gxx_once (__gthread_once_t *once, void (*func) (void));
|
||||
extern int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *));
|
||||
extern int rtems_gxx_key_delete (__gthread_key_t key);
|
||||
extern void *rtems_gxx_getspecific (__gthread_key_t key);
|
||||
extern int rtems_gxx_setspecific (__gthread_key_t key, const void *ptr);
|
||||
extern int rtems_gxx_once (__gthread_once_t *__once, void (*__func) (void));
|
||||
extern int rtems_gxx_key_create (__gthread_key_t *__key, void (*__dtor) (void *));
|
||||
extern int rtems_gxx_key_delete (__gthread_key_t __key);
|
||||
extern void *rtems_gxx_getspecific (__gthread_key_t __key);
|
||||
extern int rtems_gxx_setspecific (__gthread_key_t __key, const void *__ptr);
|
||||
|
||||
/* mutex support */
|
||||
extern void rtems_gxx_mutex_init (__gthread_mutex_t *mutex);
|
||||
extern int rtems_gxx_mutex_destroy (__gthread_mutex_t *mutex);
|
||||
extern int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex);
|
||||
extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex);
|
||||
extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex);
|
||||
extern void rtems_gxx_mutex_init (__gthread_mutex_t *__mutex);
|
||||
extern int rtems_gxx_mutex_destroy (__gthread_mutex_t *__mutex);
|
||||
extern int rtems_gxx_mutex_lock (__gthread_mutex_t *__mutex);
|
||||
extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *__mutex);
|
||||
extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *__mutex);
|
||||
|
||||
/* recursive mutex support */
|
||||
extern void rtems_gxx_recursive_mutex_init (__gthread_recursive_mutex_t *mutex);
|
||||
extern int rtems_gxx_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
|
||||
extern int rtems_gxx_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
|
||||
extern int rtems_gxx_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
|
||||
extern void rtems_gxx_recursive_mutex_init (__gthread_recursive_mutex_t *__mutex);
|
||||
extern int rtems_gxx_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex);
|
||||
extern int rtems_gxx_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex);
|
||||
extern int rtems_gxx_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex);
|
||||
|
||||
/* RTEMS threading is always active */
|
||||
static inline int
|
||||
|
@ -82,75 +82,75 @@ __gthread_active_p (void)
|
|||
|
||||
/* Wrapper calls */
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
return rtems_gxx_once( once, func );
|
||||
return rtems_gxx_once( __once, __func );
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
return rtems_gxx_key_create( key, dtor );
|
||||
return rtems_gxx_key_create( __key, __dtor );
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
return rtems_gxx_key_delete (key);
|
||||
return rtems_gxx_key_delete (__key);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
return rtems_gxx_getspecific (key);
|
||||
return rtems_gxx_getspecific (__key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return rtems_gxx_setspecific (key, ptr);
|
||||
return rtems_gxx_setspecific (__key, __ptr);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
return rtems_gxx_mutex_destroy (mutex);
|
||||
return rtems_gxx_mutex_destroy (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
return rtems_gxx_mutex_lock (mutex);
|
||||
return rtems_gxx_mutex_lock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
return rtems_gxx_mutex_trylock (mutex);
|
||||
return rtems_gxx_mutex_trylock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
return rtems_gxx_mutex_unlock( mutex );
|
||||
return rtems_gxx_mutex_unlock( __mutex );
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return rtems_gxx_recursive_mutex_lock (mutex);
|
||||
return rtems_gxx_recursive_mutex_lock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return rtems_gxx_recursive_mutex_trylock (mutex);
|
||||
return rtems_gxx_recursive_mutex_trylock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return rtems_gxx_recursive_mutex_unlock( mutex );
|
||||
return rtems_gxx_recursive_mutex_unlock( __mutex );
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 1997, 1999, 2000, 2004, 2008 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
|
@ -216,75 +217,75 @@ __gthread_active_p (void)
|
|||
}
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once UNUSED, void (*func) (void) UNUSED)
|
||||
__gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int UNUSED
|
||||
__gthread_key_create (__gthread_key_t *key UNUSED, void (*func) (void *) UNUSED)
|
||||
__gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int UNUSED
|
||||
__gthread_key_delete (__gthread_key_t key UNUSED)
|
||||
__gthread_key_delete (__gthread_key_t __key UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key UNUSED)
|
||||
__gthread_getspecific (__gthread_key_t __key UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key UNUSED, const void *v UNUSED)
|
||||
__gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *mutex UNUSED)
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex UNUSED)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex UNUSED)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex UNUSED)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_lock (mutex);
|
||||
return __gthread_mutex_lock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_trylock (mutex);
|
||||
return __gthread_mutex_trylock (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
return __gthread_mutex_unlock (mutex);
|
||||
return __gthread_mutex_unlock (__mutex);
|
||||
}
|
||||
|
||||
#endif /* _LIBOBJC */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 1997, 1999, 2000, 2004, 2005, 2006
|
||||
/* Copyright (C) 1997, 1999, 2000, 2004, 2005, 2006, 2008, 2009
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
@ -403,154 +403,155 @@ __gthread_objc_condition_signal (objc_condition_t condition)
|
|||
#else /* _LIBOBJC */
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (! __gthread_active_p ())
|
||||
return -1;
|
||||
|
||||
if (once == 0 || func == 0)
|
||||
if (__once == 0 || __func == 0)
|
||||
return EINVAL;
|
||||
|
||||
if (once->once == 0)
|
||||
if (__once->once == 0)
|
||||
{
|
||||
int status = __gthrw_(mutex_lock) (&once->mutex);
|
||||
if (status != 0)
|
||||
return status;
|
||||
if (once->once == 0)
|
||||
int __status = __gthrw_(mutex_lock) (&__once->mutex);
|
||||
if (__status != 0)
|
||||
return __status;
|
||||
if (__once->once == 0)
|
||||
{
|
||||
(*func) ();
|
||||
once->once++;
|
||||
(*__func) ();
|
||||
__once->once++;
|
||||
}
|
||||
__gthrw_(mutex_unlock) (&once->mutex);
|
||||
__gthrw_(mutex_unlock) (&__once->mutex);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
/* Solaris 2.5 contains thr_* routines no-op in libc, so test if we actually
|
||||
got a reasonable key value, and if not, fail. */
|
||||
*key = (__gthread_key_t)-1;
|
||||
if (__gthrw_(thr_keycreate) (key, dtor) != 0 || *key == (__gthread_key_t)-1)
|
||||
*__key = (__gthread_key_t)-1;
|
||||
if (__gthrw_(thr_keycreate) (__key, __dtor) != 0
|
||||
|| *__key == (__gthread_key_t)-1)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t UNUSED (key))
|
||||
__gthread_key_delete (__gthread_key_t UNUSED (__key))
|
||||
{
|
||||
/* Not possible. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
void *ptr;
|
||||
if (__gthrw_(thr_getspecific) (key, &ptr) == 0)
|
||||
return ptr;
|
||||
void *__ptr;
|
||||
if (__gthrw_(thr_getspecific) (__key, &__ptr) == 0)
|
||||
return __ptr;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return __gthrw_(thr_setspecific) (key, (void *) ptr);
|
||||
return __gthrw_(thr_setspecific) (__key, (void *) __ptr);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(mutex))
|
||||
__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(__mutex))
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(mutex_destroy) (mutex);
|
||||
return __gthrw_(mutex_destroy) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(mutex_lock) (mutex);
|
||||
return __gthrw_(mutex_lock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(mutex_trylock) (mutex);
|
||||
return __gthrw_(mutex_trylock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthrw_(mutex_unlock) (mutex);
|
||||
return __gthrw_(mutex_unlock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
mutex->depth = 0;
|
||||
mutex->owner = (thread_t) 0;
|
||||
return __gthrw_(mutex_init) (&mutex->actual, USYNC_THREAD, 0);
|
||||
__mutex->depth = 0;
|
||||
__mutex->owner = (thread_t) 0;
|
||||
return __gthrw_(mutex_init) (&__mutex->actual, USYNC_THREAD, 0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
thread_t me = __gthrw_(thr_self) ();
|
||||
thread_t __me = __gthrw_(thr_self) ();
|
||||
|
||||
if (mutex->owner != me)
|
||||
if (__mutex->owner != __me)
|
||||
{
|
||||
__gthrw_(mutex_lock) (&mutex->actual);
|
||||
mutex->owner = me;
|
||||
__gthrw_(mutex_lock) (&__mutex->actual);
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
|
||||
mutex->depth++;
|
||||
__mutex->depth++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
thread_t me = __gthrw_(thr_self) ();
|
||||
thread_t __me = __gthrw_(thr_self) ();
|
||||
|
||||
if (mutex->owner != me)
|
||||
if (__mutex->owner != __me)
|
||||
{
|
||||
if (__gthrw_(mutex_trylock) (&mutex->actual))
|
||||
if (__gthrw_(mutex_trylock) (&__mutex->actual))
|
||||
return 1;
|
||||
mutex->owner = me;
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
|
||||
mutex->depth++;
|
||||
__mutex->depth++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
if (--mutex->depth == 0)
|
||||
if (--__mutex->depth == 0)
|
||||
{
|
||||
mutex->owner = (thread_t) 0;
|
||||
__gthrw_(mutex_unlock) (&mutex->actual);
|
||||
__mutex->owner = (thread_t) 0;
|
||||
__gthrw_(mutex_unlock) (&__mutex->actual);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc.
|
||||
Compile this one with gcc.
|
||||
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2005, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
|
@ -101,129 +101,130 @@ __gthread_active_p (void)
|
|||
}
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_once) (once, func);
|
||||
return __gthrw_(pthread_once) (__once, __func);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_key_create) (key, dtor);
|
||||
return __gthrw_(pthread_key_create) (__key, __dtor);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_key_delete) (key);
|
||||
return __gthrw_(pthread_key_delete) (__key);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_getspecific) (key);
|
||||
return __gthrw_(pthread_getspecific) (__key);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_setspecific) (key, ptr);
|
||||
return __gthrw_(pthread_setspecific) (__key, __ptr);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_mutex_destroy) (mutex);
|
||||
return __gthrw_(pthread_mutex_destroy) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_mutex_lock) (mutex);
|
||||
return __gthrw_(pthread_mutex_lock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_mutex_trylock) (mutex);
|
||||
return __gthrw_(pthread_mutex_trylock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthrw_(pthread_mutex_unlock) (mutex);
|
||||
return __gthrw_(pthread_mutex_unlock) (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthread_mutex_lock (mutex);
|
||||
return __gthread_mutex_lock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthread_mutex_trylock (mutex);
|
||||
return __gthread_mutex_trylock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
return __gthread_mutex_unlock (mutex);
|
||||
return __gthread_mutex_unlock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__tpf_pthread_active ())
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int r;
|
||||
pthread_mutexattr_t __attr;
|
||||
int __r;
|
||||
|
||||
r = __gthrw_(pthread_mutexattr_init) (&attr);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutexattr_settype) (&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutex_init) (mutex, &attr);
|
||||
if (!r)
|
||||
r = __gthrw_(pthread_mutexattr_destroy) (&attr);
|
||||
return r;
|
||||
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
|
||||
PTHREAD_MUTEX_RECURSIVE);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
|
||||
if (!__r)
|
||||
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
|
||||
return __r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc for VxWorks. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997, 1999, 2000, 2008, 2009 Free Software Foundation, Inc.
|
||||
Contributed by Mike Stump <mrs@wrs.com>.
|
||||
|
||||
This file is part of GCC.
|
||||
|
@ -131,7 +131,7 @@ __gthread_once_t;
|
|||
# define __GTHREAD_ONCE_INIT { 0 }
|
||||
#endif
|
||||
|
||||
extern int __gthread_once (__gthread_once_t *once, void (*func)(void));
|
||||
extern int __gthread_once (__gthread_once_t *__once, void (*__func)(void));
|
||||
|
||||
/* Thread-specific data requires a great deal of effort, since VxWorks
|
||||
is not really set up for it. See config/vxlib.c for the gory
|
||||
|
@ -140,11 +140,11 @@ extern int __gthread_once (__gthread_once_t *once, void (*func)(void));
|
|||
|
||||
typedef unsigned int __gthread_key_t;
|
||||
|
||||
extern int __gthread_key_create (__gthread_key_t *keyp, void (*dtor)(void *));
|
||||
extern int __gthread_key_delete (__gthread_key_t key);
|
||||
extern int __gthread_key_create (__gthread_key_t *__keyp, void (*__dtor)(void *));
|
||||
extern int __gthread_key_delete (__gthread_key_t __key);
|
||||
|
||||
extern void *__gthread_getspecific (__gthread_key_t key);
|
||||
extern int __gthread_setspecific (__gthread_key_t key, void *ptr);
|
||||
extern void *__gthread_getspecific (__gthread_key_t __key);
|
||||
extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr);
|
||||
|
||||
#undef UNUSED
|
||||
|
||||
|
|
222
gcc/gthr-win32.h
222
gcc/gthr-win32.h
|
@ -1,7 +1,7 @@
|
|||
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||
/* Compile this one with gcc. */
|
||||
|
||||
/* Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005
|
||||
/* Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2008, 2009
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Mumit Khan <khan@xraylith.wisc.edu>.
|
||||
|
||||
|
@ -381,14 +381,14 @@ extern int __mingwthr_key_dtor (unsigned long, void (*) (void *));
|
|||
gthread_mutex_try_lock is not referenced by libgcc or libstdc++. */
|
||||
#ifdef __GTHREAD_I486_INLINE_LOCK_PRIMITIVES
|
||||
static inline long
|
||||
__gthr_i486_lock_cmp_xchg(long *dest, long xchg, long comperand)
|
||||
__gthr_i486_lock_cmp_xchg(long *__dest, long __xchg, long __comperand)
|
||||
{
|
||||
long result;
|
||||
__asm__ __volatile__ ("\n\
|
||||
lock\n\
|
||||
cmpxchg{l} {%4, %1|%1, %4}\n"
|
||||
: "=a" (result), "=m" (*dest)
|
||||
: "0" (comperand), "m" (*dest), "r" (xchg)
|
||||
: "=a" (result), "=m" (*__dest)
|
||||
: "0" (__comperand), "m" (*__dest), "r" (__xchg)
|
||||
: "cc");
|
||||
return result;
|
||||
}
|
||||
|
@ -431,106 +431,106 @@ extern int __gthr_win32_recursive_mutex_unlock (__gthread_recursive_mutex_t *);
|
|||
extern void __gthr_win32_mutex_destroy (__gthread_mutex_t *);
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthr_win32_once (once, func);
|
||||
return __gthr_win32_once (__once, __func);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||
{
|
||||
return __gthr_win32_key_create (key, dtor);
|
||||
return __gthr_win32_key_create (__key, __dtor);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
return __gthr_win32_key_delete (key);
|
||||
return __gthr_win32_key_delete (__key);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
return __gthr_win32_getspecific (key);
|
||||
return __gthr_win32_getspecific (__key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
return __gthr_win32_setspecific (key, ptr);
|
||||
return __gthr_win32_setspecific (__key, __ptr);
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
__gthr_win32_mutex_init_function (mutex);
|
||||
__gthr_win32_mutex_init_function (__mutex);
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
__gthr_win32_mutex_destroy (mutex);
|
||||
__gthr_win32_mutex_destroy (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthr_win32_mutex_lock (mutex);
|
||||
return __gthr_win32_mutex_lock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthr_win32_mutex_trylock (mutex);
|
||||
return __gthr_win32_mutex_trylock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthr_win32_mutex_unlock (mutex);
|
||||
return __gthr_win32_mutex_unlock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
__gthr_win32_recursive_mutex_init_function (mutex);
|
||||
__gthr_win32_recursive_mutex_init_function (__mutex);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthr_win32_recursive_mutex_lock (mutex);
|
||||
return __gthr_win32_recursive_mutex_lock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthr_win32_recursive_mutex_trylock (mutex);
|
||||
return __gthr_win32_recursive_mutex_trylock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
return __gthr_win32_recursive_mutex_unlock (mutex);
|
||||
return __gthr_win32_recursive_mutex_unlock (__mutex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -541,19 +541,19 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
|||
#include <errno.h>
|
||||
|
||||
static inline int
|
||||
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
||||
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||
{
|
||||
if (! __gthread_active_p ())
|
||||
return -1;
|
||||
else if (once == NULL || func == NULL)
|
||||
else if (__once == NULL || __func == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if (! once->done)
|
||||
if (! __once->done)
|
||||
{
|
||||
if (InterlockedIncrement (&(once->started)) == 0)
|
||||
if (InterlockedIncrement (&(__once->started)) == 0)
|
||||
{
|
||||
(*func) ();
|
||||
once->done = TRUE;
|
||||
(*__func) ();
|
||||
__once->done = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -562,7 +562,7 @@ __gthread_once (__gthread_once_t *once, void (*func) (void))
|
|||
does become an issue, the solution is to use an Event that
|
||||
we wait on here (and set above), but that implies a place to
|
||||
create the event before this routine is called. */
|
||||
while (! once->done)
|
||||
while (! __once->done)
|
||||
Sleep (0);
|
||||
}
|
||||
}
|
||||
|
@ -574,150 +574,150 @@ __gthread_once (__gthread_once_t *once, void (*func) (void))
|
|||
leaks, especially in threaded applications making extensive use of
|
||||
C++ EH. Mingw uses a thread-support DLL to work-around this problem. */
|
||||
static inline int
|
||||
__gthread_key_create (__gthread_key_t *key,
|
||||
void (*dtor) (void *) __attribute__((unused)))
|
||||
__gthread_key_create (__gthread_key_t *__key,
|
||||
void (*__dtor) (void *) __attribute__((unused)))
|
||||
{
|
||||
int status = 0;
|
||||
DWORD tls_index = TlsAlloc ();
|
||||
if (tls_index != 0xFFFFFFFF)
|
||||
int __status = 0;
|
||||
DWORD __tls_index = TlsAlloc ();
|
||||
if (__tls_index != 0xFFFFFFFF)
|
||||
{
|
||||
*key = tls_index;
|
||||
*__key = __tls_index;
|
||||
#ifdef MINGW32_SUPPORTS_MT_EH
|
||||
/* Mingw runtime will run the dtors in reverse order for each thread
|
||||
when the thread exits. */
|
||||
status = __mingwthr_key_dtor (*key, dtor);
|
||||
__status = __mingwthr_key_dtor (*__key, __dtor);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
status = (int) GetLastError ();
|
||||
return status;
|
||||
__status = (int) GetLastError ();
|
||||
return __status;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_key_delete (__gthread_key_t key)
|
||||
__gthread_key_delete (__gthread_key_t __key)
|
||||
{
|
||||
return (TlsFree (key) != 0) ? 0 : (int) GetLastError ();
|
||||
return (TlsFree (__key) != 0) ? 0 : (int) GetLastError ();
|
||||
}
|
||||
|
||||
static inline void *
|
||||
__gthread_getspecific (__gthread_key_t key)
|
||||
__gthread_getspecific (__gthread_key_t __key)
|
||||
{
|
||||
DWORD lasterror;
|
||||
void *ptr;
|
||||
DWORD __lasterror;
|
||||
void *__ptr;
|
||||
|
||||
lasterror = GetLastError ();
|
||||
__lasterror = GetLastError ();
|
||||
|
||||
ptr = TlsGetValue (key);
|
||||
__ptr = TlsGetValue (__key);
|
||||
|
||||
SetLastError (lasterror);
|
||||
SetLastError (__lasterror);
|
||||
|
||||
return ptr;
|
||||
return __ptr;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||
{
|
||||
if (TlsSetValue (key, CONST_CAST2(void *, const void *, ptr)) != 0)
|
||||
if (TlsSetValue (__key, CONST_CAST2(void *, const void *, __ptr)) != 0)
|
||||
return 0;
|
||||
else
|
||||
return GetLastError ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
mutex->counter = -1;
|
||||
mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL);
|
||||
__mutex->counter = -1;
|
||||
__mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL);
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
CloseHandle ((HANDLE) mutex->sema);
|
||||
CloseHandle ((HANDLE) __mutex->sema);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
int status = 0;
|
||||
int __status = 0;
|
||||
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
if (InterlockedIncrement (&mutex->counter) == 0 ||
|
||||
WaitForSingleObject (mutex->sema, INFINITE) == WAIT_OBJECT_0)
|
||||
status = 0;
|
||||
if (InterlockedIncrement (&__mutex->counter) == 0 ||
|
||||
WaitForSingleObject (__mutex->sema, INFINITE) == WAIT_OBJECT_0)
|
||||
__status = 0;
|
||||
else
|
||||
{
|
||||
/* WaitForSingleObject returns WAIT_FAILED, and we can only do
|
||||
some best-effort cleanup here. */
|
||||
InterlockedDecrement (&mutex->counter);
|
||||
status = 1;
|
||||
InterlockedDecrement (&__mutex->counter);
|
||||
__status = 1;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
return __status;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
int status = 0;
|
||||
int __status = 0;
|
||||
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
if (__GTHR_W32_InterlockedCompareExchange (&mutex->counter, 0, -1) < 0)
|
||||
status = 0;
|
||||
if (__GTHR_W32_InterlockedCompareExchange (&__mutex->counter, 0, -1) < 0)
|
||||
__status = 0;
|
||||
else
|
||||
status = 1;
|
||||
__status = 1;
|
||||
}
|
||||
return status;
|
||||
return __status;
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
if (InterlockedDecrement (&mutex->counter) >= 0)
|
||||
return ReleaseSemaphore (mutex->sema, 1, NULL) ? 0 : 1;
|
||||
if (InterlockedDecrement (&__mutex->counter) >= 0)
|
||||
return ReleaseSemaphore (__mutex->sema, 1, NULL) ? 0 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
mutex->counter = -1;
|
||||
mutex->depth = 0;
|
||||
mutex->owner = 0;
|
||||
mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL);
|
||||
__mutex->counter = -1;
|
||||
__mutex->depth = 0;
|
||||
__mutex->owner = 0;
|
||||
__mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL);
|
||||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
DWORD me = GetCurrentThreadId();
|
||||
if (InterlockedIncrement (&mutex->counter) == 0)
|
||||
DWORD __me = GetCurrentThreadId();
|
||||
if (InterlockedIncrement (&__mutex->counter) == 0)
|
||||
{
|
||||
mutex->depth = 1;
|
||||
mutex->owner = me;
|
||||
__mutex->depth = 1;
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
else if (mutex->owner == me)
|
||||
else if (__mutex->owner == __me)
|
||||
{
|
||||
InterlockedDecrement (&mutex->counter);
|
||||
++(mutex->depth);
|
||||
InterlockedDecrement (&__mutex->counter);
|
||||
++(__mutex->depth);
|
||||
}
|
||||
else if (WaitForSingleObject (mutex->sema, INFINITE) == WAIT_OBJECT_0)
|
||||
else if (WaitForSingleObject (__mutex->sema, INFINITE) == WAIT_OBJECT_0)
|
||||
{
|
||||
mutex->depth = 1;
|
||||
mutex->owner = me;
|
||||
__mutex->depth = 1;
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* WaitForSingleObject returns WAIT_FAILED, and we can only do
|
||||
some best-effort cleanup here. */
|
||||
InterlockedDecrement (&mutex->counter);
|
||||
InterlockedDecrement (&__mutex->counter);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -725,18 +725,18 @@ __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
|||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
DWORD me = GetCurrentThreadId();
|
||||
if (__GTHR_W32_InterlockedCompareExchange (&mutex->counter, 0, -1) < 0)
|
||||
DWORD __me = GetCurrentThreadId();
|
||||
if (__GTHR_W32_InterlockedCompareExchange (&__mutex->counter, 0, -1) < 0)
|
||||
{
|
||||
mutex->depth = 1;
|
||||
mutex->owner = me;
|
||||
__mutex->depth = 1;
|
||||
__mutex->owner = __me;
|
||||
}
|
||||
else if (mutex->owner == me)
|
||||
++(mutex->depth);
|
||||
else if (__mutex->owner == __me)
|
||||
++(__mutex->depth);
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
@ -744,17 +744,17 @@ __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
|||
}
|
||||
|
||||
static inline int
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
||||
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||
{
|
||||
if (__gthread_active_p ())
|
||||
{
|
||||
--(mutex->depth);
|
||||
if (mutex->depth == 0)
|
||||
--(__mutex->depth);
|
||||
if (__mutex->depth == 0)
|
||||
{
|
||||
mutex->owner = 0;
|
||||
__mutex->owner = 0;
|
||||
|
||||
if (InterlockedDecrement (&mutex->counter) >= 0)
|
||||
return ReleaseSemaphore (mutex->sema, 1, NULL) ? 0 : 1;
|
||||
if (InterlockedDecrement (&__mutex->counter) >= 0)
|
||||
return ReleaseSemaphore (__mutex->sema, 1, NULL) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue