1*58a2b000SEvgeniy Ivanov /* $NetBSD: panic.c,v 1.7 2011/07/17 20:54:52 joerg Exp $ */
2*58a2b000SEvgeniy Ivanov
3*58a2b000SEvgeniy Ivanov /*-
4*58a2b000SEvgeniy Ivanov * Copyright (c) 1993 John Brezak
5*58a2b000SEvgeniy Ivanov * All rights reserved.
6*58a2b000SEvgeniy Ivanov *
7*58a2b000SEvgeniy Ivanov * Redistribution and use in source and binary forms, with or without
8*58a2b000SEvgeniy Ivanov * modification, are permitted provided that the following conditions
9*58a2b000SEvgeniy Ivanov * are met:
10*58a2b000SEvgeniy Ivanov * 1. Redistributions of source code must retain the above copyright
11*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer.
12*58a2b000SEvgeniy Ivanov * 2. Redistributions in binary form must reproduce the above copyright
13*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer in the
14*58a2b000SEvgeniy Ivanov * documentation and/or other materials provided with the distribution.
15*58a2b000SEvgeniy Ivanov * 3. The name of the author may not be used to endorse or promote products
16*58a2b000SEvgeniy Ivanov * derived from this software without specific prior written permission.
17*58a2b000SEvgeniy Ivanov *
18*58a2b000SEvgeniy Ivanov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
19*58a2b000SEvgeniy Ivanov * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20*58a2b000SEvgeniy Ivanov * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21*58a2b000SEvgeniy Ivanov * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22*58a2b000SEvgeniy Ivanov * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23*58a2b000SEvgeniy Ivanov * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24*58a2b000SEvgeniy Ivanov * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25*58a2b000SEvgeniy Ivanov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26*58a2b000SEvgeniy Ivanov * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27*58a2b000SEvgeniy Ivanov * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*58a2b000SEvgeniy Ivanov * POSSIBILITY OF SUCH DAMAGE.
29*58a2b000SEvgeniy Ivanov */
30*58a2b000SEvgeniy Ivanov #include <sys/stdarg.h>
31*58a2b000SEvgeniy Ivanov
32*58a2b000SEvgeniy Ivanov #include "stand.h"
33*58a2b000SEvgeniy Ivanov
34*58a2b000SEvgeniy Ivanov __dead void
panic(const char * fmt,...)35*58a2b000SEvgeniy Ivanov panic(const char *fmt, ...)
36*58a2b000SEvgeniy Ivanov {
37*58a2b000SEvgeniy Ivanov va_list ap;
38*58a2b000SEvgeniy Ivanov #ifndef LIBSA_NO_FS_CLOSE
39*58a2b000SEvgeniy Ivanov static int paniced;
40*58a2b000SEvgeniy Ivanov
41*58a2b000SEvgeniy Ivanov if (!paniced) {
42*58a2b000SEvgeniy Ivanov paniced = 1;
43*58a2b000SEvgeniy Ivanov closeall();
44*58a2b000SEvgeniy Ivanov }
45*58a2b000SEvgeniy Ivanov #endif
46*58a2b000SEvgeniy Ivanov
47*58a2b000SEvgeniy Ivanov va_start(ap, fmt);
48*58a2b000SEvgeniy Ivanov vprintf(fmt, ap);
49*58a2b000SEvgeniy Ivanov printf("\n");
50*58a2b000SEvgeniy Ivanov va_end(ap);
51*58a2b000SEvgeniy Ivanov _rtt();
52*58a2b000SEvgeniy Ivanov /*NOTREACHED*/
53*58a2b000SEvgeniy Ivanov }
54