Home | History | Annotate | Download | only in sys
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright (c) 1992-2001 by Sun Microsystems, Inc.
     24  * All rights reserved.
     25  */
     26 
     27 #ifndef _SYS_AUDIODEBUG_H
     28 #define	_SYS_AUDIODEBUG_H
     29 
     30 #pragma ident	"@(#)audiodebug.h	1.7	05/06/08 SMI"
     31 
     32 /*
     33  * Audio debugging macros
     34  */
     35 
     36 #ifdef __cplusplus
     37 extern "C" {
     38 #endif
     39 
     40 #if defined(AUDIOTRACE) || defined(DBRITRACE)
     41 
     42 #ifndef NAUDIOTRACE
     43 #define	NAUDIOTRACE 1024
     44 #endif
     45 
     46 struct audiotrace {
     47 	int count;
     48 	int function;		/* address of function */
     49 	int trace_action;	/* descriptive 4 characters */
     50 	int object;		/* object operated on */
     51 };
     52 
     53 extern struct audiotrace audiotrace_buffer[];
     54 extern struct audiotrace *audiotrace_ptr;
     55 extern int audiotrace_count;
     56 
     57 #define	ATRACEINIT() {				\
     58 	if (audiotrace_ptr == NULL)		\
     59 		audiotrace_ptr = audiotrace_buffer; \
     60 	}
     61 
     62 #define	LOCK_TRACE()	(uint_t)ddi_enter_critical()
     63 #define	UNLOCK_TRACE(x)	ddi_exit_critical((uint_t)x)
     64 
     65 #if defined(AUDIOTRACE)
     66 #define	ATRACE(func, act, obj) {		\
     67 	int __s = LOCK_TRACE();			\
     68 	int *_p = &audiotrace_ptr->count;	\
     69 	*_p++ = ++audiotrace_count;		\
     70 	*_p++ = (int)(func);			\
     71 	*_p++ = (int)(act);			\
     72 	*_p++ = (int)(obj);			\
     73 	if ((struct audiotrace *)(void *)_p >= &audiotrace_buffer[NAUDIOTRACE])\
     74 		audiotrace_ptr = audiotrace_buffer; \
     75 	else					\
     76 		audiotrace_ptr = (struct audiotrace *)(void *)_p; \
     77 	UNLOCK_TRACE(__s);			\
     78 	}
     79 #else
     80 #define	ATRACE(a, b, c)
     81 #endif
     82 
     83 #if defined(DBRITRACE)
     84 #define	DTRACE(func, act, obj) {		\
     85 	int __s = LOCK_TRACE();			\
     86 	int *_p = &audiotrace_ptr->count;	\
     87 	*_p++ = ++audiotrace_count;		\
     88 	*_p++ = (int)(func);			\
     89 	*_p++ = (int)(act);			\
     90 	*_p++ = (int)(obj);			\
     91 	if ((struct audiotrace *)(void *)_p >= &audiotrace_buffer[NAUDIOTRACE])\
     92 		audiotrace_ptr = audiotrace_buffer; \
     93 	else					\
     94 		audiotrace_ptr = (struct audiotrace *)(void *)_p; \
     95 	UNLOCK_TRACE(__s);			\
     96 	}
     97 #else
     98 #define	DTRACE(a, b, c)
     99 #endif
    100 
    101 #else	/* !AUDIOTRACE */
    102 
    103 /* If no tracing, define no-ops */
    104 #define	ATRACEINIT()
    105 #define	ATRACE(a, b, c)
    106 #define	DTRACE(a, b, c)
    107 
    108 #endif	/* !AUDIOTRACE */
    109 
    110 #ifdef __cplusplus
    111 }
    112 #endif
    113 
    114 #endif	/* _SYS_AUDIODEBUG_H */
    115