aboutsummaryrefslogtreecommitdiff
path: root/lib/libspl/include/sys/cmn_err.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libspl/include/sys/cmn_err.h')
-rw-r--r--lib/libspl/include/sys/cmn_err.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/libspl/include/sys/cmn_err.h b/lib/libspl/include/sys/cmn_err.h
index 63ff4eb29bc8..6a29e6cff2e1 100644
--- a/lib/libspl/include/sys/cmn_err.h
+++ b/lib/libspl/include/sys/cmn_err.h
@@ -7,7 +7,7 @@
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
+ * or https://opensource.org/licenses/CDDL-1.0.
* See the License for the specific language governing permissions
* and limitations under the License.
*
@@ -27,4 +27,38 @@
#ifndef _LIBSPL_SYS_CMN_ERR_H
#define _LIBSPL_SYS_CMN_ERR_H
+#include <atomic.h>
+
+#define cmn_err_once(ce, ...) \
+do { \
+ static volatile uint32_t printed = 0; \
+ if (atomic_cas_32(&printed, 0, 1) == 0) { \
+ cmn_err(ce, __VA_ARGS__); \
+ } \
+} while (0)
+
+#define vcmn_err_once(ce, fmt, ap) \
+do { \
+ static volatile uint32_t printed = 0; \
+ if (atomic_cas_32(&printed, 0, 1) == 0) { \
+ vcmn_err(ce, fmt, ap); \
+ } \
+} while (0)
+
+#define zcmn_err_once(zone, ce, ...) \
+do { \
+ static volatile uint32_t printed = 0; \
+ if (atomic_cas_32(&printed, 0, 1) == 0) { \
+ zcmn_err(zone, ce, __VA_ARGS__); \
+ } \
+} while (0)
+
+#define vzcmn_err_once(zone, ce, fmt, ap) \
+do { \
+ static volatile uint32_t printed = 0; \
+ if (atomic_cas_32(&printed, 0, 1) == 0) { \
+ vzcmn_err(zone, ce, fmt, ap); \
+ } \
+} while (0)
+
#endif