11590Srgrimes/*
21590Srgrimes * CDDL HEADER START
31590Srgrimes *
41590Srgrimes * The contents of this file are subject to the terms of the
51590Srgrimes * Common Development and Distribution License (the "License").
61590Srgrimes * You may not use this file except in compliance with the License.
71590Srgrimes *
81590Srgrimes * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91590Srgrimes * or http://www.opensolaris.org/os/licensing.
101590Srgrimes * See the License for the specific language governing permissions
111590Srgrimes * and limitations under the License.
121590Srgrimes *
131590Srgrimes * When distributing Covered Code, include this CDDL HEADER in each
141590Srgrimes * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151590Srgrimes * If applicable, add the following below this CDDL HEADER, with the
161590Srgrimes * fields enclosed by brackets "[]" replaced with your own identifying
171590Srgrimes * information: Portions Copyright [yyyy] [name of copyright owner]
181590Srgrimes *
191590Srgrimes * CDDL HEADER END
201590Srgrimes *
211590Srgrimes * $FreeBSD: releng/11.0/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c 252392 2013-06-29 23:39:38Z smh $
221590Srgrimes */
231590Srgrimes/*
241590Srgrimes * Copyright 2007 John Birrell <jb@FreeBSD.org>. All rights reserved.
251590Srgrimes * Copyright 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
261590Srgrimes */
271590Srgrimes
281590Srgrimes#include <sys/assfail.h>
291590Srgrimes#include <sys/cmn_err.h>
301590Srgrimes
3127443Scharniervoid
321590Srgrimesvcmn_err(int ce, const char *fmt, va_list adx)
331590Srgrimes{
341590Srgrimes	char buf[256];
351590Srgrimes	const char *prefix;
361590Srgrimes
3727443Scharnier	prefix = NULL; /* silence unwitty compilers */
381590Srgrimes	switch (ce) {
3927443Scharnier	case CE_CONT:
401590Srgrimes		prefix = "Solaris(cont): ";
4199112Sobrien		break;
4299112Sobrien	case CE_NOTE:
431590Srgrimes		prefix = "Solaris: NOTICE: ";
4455206Speter		break;
452215Scsgr	case CE_WARN:
462215Scsgr		prefix = "Solaris: WARNING: ";
4755206Speter		break;
481590Srgrimes	case CE_PANIC:
49263234Srwatson		prefix = "Solaris(panic): ";
501590Srgrimes		break;
51100824Sdwmalone	case CE_IGNORE:
521590Srgrimes		break;
53100824Sdwmalone	default:
541590Srgrimes		panic("Solaris: unknown severity level");
551590Srgrimes	}
561590Srgrimes	if (ce == CE_PANIC) {
57165758Srodrigc		vsnprintf(buf, sizeof(buf), fmt, adx);
58176471Sdes		panic("%s%s", prefix, buf);
59219043Sdchagin	}
60273053Sjhb	if (ce != CE_IGNORE) {
61176471Sdes		printf("%s", prefix);
62219043Sdchagin		vprintf(fmt, adx);
63255493Sjhb		printf("\n");
64296047Soshogbo	}
65285063Soshogbo}
66285063Soshogbo
67190168Sdelphijvoid
68176471Sdescmn_err(int type, const char *fmt, ...)
69190168Sdelphij{
7027443Scharnier	va_list ap;
71176471Sdes
72176471Sdes	va_start(ap, fmt);
7327443Scharnier	vcmn_err(type, fmt, ap);
74251486Sae	va_end(ap);
75251073Spjd}
76176471Sdes
771590Srgrimesint
781590Srgrimesassfail(const char *a, const char *f, int l)
791590Srgrimes{
80292236Sjhb
81251073Spjd	panic("solaris assert: %s, file: %s, line: %d", a, f, l);
82176471Sdes
8327443Scharnier	return (0);
8427443Scharnier}
851590Srgrimes
86158766Snetchildvoid
871590Srgrimesassfail3(const char *a, uintmax_t lv, const char *op, uintmax_t rv,
88296047Soshogbo    const char *f, int l)
89296047Soshogbo{
90296047Soshogbo
91296047Soshogbo	panic("solaris assert: %s (0x%jx %s 0x%jx), file: %s, line: %d",
92296047Soshogbo	    a, lv, op, rv, f, l);
93296047Soshogbo}
94296047Soshogbo