Index: include/paths.h =================================================================== --- include/paths.h +++ include/paths.h @@ -82,11 +82,8 @@ #define _PATH_MOUNT "/sbin/mount" #define _PATH_NEWFS "/sbin/newfs" #define _PATH_NOLOGIN "/var/run/nologin" -#define _PATH_RCP "/bin/rcp" #define _PATH_REBOOT "/sbin/reboot" -#define _PATH_RLOGIN "/usr/bin/rlogin" #define _PATH_RM "/bin/rm" -#define _PATH_RSH "/usr/bin/rsh" #define _PATH_SENDMAIL "/usr/sbin/sendmail" #define _PATH_SHELLS "/etc/shells" #define _PATH_TTY "/dev/tty" @@ -133,8 +130,6 @@ #define _PATH_MOUNT "/rescue/mount" #undef _PATH_NEWFS #define _PATH_NEWFS "/rescue/newfs" -#undef _PATH_RCP -#define _PATH_RCP "/rescue/rcp" #undef _PATH_REBOOT #define _PATH_REBOOT "/rescue/reboot" #undef _PATH_RM Index: share/man/man9/OF_node_from_xref.9 =================================================================== --- share/man/man9/OF_node_from_xref.9 +++ share/man/man9/OF_node_from_xref.9 @@ -64,7 +64,7 @@ and .Fn OF_xref_from_node are used to perform conversion between these two kinds of node -identifiers. +identifiers. .Pp .Fn OF_node_from_xref returns the kernel phandle for the effective phandle Index: share/man/man9/domainset.9 =================================================================== --- share/man/man9/domainset.9 +++ share/man/man9/domainset.9 @@ -86,7 +86,7 @@ Memory is allocated from the node in the .Vt prefer member. The preferred node must be set in the allowed mask. -If the preferred node is out of memory the allocation falls back to +If the preferred node is out of memory the allocation falls back to round-robin among allowed sets. .It Dv DOMAINSET_POLICY_INTERLEAVE Memory is allocated in a striped fashion with multiple pages @@ -114,7 +114,7 @@ function is provided as a convenience for modifying or viewing domainsets that are not accessible via .Xr cpuset 2 . -It is intended for use with +It is intended for use with .Xr sysctl 9 . .Pp .Sh SEE ALSO Index: share/man/man9/ieee80211.9 =================================================================== --- share/man/man9/ieee80211.9 +++ share/man/man9/ieee80211.9 @@ -706,7 +706,7 @@ This man page was updated with the information from .Nx .Nm -man page. +man page. .Sh AUTHORS .An -nosplit The original Index: share/man/man9/socket.9 =================================================================== --- share/man/man9/socket.9 +++ share/man/man9/socket.9 @@ -56,7 +56,7 @@ .Fn sodisconnect "struct socket *so" .Ft void .Fo sodtor_set -.Fa "struct socket *so" +.Fa "struct socket *so" .Fa "void (*func)(struct socket *)" .Fc .Ft struct sockaddr * Index: share/man/man9/zone.9 =================================================================== --- share/man/man9/zone.9 +++ share/man/man9/zone.9 @@ -263,11 +263,11 @@ and .Dv dtor functions, respectively. -The +The .Fn uma_zalloc_domain function allows callers to specify a fixed .Xr numa 9 domain to allocate from. This uses a guaranteed but slow path in -the allocator which reduces concurrency. The +the allocator which reduces concurrency. The .Fn uma_zfree_domain function should be used to return memory allocated in this fashion. This function infers the domain from the pointer and does not require it as an Index: sys/opencrypto/gfmult.h =================================================================== --- sys/opencrypto/gfmult.h +++ sys/opencrypto/gfmult.h @@ -84,7 +84,7 @@ #define GF128_EQ(a, b) ((((a).v[0] ^ (b).v[0]) | \ ((a).v[1] ^ (b).v[1])) == 0) -static inline struct gf128 +static inline struct gf128 __pure gf128_read(const uint8_t *buf) { struct gf128 r; @@ -108,7 +108,7 @@ be64enc(buf, v.v[1]); } -static inline struct gf128 __pure /* XXX - __pure2 instead */ +static inline struct gf128 __pure2 gf128_add(struct gf128 a, struct gf128 b) { a.v[0] ^= b.v[0]; Index: usr.bin/top/Makefile =================================================================== --- usr.bin/top/Makefile +++ usr.bin/top/Makefile @@ -3,7 +3,7 @@ .include PROG= top -SRCS= commands.c display.c machine.c screen.c top.c \ +SRCS= commands.c color.c display.c machine.c screen.c top.c \ username.c utils.c MAN= top.1 Index: usr.bin/top/color.h =================================================================== --- /dev/null +++ usr.bin/top/color.h @@ -0,0 +1,55 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2018 Eitan Adler + * + * 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 AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _COLOR_H_ +#define _COLOR_H_ + +enum tag_id { + MIN_15, + MIN_5, + MIN_1, + MAX_TAG_ID +}; + +typedef int color_t; + +struct tag_color_info { + int min; + int max; + color_t foreground; + color_t background; +}; + +extern struct tag_color_info colors[MAX_TAG_ID]; + +extern const color_t NO_COLOR; + +void color_init(void); + +#endif Index: usr.bin/top/color.c =================================================================== --- /dev/null +++ usr.bin/top/color.c @@ -0,0 +1,128 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2018 Eitan Adler + * + * 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 AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include +#include + +#include "color.h" + +const color_t NO_COLOR = -1; + +static const struct { + const char * const name; + enum tag_id tag; +} name_tag_map[] = { + { "min1", MIN_1 }, + { "min5", MIN_5 }, + { "min15", MIN_15 }, + { NULL, MAX_TAG_ID } +}; + +struct tag_color_info colors[MAX_TAG_ID]; + +void +color_init(void) { + char *env, *curcolor; + char *tagsep, *colorsep, *minmaxsep, *bgfgsep; + size_t i; + enum tag_id whichtag; + int min, max, fg, bg; + + for (i = 0; i < MAX_TAG_ID; ++i) { + colors[i].foreground = NO_COLOR; + colors[i].background = NO_COLOR; + colors[i].min = 0; + colors[i].max = 0; + } + + env = getenv("TOPCOLOR"); + if (env == NULL) { + return; + } + + while ((curcolor = strsep(&env, ":")) != NULL) { + /* this doesn't deal well with malformed strings + * but ideally shouldn't crash. + */ + + /* First split into tag=spec*/ + tagsep = strchr(curcolor, '='); + if (tagsep == NULL) { + fprintf(stderr, "no tag found\n"); + exit(1); + } + *tagsep = 0; + tagsep++; + for (i = 0; name_tag_map[i].name != NULL; ++i) { + if (strcmp(name_tag_map[i].name, curcolor) == 0) { + whichtag = name_tag_map[i].tag; + break; + } + } + if (i+1 == nitems(name_tag_map)) { + fprintf(stderr, "no such tag: %s\n", curcolor); + exit(1); + } + + + /* starting from the spec separate into min,max and color */ + colorsep = strchr(tagsep, '#'); + colorsep++; + if (colorsep == NULL) { + fprintf(stderr, "invalid color: no # found\n"); + exit(1); + } + minmaxsep = strchr(tagsep, ','); + minmaxsep++; + if (minmaxsep == NULL || minmaxsep > colorsep) { + fprintf(stderr, "invalid color: no min/max , found\n"); + exit(1); + } + min = (int)strtol(tagsep, NULL, 10); + max = (int)strtol(minmaxsep, NULL, 10); + + bgfgsep = strchr(colorsep, ','); + bgfgsep++; + if (minmaxsep == NULL) { + fprintf(stderr, "invalid color: no fg/bg , found\n"); + exit(1); + } + fg = (int)strtol(colorsep, NULL, 10); + bg = (int)strtol(bgfgsep, NULL, 10); + + colors[whichtag].min = min; + colors[whichtag].max = max; + colors[whichtag].foreground = fg; + colors[whichtag].background = bg; + } +} Index: usr.bin/top/top.1 =================================================================== --- usr.bin/top/top.1 +++ usr.bin/top/top.1 @@ -192,6 +192,10 @@ \*(lqall\*(rq. Boolean flags are toggles. A second specification of any of these options will negate the first. +.Sh "COLORS" +.Nm will display the header in color if TOPCOLOR is set to an appropriate string. +The format for TOPCOLOR is a colon separated list of tag=value pairs. +The value is defined as min,max#fg,bg. .Sh "INTERACTIVE MODE" When .Nm @@ -376,6 +380,8 @@ .Bl -tag -width TOP -compact .It Pa TOP Default set of arguments to +.It Pa TOPCOLOR +Colors to use in top header .Nm . .El .Sh SEE ALSO Index: usr.bin/top/top.c =================================================================== --- usr.bin/top/top.c +++ usr.bin/top/top.c @@ -32,6 +32,7 @@ #include #include "commands.h" +#include "color.h" #include "display.h" /* interface to display package */ #include "screen.h" /* interface to screen package */ #include "top.h" @@ -274,6 +275,8 @@ myname++; } } + + color_init(); mypid = getpid(); Index: usr.sbin/powerd/powerd.c =================================================================== --- usr.sbin/powerd/powerd.c +++ usr.sbin/powerd/powerd.c @@ -293,7 +293,7 @@ acline_mode = ac_sysctl; if (vflag) warnx("using sysctl for AC line status"); -#if __powerpc__ +#ifdef __powerpc__ } else if (sysctlnametomib(PMUAC, acline_mib, &acline_mib_len) == 0) { acline_mode = ac_sysctl; if (vflag)