diff options
author | 2016-06-07 07:53:33 +0000 | |
---|---|---|
committer | 2016-06-07 07:53:33 +0000 | |
commit | 54dc6d2f372cf4f861b8edd2e808743fcd38f8e5 (patch) | |
tree | faeaa1b66400414f26840983bba2592e914f5243 /sys | |
parent | use io_set_nonblocking() instead of SOCK_NONBLOCKING to reduce delta with (diff) | |
download | wireguard-openbsd-54dc6d2f372cf4f861b8edd2e808743fcd38f8e5.tar.xz wireguard-openbsd-54dc6d2f372cf4f861b8edd2e808743fcd38f8e5.zip |
Move initialization macro outside of #define _KERNEL to use them in
ART regression tests.
ok dlg@, jmatthew@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/sys/refcnt.h | 6 | ||||
-rw-r--r-- | sys/sys/srp.h | 46 | ||||
-rw-r--r-- | sys/sys/task.h | 7 |
3 files changed, 28 insertions, 31 deletions
diff --git a/sys/sys/refcnt.h b/sys/sys/refcnt.h index 3d699ea8fd2..85e84cfdc2d 100644 --- a/sys/sys/refcnt.h +++ b/sys/sys/refcnt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: refcnt.h,v 1.3 2015/11/23 10:56:20 mpi Exp $ */ +/* $OpenBSD: refcnt.h,v 1.4 2016/06/07 07:53:33 mpi Exp $ */ /* * Copyright (c) 2015 David Gwynne <dlg@openbsd.org> @@ -23,10 +23,10 @@ struct refcnt { unsigned int refs; }; -#ifdef _KERNEL - #define REFCNT_INITIALIZER() { .refs = 1 } +#ifdef _KERNEL + void refcnt_init(struct refcnt *); void refcnt_take(struct refcnt *); int refcnt_rele(struct refcnt *); diff --git a/sys/sys/srp.h b/sys/sys/srp.h index 45013743969..61cedc1d799 100644 --- a/sys/sys/srp.h +++ b/sys/sys/srp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: srp.h,v 1.10 2016/06/01 03:34:32 dlg Exp $ */ +/* $OpenBSD: srp.h,v 1.11 2016/06/07 07:53:33 mpi Exp $ */ /* * Copyright (c) 2014 Jonathan Matthew <jmatthew@openbsd.org> @@ -31,6 +31,8 @@ struct srp { void *ref; }; +#define SRP_INITIALIZER() { NULL } + struct srp_hazard { struct srp *sh_p; void *sh_v; @@ -41,18 +43,33 @@ struct srp_ref { } __upunused; #define SRP_HAZARD_NUM 16 - + struct srp_gc { void (*srp_gc_dtor)(void *, void *); void *srp_gc_cookie; struct refcnt srp_gc_refcnt; }; -#ifdef _KERNEL - -#define SRP_INITIALIZER() { NULL } #define SRP_GC_INITIALIZER(_d, _c) { (_d), (_c), REFCNT_INITIALIZER() } +/* + * singly linked list built by following srps + */ + +struct srpl_rc { + void (*srpl_ref)(void *, void *); + struct srp_gc srpl_gc; +}; +#define srpl_cookie srpl_gc.srp_gc_cookie + +#define SRPL_RC_INITIALIZER(_r, _u, _c) { _r, SRP_GC_INITIALIZER(_u, _c) } + +struct srpl { + struct srp sl_head; +}; + +#ifdef _KERNEL + void srp_startup(void); void srp_gc_init(struct srp_gc *, void (*)(void *, void *), void *); void *srp_swap_locked(struct srp *, void *); @@ -78,29 +95,10 @@ void srp_leave(struct srp_ref *); #define srp_leave(_sr) do { } while (0) #endif /* MULTIPROCESSOR */ -#endif /* _KERNEL */ - -/* - * singly linked list built by following srps - */ - -struct srpl_rc { - void (*srpl_ref)(void *, void *); - struct srp_gc srpl_gc; -}; -#define srpl_cookie srpl_gc.srp_gc_cookie - -struct srpl { - struct srp sl_head; -}; - -#ifdef _KERNEL void srpl_rc_init(struct srpl_rc *, void (*)(void *, void *), void (*)(void *, void *), void *); -#define SRPL_RC_INITIALIZER(_r, _u, _c) { _r, SRP_GC_INITIALIZER(_u, _c) } - #define SRPL_INIT(_sl) srp_init(&(_sl)->sl_head) #define SRPL_HEAD(name, type) struct srpl diff --git a/sys/sys/task.h b/sys/sys/task.h index b6c4e202db7..1db033a0f0c 100644 --- a/sys/sys/task.h +++ b/sys/sys/task.h @@ -1,4 +1,4 @@ -/* $OpenBSD: task.h,v 1.10 2015/12/08 11:55:47 dlg Exp $ */ +/* $OpenBSD: task.h,v 1.11 2016/06/07 07:53:33 mpi Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> @@ -35,6 +35,8 @@ TAILQ_HEAD(task_list, task); #define TASKQ_MPSAFE (1 << 0) #define TASKQ_CANTSLEEP (1 << 1) +#define TASK_INITIALIZER(_f, _a) {{ NULL, NULL }, (_f), (_a), 0 } + #ifdef _KERNEL extern struct taskq *const systq; extern struct taskq *const systqmp; @@ -46,9 +48,6 @@ void task_set(struct task *, void (*)(void *), void *); int task_add(struct taskq *, struct task *); int task_del(struct taskq *, struct task *); -#define TASK_INITIALIZER(_f, _a) \ - { { NULL, NULL }, (_f), (_a), 0 } - #endif /* _KERNEL */ #endif /* _SYS_TASK_H_ */ |