summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2018-02-25 10:26:44 +0000
committerhselasky <hselasky@FreeBSD.org>2018-02-25 10:26:44 +0000
commit121ed165414b1a2587061adf792edc21cc9f62a9 (patch)
tree18b7233188105066cb3d652d218674672493f19b
parent0788f0ae2d3f89e525337b087907111b9a18324d (diff)
downloadFreeBSD-src-121ed165414b1a2587061adf792edc21cc9f62a9.zip
FreeBSD-src-121ed165414b1a2587061adf792edc21cc9f62a9.tar.gz
MFC r329470:
Add support for printk_ratelimit() function macro and improve the existing printk_ratelimited() function macro to return a boolean stating if there was a printout, true, or not, false. Submitted by: Johannes Lundberg <johalun0@gmail.com> Sponsored by: Mellanox Technologies
-rw-r--r--sys/compat/linuxkpi/common/include/linux/printk.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/printk.h b/sys/compat/linuxkpi/common/include/linux/printk.h
index 1480fc6..6e8e3da 100644
--- a/sys/compat/linuxkpi/common/include/linux/printk.h
+++ b/sys/compat/linuxkpi/common/include/linux/printk.h
@@ -106,10 +106,16 @@ print_hex_dump_bytes(const char *prefix_str, const int prefix_type,
print_hex_dump(NULL, prefix_str, prefix_type, 16, 1, buf, len, 0);
}
-#define printk_ratelimited(...) do { \
+#define printk_ratelimit() ({ \
static linux_ratelimit_t __ratelimited; \
- if (linux_ratelimited(&__ratelimited)) \
+ linux_ratelimited(&__ratelimited); \
+})
+
+#define printk_ratelimited(...) ({ \
+ bool __retval = printk_ratelimit(); \
+ if (__retval) \
printk(__VA_ARGS__); \
-} while (0)
+ __retval; \
+})
#endif /* _LINUX_PRINTK_H_ */
OpenPOWER on IntegriCloud