diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-03-29 14:32:40 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-03-29 14:32:40 +0400 |
commit | f00fe1b8e7bf295a0ca87ac472ead52f50037c09 (patch) | |
tree | f1d4a471ad96ee75a652778d692ab6360cd7dc22 /winsup/cygwin/thread.h | |
parent | a011f952168ce0219b64c6f0a9dc6a01f86e77c6 (diff) |
* cygwin.din (pthread_spin_destroy): Export.
(pthread_spin_init): Export.
(pthread_spin_lock): Export.
(pthread_spin_trylock): Export.
(pthread_spin_unlock): Export.
* posix.sgml (std-susv4): Add pthread_spin_destroy, pthread_spin_init,
pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock.
(std-notimpl): Remove pthread_spin_[...].
* pthread.cc (pthread_spin_init): New function.
* thread.cc (pthread_spinlock::is_good_object): New function.
(pthread_mutex::pthread_mutex): Rearrange initializers to accommodate
protected data in pthread_mutex.
(pthread_spinlock::pthread_spinlock): New constructor.
(pthread_spinlock::lock): New method.
(pthread_spinlock::unlock): New method.
(pthread_spinlock::init): New method.
(pthread_spin_lock): New function.
(pthread_spin_trylock): New function.
(pthread_spin_unlock): New function.
(pthread_spin_destroy): New function.
* thread.h (PTHREAD_SPINLOCK_MAGIC): Define.
(class pthread_mutex): Change access level of members shared with
derived classes to protected.
(pthread_mutex::set_shared): New protected method.
(class pthread_spinlock): New class, derived class of pthread_mutex.
* include/pthread.h (pthread_spin_destroy): Declare.
(pthread_spin_init): Declare.
(pthread_spin_lock): Declare.
(pthread_spin_trylock): Declare.
(pthread_spin_unlock): Declare.
* include/cygwin/types.h (pthread_spinlock_t): New typedef.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
Diffstat (limited to 'winsup/cygwin/thread.h')
-rw-r--r-- | winsup/cygwin/thread.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index bea8e2aa3..f96714f49 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -1,7 +1,7 @@ /* thread.h: Locking and threading module definitions Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, - 2008, 2009, 2010 Red Hat, Inc. + 2008, 2009, 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -98,6 +98,7 @@ class pinfo; #define PTHREAD_ONCE_MAGIC PTHREAD_MAGIC+8 #define PTHREAD_RWLOCK_MAGIC PTHREAD_MAGIC+9 #define PTHREAD_RWLOCKATTR_MAGIC PTHREAD_MAGIC+10 +#define PTHREAD_SPINLOCK_MAGIC PTHREAD_MAGIC+11 #define MUTEX_OWNER_ANONYMOUS ((pthread_t) -1) @@ -303,18 +304,15 @@ public: mutexes.for_each (&pthread_mutex::_fixup_after_fork); } -private: +protected: unsigned long lock_counter; HANDLE win32_obj_id; - unsigned int recursion_counter; - LONG condwaits; pthread_t owner; #ifdef DEBUGGING DWORD tid; /* the thread id of the owner */ #endif - int type; - int pshared; + void set_shared (int in_shared) { pshared = in_shared; } void set_owner (pthread_t self) { recursion_counter = 1; @@ -323,10 +321,17 @@ private: tid = GetCurrentThreadId (); #endif } + static const pthread_t _new_mutex; static const pthread_t _unlocked_mutex; static const pthread_t _destroyed_mutex; +private: + unsigned int recursion_counter; + LONG condwaits; + int type; + int pshared; + bool no_owner (); void _fixup_after_fork (); @@ -335,6 +340,18 @@ private: friend class pthread_cond; }; +class pthread_spinlock: public pthread_mutex +{ +public: + static bool is_good_object (pthread_spinlock_t const *); + static int init (pthread_spinlock_t *, int); + + int lock (); + int unlock (); + + pthread_spinlock (int); +}; + #define WAIT_CANCELED (WAIT_OBJECT_0 + 1) #define WAIT_SIGNALED (WAIT_OBJECT_0 + 2) |