BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / kern / sysv_shm.c
index 8e09ed1..fca74d3 100644 (file)
@@ -7,11 +7,37 @@
  * the Systems Programming Group of the University of Utah Computer
  * Science Department. Originally from University of Wisconsin.
  *
  * the Systems Programming Group of the University of Utah Computer
  * Science Department. Originally from University of Wisconsin.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  *
  * from: Utah $Hdr: uipc_shm.c 1.9 89/08/14$
  *
  *
  * from: Utah $Hdr: uipc_shm.c 1.9 89/08/14$
  *
- *     @(#)sysv_shm.c  7.12 (Berkeley) %G%
+ *     @(#)sysv_shm.c  7.15 (Berkeley) 5/13/91
  */
 
 /*
  */
 
 /*
 
 #include "param.h"
 #include "systm.h"
 
 #include "param.h"
 #include "systm.h"
-#include "user.h"
 #include "kernel.h"
 #include "proc.h"
 #include "shm.h"
 #include "malloc.h"
 #include "mman.h"
 #include "kernel.h"
 #include "proc.h"
 #include "shm.h"
 #include "malloc.h"
 #include "mman.h"
-#include "../vm/vm_param.h"
-#include "../vm/vm_map.h"
-#include "../vm/vm_kern.h"
-#include "../vm/vm_inherit.h"
-#include "../vm/vm_pager.h"
+#include "vm/vm.h"
+#include "vm/vm_kern.h"
+#include "vm/vm_inherit.h"
+#include "vm/vm_pager.h"
 
 #ifdef HPUXCOMPAT
 #include "hp300/hpux/hpux.h"
 
 #ifdef HPUXCOMPAT
 #include "hp300/hpux/hpux.h"
@@ -321,7 +345,7 @@ shmat(p, uap, retval)
                flags |= MAP_FIXED;
        else
                uva = (caddr_t)0x1000000;       /* XXX */
                flags |= MAP_FIXED;
        else
                uva = (caddr_t)0x1000000;       /* XXX */
-       error = vm_mmap(p->p_vmspace->vm_map, &uva, (vm_size_t)size, prot,
+       error = vm_mmap(&p->p_vmspace->vm_map, &uva, (vm_size_t)size, prot,
            flags, ((struct shmhandle *)shp->shm_handle)->shmh_id, 0);
        if (error)
                return(error);
            flags, ((struct shmhandle *)shp->shm_handle)->shmh_id, 0);
        if (error)
                return(error);
@@ -422,7 +446,7 @@ shmufree(p, shmd)
        register struct shmid_ds *shp;
 
        shp = &shmsegs[shmd->shmd_id % SHMMMNI];
        register struct shmid_ds *shp;
 
        shp = &shmsegs[shmd->shmd_id % SHMMMNI];
-       (void) vm_deallocate(p->p_vmspace->vm_map, shmd->shmd_uva,
+       (void) vm_deallocate(&p->p_vmspace->vm_map, shmd->shmd_uva,
                             ctob(clrnd(btoc(shp->shm_segsz))));
        shmd->shmd_id = 0;
        shmd->shmd_uva = 0;
                             ctob(clrnd(btoc(shp->shm_segsz))));
        shmd->shmd_id = 0;
        shmd->shmd_uva = 0;
@@ -437,7 +461,6 @@ shmufree(p, shmd)
 shmfree(shp)
        register struct shmid_ds *shp;
 {
 shmfree(shp)
        register struct shmid_ds *shp;
 {
-       caddr_t kva;
 
        if (shp->shm_handle == NULL)
                panic("shmfree");
 
        if (shp->shm_handle == NULL)
                panic("shmfree");
@@ -447,7 +470,7 @@ shmfree(shp)
         */
        vm_deallocate(shm_map,
                      ((struct shmhandle *)shp->shm_handle)->shmh_kva,
         */
        vm_deallocate(shm_map,
                      ((struct shmhandle *)shp->shm_handle)->shmh_kva,
-                     clrnd(btoc(shp->shm_segsz)));
+                     ctob(clrnd(btoc(shp->shm_segsz))));
        free((caddr_t)shp->shm_handle, M_SHM);
        shp->shm_handle = NULL;
        shmtot -= clrnd(btoc(shp->shm_segsz));
        free((caddr_t)shp->shm_handle, M_SHM);
        shp->shm_handle = NULL;
        shmtot -= clrnd(btoc(shp->shm_segsz));