/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: debug.h 1.9 89/10/10 $"

#ifndef	_SYS_DEBUG_H_

/* $Log:	debug.h,v $
*/

#ifdef	INKERNEL
# ifdef	NOASSERTCHECK
#  define	ASSERT(c,s)
# else
#  ifdef DEBUG
#   define	ASSERT(c,s)	if (c) /* skip */; else assfail("c",__FILE__,__LINE__,s)
#  else
#   define	ASSERT(c,s)	if (c) /* skip */; else cmn_err(CE_PANIC, s)
#  endif
# endif

# ifdef	DEBUG
#  define	ASSERT_DEBUG(c,s)	ASSERT(c,s)
# else
# define	ASSERT_DEBUG(c,s)
# endif	/* DEBUG */

/*
 * Set STREAMS_DEBUG_ID to your stream id before including debug.h to
 * make use of the following macros.
 */
#ifdef STREAMS_DEBUG_ID	   
/*
 * Flavours when level is set to 4 then 1 2 3 and 4's are printed
 *                               3      1 2 and 3's are printed
 *                               2      1 2's are printed
 *                               1      1's are printed
 *                               0      nothing is printed
 */
#ifdef DEBUG

#define DPRINTF1 	if (str_debug(STREAMS_DEBUG_ID, 1))printf
#define DPRINTF2 	if (str_debug(STREAMS_DEBUG_ID, 2))printf
#define DPRINTF3 	if (str_debug(STREAMS_DEBUG_ID, 3))printf
#define DPRINTF4 	if (str_debug(STREAMS_DEBUG_ID, 4))printf

#else /* else not DEBUG */
#ifdef lint	/* lint does not like void expressions */

#define DPRINTF1 printf
#define DPRINTF2 printf
#define DPRINTF3 printf
#define DPRINTF4 printf

#else		/* the complier will not generate code for void expressions */

#define DPRINTF1 (void)
#define DPRINTF2 (void)
#define DPRINTF3 (void)
#define DPRINTF4 (void)

#endif /* lint */
#endif /* DEBUG */

/*
 * strlog tracing
 * mid should be set to the "minor" or "idex" of the stream.
 * level can any number the greater the level the more you get.
 * fmt and args are printf like (must be completly resolved no indirection).
 */
#ifdef DEBUG

#define STRACE(mid,level,fmt) \
	strlog(STREAMS_DEBUG_ID,mid,level,SL_TRACE,fmt)
#define STRACE1(mid,level,fmt,arg1) \
	strlog(STREAMS_DEBUG_ID,mid,level,SL_TRACE,fmt,arg1)
#define STRACE2(mid,level,fmt,arg1,arg2) \
	strlog(STREAMS_DEBUG_ID,mid,level,SL_TRACE,fmt,arg1,arg2)

#else /* else not DEBUG */

#define STRACE(mid,level,fmt)
#define STRACE1(mid,level,fmt,arg1)
#define STRACE2(mid,level,fmt,arg1,arg2)
#endif /* DEBUG */

#endif /*STREAMS_DEBUG_ID*/
#endif	/* INKERNEL */

#define	_SYS_DEBUG_H_
#endif	/* _SYS_DEBUG_H_ */
