Convert all osi_timeval_t to osi_timeval32_t
[openafs.git] / src / afs / afs_lock.c
index 8573a07..4489853 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -25,8 +25,6 @@
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID
-    ("$Header$");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
@@ -35,12 +33,11 @@ RCSID
 /* probably needed if lock_trace is enabled - should ifdef */
 int afs_trclock = 0;
 
-void Lock_Obtain();
-void Lock_ReleaseR();
-void Lock_ReleaseW();
+void Lock_ReleaseR(struct afs_lock *lock);
+void Lock_ReleaseW(struct afs_lock *lock);
 
 void
-Lock_Init(register struct afs_lock *lock)
+Lock_Init(struct afs_lock *lock)
 {
 
     AFS_STATCNT(Lock_Init);
@@ -56,9 +53,9 @@ Lock_Init(register struct afs_lock *lock)
     lock->time_waiting.tv_sec = 0;
     lock->time_waiting.tv_usec = 0;
 }
-\f
+
 void
-ObtainLock(register struct afs_lock *lock, int how,
+ObtainLock(struct afs_lock *lock, int how,
           unsigned int src_indicator)
 {
     switch (how) {
@@ -95,7 +92,7 @@ ObtainLock(register struct afs_lock *lock, int how,
 }
 
 void
-ReleaseLock(register struct afs_lock *lock, int how)
+ReleaseLock(struct afs_lock *lock, int how)
 {
     if (how == READ_LOCK) {
        if (!--lock->readers_reading && lock->wait_states) {
@@ -123,9 +120,9 @@ ReleaseLock(register struct afs_lock *lock, int how)
 }
 
 void
-Afs_Lock_Obtain(register struct afs_lock *lock, int how)
+Afs_Lock_Obtain(struct afs_lock *lock, int how)
 {
-    osi_timeval_t tt1, tt2, et;
+    osi_timeval32_t tt1, tt2, et;
     afs_uint32 us;
 
     AFS_STATCNT(Lock_Obtain);
@@ -192,7 +189,7 @@ Afs_Lock_Obtain(register struct afs_lock *lock, int how)
 
 /* release a lock, giving preference to new readers */
 void
-Afs_Lock_ReleaseR(register struct afs_lock *lock)
+Afs_Lock_ReleaseR(struct afs_lock *lock)
 {
     AFS_STATCNT(Lock_ReleaseR);
     AFS_ASSERT_GLOCK();
@@ -207,7 +204,7 @@ Afs_Lock_ReleaseR(register struct afs_lock *lock)
 
 /* release a lock, giving preference to new writers */
 void
-Afs_Lock_ReleaseW(register struct afs_lock *lock)
+Afs_Lock_ReleaseW(struct afs_lock *lock)
 {
     AFS_STATCNT(Lock_ReleaseW);
     AFS_ASSERT_GLOCK();
@@ -222,7 +219,7 @@ Afs_Lock_ReleaseW(register struct afs_lock *lock)
 
 /*
 Wait for some change in the lock status.
-void Lock_Wait(register struct afs_lock *lock)
+void Lock_Wait(struct afs_lock *lock)
 {
     AFS_STATCNT(Lock_Wait);
     if (lock->readers_reading || lock->excl_locked) return 1;
@@ -238,7 +235,7 @@ void Lock_Wait(register struct afs_lock *lock)
 
 /* release a write lock and sleep on an address, atomically */
 void
-afs_osi_SleepR(register char *addr, register struct afs_lock *alock)
+afs_osi_SleepR(char *addr, struct afs_lock *alock)
 {
     AFS_STATCNT(osi_SleepR);
     ReleaseReadLock(alock);
@@ -247,7 +244,7 @@ afs_osi_SleepR(register char *addr, register struct afs_lock *alock)
 
 /* release a write lock and sleep on an address, atomically */
 void
-afs_osi_SleepW(register char *addr, register struct afs_lock *alock)
+afs_osi_SleepW(char *addr, struct afs_lock *alock)
 {
     AFS_STATCNT(osi_SleepW);
     ReleaseWriteLock(alock);
@@ -256,111 +253,13 @@ afs_osi_SleepW(register char *addr, register struct afs_lock *alock)
 
 /* release a write lock and sleep on an address, atomically */
 void
-afs_osi_SleepS(register char *addr, register struct afs_lock *alock)
+afs_osi_SleepS(char *addr, struct afs_lock *alock)
 {
     AFS_STATCNT(osi_SleepS);
     ReleaseSharedLock(alock);
     afs_osi_Sleep(addr);
 }
 
-
-#ifndef        AFS_NOBOZO_LOCK
-/* operations on locks that don't mind if we lock the same thing twice.  I'd like to dedicate
-    this function to Sun Microsystems' Version 4.0 virtual memory system, without
-    which this wouldn't have been necessary */
-void
-afs_BozonLock(struct afs_bozoLock *alock, struct vcache *avc)
-{
-    AFS_STATCNT(afs_BozonLock);
-    while (1) {
-       if (alock->count == 0) {
-           /* lock not held, we win */
-#ifdef AFS_SUN5_ENV
-           alock->proc = (char *)ttoproc(curthread);
-#else
-#ifdef AFS_64BITPOINTER_ENV
-           /* To shut up SGI compiler on remark(1413) warnings. */
-           alock->proc = (char *)(long)MyPidxx;
-#else /* AFS_64BITPOINTER_ENV */
-           alock->proc = (char *)MyPidxx;
-#endif /* AFS_64BITPOINTER_ENV */
-#endif
-           alock->count = 1;
-           return;
-#ifdef AFS_SUN5_ENV
-       } else if (alock->proc == (char *)ttoproc(curthread)) {
-#else
-#ifdef AFS_64BITPOINTER_ENV
-           /* To shut up SGI compiler on remark(1413) warnings. */
-       } else if (alock->proc == (char *)(long)MyPidxx) {
-#else /* AFS_64BITPOINTER_ENV */
-       } else if (alock->proc == (char *)MyPidxx) {
-#endif /* AFS_64BITPOINTER_ENV */
-#endif
-           /* lock is held, but by us, so we win anyway */
-           alock->count++;
-           return;
-       } else {
-           /* lock is held, and not by us; we wait */
-           alock->flags |= AFS_BOZONWAITING;
-           afs_osi_Sleep(alock);
-       }
-    }
-}
-
-/* releasing the same type of lock as defined above */
-void
-afs_BozonUnlock(struct afs_bozoLock *alock, struct vcache *avc)
-{
-    AFS_STATCNT(afs_BozonUnlock);
-    if (alock->count <= 0)
-       osi_Panic("BozoUnlock");
-    if ((--alock->count) == 0) {
-       if (alock->flags & AFS_BOZONWAITING) {
-           alock->flags &= ~AFS_BOZONWAITING;
-           afs_osi_Wakeup(alock);
-       }
-    }
-}
-
-void
-afs_BozonInit(struct afs_bozoLock *alock, struct vcache *avc)
-{
-    AFS_STATCNT(afs_BozonInit);
-    alock->count = 0;
-    alock->flags = 0;
-    alock->proc = NULL;
-}
-
-int
-afs_CheckBozonLock(struct afs_bozoLock *alock)
-{
-    AFS_STATCNT(afs_CheckBozonLock);
-    if (alock->count || (alock->flags & AFS_BOZONWAITING))
-       return 1;
-    return 0;
-}
-
-int
-afs_CheckBozonLockBlocking(struct afs_bozoLock *alock)
-{
-    AFS_STATCNT(afs_CheckBozonLockBlocking);
-    if (alock->count || (alock->flags & AFS_BOZONWAITING))
-#ifdef AFS_SUN5_ENV
-       if (alock->proc != (char *)ttoproc(curthread))
-#else
-#ifdef AFS_64BITPOINTER_ENV
-       /* To shut up SGI compiler on remark(1413) warnings. */
-       if (alock->proc != (char *)(long)MyPidxx)
-#else /* AFS_64BITPOINTER_ENV */
-       if (alock->proc != (char *)MyPidxx)
-#endif /* AFS_64BITPOINTER_ENV */
-#endif
-           return 1;
-    return 0;
-}
-#endif
-
 /* Not static - used conditionally if lock tracing is enabled */
 int
 Afs_Lock_Trace(int op, struct afs_lock *alock, int type, char *file, int line)