Remove support for Solaris pre-8
[openafs.git] / src / afs / afs_osi.c
index f469939..4829073 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000, International Business Machines Corporation and others.
+ * Copyrigh 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
  *
  * This software has been released under the terms of the IBM Public
@@ -10,8 +10,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 */
@@ -36,22 +34,18 @@ lock_t afs_event_lock;
 flid_t osi_flid;
 #endif
 
-struct AFS_UCRED *afs_osi_credp;
+afs_ucred_t *afs_osi_credp;
 
 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
 kmutex_t afs_global_lock;
-kmutex_t afs_rxglobal_lock;
 #endif
 
 #if defined(AFS_SGI_ENV) && !defined(AFS_SGI64_ENV)
 long afs_global_owner;
 #endif
 
-#if defined(AFS_OSF_ENV)
-simple_lock_data_t afs_global_lock;
-#endif
-
-#if defined(AFS_DARWIN_ENV) 
+#if defined(AFS_DARWIN_ENV)
+thread_t afs_global_owner;
 #ifdef AFS_DARWIN80_ENV
 lck_mtx_t  *afs_global_lock;
 #else
@@ -59,18 +53,18 @@ struct lock__bsd__ afs_global_lock;
 #endif
 #endif
 
-#if defined(AFS_XBSD_ENV) && !defined(AFS_FBSD50_ENV)
+#if defined(AFS_XBSD_ENV) && !defined(AFS_FBSD_ENV)
+# if defined(AFS_NBSD50_ENV)
+kmutex_t afs_global_mtx;
+# else
 struct lock afs_global_lock;
-struct proc *afs_global_owner;
-#endif
-#ifdef AFS_FBSD50_ENV
+afs_proc_t *afs_global_owner;
+# endif
+#elif defined(AFS_FBSD_ENV)
 struct mtx afs_global_mtx;
+struct thread *afs_global_owner;
 #endif
 
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
-thread_t afs_global_owner;
-#endif /* AFS_OSF_ENV */
-
 #if defined(AFS_AIX41_ENV)
 simple_lock_data afs_global_lock;
 #endif
@@ -81,31 +75,8 @@ osi_Init(void)
     static int once = 0;
     if (once++ > 0)            /* just in case */
        return;
-#if    defined(AFS_HPUX_ENV)
+
     osi_InitGlock();
-#else /* AFS_HPUX_ENV */
-#if defined(AFS_GLOBAL_SUNLOCK)
-#if defined(AFS_SGI62_ENV)
-    mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock");
-#elif defined(AFS_OSF_ENV)
-    usimple_lock_init(&afs_global_lock);
-    afs_global_owner = (thread_t) 0;
-#elif defined(AFS_FBSD50_ENV)
-    mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF);
-#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-#if !defined(AFS_DARWIN80_ENV)
-    lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
-#endif
-    afs_global_owner = 0;
-#elif defined(AFS_AIX41_ENV)
-    lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
-    simple_lock_init((void *)&afs_global_lock);
-#elif !defined(AFS_LINUX22_ENV)
-    /* Linux initialization in osi directory. Should move the others. */
-    mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL);
-#endif
-#endif /* AFS_GLOBAL_SUNLOCK */
-#endif /* AFS_HPUX_ENV */
 
     if (!afs_osicred_initialized) {
 #if defined(AFS_DARWIN80_ENV)
@@ -115,16 +86,19 @@ osi_Init(void)
 #endif
 #if defined(AFS_XBSD_ENV)
        /* Can't just invent one, must use crget() because of mutex */
-       afs_osi_credp = crdup(osi_curcred());
+       afs_osi_credp =
+         crdup(osi_curcred());
 #else
-       memset(&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
+       memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
 #if defined(AFS_LINUX26_ENV)
-        afs_osi_cred.cr_group_info = groups_alloc(0);
+        afs_set_cr_group_info(&afs_osi_cred, groups_alloc(0));
 #endif
 #if defined(AFS_DARWIN80_ENV)
         afs_osi_cred.cr_ref = 1; /* kauth_cred_get_ref needs 1 existing ref */
 #else
-       crhold(&afs_osi_cred);  /* don't let it evaporate */
+# if !(defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED))
+       crhold(&afs_osi_cred);  /* don't let it evaporate */
+# endif
 #endif
 
        afs_osi_credp = &afs_osi_cred;
@@ -154,8 +128,8 @@ afs_osi_UnmaskRxkSignals(void)
 }
 
 /* Two hacks to try and fix afsdb */
-void 
-afs_osi_MaskUserLoop()
+void
+afs_osi_MaskUserLoop(void)
 {
 #ifdef AFS_DARWIN_ENV
     afs_osi_Invisible();
@@ -165,8 +139,8 @@ afs_osi_MaskUserLoop()
 #endif
 }
 
-void 
-afs_osi_UnmaskUserLoop()
+void
+afs_osi_UnmaskUserLoop(void)
 {
 #ifdef AFS_DARWIN_ENV
     afs_osi_fullSigRestore();
@@ -177,9 +151,6 @@ afs_osi_UnmaskUserLoop()
 void
 afs_osi_RxkRegister(void)
 {
-#ifdef AFS_LINUX22_ENV
-    osi_linux_rxkreg();
-#endif
 }
 
 /* procedure for making our processes as invisible as we can */
@@ -196,6 +167,8 @@ afs_osi_Invisible(void)
 #elif defined(AFS_DARWIN_ENV)
     /* maybe call init_process instead? */
     current_proc()->p_flag |= P_SYSTEM;
+#elif defined(AFS_NBSD50_ENV)
+    /* XXX in netbsd a system thread is more than invisible */
 #elif defined(AFS_XBSD_ENV)
     curproc->p_flag |= P_SYSTEM;
 #elif defined(AFS_SGI_ENV)
@@ -205,8 +178,23 @@ afs_osi_Invisible(void)
     AFS_STATCNT(osi_Invisible);
 }
 
+void
+afs_osi_Visible(void)
+{
+#if defined(AFS_SUN5_ENV)
+    curproc->p_flag &= ~SSYS;
+#elif defined(AFS_DARWIN80_ENV)
+#elif defined(AFS_DARWIN_ENV)
+    /* maybe call init_process instead? */
+    current_proc()->p_flag &= ~P_SYSTEM;
+#elif defined(AFS_NBSD50_ENV)
+    /* XXX in netbsd a system thread is more than invisible */
+#elif defined(AFS_XBSD_ENV)
+    curproc->p_flag &= ~P_SYSTEM;
+#endif
+}
 
-#if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV)
 /* set the real time */
 void
 afs_osi_SetTime(osi_timeval_t * atv)
@@ -217,21 +205,8 @@ afs_osi_SetTime(osi_timeval_t * atv)
     t.tv_sec = atv->tv_sec;
     t.tv_nsec = atv->tv_usec * 1000;
     ksettimer(&t);             /*  Was -> settimer(TIMEOFDAY, &t); */
-#elif defined(AFS_SUN55_ENV)
-    stime(atv->tv_sec);
 #elif defined(AFS_SUN5_ENV)
-    /*
-     * To get more than second resolution we can use adjtime. The problem
-     * is that the usecs from the server are wrong (by now) so it isn't
-     * worth complicating the following code.
-     */
-    struct stimea {
-       time_t time;
-    } sta;
-
-    sta.time = atv->tv_sec;
-
-    stime(&sta, NULL);
+    stime(atv->tv_sec);
 #elif defined(AFS_SGI_ENV)
     struct stimea {
        sysarg_t time;
@@ -258,7 +233,7 @@ afs_osi_SetTime(osi_timeval_t * atv)
        /* drop the setting of the clock for now. spl7 is not
         * known on hpux11.22
         */
-       register ulong_t s;
+       ulong_t s;
        struct timeval t;
        t.tv_sec = atv->tv_sec;
        t.tv_usec = atv->tv_usec;
@@ -270,7 +245,7 @@ afs_osi_SetTime(osi_timeval_t * atv)
     }
 #else
     {
-       register int s;
+       int s;
        s = splclock();
        time = *atv;
        (void)splx(s);
@@ -303,7 +278,7 @@ shutdown_osi(void)
     }
 }
 
-#ifndef AFS_OBSD_ENV
+#if !defined(AFS_OBSD_ENV) && !defined(AFS_NBSD40_ENV)
 int
 afs_osi_suser(void *cr)
 {