Index: lib/Makefile =================================================================== RCS file: /cvs/src/lib/Makefile,v retrieving revision 1.72 diff -u -p -r1.72 Makefile --- lib/Makefile 23 Sep 2016 09:18:05 -0000 1.72 +++ lib/Makefile 4 Oct 2016 07:14:51 -0000 @@ -1,7 +1,8 @@ # $OpenBSD: Makefile,v 1.72 2016/09/23 09:18:05 sthen Exp $ # $NetBSD: Makefile,v 1.20.4.1 1996/06/14 17:22:38 cgd Exp $ -SUBDIR= csu libarch libc libcrypto libcurses libedit libevent libexpat \ +SUBDIR= csu libadt libarch libc libcrypto libcurses \ + libedit libevent libexpat \ libform libfuse libkeynote libkvm libl libm libmenu \ libossaudio libpanel libpcap libradius librthread \ librpcsvc libskey libsndio libssl libtls libusbhid \ Index: lib/libadt/Makefile =================================================================== RCS file: lib/libadt/Makefile diff -N lib/libadt/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/libadt/Makefile 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,20 @@ +# $OpenBSD: Makefile,v 1.43 2016/03/30 06:38:42 jmc Exp $ + +.include + +LIB= adt +MAN= + +# use more warnings than defined in bsd.own.mk +CDIAGFLAGS+= -Wbad-function-cast +CDIAGFLAGS+= -Wcast-align +CDIAGFLAGS+= -Wcast-qual +CDIAGFLAGS+= -Wextra +CDIAGFLAGS+= -Wmissing-declarations +CDIAGFLAGS+= -Wuninitialized +CDIAGFLAGS+= -Wno-unused-parameter + +.PATH: ${.CURDIR}/../../sys/kern +SRCS= subr_tree.c + +.include Index: lib/libadt/shlib_version =================================================================== RCS file: lib/libadt/shlib_version diff -N lib/libadt/shlib_version --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/libadt/shlib_version 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,2 @@ +major=0 +minor=1 Index: share/man/man9/RBT_INIT.9 =================================================================== RCS file: /cvs/src/share/man/man9/RBT_INIT.9,v retrieving revision 1.5 diff -u -p -r1.5 RBT_INIT.9 --- share/man/man9/RBT_INIT.9 15 Sep 2016 06:07:22 -0000 1.5 +++ share/man/man9/RBT_INIT.9 4 Oct 2016 07:14:51 -0000 @@ -69,7 +69,7 @@ .Nm RBT_CHECK .Nd Kernel red-black trees .Sh SYNOPSIS -.In sys/tree.h +.In sys/rbt.h .Fn RBT_HEAD "NAME" "TYPE" .Fn RBT_ENTRY "TYPE" .Fo RBT_PROTOTYPE Index: sys/arch/alpha/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/alpha/include/cpu.h,v retrieving revision 1.57 diff -u -p -r1.57 cpu.h --- sys/arch/alpha/include/cpu.h 30 Mar 2016 15:39:46 -0000 1.57 +++ sys/arch/alpha/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -102,6 +102,8 @@ typedef union alpha_t_float { #include #include +#include + struct pcb; struct proc; struct reg; Index: sys/arch/amd64/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/amd64/include/cpu.h,v retrieving revision 1.105 diff -u -p -r1.105 cpu.h --- sys/arch/amd64/include/cpu.h 30 Sep 2016 07:33:06 -0000 1.105 +++ sys/arch/amd64/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -46,6 +46,8 @@ #include #include #include + +#include #endif /* _KERNEL */ #include Index: sys/arch/hppa/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/hppa/include/cpu.h,v retrieving revision 1.89 diff -u -p -r1.89 cpu.h --- sys/arch/hppa/include/cpu.h 10 May 2016 14:52:03 -0000 1.89 +++ sys/arch/hppa/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -70,6 +70,8 @@ #include #include +#include + #include /* Index: sys/arch/i386/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/i386/include/cpu.h,v retrieving revision 1.148 diff -u -p -r1.148 cpu.h --- sys/arch/i386/include/cpu.h 28 Jul 2016 21:57:57 -0000 1.148 +++ sys/arch/i386/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -42,6 +42,8 @@ * Definitions unique to i386 cpu support. */ #ifdef _KERNEL +#include + #include #include #include Index: sys/arch/m88k/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/m88k/include/cpu.h,v retrieving revision 1.64 diff -u -p -r1.64 cpu.h --- sys/arch/m88k/include/cpu.h 2 Jul 2015 01:33:59 -0000 1.64 +++ sys/arch/m88k/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -63,6 +63,8 @@ #include #include +#include + #if defined(MULTIPROCESSOR) #if !defined(MAX_CPUS) || MAX_CPUS > 4 #undef MAX_CPUS Index: sys/arch/mips64/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/mips64/include/cpu.h,v retrieving revision 1.111 diff -u -p -r1.111 cpu.h --- sys/arch/mips64/include/cpu.h 14 Aug 2016 08:23:52 -0000 1.111 +++ sys/arch/mips64/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -123,6 +123,7 @@ #include #include #include +#include struct cpu_hwinfo { uint32_t c0prid; Index: sys/arch/powerpc/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/powerpc/include/cpu.h,v retrieving revision 1.63 diff -u -p -r1.63 cpu.h --- sys/arch/powerpc/include/cpu.h 7 May 2016 22:46:54 -0000 1.63 +++ sys/arch/powerpc/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -38,6 +38,7 @@ #include #include +#include struct cpu_info { struct device *ci_dev; /* our device */ Index: sys/arch/sparc64/include/cpu.h =================================================================== RCS file: /cvs/src/sys/arch/sparc64/include/cpu.h,v retrieving revision 1.89 diff -u -p -r1.89 cpu.h --- sys/arch/sparc64/include/cpu.h 17 Aug 2016 11:09:01 -0000 1.89 +++ sys/arch/sparc64/include/cpu.h 4 Oct 2016 07:14:51 -0000 @@ -78,6 +78,7 @@ #include #include +#include /* * The cpu_info structure is part of a 64KB structure mapped both the kernel Index: sys/crypto/crypto.c =================================================================== RCS file: /cvs/src/sys/crypto/crypto.c,v retrieving revision 1.78 diff -u -p -r1.78 crypto.c --- sys/crypto/crypto.c 19 Sep 2016 18:09:40 -0000 1.78 +++ sys/crypto/crypto.c 4 Oct 2016 07:14:51 -0000 @@ -24,6 +24,7 @@ #include #include #include +#include #include Index: sys/crypto/cryptodev.h =================================================================== RCS file: /cvs/src/sys/crypto/cryptodev.h,v retrieving revision 1.68 diff -u -p -r1.68 cryptodev.h --- sys/crypto/cryptodev.h 18 Apr 2016 21:05:55 -0000 1.68 +++ sys/crypto/cryptodev.h 4 Oct 2016 07:14:51 -0000 @@ -53,7 +53,7 @@ #define _CRYPTO_CRYPTO_H_ #include -#include +#include /* Some initial values */ #define CRYPTO_DRIVERS_INITIAL 4 Index: sys/kern/init_main.c =================================================================== RCS file: /cvs/src/sys/kern/init_main.c,v retrieving revision 1.259 diff -u -p -r1.259 init_main.c --- sys/kern/init_main.c 22 Sep 2016 12:55:24 -0000 1.259 +++ sys/kern/init_main.c 4 Oct 2016 07:14:51 -0000 @@ -146,6 +146,7 @@ void kqueue_init(void); void taskq_init(void); void timeout_proc_init(void); void pool_gc_pages(void *); +void srp_startup(void); extern char sigcode[], esigcode[], sigcoderet[]; #ifdef SYSCALL_DEBUG Index: sys/kern/kern_srp.c =================================================================== RCS file: /cvs/src/sys/kern/kern_srp.c,v retrieving revision 1.11 diff -u -p -r1.11 kern_srp.c --- sys/kern/kern_srp.c 15 Sep 2016 02:00:16 -0000 1.11 +++ sys/kern/kern_srp.c 4 Oct 2016 07:14:51 -0000 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include Index: sys/kern/subr_tree.c =================================================================== RCS file: /cvs/src/sys/kern/subr_tree.c,v retrieving revision 1.6 diff -u -p -r1.6 subr_tree.c --- sys/kern/subr_tree.c 20 Sep 2016 01:11:27 -0000 1.6 +++ sys/kern/subr_tree.c 4 Oct 2016 07:14:51 -0000 @@ -41,25 +41,27 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include +#include -static inline void * +static inline struct rb_entry * rb_n2e(const struct rb_type *t, void *node) { - caddr_t addr = (caddr_t)node; + unsigned long addr = (unsigned long)node; - return ((void *)(addr + t->t_offset)); + return ((struct rb_entry *)(addr + t->t_offset)); } static inline void * rb_e2n(const struct rb_type *t, struct rb_entry *rbe) { - caddr_t addr = (caddr_t)rbe; + unsigned long addr = (unsigned long)rbe; return ((void *)(addr - t->t_offset)); } +#define RBE_BLACK 0 +#define RBE_RED 1 + #define RBE_LEFT(_rbe) (_rbe)->rbt_left #define RBE_RIGHT(_rbe) (_rbe)->rbt_right #define RBE_PARENT(_rbe) (_rbe)->rbt_parent @@ -72,14 +74,14 @@ rbe_set(struct rb_entry *rbe, struct rb_ { RBE_PARENT(rbe) = parent; RBE_LEFT(rbe) = RBE_RIGHT(rbe) = NULL; - RBE_COLOR(rbe) = RB_RED; + RBE_COLOR(rbe) = RBE_RED; } static inline void rbe_set_blackred(struct rb_entry *black, struct rb_entry *red) { - RBE_COLOR(black) = RB_BLACK; - RBE_COLOR(red) = RB_RED; + RBE_COLOR(black) = RBE_BLACK; + RBE_COLOR(red) = RBE_RED; } static inline void @@ -170,13 +172,13 @@ rbe_insert_color(const struct rb_type *t struct rb_entry *parent, *gparent, *tmp; while ((parent = RBE_PARENT(rbe)) != NULL && - RBE_COLOR(parent) == RB_RED) { + RBE_COLOR(parent) == RBE_RED) { gparent = RBE_PARENT(parent); if (parent == RBE_LEFT(gparent)) { tmp = RBE_RIGHT(gparent); - if (tmp != NULL && RBE_COLOR(tmp) == RB_RED) { - RBE_COLOR(tmp) = RB_BLACK; + if (tmp != NULL && RBE_COLOR(tmp) == RBE_RED) { + RBE_COLOR(tmp) = RBE_BLACK; rbe_set_blackred(parent, gparent); rbe = gparent; continue; @@ -193,8 +195,8 @@ rbe_insert_color(const struct rb_type *t rbe_rotate_right(t, rbt, gparent); } else { tmp = RBE_LEFT(gparent); - if (tmp != NULL && RBE_COLOR(tmp) == RB_RED) { - RBE_COLOR(tmp) = RB_BLACK; + if (tmp != NULL && RBE_COLOR(tmp) == RBE_RED) { + RBE_COLOR(tmp) = RBE_BLACK; rbe_set_blackred(parent, gparent); rbe = gparent; continue; @@ -212,7 +214,7 @@ rbe_insert_color(const struct rb_type *t } } - RBE_COLOR(RBH_ROOT(rbt)) = RB_BLACK; + RBE_COLOR(RBH_ROOT(rbt)) = RBE_BLACK; } static inline void @@ -221,40 +223,40 @@ rbe_remove_color(const struct rb_type *t { struct rb_entry *tmp; - while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK) && + while ((rbe == NULL || RBE_COLOR(rbe) == RBE_BLACK) && rbe != RBH_ROOT(rbt)) { if (RBE_LEFT(parent) == rbe) { tmp = RBE_RIGHT(parent); - if (RBE_COLOR(tmp) == RB_RED) { + if (RBE_COLOR(tmp) == RBE_RED) { rbe_set_blackred(tmp, parent); rbe_rotate_left(t, rbt, parent); tmp = RBE_RIGHT(parent); } if ((RBE_LEFT(tmp) == NULL || - RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) && + RBE_COLOR(RBE_LEFT(tmp)) == RBE_BLACK) && (RBE_RIGHT(tmp) == NULL || - RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) { - RBE_COLOR(tmp) = RB_RED; + RBE_COLOR(RBE_RIGHT(tmp)) == RBE_BLACK)) { + RBE_COLOR(tmp) = RBE_RED; rbe = parent; parent = RBE_PARENT(rbe); } else { if (RBE_RIGHT(tmp) == NULL || - RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK) { + RBE_COLOR(RBE_RIGHT(tmp)) == RBE_BLACK) { struct rb_entry *oleft; oleft = RBE_LEFT(tmp); if (oleft != NULL) - RBE_COLOR(oleft) = RB_BLACK; + RBE_COLOR(oleft) = RBE_BLACK; - RBE_COLOR(tmp) = RB_RED; + RBE_COLOR(tmp) = RBE_RED; rbe_rotate_right(t, rbt, tmp); tmp = RBE_RIGHT(parent); } RBE_COLOR(tmp) = RBE_COLOR(parent); - RBE_COLOR(parent) = RB_BLACK; + RBE_COLOR(parent) = RBE_BLACK; if (RBE_RIGHT(tmp)) - RBE_COLOR(RBE_RIGHT(tmp)) = RB_BLACK; + RBE_COLOR(RBE_RIGHT(tmp)) = RBE_BLACK; rbe_rotate_left(t, rbt, parent); rbe = RBH_ROOT(rbt); @@ -262,37 +264,37 @@ rbe_remove_color(const struct rb_type *t } } else { tmp = RBE_LEFT(parent); - if (RBE_COLOR(tmp) == RB_RED) { + if (RBE_COLOR(tmp) == RBE_RED) { rbe_set_blackred(tmp, parent); rbe_rotate_right(t, rbt, parent); tmp = RBE_LEFT(parent); } if ((RBE_LEFT(tmp) == NULL || - RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) && + RBE_COLOR(RBE_LEFT(tmp)) == RBE_BLACK) && (RBE_RIGHT(tmp) == NULL || - RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) { - RBE_COLOR(tmp) = RB_RED; + RBE_COLOR(RBE_RIGHT(tmp)) == RBE_BLACK)) { + RBE_COLOR(tmp) = RBE_RED; rbe = parent; parent = RBE_PARENT(rbe); } else { if (RBE_LEFT(tmp) == NULL || - RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) { + RBE_COLOR(RBE_LEFT(tmp)) == RBE_BLACK) { struct rb_entry *oright; oright = RBE_RIGHT(tmp); if (oright != NULL) - RBE_COLOR(oright) = RB_BLACK; + RBE_COLOR(oright) = RBE_BLACK; - RBE_COLOR(tmp) = RB_RED; + RBE_COLOR(tmp) = RBE_RED; rbe_rotate_left(t, rbt, tmp); tmp = RBE_LEFT(parent); } RBE_COLOR(tmp) = RBE_COLOR(parent); - RBE_COLOR(parent) = RB_BLACK; + RBE_COLOR(parent) = RBE_BLACK; if (RBE_LEFT(tmp) != NULL) - RBE_COLOR(RBE_LEFT(tmp)) = RB_BLACK; + RBE_COLOR(RBE_LEFT(tmp)) = RBE_BLACK; rbe_rotate_right(t, rbt, parent); rbe = RBH_ROOT(rbt); @@ -302,7 +304,7 @@ rbe_remove_color(const struct rb_type *t } if (rbe != NULL) - RBE_COLOR(rbe) = RB_BLACK; + RBE_COLOR(rbe) = RBE_BLACK; } static inline struct rb_entry * @@ -381,7 +383,7 @@ rbe_remove(const struct rb_type *t, stru } else RBH_ROOT(rbt) = child; color: - if (color == RB_BLACK) + if (color == RBE_BLACK) rbe_remove_color(t, rbt, parent, child); return (old); Index: sys/kern/uipc_socket.c =================================================================== RCS file: /cvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.161 diff -u -p -r1.161 uipc_socket.c --- sys/kern/uipc_socket.c 20 Sep 2016 14:27:43 -0000 1.161 +++ sys/kern/uipc_socket.c 4 Oct 2016 07:14:51 -0000 @@ -49,6 +49,7 @@ #include #include #include +#include #ifdef DDB #include Index: sys/net/art.c =================================================================== RCS file: /cvs/src/sys/net/art.c,v retrieving revision 1.24 diff -u -p -r1.24 art.c --- sys/net/art.c 15 Sep 2016 02:00:18 -0000 1.24 +++ sys/net/art.c 4 Oct 2016 07:14:51 -0000 @@ -33,6 +33,7 @@ #include #include #include +#include #endif #include Index: sys/net/art.h =================================================================== RCS file: /cvs/src/sys/net/art.h,v retrieving revision 1.15 diff -u -p -r1.15 art.h --- sys/net/art.h 30 Aug 2016 07:42:57 -0000 1.15 +++ sys/net/art.h 4 Oct 2016 07:14:51 -0000 @@ -19,7 +19,8 @@ #ifndef _NET_ART_H_ #define _NET_ART_H_ -#include +#include +#include #define ART_MAXLVL 32 /* We currently use 32 levels for IPv6. */ Index: sys/net/if.c =================================================================== RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.451 diff -u -p -r1.451 if.c --- sys/net/if.c 28 Sep 2016 08:31:42 -0000 1.451 +++ sys/net/if.c 4 Oct 2016 07:14:51 -0000 @@ -84,6 +84,7 @@ #include #include #include +#include #include #include Index: sys/net/if_bridge.c =================================================================== RCS file: /cvs/src/sys/net/if_bridge.c,v retrieving revision 1.285 diff -u -p -r1.285 if_bridge.c --- sys/net/if_bridge.c 29 Sep 2016 11:37:44 -0000 1.285 +++ sys/net/if_bridge.c 4 Oct 2016 07:14:51 -0000 @@ -44,6 +44,7 @@ #include #include #include +#include #include #include Index: sys/net/if_ethersubr.c =================================================================== RCS file: /cvs/src/sys/net/if_ethersubr.c,v retrieving revision 1.239 diff -u -p -r1.239 if_ethersubr.c --- sys/net/if_ethersubr.c 12 Jul 2016 09:33:13 -0000 1.239 +++ sys/net/if_ethersubr.c 4 Oct 2016 07:14:51 -0000 @@ -86,6 +86,7 @@ didn't get a copy, you may request one f #include #include #include +#include #include #include Index: sys/net/if_pfsync.c =================================================================== RCS file: /cvs/src/sys/net/if_pfsync.c,v retrieving revision 1.234 diff -u -p -r1.234 if_pfsync.c --- sys/net/if_pfsync.c 27 Sep 2016 04:57:17 -0000 1.234 +++ sys/net/if_pfsync.c 4 Oct 2016 07:14:51 -0000 @@ -54,6 +54,7 @@ #include #include #include +#include #include #include Index: sys/net/if_var.h =================================================================== RCS file: /cvs/src/sys/net/if_var.h,v retrieving revision 1.75 diff -u -p -r1.75 if_var.h --- sys/net/if_var.h 4 Sep 2016 15:46:39 -0000 1.75 +++ sys/net/if_var.h 4 Oct 2016 07:14:51 -0000 @@ -38,10 +38,11 @@ #ifdef _KERNEL +#include +#include + #include #include -#include -#include #include #include Index: sys/net/if_vlan.c =================================================================== RCS file: /cvs/src/sys/net/if_vlan.c,v retrieving revision 1.166 diff -u -p -r1.166 if_vlan.c --- sys/net/if_vlan.c 3 Sep 2016 13:46:57 -0000 1.166 +++ sys/net/if_vlan.c 4 Oct 2016 07:14:51 -0000 @@ -57,6 +57,7 @@ #include #include #include +#include #include #include Index: sys/net/pf.c =================================================================== RCS file: /cvs/src/sys/net/pf.c,v retrieving revision 1.987 diff -u -p -r1.987 pf.c --- sys/net/pf.c 27 Sep 2016 04:57:17 -0000 1.987 +++ sys/net/pf.c 4 Oct 2016 07:14:51 -0000 @@ -52,6 +52,7 @@ #include #include #include +#include #include #include Index: sys/net/pfvar.h =================================================================== RCS file: /cvs/src/sys/net/pfvar.h,v retrieving revision 1.440 diff -u -p -r1.440 pfvar.h --- sys/net/pfvar.h 27 Sep 2016 04:57:17 -0000 1.440 +++ sys/net/pfvar.h 4 Oct 2016 07:14:51 -0000 @@ -36,9 +36,9 @@ #include #include -#include #include -#include +#include +#include #include Index: sys/netinet/ip_carp.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_carp.c,v retrieving revision 1.293 diff -u -p -r1.293 ip_carp.c --- sys/netinet/ip_carp.c 25 Jul 2016 16:44:04 -0000 1.293 +++ sys/netinet/ip_carp.c 4 Oct 2016 07:14:51 -0000 @@ -49,6 +49,7 @@ #include #include #include +#include #include #include Index: sys/netinet/ip_mroute.h =================================================================== RCS file: /cvs/src/sys/netinet/ip_mroute.h,v retrieving revision 1.19 diff -u -p -r1.19 ip_mroute.h --- sys/netinet/ip_mroute.h 9 Feb 2015 12:18:19 -0000 1.19 +++ sys/netinet/ip_mroute.h 4 Oct 2016 07:14:51 -0000 @@ -19,9 +19,6 @@ * bandwidth metering and signaling. */ -#include -#include - /* * Multicast Routing set/getsockopt commands. */ @@ -236,6 +233,9 @@ struct mrtstat { #ifdef _KERNEL + +#include +#include /* * The kernel's virtual-interface structure. Index: sys/netinet/tcp_var.h =================================================================== RCS file: /cvs/src/sys/netinet/tcp_var.h,v retrieving revision 1.115 diff -u -p -r1.115 tcp_var.h --- sys/netinet/tcp_var.h 20 Jul 2016 19:57:53 -0000 1.115 +++ sys/netinet/tcp_var.h 4 Oct 2016 07:14:51 -0000 @@ -35,7 +35,8 @@ #ifndef _NETINET_TCP_VAR_H_ #define _NETINET_TCP_VAR_H_ -#include +#include +#include /* * Kernel variables for tcp. @@ -261,8 +262,21 @@ union syn_cache_sa { struct sockaddr_in6 sin6; }; +struct syn_cache_key { + union syn_cache_sa sck_src; + union syn_cache_sa sck_dst; + u_int sck_rtableid; +}; + struct syn_cache { - TAILQ_ENTRY(syn_cache) sc_bucketq; /* link on bucket list */ + struct syn_cache_key sc_key; +#define sc_rtableid sc_key.sck_rtableid +#define sc_src sc_key.sck_src +#define sc_dst sc_key.sck_dst + + RB_ENTRY(syn_cache) sc_tentry; + TAILQ_ENTRY(syn_cache) sc_lentry; + struct timeout sc_timer; /* rexmt timer */ union { /* cached route */ struct route route4; @@ -275,19 +289,14 @@ struct syn_cache { #define sc_route6 sc_route_u.route6 #endif long sc_win; /* advertised window */ - struct syn_cache_head *sc_buckethead; /* our bucket index */ - struct syn_cache_set *sc_set; /* our syn cache set */ u_int32_t sc_hash; u_int32_t sc_timestamp; /* timestamp from SYN */ u_int32_t sc_modulate; /* our timestamp modulator */ #if 0 u_int32_t sc_timebase; /* our local timebase */ #endif - union syn_cache_sa sc_src; - union syn_cache_sa sc_dst; tcp_seq sc_irs; tcp_seq sc_iss; - u_int sc_rtableid; u_int sc_rxtcur; /* current rxt timeout */ u_int sc_rxttot; /* total time spend on queues */ u_short sc_rxtshift; /* for computing backoff */ @@ -310,19 +319,6 @@ struct syn_cache { LIST_ENTRY(syn_cache) sc_tpq; /* list of entries by same tp */ }; -struct syn_cache_head { - TAILQ_HEAD(, syn_cache) sch_bucket; /* bucket entries */ - u_short sch_length; /* # entries in bucket */ -}; - -struct syn_cache_set { - struct syn_cache_head *scs_buckethead; - int scs_size; - int scs_count; - int scs_use; - u_int32_t scs_random[5]; -}; - #endif /* _KERNEL */ /* @@ -547,7 +543,7 @@ struct tcpstat { &tcp_ack_on_push, \ NULL, \ &tcp_syn_cache_limit, \ - &tcp_syn_bucket_limit, \ + NULL, \ &tcp_do_rfc3390, \ NULL, \ NULL, \ @@ -585,12 +581,7 @@ extern int tcp_do_rfc3390; /* RFC3390 In extern struct pool tcpqe_pool; extern int tcp_reass_limit; /* max entries for tcp reass queues */ -extern int tcp_syn_hash_size; /* adjustable size of the hash array */ extern int tcp_syn_cache_limit; /* max entries for compressed state engine */ -extern int tcp_syn_bucket_limit;/* max entries per hash bucket */ -extern int tcp_syn_use_limit; /* number of uses before reseeding hash */ -extern struct syn_cache_set tcp_syn_cache[]; -extern int tcp_syn_cache_active; /* active syn cache, may be 0 or 1 */ int tcp_attach(struct socket *); void tcp_canceltimers(struct tcpcb *); @@ -679,9 +670,6 @@ struct socket *syn_cache_get(struct sock struct tcphdr *, unsigned int, unsigned int, struct socket *so, struct mbuf *); void syn_cache_init(void); -void syn_cache_insert(struct syn_cache *, struct tcpcb *); -struct syn_cache *syn_cache_lookup(struct sockaddr *, struct sockaddr *, - struct syn_cache_head **, u_int); void syn_cache_reset(struct sockaddr *, struct sockaddr *, struct tcphdr *, u_int); int syn_cache_respond(struct syn_cache *, struct mbuf *); Index: sys/sys/cdefs.h =================================================================== RCS file: /cvs/src/sys/sys/cdefs.h,v retrieving revision 1.39 diff -u -p -r1.39 cdefs.h --- sys/sys/cdefs.h 18 Apr 2014 11:51:17 -0000 1.39 +++ sys/sys/cdefs.h 4 Oct 2016 07:14:51 -0000 @@ -87,6 +87,15 @@ #endif /* !__GNUC__ */ #endif /* !(__STDC__ || __cplusplus) */ +/* Macros for calculating the offset of a field */ +#ifndef __offsetof +#if __GNUC_PREREQ__(4, 0) +#define __offsetof(s, e) __builtin_offsetof(s, e) +#else +#define __offsetof(s, e) ((size_t)&((s *)0)->e) +#endif +#endif + /* * GCC1 and some versions of GCC2 declare dead (non-returning) and * pure (no side effects) functions using "volatile" and "const"; Index: sys/sys/disk.h =================================================================== RCS file: /cvs/src/sys/sys/disk.h,v retrieving revision 1.35 diff -u -p -r1.35 disk.h --- sys/sys/disk.h 21 May 2016 14:00:27 -0000 1.35 +++ sys/sys/disk.h 4 Oct 2016 07:14:51 -0000 @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include struct buf; Index: sys/sys/filedesc.h =================================================================== RCS file: /cvs/src/sys/sys/filedesc.h,v retrieving revision 1.30 diff -u -p -r1.30 filedesc.h --- sys/sys/filedesc.h 6 May 2015 08:52:17 -0000 1.30 +++ sys/sys/filedesc.h 4 Oct 2016 07:14:51 -0000 @@ -32,7 +32,7 @@ * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 */ -#include +#include /* * This structure is used for the management of descriptors. It may be * shared by multiple processes. Index: sys/sys/mount.h =================================================================== RCS file: /cvs/src/sys/sys/mount.h,v retrieving revision 1.127 diff -u -p -r1.127 mount.h --- sys/sys/mount.h 10 Sep 2016 16:53:30 -0000 1.127 +++ sys/sys/mount.h 4 Oct 2016 07:14:51 -0000 @@ -40,7 +40,7 @@ #include #endif #include -#include +#include typedef struct { int32_t val[2]; } fsid_t; /* file system id type */ Index: sys/sys/param.h =================================================================== RCS file: /cvs/src/sys/sys/param.h,v retrieving revision 1.123 diff -u -p -r1.123 param.h --- sys/sys/param.h 9 Sep 2016 18:12:37 -0000 1.123 +++ sys/sys/param.h 4 Oct 2016 07:14:51 -0000 @@ -77,7 +77,6 @@ #include #include #include -#include #endif /* Signals. */ Index: sys/sys/rbt.h =================================================================== RCS file: sys/sys/rbt.h diff -N sys/sys/rbt.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/sys/rbt.h 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,219 @@ +/* $OpenBSD: tree.h,v 1.24 2016/09/15 06:07:22 dlg Exp $ */ + +/* + * Copyright (c) 2016 David Gwynne + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_RBT_H_ +#define _SYS_RBT_H_ + +#include +#include /* for __offsetof */ + +#include + +static inline void +_rb_init(struct rb_tree *rbt) +{ + rbt->rbt_root = NULL; +} + +static inline int +_rb_empty(struct rb_tree *rbt) +{ + return (rbt->rbt_root == NULL); +} + +void *_rb_insert(const struct rb_type *, struct rb_tree *, void *); +void *_rb_remove(const struct rb_type *, struct rb_tree *, void *); +void *_rb_find(const struct rb_type *, struct rb_tree *, const void *); +void *_rb_nfind(const struct rb_type *, struct rb_tree *, const void *); +void *_rb_root(const struct rb_type *, struct rb_tree *); +void *_rb_min(const struct rb_type *, struct rb_tree *); +void *_rb_max(const struct rb_type *, struct rb_tree *); +void *_rb_next(const struct rb_type *, void *); +void *_rb_prev(const struct rb_type *, void *); +void *_rb_left(const struct rb_type *, void *); +void *_rb_right(const struct rb_type *, void *); +void *_rb_parent(const struct rb_type *, void *); +void *_rb_color(const struct rb_type *, void *); +void _rb_poison(const struct rb_type *, void *, unsigned long); +int _rb_check(const struct rb_type *, void *, unsigned long); + +#define RBT_INITIALIZER(_head) { { NULL } } + +#define RBT_PROTOTYPE(_name, _type, _field, _cmp) \ +extern const struct rb_type *const _name##_RBT_TYPE; \ + \ +static inline void \ +_name##_RBT_INIT(struct _name *head) \ +{ \ + _rb_init(&head->rbh_root); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_INSERT(struct _name *head, struct _type *elm) \ +{ \ + return _rb_insert(_name##_RBT_TYPE, &head->rbh_root, elm); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_REMOVE(struct _name *head, struct _type *elm) \ +{ \ + return _rb_remove(_name##_RBT_TYPE, &head->rbh_root, elm); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_FIND(struct _name *head, const struct _type *key) \ +{ \ + return _rb_find(_name##_RBT_TYPE, &head->rbh_root, key); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_NFIND(struct _name *head, const struct _type *key) \ +{ \ + return _rb_nfind(_name##_RBT_TYPE, &head->rbh_root, key); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_ROOT(struct _name *head) \ +{ \ + return _rb_root(_name##_RBT_TYPE, &head->rbh_root); \ +} \ + \ +static inline int \ +_name##_RBT_EMPTY(struct _name *head) \ +{ \ + return _rb_empty(&head->rbh_root); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_MIN(struct _name *head) \ +{ \ + return _rb_min(_name##_RBT_TYPE, &head->rbh_root); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_MAX(struct _name *head) \ +{ \ + return _rb_max(_name##_RBT_TYPE, &head->rbh_root); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_NEXT(struct _type *elm) \ +{ \ + return _rb_next(_name##_RBT_TYPE, elm); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_PREV(struct _type *elm) \ +{ \ + return _rb_prev(_name##_RBT_TYPE, elm); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_LEFT(struct _type *elm) \ +{ \ + return _rb_left(_name##_RBT_TYPE, elm); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_RIGHT(struct _type *elm) \ +{ \ + return _rb_right(_name##_RBT_TYPE, elm); \ +} \ + \ +static inline struct _type * \ +_name##_RBT_PARENT(struct _type *elm) \ +{ \ + return _rb_parent(_name##_RBT_TYPE, elm); \ +} \ + \ +static inline void \ +_name##_RBT_POISON(struct _type *elm, unsigned long poison) \ +{ \ + return _rb_poison(_name##_RBT_TYPE, elm, poison); \ +} \ + \ +static inline int \ +_name##_RBT_CHECK(struct _type *elm, unsigned long poison) \ +{ \ + return _rb_check(_name##_RBT_TYPE, elm, poison); \ +} + +#define RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \ +static int \ +_name##_RBT_COMPARE(const void *lptr, const void *rptr) \ +{ \ + const struct _type *l = lptr, *r = rptr; \ + return _cmp(l, r); \ +} \ +static const struct rb_type _name##_RBT_INFO = { \ + _name##_RBT_COMPARE, \ + _aug, \ + __offsetof(struct _type, _field), \ +}; \ +const struct rb_type *const _name##_RBT_TYPE = &_name##_RBT_INFO + +#define RBT_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \ +static void \ +_name##_RBT_AUGMENT(void *ptr) \ +{ \ + struct _type *p = ptr; \ + return _aug(p); \ +} \ +RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RBT_AUGMENT) + +#define RBT_GENERATE(_name, _type, _field, _cmp) \ + RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL) + +#define RBT_INIT(_name, _head) _name##_RBT_INIT(_head) +#define RBT_INSERT(_name, _head, _elm) _name##_RBT_INSERT(_head, _elm) +#define RBT_REMOVE(_name, _head, _elm) _name##_RBT_REMOVE(_head, _elm) +#define RBT_FIND(_name, _head, _key) _name##_RBT_FIND(_head, _key) +#define RBT_NFIND(_name, _head, _key) _name##_RBT_NFIND(_head, _key) +#define RBT_ROOT(_name, _head) _name##_RBT_ROOT(_head) +#define RBT_EMPTY(_name, _head) _name##_RBT_EMPTY(_head) +#define RBT_MIN(_name, _head) _name##_RBT_MIN(_head) +#define RBT_MAX(_name, _head) _name##_RBT_MAX(_head) +#define RBT_NEXT(_name, _elm) _name##_RBT_NEXT(_elm) +#define RBT_PREV(_name, _elm) _name##_RBT_PREV(_elm) +#define RBT_LEFT(_name, _elm) _name##_RBT_LEFT(_elm) +#define RBT_RIGHT(_name, _elm) _name##_RBT_RIGHT(_elm) +#define RBT_PARENT(_name, _elm) _name##_RBT_PARENT(_elm) +#define RBT_POISON(_name, _elm, _p) _name##_RBT_POISON(_elm, _p) +#define RBT_CHECK(_name, _elm, _p) _name##_RBT_CHECK(_elm, _p) + +#define RBT_FOREACH(_e, _name, _head) \ + for ((_e) = RBT_MIN(_name, (_head)); \ + (_e) != NULL; \ + (_e) = RBT_NEXT(_name, (_e))) + +#define RBT_FOREACH_SAFE(_e, _name, _head, _n) \ + for ((_e) = RBT_MIN(_name, (_head)); \ + (_e) != NULL && ((_n) = RBT_NEXT(_name, (_e)), 1); \ + (_e) = (_n)) + +#define RBT_FOREACH_REVERSE(_e, _name, _head) \ + for ((_e) = RBT_MAX(_name, (_head)); \ + (_e) != NULL; \ + (_e) = RBT_PREV(_name, (_e))) + +#define RBT_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \ + for ((_e) = RBT_MAX(_name, (_head)); \ + (_e) != NULL && ((_n) = RBT_PREV(_name, (_e)), 1); \ + (_e) = (_n)) + +#endif /* _SYS_RBT_H_ */ Index: sys/sys/rbt_t.h =================================================================== RCS file: sys/sys/rbt_t.h diff -N sys/sys/rbt_t.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/sys/rbt_t.h 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,46 @@ +/* $OpenBSD: tree.h,v 1.24 2016/09/15 06:07:22 dlg Exp $ */ + +/* + * Copyright (c) 2016 David Gwynne + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_RBT_T_H_ +#define _SYS_RBT_T_H_ + +struct rb_type { + int (*t_compare)(const void *, const void *); + void (*t_augment)(void *); + unsigned int t_offset; /* offset of rb_entry in type */ +}; + +struct rb_tree { + struct rb_entry *rbt_root; +}; + +struct rb_entry { + struct rb_entry *rbt_parent; + struct rb_entry *rbt_left; + struct rb_entry *rbt_right; + unsigned int rbt_color; +}; + +#define RBT_HEAD(_name, _type) \ +struct _name { \ + struct rb_tree rbh_root; \ +} + +#define RBT_ENTRY(_type) struct rb_entry + +#endif /* _SYS_RBT_T_H_ */ Index: sys/sys/refcnt.h =================================================================== RCS file: /cvs/src/sys/sys/refcnt.h,v retrieving revision 1.4 diff -u -p -r1.4 refcnt.h --- sys/sys/refcnt.h 7 Jun 2016 07:53:33 -0000 1.4 +++ sys/sys/refcnt.h 4 Oct 2016 07:14:51 -0000 @@ -19,13 +19,11 @@ #ifndef _SYS_REFCNT_H_ #define _SYS_REFCNT_H_ -struct refcnt { - unsigned int refs; -}; - -#define REFCNT_INITIALIZER() { .refs = 1 } +#include #ifdef _KERNEL + +#define REFCNT_INITIALIZER() { .refs = 1 } void refcnt_init(struct refcnt *); void refcnt_take(struct refcnt *); Index: sys/sys/refcnt_t.h =================================================================== RCS file: sys/sys/refcnt_t.h diff -N sys/sys/refcnt_t.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/sys/refcnt_t.h 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,26 @@ +/* $OpenBSD: refcnt.h,v 1.4 2016/06/07 07:53:33 mpi Exp $ */ + +/* + * Copyright (c) 2015 David Gwynne + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_REFCNT_T_H_ +#define _SYS_REFCNT_T_H_ + +struct refcnt { + unsigned int refs; +}; + +#endif /* _SYS_REFCNT_H_ */ Index: sys/sys/rwlock.h =================================================================== RCS file: /cvs/src/sys/sys/rwlock.h,v retrieving revision 1.20 diff -u -p -r1.20 rwlock.h --- sys/sys/rwlock.h 21 Sep 2016 10:19:13 -0000 1.20 +++ sys/sys/rwlock.h 4 Oct 2016 07:14:51 -0000 @@ -54,14 +54,9 @@ #ifndef _SYS_RWLOCK_H #define _SYS_RWLOCK_H -struct proc; - -struct rwlock { - volatile unsigned long rwl_owner; - const char *rwl_name; -}; +#include -#define RWLOCK_INITIALIZER(name) { 0, name } +struct proc; #define RWLOCK_WAIT 0x01UL #define RWLOCK_WRWANT 0x02UL @@ -89,13 +84,9 @@ struct rwlock { */ #define RW_WRITE_OTHER 0x0100UL -/* recursive rwlocks; */ -struct rrwlock { - struct rwlock rrwl_lock; - uint32_t rrwl_wcnt; /* # writers. */ -}; - #ifdef _KERNEL + +#define RWLOCK_INITIALIZER(name) { 0, name } void rw_init(struct rwlock *, const char *); Index: sys/sys/rwlock_t.h =================================================================== RCS file: sys/sys/rwlock_t.h diff -N sys/sys/rwlock_t.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/sys/rwlock_t.h 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,33 @@ +/* $OpenBSD: rwlock.h,v 1.19 2016/09/21 07:44:36 mpi Exp $ */ + +/* + * Copyright (c) 2002 Artur Grabowski + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_RWLOCK_T_H +#define _SYS_RWLOCK_T_H + +struct rwlock { + volatile unsigned long rwl_owner; + const char *rwl_name; +}; + +/* recursive rwlocks; */ +struct rrwlock { + struct rwlock rrwl_lock; + uint32_t rrwl_wcnt; /* # writers. */ +}; + +#endif /* _SYS_RWLOCK_T_H */ Index: sys/sys/socketvar.h =================================================================== RCS file: /cvs/src/sys/sys/socketvar.h,v retrieving revision 1.65 diff -u -p -r1.65 socketvar.h --- sys/sys/socketvar.h 4 Sep 2016 11:10:19 -0000 1.65 +++ sys/sys/socketvar.h 4 Oct 2016 07:14:51 -0000 @@ -34,9 +34,9 @@ #include /* for struct selinfo */ #include -#include -#include -#include +#include +#include +#include #ifndef _SOCKLEN_T_DEFINED_ #define _SOCKLEN_T_DEFINED_ Index: sys/sys/srp.h =================================================================== RCS file: /cvs/src/sys/sys/srp.h,v retrieving revision 1.11 diff -u -p -r1.11 srp.h --- sys/sys/srp.h 7 Jun 2016 07:53:33 -0000 1.11 +++ sys/sys/srp.h 4 Oct 2016 07:14:51 -0000 @@ -19,57 +19,19 @@ #ifndef _SYS_SRP_H_ #define _SYS_SRP_H_ -#include +#include -#ifdef MULTIPROCESSOR -#define __upunused -#else -#define __upunused __attribute__((__unused__)) +#ifndef _KERNEL +#error srp.h without _KERNEL #endif -struct srp { - void *ref; -}; - -#define SRP_INITIALIZER() { NULL } - -struct srp_hazard { - struct srp *sh_p; - void *sh_v; -}; - -struct srp_ref { - struct srp_hazard *hz; -} __upunused; - -#define SRP_HAZARD_NUM 16 - -struct srp_gc { - void (*srp_gc_dtor)(void *, void *); - void *srp_gc_cookie; - struct refcnt srp_gc_refcnt; -}; - -#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 +#include + +#define SRP_INITIALIZER() { NULL } +#define SRP_GC_INITIALIZER(_d, _c) { (_d), (_c), REFCNT_INITIALIZER() } + void srp_startup(void); void srp_gc_init(struct srp_gc *, void (*)(void *, void *), void *); void *srp_swap_locked(struct srp *, void *); @@ -96,17 +58,12 @@ void srp_leave(struct srp_ref *); #endif /* MULTIPROCESSOR */ +#define SRPL_RC_INITIALIZER(_r, _u, _c) { _r, SRP_GC_INITIALIZER(_u, _c) } + void srpl_rc_init(struct srpl_rc *, void (*)(void *, void *), void (*)(void *, void *), void *); #define SRPL_INIT(_sl) srp_init(&(_sl)->sl_head) - -#define SRPL_HEAD(name, type) struct srpl - -#define SRPL_ENTRY(type) \ -struct { \ - struct srp se_next; \ -} #define SRPL_ENTER(_sr, _sl) srp_enter((_sr), &(_sl)->sl_head) Index: sys/sys/srp_t.h =================================================================== RCS file: sys/sys/srp_t.h diff -N sys/sys/srp_t.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/sys/srp_t.h 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,72 @@ +/* $OpenBSD: srp.h,v 1.11 2016/06/07 07:53:33 mpi Exp $ */ + +/* + * Copyright (c) 2014 Jonathan Matthew + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_SRP_T_H_ +#define _SYS_SRP_T_H_ + +#include + +#ifdef MULTIPROCESSOR +#define __upunused +#else +#define __upunused __attribute__((__unused__)) +#endif + +struct srp { + void *ref; +}; + +struct srp_hazard { + struct srp *sh_p; + void *sh_v; +}; + +struct srp_ref { + struct srp_hazard *hz; +} __upunused; + +#define SRP_HAZARD_NUM 16 + +struct srp_gc { + void (*srp_gc_dtor)(void *, void *); + void *srp_gc_cookie; + struct refcnt srp_gc_refcnt; +}; + +/* + * 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; +}; + +#define SRPL_HEAD(name, type) struct srpl + +#define SRPL_ENTRY(type) \ +struct { \ + struct srp se_next; \ +} + +#endif /* _SYS_SRP_T_H_ */ Index: sys/sys/task.h =================================================================== RCS file: /cvs/src/sys/sys/task.h,v retrieving revision 1.11 diff -u -p -r1.11 task.h --- sys/sys/task.h 7 Jun 2016 07:53:33 -0000 1.11 +++ sys/sys/task.h 4 Oct 2016 07:14:51 -0000 @@ -19,27 +19,17 @@ #ifndef _SYS_TASK_H_ #define _SYS_TASK_H_ -#include - -struct taskq; - -struct task { - TAILQ_ENTRY(task) t_entry; - void (*t_func)(void *); - void *t_arg; - unsigned int t_flags; -}; - -TAILQ_HEAD(task_list, task); +#include #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; + +#define TASK_INITIALIZER(_f, _a) { { NULL, NULL }, (_f), (_a), 0 } struct taskq *taskq_create(const char *, unsigned int, int, unsigned int); void taskq_destroy(struct taskq *); Index: sys/sys/task_t.h =================================================================== RCS file: sys/sys/task_t.h diff -N sys/sys/task_t.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/sys/task_t.h 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,34 @@ +/* $OpenBSD: task.h,v 1.11 2016/06/07 07:53:33 mpi Exp $ */ + +/* + * Copyright (c) 2013 David Gwynne + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _SYS_TASK_T_H_ +#define _SYS_TASK_T_H_ + +#include + +struct taskq; + +struct task { + TAILQ_ENTRY(task) t_entry; + void (*t_func)(void *); + void *t_arg; + unsigned int t_flags; +}; +TAILQ_HEAD(task_list, task); + +#endif /* _SYS_TASK_T_H_ */ Index: sys/sys/timeout.h =================================================================== RCS file: /cvs/src/sys/sys/timeout.h,v retrieving revision 1.26 diff -u -p -r1.26 timeout.h --- sys/sys/timeout.h 22 Sep 2016 12:55:24 -0000 1.26 +++ sys/sys/timeout.h 4 Oct 2016 07:14:51 -0000 @@ -27,6 +27,8 @@ #ifndef _SYS_TIMEOUT_H_ #define _SYS_TIMEOUT_H_ +#include + /* * Interface for handling time driven events in the kernel. * @@ -51,19 +53,6 @@ * These functions may be called in interrupt context (anything below splhigh). */ -struct circq { - struct circq *next; /* next element */ - struct circq *prev; /* previous element */ -}; - -struct timeout { - struct circq to_list; /* timeout queue, don't move */ - void (*to_func)(void *); /* function to call */ - void *to_arg; /* function argument */ - int to_time; /* ticks on event */ - int to_flags; /* misc flags */ -}; - /* * flags in the to_flags field. */ @@ -72,7 +61,6 @@ struct timeout { #define TIMEOUT_INITIALIZED 4 /* timeout is initialized */ #define TIMEOUT_TRIGGERED 8 /* timeout is running or ran */ -#ifdef _KERNEL /* * special macros * @@ -83,10 +71,12 @@ struct timeout { #define timeout_initialized(to) ((to)->to_flags & TIMEOUT_INITIALIZED) #define timeout_triggered(to) ((to)->to_flags & TIMEOUT_TRIGGERED) -#define TIMEOUT_INITIALIZER(_f, _a) \ - { { NULL, NULL }, (_f), (_a), 0, TIMEOUT_INITIALIZED } +#ifdef _KERNEL struct bintime; + +#define TIMEOUT_INITIALIZER(_f, _a) \ + { { NULL, NULL }, (_f), (_a), 0, TIMEOUT_INITIALIZED } void timeout_set(struct timeout *, void (*)(void *), void *); void timeout_set_proc(struct timeout *, void (*)(void *), void *); Index: sys/sys/timeout_t.h =================================================================== RCS file: sys/sys/timeout_t.h diff -N sys/sys/timeout_t.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/sys/timeout_t.h 4 Oct 2016 07:14:51 -0000 @@ -0,0 +1,43 @@ +/* $OpenBSD: timeout.h,v 1.25 2014/12/22 04:43:38 dlg Exp $ */ +/* + * Copyright (c) 2000-2001 Artur Grabowski + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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. + */ + +#ifndef _SYS_TIMEOUT_T_H_ +#define _SYS_TIMEOUT_T_H_ + +struct circq { + struct circq *next; /* next element */ + struct circq *prev; /* previous element */ +}; + +struct timeout { + struct circq to_list; /* timeout queue, don't move */ + void (*to_func)(void *); /* function to call */ + void *to_arg; /* function argument */ + int to_time; /* ticks on event */ + int to_flags; /* misc flags */ +}; + +#endif /* _SYS_TIMEOUT_T_H_ */ Index: sys/sys/tree.h =================================================================== RCS file: /cvs/src/sys/sys/tree.h,v retrieving revision 1.25 diff -u -p -r1.25 tree.h --- sys/sys/tree.h 26 Sep 2016 08:08:51 -0000 1.25 +++ sys/sys/tree.h 4 Oct 2016 07:14:51 -0000 @@ -747,241 +747,16 @@ name##_RB_MINMAX(struct name *head, int ((x) != NULL) && ((y) = name##_RB_PREV(x), 1); \ (x) = (y)) - /* - * Copyright (c) 2016 David Gwynne - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. + * provide compat access to the function version of red-black trees * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * the types are included first so theyre always visible, and the api is + * included for use immediate use in the kernel. */ -struct rb_type { - int (*t_compare)(const void *, const void *); - void (*t_augment)(void *); - unsigned int t_offset; /* offset of rb_entry in type */ -}; - -struct rb_tree { - struct rb_entry *rbt_root; -}; - -struct rb_entry { - struct rb_entry *rbt_parent; - struct rb_entry *rbt_left; - struct rb_entry *rbt_right; - unsigned int rbt_color; -}; - -#define RBT_HEAD(_name, _type) \ -struct _name { \ - struct rb_tree rbh_root; \ -} - -#define RBT_ENTRY(_type) struct rb_entry - +#include #ifdef _KERNEL - -static inline void -_rb_init(struct rb_tree *rbt) -{ - rbt->rbt_root = NULL; -} - -static inline int -_rb_empty(struct rb_tree *rbt) -{ - return (rbt->rbt_root == NULL); -} - -void *_rb_insert(const struct rb_type *, struct rb_tree *, void *); -void *_rb_remove(const struct rb_type *, struct rb_tree *, void *); -void *_rb_find(const struct rb_type *, struct rb_tree *, const void *); -void *_rb_nfind(const struct rb_type *, struct rb_tree *, const void *); -void *_rb_root(const struct rb_type *, struct rb_tree *); -void *_rb_min(const struct rb_type *, struct rb_tree *); -void *_rb_max(const struct rb_type *, struct rb_tree *); -void *_rb_next(const struct rb_type *, void *); -void *_rb_prev(const struct rb_type *, void *); -void *_rb_left(const struct rb_type *, void *); -void *_rb_right(const struct rb_type *, void *); -void *_rb_parent(const struct rb_type *, void *); -void *_rb_color(const struct rb_type *, void *); -void _rb_poison(const struct rb_type *, void *, unsigned long); -int _rb_check(const struct rb_type *, void *, unsigned long); - -#define RBT_INITIALIZER(_head) { { NULL } } - -#define RBT_PROTOTYPE(_name, _type, _field, _cmp) \ -extern const struct rb_type *const _name##_RBT_TYPE; \ - \ -__unused static inline void \ -_name##_RBT_INIT(struct _name *head) \ -{ \ - _rb_init(&head->rbh_root); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_INSERT(struct _name *head, struct _type *elm) \ -{ \ - return _rb_insert(_name##_RBT_TYPE, &head->rbh_root, elm); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_REMOVE(struct _name *head, struct _type *elm) \ -{ \ - return _rb_remove(_name##_RBT_TYPE, &head->rbh_root, elm); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_FIND(struct _name *head, const struct _type *key) \ -{ \ - return _rb_find(_name##_RBT_TYPE, &head->rbh_root, key); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_NFIND(struct _name *head, const struct _type *key) \ -{ \ - return _rb_nfind(_name##_RBT_TYPE, &head->rbh_root, key); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_ROOT(struct _name *head) \ -{ \ - return _rb_root(_name##_RBT_TYPE, &head->rbh_root); \ -} \ - \ -__unused static inline int \ -_name##_RBT_EMPTY(struct _name *head) \ -{ \ - return _rb_empty(&head->rbh_root); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_MIN(struct _name *head) \ -{ \ - return _rb_min(_name##_RBT_TYPE, &head->rbh_root); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_MAX(struct _name *head) \ -{ \ - return _rb_max(_name##_RBT_TYPE, &head->rbh_root); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_NEXT(struct _type *elm) \ -{ \ - return _rb_next(_name##_RBT_TYPE, elm); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_PREV(struct _type *elm) \ -{ \ - return _rb_prev(_name##_RBT_TYPE, elm); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_LEFT(struct _type *elm) \ -{ \ - return _rb_left(_name##_RBT_TYPE, elm); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_RIGHT(struct _type *elm) \ -{ \ - return _rb_right(_name##_RBT_TYPE, elm); \ -} \ - \ -__unused static inline struct _type * \ -_name##_RBT_PARENT(struct _type *elm) \ -{ \ - return _rb_parent(_name##_RBT_TYPE, elm); \ -} \ - \ -__unused static inline void \ -_name##_RBT_POISON(struct _type *elm, unsigned long poison) \ -{ \ - return _rb_poison(_name##_RBT_TYPE, elm, poison); \ -} \ - \ -__unused static inline int \ -_name##_RBT_CHECK(struct _type *elm, unsigned long poison) \ -{ \ - return _rb_check(_name##_RBT_TYPE, elm, poison); \ -} - -#define RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \ -static int \ -_name##_RBT_COMPARE(const void *lptr, const void *rptr) \ -{ \ - const struct _type *l = lptr, *r = rptr; \ - return _cmp(l, r); \ -} \ -static const struct rb_type _name##_RBT_INFO = { \ - _name##_RBT_COMPARE, \ - _aug, \ - offsetof(struct _type, _field), \ -}; \ -const struct rb_type *const _name##_RBT_TYPE = &_name##_RBT_INFO - -#define RBT_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \ -static void \ -_name##_RBT_AUGMENT(void *ptr) \ -{ \ - struct _type *p = ptr; \ - return _aug(p); \ -} \ -RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RBT_AUGMENT) - -#define RBT_GENERATE(_name, _type, _field, _cmp) \ - RBT_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL) - -#define RBT_INIT(_name, _head) _name##_RBT_INIT(_head) -#define RBT_INSERT(_name, _head, _elm) _name##_RBT_INSERT(_head, _elm) -#define RBT_REMOVE(_name, _head, _elm) _name##_RBT_REMOVE(_head, _elm) -#define RBT_FIND(_name, _head, _key) _name##_RBT_FIND(_head, _key) -#define RBT_NFIND(_name, _head, _key) _name##_RBT_NFIND(_head, _key) -#define RBT_ROOT(_name, _head) _name##_RBT_ROOT(_head) -#define RBT_EMPTY(_name, _head) _name##_RBT_EMPTY(_head) -#define RBT_MIN(_name, _head) _name##_RBT_MIN(_head) -#define RBT_MAX(_name, _head) _name##_RBT_MAX(_head) -#define RBT_NEXT(_name, _elm) _name##_RBT_NEXT(_elm) -#define RBT_PREV(_name, _elm) _name##_RBT_PREV(_elm) -#define RBT_LEFT(_name, _elm) _name##_RBT_LEFT(_elm) -#define RBT_RIGHT(_name, _elm) _name##_RBT_RIGHT(_elm) -#define RBT_PARENT(_name, _elm) _name##_RBT_PARENT(_elm) -#define RBT_POISON(_name, _elm, _p) _name##_RBT_POISON(_elm, _p) -#define RBT_CHECK(_name, _elm, _p) _name##_RBT_CHECK(_elm, _p) - -#define RBT_FOREACH(_e, _name, _head) \ - for ((_e) = RBT_MIN(_name, (_head)); \ - (_e) != NULL; \ - (_e) = RBT_NEXT(_name, (_e))) - -#define RBT_FOREACH_SAFE(_e, _name, _head, _n) \ - for ((_e) = RBT_MIN(_name, (_head)); \ - (_e) != NULL && ((_n) = RBT_NEXT(_name, (_e)), 1); \ - (_e) = (_n)) - -#define RBT_FOREACH_REVERSE(_e, _name, _head) \ - for ((_e) = RBT_MAX(_name, (_head)); \ - (_e) != NULL; \ - (_e) = RBT_PREV(_name, (_e))) - -#define RBT_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \ - for ((_e) = RBT_MAX(_name, (_head)); \ - (_e) != NULL && ((_n) = RBT_PREV(_name, (_e)), 1); \ - (_e) = (_n)) - +#include #endif /* _KERNEL */ #endif /* _SYS_TREE_H_ */ Index: usr.sbin/procmap/Makefile =================================================================== RCS file: /cvs/src/usr.sbin/procmap/Makefile,v retrieving revision 1.6 diff -u -p -r1.6 Makefile --- usr.sbin/procmap/Makefile 16 Sep 2016 04:45:35 -0000 1.6 +++ usr.sbin/procmap/Makefile 4 Oct 2016 07:14:51 -0000 @@ -3,10 +3,7 @@ PROG= procmap SRCS= procmap.c CFLAGS+= -Wall -LDADD= -lkvm -DPADD= ${LIBKVM} - -.PATH: ${.CURDIR}/../../sys/kern -SRCS+= subr_tree.c +LDADD= -lkvm -ladt +DPADD= ${LIBKVM} ${LIBADT} .include Index: procmap.c =================================================================== RCS file: /cvs/src/usr.sbin/procmap/procmap.c,v retrieving revision 1.63 diff -u -p -r1.63 procmap.c --- procmap.c 16 Sep 2016 04:45:35 -0000 1.63 +++ procmap.c 4 Oct 2016 10:35:57 -0000 @@ -30,10 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#define _KERNEL -#include -#undef _KERNEL - #include /* MAXCOMLEN */ #include #include @@ -44,6 +40,7 @@ #include #include #include +#include /* XXX until uvm gets cleaned up */ typedef int boolean_t;