svn commit: r329962 - stable/11/sys/compat/linuxkpi/common/include/linux

Hans Petter Selasky hselasky at FreeBSD.org
Sun Feb 25 10:26:45 UTC 2018


Author: hselasky
Date: Sun Feb 25 10:26:44 2018
New Revision: 329962
URL: https://svnweb.freebsd.org/changeset/base/329962

Log:
  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 at gmail.com>
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/printk.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/printk.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/printk.h	Sun Feb 25 10:25:47 2018	(r329961)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/printk.h	Sun Feb 25 10:26:44 2018	(r329962)
@@ -106,10 +106,16 @@ print_hex_dump_bytes(const char *prefix_str, const int
 	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_ */


More information about the svn-src-all mailing list