/*
 *
 *	$Header: /usr/u/wjr/src/panic/RCS/panic.h,v 1.3 1992/02/19 20:14:38 wjr Exp $
 *
 */
/*
 *
 * panic.h - declaration of panic functions.
 *
 */

#ifndef PANIC_H
#define PANIC_H

/* These two are used for panics: internal consistency check failure */

#include <stdlib.h>
#include <unistd.h>


extern volatile void _panic(char *why, char *msg, char *rcsid, int line,
			    char *file, void (*die)(int v), int exitval);

#define panicfv(msg, f, v)  _panic("Panic", (msg), rcsid, __LINE__, __FILE__, (f), (v))
#define panic(msg)          panicfv((msg), &exit, 1)
#define assertfail(msg)  _panic("Assert failure", (msg), rcsid, __LINE__, __FILE__, exit, 1)
#define warn(msg)        _panic("Warning",        (msg), rcsid, __LINE__, __FILE__, 0, 0)

/* assert is for internal checks. In the production version it can be
 * redefined to null, for speed. Eassert() is an expression version */

#define assert(x)       do { if (!(x)) assertfail(#x); } while (0)
#define	eassert(x)	(!(x) ? (assertfail(#x), 0) : 0)

#define warnif(x)       do { if ((x)) warn((#x)); } while (0)
#define ewarnif(x)	((x) ? (warn((#x)), 0) : 0)

#endif
