MCLALLOC must be called at splimp
[unix-history] / usr / src / sys / kern / subr_xxx.c
index 43690a6..c2a540d 100644 (file)
@@ -1,79 +1,33 @@
-/*     subr_xxx.c      4.14    82/07/25        */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/inode.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/proc.h"
-#include "../h/fs.h"
-#include "../h/vm.h"
-#include "../h/pte.h"
-#include "../h/cmap.h"
-
 /*
 /*
- * Pass back  c  to the user at his location u_base;
- * update u_base, u_count, and u_offset.  Return -1
- * on the last character of the user's read.
- * u_base is in the user address space unless u_segflg is set.
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)subr_xxx.c  7.1 (Berkeley) %G%
  */
  */
-passc(c)
-register c;
-{
-       register id;
-
-       if ((id = u.u_segflg) == 1)
-               *u.u_base = c;
-       else
-               if (id?suibyte(u.u_base, c):subyte(u.u_base, c) < 0) {
-                       u.u_error = EFAULT;
-                       return (-1);
-               }
-       u.u_count--;
-       u.u_offset++;
-       u.u_base++;
-       return (u.u_count == 0? -1: 0);
-}
 
 
-#include "ct.h"
-#if NCT > 0
-/*
- * Pick up and return the next character from the user's
- * write call at location u_base;
- * update u_base, u_count, and u_offset.  Return -1
- * when u_count is exhausted.  u_base is in the user's
- * address space unless u_segflg is set.
- */
-cpass()
-{
-       register c, id;
-
-       if (u.u_count == 0)
-               return (-1);
-       if ((id = u.u_segflg) == 1)
-               c = *u.u_base;
-       else
-               if ((c = id==0?fubyte(u.u_base):fuibyte(u.u_base)) < 0) {
-                       u.u_error = EFAULT;
-                       return (-1);
-               }
-       u.u_count--;
-       u.u_offset++;
-       u.u_base++;
-       return (c&0377);
-}
-#endif
+#include "../machine/pte.h"
+
+#include "param.h"
+#include "systm.h"
+#include "conf.h"
+#include "inode.h"
+#include "dir.h"
+#include "user.h"
+#include "buf.h"
+#include "proc.h"
+#include "fs.h"
+#include "vm.h"
+#include "cmap.h"
+#include "uio.h"
 
 /*
 
 /*
- * Routine which sets a user error; placed in
- * illegal entries in the bdevsw and cdevsw tables.
+ * Routine placed in illegal entries in the bdevsw and cdevsw tables.
  */
 nodev()
 {
 
  */
 nodev()
 {
 
-       u.u_error = ENODEV;
+       return (ENODEV);
 }
 
 /*
 }
 
 /*
@@ -83,8 +37,10 @@ nodev()
 nulldev()
 {
 
 nulldev()
 {
 
+       return (0);
 }
 
 }
 
+#ifdef notdef
 imin(a, b)
 {
 
 imin(a, b)
 {
 
@@ -99,7 +55,7 @@ imax(a, b)
 
 unsigned
 min(a, b)
 
 unsigned
 min(a, b)
-       unsigned int a, b;
+       u_int a, b;
 {
 
        return (a < b ? a : b);
 {
 
        return (a < b ? a : b);
@@ -107,23 +63,13 @@ min(a, b)
 
 unsigned
 max(a, b)
 
 unsigned
 max(a, b)
-       unsigned int a, b;
+       u_int a, b;
 {
 
        return (a > b ? a : b);
 }
 {
 
        return (a > b ? a : b);
 }
+#endif notdef
 
 
-struct proc *
-pfind(pid)
-       int pid;
-{
-       register struct proc *p;
-
-       for (p = &proc[pidhash[PIDHASH(pid)]]; p != &proc[0]; p = &proc[p->p_idhash])
-               if (p->p_pid == pid)
-                       return (p);
-       return ((struct proc *)0);
-}
 extern cabase, calimit;
 extern struct pte camap[];
 
 extern cabase, calimit;
 extern struct pte camap[];
 
@@ -159,26 +105,25 @@ calloc(size)
        return (res);
 }
 
        return (res);
 }
 
-#ifndef vax
-ffs(mask)
-       register long mask;
+#ifdef GPROF
+/*
+ * Stub routine in case it is ever possible to free space.
+ */
+cfreemem(cp, size)
+       caddr_t cp;
+       int size;
 {
 {
-       register int i;
-
-       for(i=1; i<NSIG; i++) {
-               if (mask & 1)
-                       return (i);
-               mask >>= 1;
-       }
-       return (0);
+       printf("freeing %x, size %d\n", cp, size);
 }
 }
+#endif
 
 
+#ifndef vax
 ffs(mask)
        register long mask;
 {
        register int i;
 
 ffs(mask)
        register long mask;
 {
        register int i;
 
-       for(i=1; i<NSIG; i++) {
+       for(i = 1; i < NSIG; i++) {
                if (mask & 1)
                        return (i);
                mask >>= 1;
                if (mask & 1)
                        return (i);
                mask >>= 1;
@@ -191,7 +136,7 @@ bcmp(s1, s2, len)
        register int len;
 {
 
        register int len;
 {
 
-       while (--len)
+       while (len--)
                if (*s1++ != *s2++)
                        return (1);
        return (0);
                if (*s1++ != *s2++)
                        return (1);
        return (0);