xref: /illumos-gate/usr/src/cmd/audio/include/libaudio_impl.h (revision 1cb875ae88fb9463b368e725c2444776595895cb)
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_LIBAUDIO_IMPL_H
28 #define	_MULTIMEDIA_LIBAUDIO_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <malloc.h>
33 #include <unistd.h>
34 #include <stdlib.h>
35 #include <sys/types.h>
36 #include <libaudio.h>
37 #include <archdep.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Useful defines
45  *
46  * CALLOC - allocate memory and clear it
47  *		foo = CALLOC(15, char *);		-- alloc 15 ptrs
48  *
49  * MALLOC - allocate memory
50  *		foo = MALLOC(struct foobar);		-- alloc 1 foobar
51  *
52  * REALLOC - re-allocate a larger amount of memory
53  *		foo = REALLOC(foo, 10, struct foo);	-- extend to 10 foos
54  *
55  * FREE - de-allocate memory
56  *
57  * NOTE: These routines all operate on objects they can take the size of,
58  *	 rather than byte counts.
59  *
60  *
61  * XXX - the (long) in the following defines is used to make
62  * XXX   lint shut up about pointer alignment problems.
63  */
64 #define	MALLOC(type)	\
65 	(type *)(long)malloc(sizeof (type))
66 #define	CALLOC(number, type) \
67 	(type *)(long)calloc((unsigned)(number), sizeof (type))
68 #define	REALLOC(ptr, number, type) \
69 	(type *)(long)realloc((char *)(ptr), (unsigned)(number) * sizeof (type))
70 #define	FREE(ptr)	\
71 	(void) free((char *)(ptr))
72 
73 /*
74  * START_C_FUNC - declare this function with C linkage
75  * END_C_FUNC - put at the end of the function
76  */
77 #define	START_C_FUNC	extern "C" {
78 #define	END_C_FUNC	}
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* !_MULTIMEDIA_LIBAUDIO_IMPL_H */
85