diff options
author | Renato Botelho <renato@netgate.com> | 2016-08-01 12:53:16 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-08-01 12:53:16 -0300 |
commit | 80c20d0bef69a2c543d1bc2dddd2bc34198fec9b (patch) | |
tree | fc6009a2d49da5ab043d4c847a288f71ec6aa731 /sys/kern/subr_prf.c | |
parent | f235fecdc77c17505022bc5202d74f3d36b33359 (diff) | |
parent | eed7d9e93aec04a3f6a7d157c4cac7452a6c1727 (diff) | |
download | FreeBSD-src-80c20d0bef69a2c543d1bc2dddd2bc34198fec9b.zip FreeBSD-src-80c20d0bef69a2c543d1bc2dddd2bc34198fec9b.tar.gz |
Merge remote-tracking branch 'origin/stable/11' into devel-11
Diffstat (limited to 'sys/kern/subr_prf.c')
-rw-r--r-- | sys/kern/subr_prf.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 5bcf39b..3784ffd 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -1196,3 +1196,24 @@ sbuf_hexdump(struct sbuf *sb, const void *ptr, int length, const char *hdr, } } +#ifdef _KERNEL +void +counted_warning(unsigned *counter, const char *msg) +{ + struct thread *td; + unsigned c; + + for (;;) { + c = *counter; + if (c == 0) + break; + if (atomic_cmpset_int(counter, c, c - 1)) { + td = curthread; + log(LOG_INFO, "pid %d (%s) %s%s\n", + td->td_proc->p_pid, td->td_name, msg, + c > 1 ? "" : " - not logging anymore"); + break; + } + } +} +#endif |