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