xref: /titanic_41/usr/src/cmd/audio/include/audio_types.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 _MULTIMEDIA_AUDIO_TYPES_H
28 #define	_MULTIMEDIA_AUDIO_TYPES_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * NOTE: The following is the contents of c_varieties.h. We'll use the
38  * _C_VARIETIES_H header guard so there's no conflict if c_varieties.h
39  * is also included.  The C_VARIETIES_H header guard is in <xview/xv_c_types.h>
40  */
41 #ifndef	_C_VARIETIES_H
42 #define	_C_VARIETIES_H
43 #ifndef	C_VARIETIES_H
44 #define	C_VARIETIES_H
45 
46 /*
47  *	This file defines some macros that are used to make code
48  *	portable among the major C dialects currently in use at
49  *	Sun.  As of 12/90, these include Sun C (a lot like K&R C),
50  *	ANSI C, and C++.
51  *
52  * external functions:
53  *	To declare an external function, invoke the EXTERN_FUNCTION
54  *	macro; the macro's first parameter should be the function's
55  *	return type and function name, and the second macro parameter
56  *	should be the parenthesized list of function arguments (or an
57  *	ellipsis - DOTDOTDOT macro should be used to indicate the
58  *      ellipsis as explained later in this file - if the arguments are
59  *      unspecified or of varying number or type, or the uppercase word
60  *      "_VOID_" if the function takes no arguments).  Some examples:
61  *
62  *	    EXTERN_FUNCTION( void printf, (char *, DOTDOTDOT) );
63  *	    EXTERN_FUNCTION( int fread, (char*, int, int, FILE*) );
64  *	    EXTERN_FUNCTION( int getpid, (_VOID_) );
65  *
66  *	Note that to be ANSI-C conformant, one should put "," at the end
67  *	first argument of printf() declaration.
68  *
69  * structure tags:
70  *	In order to handle cases where a structure tag has the same name
71  *	as a type, the STRUCT_TAG macro makes the tag disappear in C++.
72  *	An example (from <sys/types.h>):
73  *
74  *	    typedef struct STRUCT_TAG(fd_set) { ... } fd_set;
75  *
76  * enum bitfields:
77  *	In K&R C as interpreted at UCB, bitfields may be declared to
78  *	be of an enumerated type.  Neither ANSI C nor C++ permit this,
79  *	so the ENUM_BITFIELD macro replaces the enum declaration with
80  *	"unsigned".   An example (from <sunwindow/attr.h>):
81  *
82  *	    struct {
83  *		ENUM_BITFIELD( Attr_pkg )	pkg		: 8;
84  *		unsigned			ordinal		: 8;
85  *		ENUM_BITFIELD( Attr_list_type )	list_type	: 8;
86  *		...
87  *	    };
88  *
89  * enum type specifier:
90  *	In K&R C, it is OK to use "enum xyz" as return type but in C++,
91  * 	one should use "xyz".  ENUM_TYPE macro is used to handle this.
92  *
93  *		ENUM_TYPE(enum, xyz) (*func) (...);
94  *
95  * "struct s s;":
96  *	C++ does not allow this sort of name conflict, since struct tags are
97  *	in the same namespace as variables.  In this case, we use the
98  *	NAME_CONFLICT macro to prepend (for C++) an underscore to the
99  *	variable (or struct member) name.  E.g. from <pixrect/pixrect.h>:
100  *
101  *	    typedef struct pixrect {
102  *		struct	pixrectops *pr_ops;
103  *		struct	pr_size NAME_CONFLICT(pr_size);
104  *	    } Pixrect;
105  *	    #define pr_height	NAME_CONFLICT(pr_size).y
106  *	    #define pr_width	NAME_CONFLICT(pr_size).x
107  *
108  *	Note that no spaces are allowed within the parentheses in the
109  *	invocation of NAME_CONFLICT.
110  *
111  * Pointers to functions declared as struct members:
112  *	Instead of getting picky about the types expected by struct
113  *	members which are pointers to functions, we use DOTDOTDOT to
114  *	tell C++ not to be so uptight:
115  *
116  *	    struct pixrectops {
117  *		    int	(*pro_rop)( DOTDOTDOT );
118  *		    int	(*pro_stencil)( DOTDOTDOT );
119  *		    int	(*pro_batchrop)( DOTDOTDOT );
120  *		    . . .
121  *	    };
122  *
123  */
124 
125 /* Which type of C/C++ compiler are we using? */
126 
127 #if defined(__cplusplus)
128 	/*
129 	 * Definitions for C++ 2.0 and later require extern "C" { decl; }
130 	 */
131 #define	EXTERN_FUNCTION(rtn, args) extern "C" { rtn args; }
132 #define	STRUCT_TAG(tag_name) /* the tag disappears */
133 #define	ENUM_BITFIELD(enum_type) unsigned
134 #define	ENUM_TYPE(enum_sp, enum_ty) enum_ty
135 
136 #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
137 #define	NAME_CONFLICT(name) _##name
138 #else
139 #define	NAME_CONFLICT(name) _**name
140 #endif
141 
142 #define	DOTDOTDOT ...
143 #define	_VOID_ /* anachronism */
144 #define	CONST const
145 
146 /*
147  * This is not necessary for 2.0 since 2.0 has corrected the void (*) () problem
148  */
149 typedef void (*_PFV_)();
150 typedef int (*_PFI_)();
151 
152 #elif defined(c_plusplus)
153 /*
154  * Definitions for C++ 1.2
155  */
156 #define	EXTERN_FUNCTION(rtn, args) rtn args
157 #define	STRUCT_TAG(tag_name)  /* the tag disappears */
158 #define	ENUM_BITFIELD(enum_type) unsigned
159 #define	ENUM_TYPE(enum_sp, enum_ty) enum_ty
160 #define	NAME_CONFLICT(name) _**name
161 #define	DOTDOTDOT ...
162 #define	_VOID_ /* anachronism */
163 #define	CONST const
164 
165 typedef void (*_PFV_)();
166 typedef int (*_PFI_)();
167 
168 #elif defined(__STDC__)
169 	/*
170 	 * Definitions for ANSI C
171 	 */
172 #define	EXTERN_FUNCTION(rtn, args) rtn args
173 #define	STRUCT_TAG(tag_name) tag_name
174 #define	ENUM_BITFIELD(enum_type) unsigned
175 #define	ENUM_TYPE(enum_sp, enum_ty) enum_sp enum_ty
176 #define	NAME_CONFLICT(name) name
177 #define	DOTDOTDOT ...
178 #define	_VOID_ void
179 #define	CONST
180 
181 #else
182 	/*
183 	 * Definitions for Sun/K&R C -- ignore function prototypes,
184 	 * but preserve tag names and enum bitfield declarations.
185 	 */
186 #define	EXTERN_FUNCTION(rtn, args) rtn()
187 #define	STRUCT_TAG(tag_name) tag_name
188 #define	ENUM_BITFIELD(enum_type) enum_type
189 #define	ENUM_TYPE(enum_sp, enum_ty) enum_sp enum_ty
190 #define	NAME_CONFLICT(name) name
191 #define	DOTDOTDOT
192 #define	_VOID_
193 	/* VOID is only used where it disappears anyway */
194 #define	CONST
195 
196 #endif /* Which type of C/C++ compiler are we using? */
197 
198 #endif /* !C_VARIETIES_H */
199 #endif /* !_C_VARIETIES_H */
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 
205 #endif /* !_MULTIMEDIA_AUDIO_TYPES_H */
206