Blame include/complib/cl_debug.h

Packit 13e616
/*
Packit 13e616
 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
Packit 13e616
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
Packit 13e616
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
Packit 13e616
 *
Packit 13e616
 * This software is available to you under a choice of one of two
Packit 13e616
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 13e616
 * General Public License (GPL) Version 2, available from the file
Packit 13e616
 * COPYING in the main directory of this source tree, or the
Packit 13e616
 * OpenIB.org BSD license below:
Packit 13e616
 *
Packit 13e616
 *     Redistribution and use in source and binary forms, with or
Packit 13e616
 *     without modification, are permitted provided that the following
Packit 13e616
 *     conditions are met:
Packit 13e616
 *
Packit 13e616
 *      - Redistributions of source code must retain the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer.
Packit 13e616
 *
Packit 13e616
 *      - Redistributions in binary form must reproduce the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer in the documentation and/or other materials
Packit 13e616
 *        provided with the distribution.
Packit 13e616
 *
Packit 13e616
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 13e616
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 13e616
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 13e616
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 13e616
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 13e616
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 13e616
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 13e616
 * SOFTWARE.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
/*
Packit 13e616
 * Abstract:
Packit 13e616
 *	Declaration of functions for reporting debug output.
Packit 13e616
 */
Packit 13e616
Packit 13e616
#ifndef _CL_DEBUG_H_
Packit 13e616
#define _CL_DEBUG_H_
Packit 13e616
Packit 13e616
#include <complib/cl_debug_osd.h>
Packit 13e616
Packit 13e616
#ifdef __cplusplus
Packit 13e616
#  define BEGIN_C_DECLS extern "C" {
Packit 13e616
#  define END_C_DECLS   }
Packit 13e616
#else				/* !__cplusplus */
Packit 13e616
#  define BEGIN_C_DECLS
Packit 13e616
#  define END_C_DECLS
Packit 13e616
#endif				/* __cplusplus */
Packit 13e616
Packit 13e616
BEGIN_C_DECLS
Packit 13e616
/****h* Component Library/Debug Output
Packit 13e616
* NAME
Packit 13e616
*	Debug Output
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The debug output functions and macros send debug messages to the current
Packit 13e616
*	debug target.
Packit 13e616
*********/
Packit 13e616
/****f* Component Library: Debug Output/cl_break
Packit 13e616
* NAME
Packit 13e616
*	cl_break
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The cl_break function halts execution.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*	void
Packit 13e616
*	cl_break();
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	In a release build, cl_break has no effect.
Packit 13e616
*********/
Packit 13e616
/****f* Component Library: Debug Output/cl_is_debug
Packit 13e616
* NAME
Packit 13e616
*	cl_is_debug
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The cl_is_debug function returns TRUE if the complib was compiled
Packit 13e616
*  in debug mode, and FALSE otherwise.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
boolean_t cl_is_debug(void);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*    None
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	  TRUE if compiled in debug version. FALSE otherwise.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
#if defined( _DEBUG_ )
Packit 13e616
#ifndef cl_dbg_out
Packit 13e616
/****f* Component Library: Debug Output/cl_dbg_out
Packit 13e616
* NAME
Packit 13e616
*	cl_dbg_out
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The cl_dbg_out function sends a debug message to the debug target in
Packit 13e616
*	debug builds only.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void cl_dbg_out(IN const char *const debug_message, IN ...);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	debug_message
Packit 13e616
*		[in] ANSI string formatted identically as for a call to the standard C
Packit 13e616
*		function printf.
Packit 13e616
*
Packit 13e616
*	...
Packit 13e616
*		[in] Extra parameters for string formatting, as defined for the
Packit 13e616
*		standard C function printf.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	In a release build, cl_dbg_out has no effect.
Packit 13e616
*
Packit 13e616
*	The formatting of the debug_message string is the same as for printf
Packit 13e616
*
Packit 13e616
*	cl_dbg_out sends the debug message to the current debug target.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, cl_msg_out
Packit 13e616
*********/
Packit 13e616
#endif
Packit 13e616
#else
Packit 13e616
static inline void cl_dbg_out(IN const char *const debug_message, IN ...)
Packit 13e616
{
Packit 13e616
	UNUSED_PARAM(debug_message);
Packit 13e616
}
Packit 13e616
#endif				/* defined( _DEBUG_ ) */
Packit 13e616
Packit 13e616
#ifndef cl_msg_out
Packit 13e616
/****f* Component Library: Debug Output/cl_msg_out
Packit 13e616
* NAME
Packit 13e616
*	cl_msg_out
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The cl_msg_out function sends a debug message to the message log target.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void cl_msg_out(IN const char *const message, IN ...);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	message
Packit 13e616
*		[in] ANSI string formatted identically as for a call to the standard C
Packit 13e616
*		function printf.
Packit 13e616
*
Packit 13e616
*	...
Packit 13e616
*		[in] Extra parameters for string formatting, as defined for the
Packit 13e616
*		standard C function printf.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	cl_msg_out is available in both debug and release builds.
Packit 13e616
*
Packit 13e616
*	The formatting of the message string is the same as for printf
Packit 13e616
*
Packit 13e616
*	cl_msg_out sends the message to the current message logging target.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, cl_dbg_out
Packit 13e616
*********/
Packit 13e616
#endif
Packit 13e616
Packit 13e616
/****d* Component Library: Debug Output/Debug Levels
Packit 13e616
* NAME
Packit 13e616
*	Debug Levels
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The debug output macros reserve the upper bit of the debug level to
Packit 13e616
*	convey an error.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
#define	CL_DBG_DISABLE		0
Packit 13e616
#define	CL_DBG_ERROR		0x80000000
Packit 13e616
#define	CL_DBG_ALL		0xFFFFFFFF
Packit 13e616
/*
Packit 13e616
* VALUES
Packit 13e616
*	CL_DBG_DISABLE
Packit 13e616
*		Disable all debug output, including errors.
Packit 13e616
*
Packit 13e616
*	CL_DBG_ERROR
Packit 13e616
*		Enable error debug output.
Packit 13e616
*
Packit 13e616
*	CL_DBG_ALL
Packit 13e616
*		Enbale all debug output.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	Users can define custom debug levels using the lower 31 bits of their
Packit 13e616
*	debug level to control non-error debug output.  Error messages are
Packit 13e616
*	always displayed, regardless of the lower bit definition.
Packit 13e616
*
Packit 13e616
*	When specifying the debug output desired for non-error messages
Packit 13e616
*	(the CHK_LVL parameter in the debug output macros), users must define
Packit 13e616
*	all bits whose output they are interested in.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, CL_PRINT, CL_ENTER, CL_EXIT, CL_TRACE, CL_TRACE_EXIT
Packit 13e616
*********/
Packit 13e616
Packit 13e616
#if defined(_DEBUG_)
Packit 13e616
Packit 13e616
/****d* Component Library: Debug Output/CL_PRINT
Packit 13e616
* NAME
Packit 13e616
*	CL_PRINT
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The CL_PRINT macro sends a string to the current debug target if
Packit 13e616
*	the requested debug level matches the current debug level.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*	CL_PRINT( DBG_LVL, CHK_LVL, STRING );
Packit 13e616
*
Packit 13e616
* PARAMETERS
Packit 13e616
*	DBG_LVL
Packit 13e616
*		[in] Debug level for the string to output
Packit 13e616
*
Packit 13e616
*	CHK_LVL
Packit 13e616
*		[in] Current debug level against which to check DBG_LVL
Packit 13e616
*
Packit 13e616
*	STRING
Packit 13e616
*		[in] String to send to the current debug target.  The string includes
Packit 13e616
*		parentheses in order to allow additional parameters.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This macro does not return a value.
Packit 13e616
*
Packit 13e616
* EXAMPLE
Packit 13e616
*	#define	MY_FUNC_DBG_LVL	1
Packit 13e616
*
Packit 13e616
*	uint32_t	my_dbg_lvl = CL_DBG_ALL;
Packit 13e616
*
Packit 13e616
*	void
Packit 13e616
*	my_func()
Packit 13e616
*	{
Packit 13e616
*		CL_PRINT( MY_FUNC_DBG_LVL, my_dbg_lvl, ("Hello %s!\n", "world") );
Packit 13e616
*	}
Packit 13e616
*
Packit 13e616
* RESULT
Packit 13e616
*	Hello world!
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	The requested string is printed only if all bits set in DBG_LVL are also
Packit 13e616
*	set in CHK_LVL unless the most significant bit is set (indicating an
Packit 13e616
*	error), in which case the lower bits are ignored.  CHK_LVL may have
Packit 13e616
*	additional bits set.
Packit 13e616
*
Packit 13e616
*	In multi-processor environments where the current processor can be
Packit 13e616
*	determined, the zero-based number of the processor on which the output
Packit 13e616
*	is generated is prepended to the output.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, Debug Levels, CL_ENTER, CL_EXIT, CL_TRACE, CL_TRACE_EXIT
Packit 13e616
*********/
Packit 13e616
#define	CL_PRINT( DBG_LVL, CHK_LVL, STRING )				\
Packit 13e616
	{								\
Packit 13e616
	if( DBG_LVL & CL_DBG_ERROR )					\
Packit 13e616
		cl_dbg_out STRING;					\
Packit 13e616
	else if( (DBG_LVL & CHK_LVL) == DBG_LVL )			\
Packit 13e616
		cl_dbg_out STRING;					\
Packit 13e616
	}
Packit 13e616
Packit 13e616
/****d* Component Library: Debug Output/CL_ENTER
Packit 13e616
* NAME
Packit 13e616
*	CL_ENTER
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The CL_ENTER macro marks the entrance into a function by sending a
Packit 13e616
*	string to the current debug target if the requested debug level matches
Packit 13e616
*	the current debug level.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*	CL_ENTER( DBG_LVL, CHK_LVL );
Packit 13e616
*
Packit 13e616
* PARAMETERS
Packit 13e616
*	DBG_LVL
Packit 13e616
*		[in] Debug level for the string to output
Packit 13e616
*
Packit 13e616
*	CHK_LVL
Packit 13e616
*		[in] Current debug level against which to check DBG_LVL
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This macro does not return a value.
Packit 13e616
*
Packit 13e616
* EXAMPLE
Packit 13e616
*	#define __MODULE__	"my_module"
Packit 13e616
*	#define	MY_FUNC_DBG_LVL	1
Packit 13e616
*
Packit 13e616
*	uint32_t	my_dbg_lvl = CL_DBG_ALL;
Packit 13e616
*
Packit 13e616
*	void
Packit 13e616
*	my_func()
Packit 13e616
*	{
Packit 13e616
*		CL_ENTER( MY_FUNC_DBG_LVL, my_dbg_lvl );
Packit 13e616
*		CL_EXIT( MY_FUNC_DBG_LVL, my_dbg_lvl );
Packit 13e616
*	}
Packit 13e616
*
Packit 13e616
* RESULT
Packit 13e616
*	my_module:my_func() [
Packit 13e616
*	my_module:my_func() ]
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	The function entrance notification is printed only if all bits set
Packit 13e616
*	in DBG_LVL are also set in CHK_LVL.  CHK_LVL may have additional bits set.
Packit 13e616
*
Packit 13e616
*	If the __MODULE__ preprocessor keyword is defined, that keyword will be
Packit 13e616
*	prepended to the function name, separated with a colon.
Packit 13e616
*
Packit 13e616
*	In multi-processor environments where the current processor can be
Packit 13e616
*	determined, the zero-based number of the processor on which the output
Packit 13e616
*	is generated is prepended to the output.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, Debug Levels, CL_PRINT, CL_EXIT, CL_TRACE, CL_TRACE_EXIT
Packit 13e616
*********/
Packit 13e616
#define CL_ENTER( DBG_LVL, CHK_LVL )			\
Packit 13e616
	CL_CHK_STK;					\
Packit 13e616
	CL_PRINT( DBG_LVL, CHK_LVL, _CL_DBG_ENTER );
Packit 13e616
Packit 13e616
/****d* Component Library: Debug Output/CL_EXIT
Packit 13e616
* NAME
Packit 13e616
*	CL_EXIT
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The CL_EXIT macro marks the exit from a function by sending a string
Packit 13e616
*	to the current debug target if the requested debug level matches the
Packit 13e616
*	current debug level.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*	CL_EXIT( DBG_LVL, CHK_LVL );
Packit 13e616
*
Packit 13e616
* PARAMETERS
Packit 13e616
*	DBG_LVL
Packit 13e616
*		[in] Debug level for the string to output
Packit 13e616
*
Packit 13e616
*	CHK_LVL
Packit 13e616
*		[in] Current debug level against which to check DBG_LVL
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This macro does not return a value.
Packit 13e616
*
Packit 13e616
* EXAMPLE
Packit 13e616
*	#define __MODULE__	"my_module"
Packit 13e616
*	#define	MY_FUNC_DBG_LVL	1
Packit 13e616
*
Packit 13e616
*	uint32_t	my_dbg_lvl = CL_DBG_ALL;
Packit 13e616
*
Packit 13e616
*	void
Packit 13e616
*	my_func()
Packit 13e616
*	{
Packit 13e616
*		CL_ENTER( MY_FUNC_DBG_LVL, my_dbg_lvl );
Packit 13e616
*		CL_EXIT( MY_FUNC_DBG_LVL, my_dbg_lvl );
Packit 13e616
*	}
Packit 13e616
*
Packit 13e616
* RESULT
Packit 13e616
*	my_module:my_func() [
Packit 13e616
*	my_module:my_func() ]
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	The exit notification is printed only if all bits set in DBG_LVL are also
Packit 13e616
*	set in CHK_LVL.  CHK_LVL may have additional bits set.
Packit 13e616
*
Packit 13e616
*	The CL_EXIT macro must only be used after the CL_ENTRY macro as it
Packit 13e616
*	depends on that macro's implementation.
Packit 13e616
*
Packit 13e616
*	If the __MODULE__ preprocessor keyword is defined, that keyword will be
Packit 13e616
*	prepended to the function name, separated with a colon.
Packit 13e616
*
Packit 13e616
*	In multi-processor environments where the current processor can be
Packit 13e616
*	determined, the zero-based number of the processor on which the output
Packit 13e616
*	is generated is prepended to the output.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, Debug Levels, CL_PRINT, CL_ENTER, CL_TRACE, CL_TRACE_EXIT
Packit 13e616
*********/
Packit 13e616
#define CL_EXIT( DBG_LVL, CHK_LVL )			\
Packit 13e616
	CL_PRINT( DBG_LVL, CHK_LVL, _CL_DBG_EXIT );
Packit 13e616
Packit 13e616
/****d* Component Library: Debug Output/CL_TRACE
Packit 13e616
* NAME
Packit 13e616
*	CL_TRACE
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The CL_TRACE macro sends a string to the current debug target if
Packit 13e616
*	the requested debug level matches the current debug level.  The
Packit 13e616
*	output is prepended with the function name and, depending on the
Packit 13e616
*	debug level requested, an indication of the severity of the message.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*	CL_TRACE( DBG_LVL, CHK_LVL, STRING );
Packit 13e616
*
Packit 13e616
* PARAMETERS
Packit 13e616
*	DBG_LVL
Packit 13e616
*		[in] Debug level for the string to output
Packit 13e616
*
Packit 13e616
*	CHK_LVL
Packit 13e616
*		[in] Current debug level against which to check DBG_LVL
Packit 13e616
*
Packit 13e616
*	STRING
Packit 13e616
*		[in] String to send to the current debug target.  The string includes
Packit 13e616
*		parentheses in order to allow additional parameters.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This macro does not return a value.
Packit 13e616
*
Packit 13e616
* EXAMPLE
Packit 13e616
*	#define __MODULE__	"my_module"
Packit 13e616
*	#define	MY_FUNC_DBG_LVL	1
Packit 13e616
*
Packit 13e616
*	uint32_t	my_dbg_lvl = CL_DBG_ALL;
Packit 13e616
*
Packit 13e616
*	void
Packit 13e616
*	my_func()
Packit 13e616
*	{
Packit 13e616
*		CL_ENTER( MY_FUNC_DBG_LVL, my_dbg_lvl );
Packit 13e616
*		CL_TRACE( MY_FUNC_DBG_LVL, my_dbg_lvl, ("Hello %s!\n", "world") );
Packit 13e616
*		CL_EXIT( MY_FUNC_DBG_LVL, my_dbg_lvl );
Packit 13e616
*	}
Packit 13e616
*
Packit 13e616
* RESULT
Packit 13e616
*	my_module:my_func() [
Packit 13e616
*	my_module:my_func(): Hello world!
Packit 13e616
*	my_module:my_func() ]
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	The requested string is printed only if all bits set in DBG_LVL are also
Packit 13e616
*	set in CHK_LVL.  CHK_LVL may have additional bits set.
Packit 13e616
*
Packit 13e616
*	The CL_TRACE macro must only be used after the CL_ENTRY macro as it
Packit 13e616
*	depends on that macro's implementation.
Packit 13e616
*
Packit 13e616
*	If the DBG_LVL has the upper bit set, the output will contain
Packit 13e616
*	an "!ERROR!" statement between the function name and STRING.
Packit 13e616
*
Packit 13e616
*	If the __MODULE__ preprocessor keyword is defined, that keyword will be
Packit 13e616
*	prepended to the function name, separated with a colon.
Packit 13e616
*
Packit 13e616
*	In multi-processor environments where the current processor can be
Packit 13e616
*	determined, the zero-based number of the processor on which the output
Packit 13e616
*	is generated is prepended to the output.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, Debug Levels, CL_PRINT, CL_ENTER, CL_EXIT, CL_TRACE_EXIT
Packit 13e616
*********/
Packit 13e616
#define CL_TRACE( DBG_LVL, CHK_LVL, STRING )			\
Packit 13e616
{								\
Packit 13e616
switch( DBG_LVL & CL_DBG_ERROR )				\
Packit 13e616
{								\
Packit 13e616
	case CL_DBG_ERROR:					\
Packit 13e616
		CL_PRINT( DBG_LVL, CHK_LVL, _CL_DBG_ERROR );	\
Packit 13e616
		break;						\
Packit 13e616
	default:						\
Packit 13e616
		CL_PRINT( DBG_LVL, CHK_LVL, _CL_DBG_INFO );	\
Packit 13e616
		break;						\
Packit 13e616
}								\
Packit 13e616
CL_PRINT( DBG_LVL, CHK_LVL, STRING );				\
Packit 13e616
}
Packit 13e616
Packit 13e616
/****d* Component Library: Debug Output/CL_TRACE_EXIT
Packit 13e616
* NAME
Packit 13e616
*	CL_TRACE_EXIT
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The CL_TRACE_EXIT macro combines the functionality of the CL_TRACE and
Packit 13e616
*	CL_EXIT macros, in that order.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*	CL_TRACE_EXIT(  DBG_LVL, CHK_LVL, STRING );
Packit 13e616
*
Packit 13e616
* PARAMETERS
Packit 13e616
*	DBG_LVL
Packit 13e616
*		[in] Debug level for the string to output
Packit 13e616
*
Packit 13e616
*	CHK_LVL
Packit 13e616
*		[in] Current debug level against which to check DBG_LVL
Packit 13e616
*
Packit 13e616
*	STRING
Packit 13e616
*		[in] String to send to the current debug target.  The string includes
Packit 13e616
*		parentheses in order to allow additional parameters.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This macro does not return a value.
Packit 13e616
*
Packit 13e616
* EXAMPLE
Packit 13e616
*	#define __MODULE__	"my_module"
Packit 13e616
*	#define	MY_FUNC_DBG_LVL	1
Packit 13e616
*
Packit 13e616
*	uint32_t	my_dbg_lvl = CL_DBG_ALL;
Packit 13e616
*
Packit 13e616
*	void
Packit 13e616
*	my_func()
Packit 13e616
*	{
Packit 13e616
*		CL_ENTER( MY_FUNC_DBG_LVL, my_dbg_lvl );
Packit 13e616
*		CL_TRACE_EXIT( MY_FUNC_DBG_LVL, my_dbg_lvl, ("Hello %s!\n", "world") );
Packit 13e616
*	}
Packit 13e616
*
Packit 13e616
* RESULT
Packit 13e616
*	my_module:my_func() [
Packit 13e616
*	my_module:my_func(): Hello world!
Packit 13e616
*	my_module:my_func() ]
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	The requested string is printed only if all bits set in DBG_LVL are also
Packit 13e616
*	set in CHK_LVL.  CHK_LVL may have additional bits set.
Packit 13e616
*
Packit 13e616
*	The CL_TRACE_EXIT macro must only be used after the CL_ENTRY macro as it
Packit 13e616
*	depends on that macro's implementation.
Packit 13e616
*
Packit 13e616
*	If the DBG_LVL has the upper bit set, the output will contain
Packit 13e616
*	an "!ERROR!" statement between the function name and STRING.
Packit 13e616
*
Packit 13e616
*	If the __MODULE__ preprocessor keyword is defined, that keyword will be
Packit 13e616
*	prepended to the function name, separated with a colon.
Packit 13e616
*
Packit 13e616
*	In multi-processor environments where the current processor can be
Packit 13e616
*	determined, the zero-based number of the processor on which the output
Packit 13e616
*	is generated is prepended to the output.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Debug Output, Debug Levels, CL_PRINT, CL_ENTER, CL_EXIT, CL_TRACE
Packit 13e616
*********/
Packit 13e616
#define CL_TRACE_EXIT( DBG_LVL, CHK_LVL, STRING )		\
Packit 13e616
	CL_TRACE( DBG_LVL, CHK_LVL, STRING );			\
Packit 13e616
	CL_EXIT( DBG_LVL, CHK_LVL );
Packit 13e616
Packit 13e616
#else				/* defined(_DEBUG_) */
Packit 13e616
Packit 13e616
/* Define as NULL macros in a free build. */
Packit 13e616
#define CL_PRINT( DBG_LVL, CHK_LVL, STRING );
Packit 13e616
#define CL_ENTER( DBG_LVL, CHK_LVL );
Packit 13e616
#define CL_EXIT( DBG_LVL, CHK_LVL );
Packit 13e616
#define CL_TRACE( DBG_LVL, CHK_LVL, STRING );
Packit 13e616
#define CL_TRACE_EXIT( DBG_LVL, CHK_LVL, STRING );
Packit 13e616
Packit 13e616
#endif				/* defined(_DEBUG_) */
Packit 13e616
Packit 13e616
/****d* Component Library: Debug Output/64-bit Print Format
Packit 13e616
* NAME
Packit 13e616
*	64-bit Print Format
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The 64-bit print keywords allow users to use 64-bit values in debug or
Packit 13e616
*	console output.
Packit 13e616
*
Packit 13e616
*	Different platforms define 64-bit print formats differently. The 64-bit
Packit 13e616
*	print formats exposed by the component library are supported in all
Packit 13e616
*	platforms.
Packit 13e616
*
Packit 13e616
* VALUES
Packit 13e616
*	PRId64
Packit 13e616
*		Print a 64-bit integer in signed decimal format.
Packit 13e616
*	PRIx64
Packit 13e616
*		Print a 64-bit integer in hexadecimal format.
Packit 13e616
*	PRIo64
Packit 13e616
*		Print a 64-bit integer in octal format.
Packit 13e616
*	PRIu64
Packit 13e616
*		Print a 64-bit integer in unsigned decimal format.
Packit 13e616
*
Packit 13e616
* EXAMPLE
Packit 13e616
*	uint64 MyVal = 2;
Packit 13e616
*	// Print a 64-bit integer in hexadecimal format.
Packit 13e616
*	cl_dbg_out( "MyVal: 0x%" PRIx64 "\n", MyVal );
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	Standard print flags to specify padding and precision can still be used
Packit 13e616
*	following the '%' sign in the string preceding the 64-bit print keyword.
Packit 13e616
*
Packit 13e616
*	The above keywords are strings and make use of compilers' string
Packit 13e616
*	concatenation ability.
Packit 13e616
*********/
Packit 13e616
Packit 13e616
void complib_init(void) __attribute__ ((deprecated));
Packit 13e616
cl_status_t complib_init_v2(void);
Packit 13e616
Packit 13e616
void complib_exit(void);
Packit 13e616
Packit 13e616
END_C_DECLS
Packit 13e616
#endif				/* _CL_DEBUG_H_ */