opensolaris_cmn_err.c revision 240303
185909Simp/* 285909Simp * CDDL HEADER START 3122116Sbde * 4122116Sbde * The contents of this file are subject to the terms of the 5122116Sbde * Common Development and Distribution License (the "License"). 6180012Sru * You may not use this file except in compliance with the License. 7240468Sbrooks * 8160440Sobrien * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9210151Simp * or http://www.opensolaris.org/os/licensing. 10239272Sgonzo * See the License for the specific language governing permissions 11210151Simp * and limitations under the License. 1285909Simp * 1385909Simp * When distributing Covered Code, include this CDDL HEADER in each 1485909Simp * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1585909Simp * If applicable, add the following below this CDDL HEADER, with the 16175888Simp * fields enclosed by brackets "[]" replaced with your own identifying 17175888Simp * information: Portions Copyright [yyyy] [name of copyright owner] 1885909Simp * 19218538Simp * CDDL HEADER END 2085909Simp * 2191512Sobrien * $FreeBSD: head/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c 240303 2012-09-10 10:24:57Z mm $ 22240451Snp */ 23116341Smarkm/* 2485909Simp * Copyright 2007 John Birrell <jb@FreeBSD.org>. All rights reserved. 2585909Simp * Copyright 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. 2685909Simp */ 2785909Simp 28220863Sdim#include <sys/assfail.h> 29140606Sobrien#include <sys/cmn_err.h> 30187103Sgnn 31220863Sdimvoid 32224882Snwhitehornvcmn_err(int ce, const char *fmt, va_list adx) 33224882Snwhitehorn{ 34224882Snwhitehorn char buf[256]; 35140606Sobrien const char *prefix; 36220863Sdim 37224882Snwhitehorn prefix = NULL; /* silence unwitty compilers */ 38220863Sdim switch (ce) { 39240468Sbrooks case CE_CONT: 40127204Sobrien prefix = "Solaris(cont): "; 41220863Sdim break; 42228868Sdim case CE_NOTE: 43228868Sdim prefix = "Solaris: NOTICE: "; 44228868Sdim break; 45140606Sobrien case CE_WARN: 46220863Sdim prefix = "Solaris: WARNING: "; 47220863Sdim break; 48124834Sru case CE_PANIC: 49124834Sru prefix = "Solaris(panic): "; 5085909Simp break; 5185909Simp case CE_IGNORE: 5285909Simp break; 53160043Sobrien default: 54126890Strhodes panic("Solaris: unknown severity level"); 5585909Simp } 56192901Sthompsa if (ce == CE_PANIC) { 57126890Strhodes vsnprintf(buf, sizeof(buf), fmt, adx); 58151605Sobrien panic("%s%s", prefix, buf); 59151605Sobrien } 60130416Smlaier if (ce != CE_IGNORE) { 61130416Smlaier printf("%s", prefix); 62149978Sobrien vprintf(fmt, adx); 63149978Sobrien } 64149978Sobrien} 65149978Sobrien 66149978Sobrienvoid 67185522Ssamcmn_err(int type, const char *fmt, ...) 68250173Sadrian{ 69149978Sobrien va_list ap; 70149978Sobrien 71149978Sobrien va_start(ap, fmt); 72149978Sobrien vcmn_err(type, fmt, ap); 73229353Sgjb va_end(ap); 74149978Sobrien} 75149978Sobrien 76218792Snpint 77218792Snpassfail(const char *a, const char *f, int l) { 78183292Skmacy 79149978Sobrien panic("solaris assert: %s, file: %s, line: %d", a, f, l); 80149978Sobrien 81160043Sobrien return (0); 82150966Sglebius} 83240468Sbrooks 84124834Sruvoid 85210311Sjmallettassfail3(const char *a, uintmax_t lv, const char *op, uintmax_t rv, 86132766Skan const char *f, int l) { 87132766Skan 88210311Sjmallett panic("solaris assert: %s (0x%jx %s 0x%jx), file: %s, line: %d", 89210311Sjmallett a, lv, op, rv, f, l); 90215988Sjmallett} 91210311Sjmallett