afs: afs_osi_Alloc_NoSleep() cleanup
[openafs.git] / src / afs / afs_osi_alloc.c
index f5e6d8b..4d7b229 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
 #include "sys/sleep.h"
 #include "sys/syspest.h"
 #include "sys/lock_def.h"
-/*lock_t osi_fsplock = LOCK_AVAIL;*/
 #endif
 
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
+
 afs_lock_t osi_fsplock;
+afs_lock_t osi_flplock;
 
 static struct osi_packet {
     struct osi_packet *next;
-} *freePacketList = NULL, *freeSmallList;
-afs_lock_t osi_flplock;
+} *freePacketList = NULL, *freeSmallList = NULL;
+
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
 
 static char memZero;           /* address of 0 bytes for kmem_alloc */
 
@@ -40,13 +43,13 @@ struct osimem {
     struct osimem *next;
 };
 
-#if !defined(AFS_NBSD_ENV)
+#if !defined(AFS_NBSD_ENV) || defined(AFS_NBSD50_ENV)
 void *
 afs_osi_Alloc(size_t x)
 {
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
-    register struct osimem *tm = NULL;
-    register int size;
+    struct osimem *tm = NULL;
+    int size;
 #endif
 
     AFS_STATCNT(osi_Alloc);
@@ -73,29 +76,6 @@ afs_osi_Alloc(size_t x)
 #endif
 }
 
-#if    defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
-
-void *
-afs_osi_Alloc_NoSleep(size_t x)
-{
-    register struct osimem *tm;
-    register int size;
-
-    AFS_STATCNT(osi_Alloc);
-    /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
-     * things so that NULL returned iff an error occurred */
-    if (x == 0)
-       return &memZero;
-
-    size = x;
-    AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
-    AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
-    tm = (struct osimem *)AFS_KALLOC_NOSLEEP(size);
-    return (void *)tm;
-}
-
-#endif /* SUN || SGI */
-
 void
 afs_osi_Free(void *x, size_t asize)
 {
@@ -109,7 +89,7 @@ afs_osi_Free(void *x, size_t asize)
     osi_linux_free(x);
 #elif defined(AFS_FBSD_ENV)
     osi_fbsd_free(x);
-#elif defined(AFS_OBSD44_ENV)
+#elif defined(AFS_OBSD_ENV)
     osi_obsd_Free(x, asize);
 #else
     AFS_KFREE((struct osimem *)x, asize);
@@ -122,6 +102,10 @@ afs_osi_FreeStr(char *x)
     afs_osi_Free(x, strlen(x) + 1);
 }
 
+#endif /* !AFS_NBSD_ENV && !defined(AFS_NBSD50_ENV) */
+
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
+
 /* free space allocated by AllocLargeSpace.  Also called by mclput when freeing
  * a packet allocated by osi_NetReceive. */
 
@@ -158,7 +142,7 @@ osi_FreeSmallSpace(void *adata)
 void *
 osi_AllocLargeSpace(size_t size)
 {
-    register struct osi_packet *tp;
+    struct osi_packet *tp;
 
     AFS_ASSERT_GLOCK();
 
@@ -194,7 +178,7 @@ osi_AllocLargeSpace(size_t size)
 void *
 osi_AllocSmallSpace(size_t size)
 {
-    register struct osi_packet *tp;
+    struct osi_packet *tp;
 
     AFS_STATCNT(osi_AllocSmallSpace);
     if (size > AFS_SMALLOCSIZ)
@@ -217,13 +201,13 @@ osi_AllocSmallSpace(size_t size)
     ReleaseWriteLock(&osi_fsplock);
     return (char *)tp;
 }
-
-#endif /* !AFS_NBSD_ENV */
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
 
 void
 shutdown_osinet(void)
 {
     AFS_STATCNT(shutdown_osinet);
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
     if (afs_cold_shutdown) {
        struct osi_packet *tp;
 
@@ -245,11 +229,13 @@ shutdown_osinet(void)
        LOCK_INIT(&osi_fsplock, "osi_fsplock");
        LOCK_INIT(&osi_flplock, "osi_flplock");
     }
-    if (afs_stats_cmperf.LargeBlocksActive || 
-       afs_stats_cmperf.SmallBlocksActive) 
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
+    if (afs_stats_cmperf.LargeBlocksActive ||
+       afs_stats_cmperf.SmallBlocksActive)
     {
-       afs_warn("WARNING: not all blocks freed: large %d small %d\n", 
-                afs_stats_cmperf.LargeBlocksActive, 
+       afs_warn("WARNING: not all blocks freed: large %d small %d\n",
+                afs_stats_cmperf.LargeBlocksActive,
                 afs_stats_cmperf.SmallBlocksActive);
     }
 }
+