xref: /illumos-gate/usr/src/common/devid/devid_impl.h (revision 440a8a36792bdf9ef51639066aab0b7771ffcab8)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_DEVID_IMPL_H
28 #define	_DEVID_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifndef	TRUE
37 #define	TRUE 1
38 #endif	/* TRUE */
39 
40 #ifndef	FALSE
41 #define	FALSE 0
42 #endif	/* FALSE */
43 
44 /*
45  * Macros to make kernel and library code identical.
46  *
47  * NOTE: to get ddi_ entrypoints to show up in cscope, DEVID_FUNC
48  * is NOT used in function definitions.
49  */
50 #ifdef	_KERNEL
51 #include <sys/kmem.h>
52 #include <sys/sunddi.h>
53 
54 #define	DEVID_MALLOC(n)		kmem_alloc(n, KM_SLEEP)
55 #define	DEVID_FREE(x, n)	kmem_free(x, n)
56 #define	DEVID_FUNC(x)		ddi_##x
57 #define	DEVID_ASSERT(x)		ASSERT(x)
58 #define	DEVID_SUCCESS		DDI_SUCCESS
59 #define	DEVID_FAILURE		DDI_FAILURE
60 #define	DEVID_RETRY		DDI_NOT_WELL_FORMED
61 #define	DEVID_RET_VALID		DDI_SUCCESS
62 #define	DEVID_RET_INVALID	DDI_FAILURE
63 #else	/* !_KERNEL */
64 #include <stdlib.h>
65 #include <strings.h>
66 #include <devid.h>
67 
68 #define	DEVID_MALLOC(n)		malloc(n)
69 #define	DEVID_FREE(x, n)	free(x)
70 #define	DEVID_FUNC(x)		x
71 #define	DEVID_ASSERT(x)
72 #define	DEVID_SUCCESS		0
73 #define	DEVID_FAILURE		-1
74 #define	DEVID_RETRY		-2
75 #define	DEVID_RET_VALID		1
76 #define	DEVID_RET_INVALID	0
77 #endif  /* _KERNEL */
78 
79 #ifdef	__cplusplus
80 }
81 #endif
82 
83 #endif	/* _DEVID_IMPL_H */
84