summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2018-06-08 15:38:15 +0000
committerguenther <guenther@openbsd.org>2018-06-08 15:38:15 +0000
commite0c5510e7ddba29f5e83400a0ff636d5ba7c972c (patch)
tree9050ef44f49d5b4ff4332cbc5d5b3d0b31cd5b49 /sys
parentThe udp control option processing was implemented three times. (diff)
downloadwireguard-openbsd-e0c5510e7ddba29f5e83400a0ff636d5ba7c972c.tar.xz
wireguard-openbsd-e0c5510e7ddba29f5e83400a0ff636d5ba7c972c.zip
Constipate all the struct lock_type's so they go into .rodata
ok visa@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_lock.c6
-rw-r--r--sys/kern/kern_rwlock.c8
-rw-r--r--sys/kern/subr_pool.c10
-rw-r--r--sys/kern/subr_witness.c17
-rw-r--r--sys/sys/_lock.h4
-rw-r--r--sys/sys/mplock.h6
-rw-r--r--sys/sys/mutex.h8
-rw-r--r--sys/sys/rwlock.h14
-rw-r--r--sys/sys/witness.h4
9 files changed, 40 insertions, 37 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 657e028d4c5..0c3e40e721d 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lock.c,v 1.64 2018/05/14 12:31:21 mpi Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.65 2018/06/08 15:38:15 guenther Exp $ */
/*
* Copyright (c) 2017 Visa Hankala
@@ -91,7 +91,7 @@ _kernel_lock_held(void)
#include <machine/cpu.h>
void
-___mp_lock_init(struct __mp_lock *mpl, struct lock_type *type)
+___mp_lock_init(struct __mp_lock *mpl, const struct lock_type *type)
{
memset(mpl->mpl_cpus, 0, sizeof(mpl->mpl_cpus));
mpl->mpl_users = 0;
@@ -374,7 +374,7 @@ __mtx_leave(struct mutex *mtx)
#ifdef WITNESS
void
_mtx_init_flags(struct mutex *m, int ipl, const char *name, int flags,
- struct lock_type *type)
+ const struct lock_type *type)
{
struct lock_object *lo = MUTEX_LOCK_OBJECT(m);
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index 97e22a5e966..eff5f167235 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_rwlock.c,v 1.36 2018/06/04 04:46:07 guenther Exp $ */
+/* $OpenBSD: kern_rwlock.c,v 1.37 2018/06/08 15:38:15 guenther Exp $ */
/*
* Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org>
@@ -187,7 +187,7 @@ rw_enter_diag(struct rwlock *rwl, int flags)
static void
_rw_init_flags_witness(struct rwlock *rwl, const char *name, int lo_flags,
- struct lock_type *type)
+ const struct lock_type *type)
{
rwl->rwl_owner = 0;
rwl->rwl_name = name;
@@ -205,7 +205,7 @@ _rw_init_flags_witness(struct rwlock *rwl, const char *name, int lo_flags,
void
_rw_init_flags(struct rwlock *rwl, const char *name, int flags,
- struct lock_type *type)
+ const struct lock_type *type)
{
_rw_init_flags_witness(rwl, name, RWLOCK_LO_FLAGS(flags), type);
}
@@ -383,7 +383,7 @@ rw_assert_unlocked(struct rwlock *rwl)
/* recursive rwlocks; */
void
_rrw_init_flags(struct rrwlock *rrwl, char *name, int flags,
- struct lock_type *type)
+ const struct lock_type *type)
{
memset(rrwl, 0, sizeof(struct rrwlock));
_rw_init_flags_witness(&rrwl->rrwl_lock, name, RRWLOCK_LO_FLAGS(flags),
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index f1c08735591..4837ba927fc 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.222 2018/02/06 22:35:32 dlg Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.223 2018/06/08 15:38:15 guenther Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -77,7 +77,7 @@ struct pool phpool;
struct pool_lock_ops {
void (*pl_init)(struct pool *, union pool_lock *,
- struct lock_type *);
+ const struct lock_type *);
void (*pl_enter)(union pool_lock * LOCK_FL_VARS);
int (*pl_enter_try)(union pool_lock * LOCK_FL_VARS);
void (*pl_leave)(union pool_lock * LOCK_FL_VARS);
@@ -91,7 +91,7 @@ static const struct pool_lock_ops pool_lock_ops_rw;
#ifdef WITNESS
#define pl_init(pp, pl) do { \
- static struct lock_type __lock_type = { .lt_name = #pl }; \
+ static const struct lock_type __lock_type = { .lt_name = #pl }; \
(pp)->pr_lock_ops->pl_init(pp, pl, &__lock_type); \
} while (0)
#else /* WITNESS */
@@ -2190,7 +2190,7 @@ pool_cache_cpus_info(struct pool *pp, void *oldp, size_t *oldlenp)
void
pool_lock_mtx_init(struct pool *pp, union pool_lock *lock,
- struct lock_type *type)
+ const struct lock_type *type)
{
_mtx_init_flags(&lock->prl_mtx, pp->pr_ipl, pp->pr_wchan, 0, type);
}
@@ -2244,7 +2244,7 @@ static const struct pool_lock_ops pool_lock_ops_mtx = {
void
pool_lock_rw_init(struct pool *pp, union pool_lock *lock,
- struct lock_type *type)
+ const struct lock_type *type)
{
_rw_init_flags(&lock->prl_rwlock, pp->pr_wchan, 0, type);
}
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 2470ac13055..2f785d3a3d0 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_witness.c,v 1.18 2018/06/01 15:48:19 visa Exp $ */
+/* $OpenBSD: subr_witness.c,v 1.19 2018/06/08 15:38:15 guenther Exp $ */
/*-
* Copyright (c) 2008 Isilon Systems, Inc.
@@ -226,7 +226,7 @@ struct lock_list_entry {
* (for example, "vnode interlock").
*/
struct witness {
- struct lock_type *w_type;
+ const struct lock_type *w_type;
const char *w_subtype;
uint32_t w_index; /* Index in the relationship matrix */
struct lock_class *w_class;
@@ -282,7 +282,7 @@ struct witness_lock_order_hash {
};
struct witness_pendhelp {
- struct lock_type *wh_type;
+ const struct lock_type *wh_type;
struct lock_object *wh_lock;
};
@@ -315,7 +315,7 @@ witness_lock_order_key_equal(const struct witness_lock_order_key *a,
static int _isitmyx(struct witness *w1, struct witness *w2, int rmask,
const char *fname);
static void adopt(struct witness *parent, struct witness *child);
-static struct witness *enroll(struct lock_type *, const char *,
+static struct witness *enroll(const struct lock_type *, const char *,
struct lock_class *);
static struct lock_instance *find_instance(struct lock_list_entry *list,
const struct lock_object *lock);
@@ -337,7 +337,8 @@ static void witness_debugger(int dump);
static void witness_free(struct witness *m);
static struct witness *witness_get(void);
static uint32_t witness_hash_djb2(const uint8_t *key, uint32_t size);
-static struct witness *witness_hash_get(struct lock_type *, const char *);
+static struct witness *witness_hash_get(const struct lock_type *,
+ const char *);
static void witness_hash_put(struct witness *w);
static void witness_init_hash_tables(void);
static void witness_increment_graph_generation(void);
@@ -528,7 +529,7 @@ witness_initialize(void)
}
void
-witness_init(struct lock_object *lock, struct lock_type *type)
+witness_init(struct lock_object *lock, const struct lock_type *type)
{
struct lock_class *class;
@@ -1475,7 +1476,7 @@ witness_line(struct lock_object *lock)
}
static struct witness *
-enroll(struct lock_type *type, const char *subtype,
+enroll(const struct lock_type *type, const char *subtype,
struct lock_class *lock_class)
{
struct witness *w;
@@ -2369,7 +2370,7 @@ witness_init_hash_tables(void)
}
static struct witness *
-witness_hash_get(struct lock_type *type, const char *subtype)
+witness_hash_get(const struct lock_type *type, const char *subtype)
{
struct witness *w;
uint32_t hash;
diff --git a/sys/sys/_lock.h b/sys/sys/_lock.h
index 6db33f07cd0..8a09c6b942a 100644
--- a/sys/sys/_lock.h
+++ b/sys/sys/_lock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: _lock.h,v 1.1 2017/04/20 12:59:36 visa Exp $ */
+/* $OpenBSD: _lock.h,v 1.2 2018/06/08 15:38:15 guenther Exp $ */
/*-
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@@ -57,7 +57,7 @@ enum lock_class_index {
};
struct lock_object {
- struct lock_type *lo_type;
+ const struct lock_type *lo_type;
const char *lo_name; /* Individual lock name. */
struct witness *lo_witness; /* Data for witness. */
uint32_t lo_flags;
diff --git a/sys/sys/mplock.h b/sys/sys/mplock.h
index 1d64bbc904b..6e9d4c5bedf 100644
--- a/sys/sys/mplock.h
+++ b/sys/sys/mplock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mplock.h,v 1.11 2017/12/04 09:51:03 mpi Exp $ */
+/* $OpenBSD: mplock.h,v 1.12 2018/06/08 15:38:15 guenther Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
@@ -47,7 +47,7 @@ struct __mp_lock {
#endif
};
-void ___mp_lock_init(struct __mp_lock *, struct lock_type *);
+void ___mp_lock_init(struct __mp_lock *, const struct lock_type *);
void ___mp_lock(struct __mp_lock * LOCK_FL_VARS);
void ___mp_unlock(struct __mp_lock * LOCK_FL_VARS);
int ___mp_release_all(struct __mp_lock * LOCK_FL_VARS);
@@ -58,7 +58,7 @@ int __mp_lock_held(struct __mp_lock *, struct cpu_info *);
#ifdef WITNESS
#define __mp_lock_init(mpl) do { \
- static struct lock_type __lock_type = { .lt_name = #mpl }; \
+ static const struct lock_type __lock_type = { .lt_name = #mpl };\
___mp_lock_init((mpl), &__lock_type); \
} while (0)
diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h
index 3cc61b39a8a..39706e0e9f8 100644
--- a/sys/sys/mutex.h
+++ b/sys/sys/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.14 2018/03/27 08:32:29 mpi Exp $ */
+/* $OpenBSD: mutex.h,v 1.15 2018/06/08 15:38:15 guenther Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -104,7 +104,7 @@ void __mtx_init(struct mutex *, int);
#define __MTX_NAME __FILE__ ":" __MTX_S(__LINE__)
#define MTX_LO_INITIALIZER(name, flags) \
- { .lo_type = &(struct lock_type){ .lt_name = __MTX_NAME }, \
+ { .lo_type = &(const struct lock_type){ .lt_name = __MTX_NAME }, \
.lo_name = (name) != NULL ? (name) : __MTX_NAME, \
.lo_flags = MTX_LO_FLAGS(flags) }
@@ -133,14 +133,14 @@ void __mtx_leave(struct mutex *);
#ifdef WITNESS
void _mtx_init_flags(struct mutex *, int, const char *, int,
- struct lock_type *);
+ const struct lock_type *);
void _mtx_enter(struct mutex *, const char *, int);
int _mtx_enter_try(struct mutex *, const char *, int);
void _mtx_leave(struct mutex *, const char *, int);
#define mtx_init_flags(m, ipl, name, flags) do { \
- static struct lock_type __lock_type = { .lt_name = #m }; \
+ static const struct lock_type __lock_type = { .lt_name = #m }; \
_mtx_init_flags(m, ipl, name, flags, &__lock_type); \
} while (0)
diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h
index 740ea3be1d6..bd439f548a2 100644
--- a/sys/sys/rwlock.h
+++ b/sys/sys/rwlock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rwlock.h,v 1.23 2018/06/04 04:46:07 guenther Exp $ */
+/* $OpenBSD: rwlock.h,v 1.24 2018/06/08 15:38:15 guenther Exp $ */
/*
* Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
*
@@ -81,7 +81,7 @@ struct rwlock {
(LO_CLASS_RRWLOCK << LO_CLASSSHIFT))
#define RWLOCK_LO_INITIALIZER(name, flags) \
- { .lo_type = &(struct lock_type){ .lt_name = name }, \
+ { .lo_type = &(const struct lock_type){ .lt_name = name }, \
.lo_name = (name), \
.lo_flags = RWLOCK_LO_FLAGS(flags) }
@@ -132,11 +132,12 @@ struct rrwlock {
#ifdef _KERNEL
-void _rw_init_flags(struct rwlock *, const char *, int, struct lock_type *);
+void _rw_init_flags(struct rwlock *, const char *, int,
+ const struct lock_type *);
#ifdef WITNESS
#define rw_init_flags(rwl, name, flags) do { \
- static struct lock_type __lock_type = { .lt_name = #rwl }; \
+ static const struct lock_type __lock_type = { .lt_name = #rwl };\
_rw_init_flags(rwl, name, flags, &__lock_type); \
} while (0)
#define rw_init(rwl, name) rw_init_flags(rwl, name, 0)
@@ -175,14 +176,15 @@ int rw_status(struct rwlock *);
#define rw_enter(rwl, flags) _rw_enter(rwl, flags LOCK_FILE_LINE)
#define rw_exit(rwl) _rw_exit(rwl LOCK_FILE_LINE)
-void _rrw_init_flags(struct rrwlock *, char *, int, struct lock_type *);
+void _rrw_init_flags(struct rrwlock *, char *, int,
+ const struct lock_type *);
int _rrw_enter(struct rrwlock *, int LOCK_FL_VARS);
void _rrw_exit(struct rrwlock * LOCK_FL_VARS);
int rrw_status(struct rrwlock *);
#ifdef WITNESS
#define rrw_init_flags(rrwl, name, flags) do { \
- static struct lock_type __lock_type = { .lt_name = #rrwl }; \
+ static const struct lock_type __lock_type = { .lt_name = #rrwl };\
_rrw_init_flags(rrwl, name, flags, &__lock_type); \
} while (0)
#define rrw_init(rrwl, name) rrw_init_flags(rrwl, name, 0)
diff --git a/sys/sys/witness.h b/sys/sys/witness.h
index b90af325f50..8ef6aef68e0 100644
--- a/sys/sys/witness.h
+++ b/sys/sys/witness.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: witness.h,v 1.2 2018/05/16 14:53:43 visa Exp $ */
+/* $OpenBSD: witness.h,v 1.3 2018/06/08 15:38:15 guenther Exp $ */
/*-
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@@ -70,7 +70,7 @@
#ifdef _KERNEL
void witness_initialize(void);
-void witness_init(struct lock_object *, struct lock_type *);
+void witness_init(struct lock_object *, const struct lock_type *);
int witness_defineorder(struct lock_object *, struct lock_object *);
void witness_checkorder(struct lock_object *, int, const char *, int,
struct lock_object *);