Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Use kern_mutex_obj.c directly inst...



details:   https://anonhg.NetBSD.org/src/rev/37472d23187b
branches:  trunk
changeset: 748744:37472d23187b
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Nov 04 13:32:39 2009 +0000

description:
Use kern_mutex_obj.c directly instead of copypasting code.

diffstat:

 sys/rump/librump/rumpkern/Makefile.rumpkern |   7 +-
 sys/rump/librump/rumpkern/locks.c           |  69 +----------------------------
 sys/rump/librump/rumpkern/rump.c            |   6 +-
 3 files changed, 10 insertions(+), 72 deletions(-)

diffs (137 lines):

diff -r d8b17f74b127 -r 37472d23187b sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern       Wed Nov 04 13:29:45 2009 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern       Wed Nov 04 13:32:39 2009 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpkern,v 1.56 2009/11/03 18:44:15 pooka Exp $
+#      $NetBSD: Makefile.rumpkern,v 1.57 2009/11/04 13:32:39 pooka Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -31,8 +31,9 @@
 #
 # sys/kern
 SRCS+= init_sysctl_base.c kern_auth.c kern_descrip.c kern_event.c      \
-       kern_ksyms.c kern_malloc_stdtype.c kern_module.c kern_rate.c    \
-       kern_stub.c kern_sysctl.c kern_timeout.c kern_uidinfo.c param.c \
+       kern_ksyms.c kern_malloc_stdtype.c kern_module.c                \
+       kern_mutex_obj.c kern_rate.c kern_stub.c kern_sysctl.c          \
+       kern_timeout.c kern_uidinfo.c param.c                           \
        sys_descrip.c sys_generic.c sys_select.c syscalls.c
 
 # sys/kern subr (misc)
diff -r d8b17f74b127 -r 37472d23187b sys/rump/librump/rumpkern/locks.c
--- a/sys/rump/librump/rumpkern/locks.c Wed Nov 04 13:29:45 2009 +0000
+++ b/sys/rump/librump/rumpkern/locks.c Wed Nov 04 13:32:39 2009 +0000
@@ -1,30 +1,4 @@
-/*     $NetBSD: locks.c,v 1.32 2009/10/16 00:14:53 pooka Exp $ */
-
-/*-
- * Copyright (c) 2008 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
+/*     $NetBSD: locks.c,v 1.33 2009/11/04 13:32:39 pooka Exp $ */
 
 /*
  * Copyright (c) 2007, 2008 Antti Kantee.  All Rights Reserved.
@@ -55,10 +29,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.32 2009/10/16 00:14:53 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.33 2009/11/04 13:32:39 pooka Exp $");
 
 #include <sys/param.h>
-#include <sys/atomic.h>
 #include <sys/kmem.h>
 #include <sys/mutex.h>
 #include <sys/rwlock.h>
@@ -396,41 +369,3 @@
        if (nlocks)
                _kernel_lock(nlocks);
 }
-
-struct kmutexobj {
-       kmutex_t        mo_lock;
-       u_int           mo_refcnt;
-};
-
-kmutex_t *
-mutex_obj_alloc(kmutex_type_t type, int ipl)
-{
-       struct kmutexobj *mo;
-
-       mo = kmem_alloc(sizeof(*mo), KM_SLEEP);
-       mutex_init(&mo->mo_lock, type, ipl);
-       mo->mo_refcnt = 1;
-
-       return (kmutex_t *)mo;
-}
-
-void
-mutex_obj_hold(kmutex_t *lock)
-{
-       struct kmutexobj *mo = (struct kmutexobj *)lock;
-
-       atomic_inc_uint(&mo->mo_refcnt);
-}
-
-bool
-mutex_obj_free(kmutex_t *lock)
-{
-       struct kmutexobj *mo = (struct kmutexobj *)lock;
-
-       if (atomic_dec_uint_nv(&mo->mo_refcnt) > 0) {
-               return false;
-       }
-       mutex_destroy(&mo->mo_lock);
-       kmem_free(mo, sizeof(*mo));
-       return true;
-}
diff -r d8b17f74b127 -r 37472d23187b sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Wed Nov 04 13:29:45 2009 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Wed Nov 04 13:32:39 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.132 2009/11/03 20:25:31 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.133 2009/11/04 13:32:39 pooka Exp $ */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.132 2009/11/03 20:25:31 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.133 2009/11/04 13:32:39 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -230,6 +230,8 @@
        pool_subsystem_init();
        kmem_init();
 
+       mutex_obj_init();
+
        kprintf_init();
        loginit();
 



Home | Main Index | Thread Index | Old Index