1179263Sjb/* 2179263Sjb * CDDL HEADER START 3179263Sjb * 4179263Sjb * The contents of this file are subject to the terms of the 5179263Sjb * Common Development and Distribution License (the "License"). 6179263Sjb * You may not use this file except in compliance with the License. 7179263Sjb * 8179263Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9179263Sjb * or http://www.opensolaris.org/os/licensing. 10179263Sjb * See the License for the specific language governing permissions 11179263Sjb * and limitations under the License. 12179263Sjb * 13179263Sjb * When distributing Covered Code, include this CDDL HEADER in each 14179263Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15179263Sjb * If applicable, add the following below this CDDL HEADER, with the 16179263Sjb * fields enclosed by brackets "[]" replaced with your own identifying 17179263Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 18179263Sjb * 19179263Sjb * CDDL HEADER END 20179263Sjb * 21179263Sjb * $FreeBSD$ 22179263Sjb */ 23240303Smm/* 24240303Smm * Copyright 2007 John Birrell <jb@FreeBSD.org>. All rights reserved. 25240303Smm * Copyright 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. 26240303Smm */ 27179263Sjb 28240303Smm#include <sys/assfail.h> 29179263Sjb#include <sys/cmn_err.h> 30179263Sjb 31179263Sjbvoid 32179263Sjbvcmn_err(int ce, const char *fmt, va_list adx) 33179263Sjb{ 34179263Sjb char buf[256]; 35228710Savg const char *prefix; 36179263Sjb 37228710Savg prefix = NULL; /* silence unwitty compilers */ 38179263Sjb switch (ce) { 39179263Sjb case CE_CONT: 40228710Savg prefix = "Solaris(cont): "; 41179263Sjb break; 42179263Sjb case CE_NOTE: 43228710Savg prefix = "Solaris: NOTICE: "; 44179263Sjb break; 45179263Sjb case CE_WARN: 46228710Savg prefix = "Solaris: WARNING: "; 47179263Sjb break; 48179263Sjb case CE_PANIC: 49228710Savg prefix = "Solaris(panic): "; 50179263Sjb break; 51179263Sjb case CE_IGNORE: 52179263Sjb break; 53179263Sjb default: 54179263Sjb panic("Solaris: unknown severity level"); 55179263Sjb } 56228710Savg if (ce == CE_PANIC) { 57228710Savg vsnprintf(buf, sizeof(buf), fmt, adx); 58228710Savg panic("%s%s", prefix, buf); 59228710Savg } 60228710Savg if (ce != CE_IGNORE) { 61228710Savg printf("%s", prefix); 62228710Savg vprintf(fmt, adx); 63243498Savg printf("\n"); 64228710Savg } 65179263Sjb} 66179263Sjb 67179263Sjbvoid 68179263Sjbcmn_err(int type, const char *fmt, ...) 69179263Sjb{ 70179263Sjb va_list ap; 71179263Sjb 72179263Sjb va_start(ap, fmt); 73179263Sjb vcmn_err(type, fmt, ap); 74179263Sjb va_end(ap); 75179263Sjb} 76240303Smm 77240303Smmint 78252392Ssmhassfail(const char *a, const char *f, int l) 79252392Ssmh{ 80240303Smm 81240303Smm panic("solaris assert: %s, file: %s, line: %d", a, f, l); 82240303Smm 83240303Smm return (0); 84240303Smm} 85240303Smm 86240303Smmvoid 87240303Smmassfail3(const char *a, uintmax_t lv, const char *op, uintmax_t rv, 88252392Ssmh const char *f, int l) 89252392Ssmh{ 90240303Smm 91240303Smm panic("solaris assert: %s (0x%jx %s 0x%jx), file: %s, line: %d", 92240303Smm a, lv, op, rv, f, l); 93240303Smm} 94