remove lock.c/lock.h; don't need them for what i planned after all
authorNathan Bryant <loanshark@uncensored.citadel.org>
Thu, 17 Jan 2002 20:09:29 +0000 (20:09 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Thu, 17 Jan 2002 20:09:29 +0000 (20:09 +0000)
citadel/lock.c [deleted file]
citadel/lock.h [deleted file]

diff --git a/citadel/lock.c b/citadel/lock.c
deleted file mode 100644 (file)
index b1df8c3..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * read/write locks.
- * this is just a thin wrapper around POSIX rwlocks to provide recursive
- * write-locking.
- * by nathan bryant <nbryant@optonline.net>
- *
- * pthread_rwlock_* directly maps to lock_*, using lock_t instead of
- * pthread_rwlock_t, except lock_init doesn't take an attribute parameter
- *
- * There is no initializer macro; use lock_init().
- *
- * $Id$
- */
-
-#define _XOPEN_SOURCE 500 /* Unix98 */
-
-#include "lock.h"
-
-int lock_init(lock_t *lock) {
-       int ret;
-       
-        if ((ret = pthread_key_create(&lock->count, NULL)))
-               return ret;
-
-       return pthread_rwlock_init(&lock->lock, NULL);
-}
-
-int lock_wrlock(lock_t *lock) {
-       int ret;
-       long count;
-
-       if ((count = (long)pthread_getspecific(lock->count)) > 0)
-               return pthread_setspecific(lock->count, (void *)(count + 1));
-
-       ret = pthread_rwlock_wrlock(&lock->lock);
-       if (!ret) {
-               ret = pthread_setspecific(lock->count, (void *)1);
-
-               if (ret)
-                       pthread_rwlock_unlock(&lock->lock);
-       }
-
-       return ret;
-}
-
-int lock_trywrlock(lock_t *lock) {
-        int ret;
-       long count;
-
-        if ((count = (long)pthread_getspecific(lock->count)) > 0)
-                return pthread_setspecific(lock->count, (void *)(count + 1));
-
-        ret = pthread_rwlock_trywrlock(&lock->lock);
-        if (!ret) {
-                ret = pthread_setspecific(lock->count, (void *)1);
-
-               if (ret)
-                       pthread_rwlock_unlock(&lock->lock);
-       }
-
-        return ret;
-}
-
-int lock_unlock(lock_t *lock) {
-       int ret;
-       long count;
-
-       if ((count = (long)pthread_getspecific(lock->count)) > 0) {
-               if (count > 1)
-                       return pthread_setspecific(lock->count,
-                                                  (void *)(count - 1));
-
-               ret = pthread_rwlock_unlock(&lock->lock);
-               if (ret)
-                       return ret;
-
-               return pthread_setspecific(lock->count, (void *)0);
-       }
-
-       return pthread_rwlock_unlock(&lock->lock);
-}
-
-int lock_destroy(lock_t *lock) {
-       int ret1, ret2;
-
-       ret1 = pthread_key_delete(lock->count);
-       ret2 = pthread_rwlock_destroy(&lock->lock);
-
-       if (ret2)
-               return ret2;
-
-       return ret1;
-}
diff --git a/citadel/lock.h b/citadel/lock.h
deleted file mode 100644 (file)
index 163c6b1..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * read/write locks.
- * this is just a thin wrapper around POSIX rwlocks to provide recursive
- * write-locking.
- * by nathan bryant <nbryant@optonline.net>
- *
- * pthread_rwlock_* directly maps to lock_*, using lock_t instead of
- * pthread_rwlock_t, except lock_init doesn't take an attribute parameter
- *
- * There is no initializer macro; use lock_init().
- *
- * $Id$
- */
-
-#ifndef LOCK_H
-#define LOCK_H
-
-#include <pthread.h>
-
-typedef struct {
-       pthread_rwlock_t lock;
-       pthread_key_t count;
-} lock_t;
-
-/* The following are implemented in lock.c */
-
-int lock_init(lock_t *lock);
-int lock_wrlock(lock_t *lock);
-int lock_trywrlock(lock_t *lock);
-int lock_unlock(lock_t *lock);
-int lock_destroy(lock_t *lock);
-
-/* The remaining functions are actually implemented here as macros:
-
-int lock_rdlock(lock_t *lock);
-int lock_tryrdlock(lock_t *lock);
-
-*/
-
-#define lock_rdlock(lock) (pthread_rwlock_rdlock(&(lock)->lock))
-#define lock_tryrdlock(lock) (pthread_rwlock_tryrdlock(&(lock)->lock))
-
-#endif /* LOCK_H */