1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License, Version 1.0 only 7 * (the "License"). You may not use this file except in compliance 8 * with the License. 9 * 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * or https://opensource.org/licenses/CDDL-1.0. 12 * See the License for the specific language governing permissions 13 * and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 */ 23 /* 24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #ifndef _LIBSPL_SYS_CMN_ERR_H 29 #define _LIBSPL_SYS_CMN_ERR_H 30 31 #include <atomic.h> 32 33 #define cmn_err_once(ce, ...) \ 34 do { \ 35 static volatile uint32_t printed = 0; \ 36 if (atomic_cas_32(&printed, 0, 1) == 0) { \ 37 cmn_err(ce, __VA_ARGS__); \ 38 } \ 39 } while (0) 40 41 #define vcmn_err_once(ce, fmt, ap) \ 42 do { \ 43 static volatile uint32_t printed = 0; \ 44 if (atomic_cas_32(&printed, 0, 1) == 0) { \ 45 vcmn_err(ce, fmt, ap); \ 46 } \ 47 } while (0) 48 49 #define zcmn_err_once(zone, ce, ...) \ 50 do { \ 51 static volatile uint32_t printed = 0; \ 52 if (atomic_cas_32(&printed, 0, 1) == 0) { \ 53 zcmn_err(zone, ce, __VA_ARGS__); \ 54 } \ 55 } while (0) 56 57 #define vzcmn_err_once(zone, ce, fmt, ap) \ 58 do { \ 59 static volatile uint32_t printed = 0; \ 60 if (atomic_cas_32(&printed, 0, 1) == 0) { \ 61 vzcmn_err(zone, ce, fmt, ap); \ 62 } \ 63 } while (0) 64 65 #endif 66