Path: blob/main/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c
48383 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License (the "License").5* You may not use this file except in compliance with the License.6*7* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE8* or http://www.opensolaris.org/os/licensing.9* See the License for the specific language governing permissions10* and limitations under the License.11*12* When distributing Covered Code, include this CDDL HEADER in each13* file and include the License file at usr/src/OPENSOLARIS.LICENSE.14* If applicable, add the following below this CDDL HEADER, with the15* fields enclosed by brackets "[]" replaced with your own identifying16* information: Portions Copyright [yyyy] [name of copyright owner]17*18* CDDL HEADER END19*/20/*21* Copyright 2007 John Birrell <[email protected]>. All rights reserved.22* Copyright 2012 Martin Matuska <[email protected]>. All rights reserved.23*/2425#include <sys/assfail.h>26#include <sys/cmn_err.h>2728void29vcmn_err(int ce, const char *fmt, va_list adx)30{31char buf[256];32const char *prefix;3334prefix = NULL; /* silence unwitty compilers */35switch (ce) {36case CE_CONT:37prefix = "Solaris(cont): ";38break;39case CE_NOTE:40prefix = "Solaris: NOTICE: ";41break;42case CE_WARN:43prefix = "Solaris: WARNING: ";44break;45case CE_PANIC:46prefix = "Solaris(panic): ";47break;48case CE_IGNORE:49break;50default:51panic("Solaris: unknown severity level");52}53if (ce == CE_PANIC) {54vsnprintf(buf, sizeof(buf), fmt, adx);55panic("%s%s", prefix, buf);56}57if (ce != CE_IGNORE) {58printf("%s", prefix);59vprintf(fmt, adx);60printf("\n");61}62}6364void65cmn_err(int type, const char *fmt, ...)66{67va_list ap;6869va_start(ap, fmt);70vcmn_err(type, fmt, ap);71va_end(ap);72}7374int75assfail(const char *a, const char *f, int l)76{7778panic("solaris assert: %s, file: %s, line: %d", a, f, l);7980return (0);81}8283void84assfail3(const char *a, uintmax_t lv, const char *op, uintmax_t rv,85const char *f, int l)86{8788panic("solaris assert: %s (0x%jx %s 0x%jx), file: %s, line: %d",89a, lv, op, rv, f, l);90}919293