Source-Changes-HG archive

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

[src/trunk]: src/sys more const



details:   https://anonhg.NetBSD.org/src/rev/0f9ba418aa9d
branches:  trunk
changeset: 826613:0f9ba418aa9d
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 16 23:55:33 2017 +0000

description:
more const

diffstat:

 sys/arch/x86/include/lock.h                  |   6 +++---
 sys/external/bsd/drm2/linux/linux_ww_mutex.c |  12 ++++++------
 sys/kern/kern_lock.c                         |   8 ++++----
 sys/kern/kern_mutex.c                        |  15 ++++++++-------
 sys/kern/kern_rwlock.c                       |  10 +++++-----
 sys/kern/subr_lockdebug.c                    |  14 +++++++-------
 6 files changed, 33 insertions(+), 32 deletions(-)

diffs (261 lines):

diff -r fe50e8d1e2ab -r 0f9ba418aa9d sys/arch/x86/include/lock.h
--- a/sys/arch/x86/include/lock.h       Sat Sep 16 23:55:16 2017 +0000
+++ b/sys/arch/x86/include/lock.h       Sat Sep 16 23:55:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.h,v 1.27 2013/01/22 22:09:44 christos Exp $       */
+/*     $NetBSD: lock.h,v 1.28 2017/09/16 23:55:45 christos Exp $       */
 
 /*-
  * Copyright (c) 2000, 2006 The NetBSD Foundation, Inc.
@@ -39,13 +39,13 @@
 #include <sys/param.h>
 
 static __inline int
-__SIMPLELOCK_LOCKED_P(__cpu_simple_lock_t *__ptr)
+__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *__ptr)
 {
        return *__ptr == __SIMPLELOCK_LOCKED;
 }
 
 static __inline int
-__SIMPLELOCK_UNLOCKED_P(__cpu_simple_lock_t *__ptr)
+__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *__ptr)
 {
        return *__ptr == __SIMPLELOCK_UNLOCKED;
 }
diff -r fe50e8d1e2ab -r 0f9ba418aa9d sys/external/bsd/drm2/linux/linux_ww_mutex.c
--- a/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Sat Sep 16 23:55:16 2017 +0000
+++ b/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Sat Sep 16 23:55:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_ww_mutex.c,v 1.3 2017/08/25 14:14:44 riastradh Exp $     */
+/*     $NetBSD: linux_ww_mutex.c,v 1.4 2017/09/16 23:56:42 christos Exp $      */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.3 2017/08/25 14:14:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.4 2017/09/16 23:56:42 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -122,9 +122,9 @@
 
 #ifdef LOCKDEBUG
 static void
-ww_dump(volatile void *cookie)
+ww_dump(const volatile void *cookie)
 {
-       volatile struct ww_mutex *mutex = cookie;
+       const volatile struct ww_mutex *mutex = cookie;
 
        printf_nolog("%-13s: ", "state");
        switch (mutex->wwm_state) {
@@ -135,7 +135,7 @@
                printf_nolog("owned by lwp\n");
                printf_nolog("%-13s: %p\n", "owner", mutex->wwm_u.owner);
                printf_nolog("%-13s: %s\n", "waiters",
-                   cv_has_waiters(__UNVOLATILE(&mutex->wwm_cv))
+                   cv_has_waiters((void *)(intptr_t)&mutex->wwm_cv)
                        ? "yes" : "no");
                break;
        case WW_CTX:
@@ -144,7 +144,7 @@
                printf_nolog("%-13s: %p\n", "lwp",
                    mutex->wwm_u.ctx->wwx_owner);
                printf_nolog("%-13s: %s\n", "waiters",
-                   cv_has_waiters(__UNVOLATILE(&mutex->wwm_cv))
+                   cv_has_waiters((void *)(intptr_t)&mutex->wwm_cv)
                        ? "yes" : "no");
                break;
        case WW_WANTOWN:
diff -r fe50e8d1e2ab -r 0f9ba418aa9d sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c      Sat Sep 16 23:55:16 2017 +0000
+++ b/sys/kern/kern_lock.c      Sat Sep 16 23:55:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lock.c,v 1.158 2017/01/26 04:11:56 christos Exp $ */
+/*     $NetBSD: kern_lock.c,v 1.159 2017/09/16 23:55:33 christos Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.158 2017/01/26 04:11:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.159 2017/09/16 23:55:33 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -113,7 +113,7 @@
 #define        _KERNEL_LOCK_ASSERT(cond)       /* nothing */
 #endif
 
-void   _kernel_lock_dump(volatile void *);
+void   _kernel_lock_dump(const volatile void *);
 
 lockops_t _kernel_lock_ops = {
        "Kernel lock",
@@ -138,7 +138,7 @@
  * Print debugging information about the kernel lock.
  */
 void
-_kernel_lock_dump(volatile void *junk)
+_kernel_lock_dump(const volatile void *junk)
 {
        struct cpu_info *ci = curcpu();
 
diff -r fe50e8d1e2ab -r 0f9ba418aa9d sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c     Sat Sep 16 23:55:16 2017 +0000
+++ b/sys/kern/kern_mutex.c     Sat Sep 16 23:55:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_mutex.c,v 1.66 2017/09/16 23:25:34 christos Exp $ */
+/*     $NetBSD: kern_mutex.c,v 1.67 2017/09/16 23:55:33 christos Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #define        __MUTEX_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.66 2017/09/16 23:25:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.67 2017/09/16 23:55:33 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -264,8 +264,9 @@
 __strong_alias(mutex_spin_exit,mutex_vector_exit);
 #endif
 
-static void    mutex_abort(const char *, size_t, kmutex_t *, const char *);
-static void    mutex_dump(volatile void *);
+static void    mutex_abort(const char *, size_t, const kmutex_t *,
+    const char *);
+static void    mutex_dump(const volatile void *);
 
 lockops_t mutex_spin_lockops = {
        "Mutex",
@@ -293,9 +294,9 @@
  *     Dump the contents of a mutex structure.
  */
 void
-mutex_dump(volatile void *cookie)
+mutex_dump(const volatile void *cookie)
 {
-       volatile kmutex_t *mtx = cookie;
+       const volatile kmutex_t *mtx = cookie;
 
        printf_nolog("owner field  : %#018lx wait/spin: %16d/%d\n",
            (long)MUTEX_OWNER(mtx->mtx_owner), MUTEX_HAS_WAITERS(mtx),
@@ -310,7 +311,7 @@
  *     we ask the compiler to not inline it.
  */
 void __noinline
-mutex_abort(const char *func, size_t line, kmutex_t *mtx, const char *msg)
+mutex_abort(const char *func, size_t line, const kmutex_t *mtx, const char *msg)
 {
 
        LOCKDEBUG_ABORT(func, line, mtx, (MUTEX_SPIN_P(mtx) ?
diff -r fe50e8d1e2ab -r 0f9ba418aa9d sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c    Sat Sep 16 23:55:16 2017 +0000
+++ b/sys/kern/kern_rwlock.c    Sat Sep 16 23:55:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rwlock.c,v 1.46 2017/01/26 04:11:56 christos Exp $        */
+/*     $NetBSD: kern_rwlock.c,v 1.47 2017/09/16 23:55:33 christos Exp $        */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.46 2017/01/26 04:11:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.47 2017/09/16 23:55:33 christos Exp $");
 
 #define        __RWLOCK_PRIVATE
 
@@ -112,7 +112,7 @@
 #endif /* defined(LOCKDEBUG) */
 
 static void    rw_abort(const char *, size_t, krwlock_t *, const char *);
-static void    rw_dump(volatile void *);
+static void    rw_dump(const volatile void *);
 static lwp_t   *rw_owner(wchan_t);
 
 static inline uintptr_t
@@ -167,9 +167,9 @@
  *     Dump the contents of a rwlock structure.
  */
 static void
-rw_dump(volatile void *cookie)
+rw_dump(const volatile void *cookie)
 {
-       volatile krwlock_t *rw = cookie;
+       const volatile krwlock_t *rw = cookie;
 
        printf_nolog("owner/count  : %#018lx flags    : %#018x\n",
            (long)RW_OWNER(rw), (int)RW_FLAGS(rw));
diff -r fe50e8d1e2ab -r 0f9ba418aa9d sys/kern/subr_lockdebug.c
--- a/sys/kern/subr_lockdebug.c Sat Sep 16 23:55:16 2017 +0000
+++ b/sys/kern/subr_lockdebug.c Sat Sep 16 23:55:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_lockdebug.c,v 1.57 2017/06/01 02:45:13 chs Exp $  */
+/*     $NetBSD: subr_lockdebug.c,v 1.58 2017/09/16 23:55:33 christos Exp $     */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.57 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.58 2017/09/16 23:55:33 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -145,14 +145,14 @@
 };
 
 static inline lockdebug_t *
-lockdebug_lookup1(volatile void *lock)
+lockdebug_lookup1(const volatile void *lock)
 {
        lockdebug_t *ld;
        struct cpu_info *ci;
 
        ci = curcpu();
        __cpu_simple_lock(&ci->ci_data.cpu_ld_lock);
-       ld = (lockdebug_t *)rb_tree_find_node(&ld_rb_tree, __UNVOLATILE(lock));
+       ld = rb_tree_find_node(&ld_rb_tree, (void *)(intptr_t)lock);
        __cpu_simple_unlock(&ci->ci_data.cpu_ld_lock);
        if (ld == NULL) {
                return NULL;
@@ -190,7 +190,7 @@
  *     Find a lockdebug structure by a pointer to a lock and return it locked.
  */
 static inline lockdebug_t *
-lockdebug_lookup(const char *func, size_t line, volatile void *lock,
+lockdebug_lookup(const char *func, size_t line, const volatile void *lock,
     uintptr_t where)
 {
        lockdebug_t *ld;
@@ -420,7 +420,7 @@
  */
 void
 lockdebug_wantlock(const char *func, size_t line,
-    volatile void *lock, uintptr_t where, int shared)
+    const volatile void *lock, uintptr_t where, int shared)
 {
        struct lwp *l = curlwp;
        lockdebug_t *ld;
@@ -842,7 +842,7 @@
  *     An error has been trapped - dump lock info and call panic().
  */
 void
-lockdebug_abort(const char *func, size_t line, volatile void *lock,
+lockdebug_abort(const char *func, size_t line, const volatile void *lock,
     lockops_t *ops, const char *msg)
 {
 #ifdef LOCKDEBUG



Home | Main Index | Thread Index | Old Index