]> git.sesse.net Git - vlc/blobdiff - src/os2/thread.c
Define explicit makefile variable for libpthread
[vlc] / src / os2 / thread.c
index 197ca0113347bb6ad15e020fe2f30b29aee37129..e51b086f38706e675e3cc684b0c1ed831d7bd0d4 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * thread.c : OS/2 back-end for LibVLC
  *****************************************************************************
- * Copyright (C) 1999-2011 the VideoLAN team
+ * Copyright (C) 1999-2011 VLC authors and VideoLAN
  *
  * Authors: KO Myung-Hun <komh@chollian.net>
  *          Jean-Marc Dressler <polux@via.ecp.fr>
  *          RĂ©mi Denis-Courmont
  *          Pierre Ynard
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program 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.1 of the License, or
  * (at your option) any later version.
  *
  * This program 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 General Public License for more details.
+ * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -434,7 +434,6 @@ void vlc_rwlock_init (vlc_rwlock_t *lock)
     vlc_mutex_init (&lock->mutex);
     vlc_cond_init (&lock->wait);
     lock->readers = 0; /* active readers */
-    lock->writers = 0; /* waiting or active writers */
     lock->writer = 0; /* ID of active writer */
 }
 
@@ -447,13 +446,7 @@ void vlc_rwlock_destroy (vlc_rwlock_t *lock)
 void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
 {
     vlc_mutex_lock (&lock->mutex);
-    /* Recursive read-locking is allowed. With the infos available:
-     *  - the loosest possible condition (no active writer) is:
-     *     (lock->writer != 0)
-     *  - the strictest possible condition is:
-     *     (lock->writer != 0 || (lock->readers == 0 && lock->writers > 0))
-     *  or (lock->readers == 0 && (lock->writer != 0 || lock->writers > 0))
-     */
+    /* Recursive read-locking is allowed. */
     while (lock->writer != 0)
     {
         assert (lock->readers == 0);
@@ -471,7 +464,7 @@ static void vlc_rwlock_rdunlock (vlc_rwlock_t *lock)
     assert (lock->readers > 0);
 
     /* If there are no readers left, wake up a writer. */
-    if (--lock->readers == 0 && lock->writers > 0)
+    if (--lock->readers == 0)
         vlc_cond_signal (&lock->wait);
     vlc_mutex_unlock (&lock->mutex);
 }
@@ -479,13 +472,9 @@ static void vlc_rwlock_rdunlock (vlc_rwlock_t *lock)
 void vlc_rwlock_wrlock (vlc_rwlock_t *lock)
 {
     vlc_mutex_lock (&lock->mutex);
-    if (unlikely(lock->writers == ULONG_MAX))
-        abort ();
-    lock->writers++;
     /* Wait until nobody owns the lock in either way. */
     while ((lock->readers > 0) || (lock->writer != 0))
         vlc_cond_wait (&lock->wait, &lock->mutex);
-    lock->writers--;
     assert (lock->writer == 0);
     lock->writer = _gettid ();
     vlc_mutex_unlock (&lock->mutex);