Unix CM: Remove erroneous comment
[openafs.git] / src / afs / afs_axscache.c
index 23083c6..7c56335 100644 (file)
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID("$Header$");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
-#include "afs/afs_stats.h" /* statistics */
+#include "afs/afs_stats.h"     /* statistics */
 #include "afs/stds.h"
 static struct axscache *afs_axsfreelist = NULL;
-static struct xfreelist { struct xfreelist *next; } *xfreemallocs = 0;
+
+#define NAXSs (1000 / sizeof(struct axscache))
+static struct xfreelist {
+    struct xfreelist *next;
+    struct axscache data[NAXSs];
+} *xfreemallocs = 0;
 static int afs_xaxscnt = 0;
 afs_rwlock_t afs_xaxs;
 
@@ -25,60 +29,64 @@ afs_rwlock_t afs_xaxs;
 /* PRECONDITION: first field has been checked and doesn't match! 
  * INVARIANT:  isparent(i,j) ^ isparent(j,i)  (ie, they switch around)
  */
-struct axscache *afs_SlowFindAxs(struct axscache **cachep, afs_int32 id)
+struct axscache *
+afs_SlowFindAxs(struct axscache **cachep, afs_int32 id)
 {
-    register struct axscache *i,*j;
+    register struct axscache *i, *j;
 
-    j=(*cachep);
-    i=j->next;
+    j = (*cachep);
+    i = j->next;
     while (i) {
        if (i->uid == id) {
-           axs_Front(cachep,j,i);        /* maintain LRU queue */
-           return(i);
+           axs_Front(cachep, j, i);    /* maintain LRU queue */
+           return (i);
        }
 
-       if ((j=i->next)) {   /* ASSIGNMENT HERE! */
+       if ((j = i->next)) {    /* ASSIGNMENT HERE! */
            if (j->uid == id) {
-               axs_Front(cachep,i,j);
-               return(j);
+               axs_Front(cachep, i, j);
+               return (j);
            }
-       } else 
-           return ((struct axscache *) NULL);
-       i=j->next;
+       } else
+           return ((struct axscache *)NULL);
+       i = j->next;
     }
-    return ((struct axscache *) NULL);
+    return ((struct axscache *)NULL);
 }
 
 
-#define NAXSs (1000 / sizeof(struct axscache))
-struct axscache *axs_Alloc(void) 
+struct axscache *
+axs_Alloc(void)
 {
-    register struct axscache *i, *j, *xsp;
-    struct axscache *h;
+    struct axscache *i, *j;
+    struct xfreelist *h, *xsp;
     int k;
 
-    ObtainWriteLock(&afs_xaxs,174);
-    if ((h = afs_axsfreelist)) {
-       afs_axsfreelist = h->next;
+    ObtainWriteLock(&afs_xaxs, 174);
+    if ((i = afs_axsfreelist)) {
+       afs_axsfreelist = i->next;
+       ReleaseWriteLock(&afs_xaxs);
+       return i;
     } else {
-       h=i=j= (struct axscache *) afs_osi_Alloc(NAXSs * sizeof(struct axscache));
+       h = afs_osi_Alloc(sizeof(struct xfreelist));
        afs_xaxscnt++;
-       xsp = (struct axscache *)xfreemallocs;
-       xfreemallocs = (struct xfreelist *)h;
-       xfreemallocs->next = (struct xfreelist *)xsp;
-       for (k = 0; k < NAXSs-1; k++, i++) {
+       xsp = xfreemallocs;
+       xfreemallocs = h;
+       xfreemallocs->next = xsp;
+       i = j = h->data;
+       for (k = 0; k < NAXSs - 1; k++, i++) {
            i->uid = -2;
            i->axess = 0;
-           i->next = ++j;       /* need j because order of evaluation not defined */
+           i->next = ++j;      /* need j because order of evaluation not defined */
        }
        i->uid = -2;
        i->axess = 0;
        i->next = NULL;
-       afs_axsfreelist = h->next;
+       afs_axsfreelist = (h->data)->next;
     }
     ReleaseWriteLock(&afs_xaxs);
-    return(h);
-} 
+    return (h->data);
+}
 
 
 #define axs_Free(axsp) { \
@@ -91,35 +99,36 @@ struct axscache *axs_Alloc(void)
 
 /* I optimize for speed on lookup, and don't give a RIP about delete.
  */
-void afs_RemoveAxs(struct axscache **headp, struct axscache *axsp)
+void
+afs_RemoveAxs(struct axscache **headp, struct axscache *axsp)
 {
     struct axscache *i, *j;
 
-    if (*headp && axsp) {              /* is bullet-proofing really neccessary? */   
-       if (*headp == axsp) {           /* most common case, I think */
+    if (*headp && axsp) {      /* is bullet-proofing really neccessary? */
+       if (*headp == axsp) {   /* most common case, I think */
            *headp = axsp->next;
            axs_Free(axsp);
            return;
        }
 
-       i= *headp;
-       j=i->next; 
-    
+       i = *headp;
+       j = i->next;
+
        while (j) {
            if (j == axsp) {
                i->next = j->next;
                axs_Free(axsp);
                return;
            }
-           if ((i = j->next)) {   /* ASSIGNMENT HERE! */
+           if ((i = j->next)) {        /* ASSIGNMENT HERE! */
                j->next = i->next;
                axs_Free(axsp);
                return;
            }
        }
-    }  /* end of "if neither pointer is NULL" */
-
-    return;   /* !#@  FAILED to find it! */
+    }
+    /* end of "if neither pointer is NULL" */
+    return;                    /* !#@  FAILED to find it! */
 }
 
 
@@ -127,51 +136,50 @@ void afs_RemoveAxs(struct axscache **headp, struct axscache *axsp)
  * Takes an entire list of access cache structs and prepends them, lock, stock,
  * and barrel, to the front of the freelist.
  */
-void afs_FreeAllAxs(struct axscache **headp)
+void
+afs_FreeAllAxs(struct axscache **headp)
 {
-    struct axscache *i,*j;
+    struct axscache *i, *j;
 
-    i= *headp;
-    j=NULL;
+    i = *headp;
+    j = NULL;
 
-    while (i) {   /* chase down the list 'til we reach the end */
-       j=i->next;
+    while (i) {                        /* chase down the list 'til we reach the end */
+       j = i->next;
        if (!j) {
-           ObtainWriteLock (&afs_xaxs,176);
-           i->next = afs_axsfreelist;   /* tack on the freelist to the end */
+           ObtainWriteLock(&afs_xaxs, 176);
+           i->next = afs_axsfreelist;  /* tack on the freelist to the end */
            afs_axsfreelist = *headp;
-           ReleaseWriteLock (&afs_xaxs);
+           ReleaseWriteLock(&afs_xaxs);
            *headp = NULL;
            return;
        }
-       i=j->next;
+       i = j->next;
     }
 
-    if (j) {    /* we ran off the end of the list... */
-       ObtainWriteLock (&afs_xaxs,177);
-       j->next = afs_axsfreelist;   /* tack on the freelist to the end */
+    if (j) {                   /* we ran off the end of the list... */
+       ObtainWriteLock(&afs_xaxs, 177);
+       j->next = afs_axsfreelist;      /* tack on the freelist to the end */
        afs_axsfreelist = *headp;
-       ReleaseWriteLock (&afs_xaxs);
-    }   
+       ReleaseWriteLock(&afs_xaxs);
+    }
     *headp = NULL;
     return;
 }
-   
 
-/* doesn't appear to be used at all */
-#if 0
-static void shutdown_xscache(void) 
+
+void
+shutdown_xscache(void)
 {
     struct xfreelist *xp, *nxp;
 
-    RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
-    xp =  xfreemallocs;
+    AFS_RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
+    xp = xfreemallocs;
     while (xp) {
        nxp = xp->next;
-       afs_osi_Free((char *)xp, NAXSs * sizeof(struct axscache));
+       afs_osi_Free(xp, sizeof(struct xfreelist));
        xp = nxp;
     }
     afs_axsfreelist = NULL;
     xfreemallocs = NULL;
 }
-#endif