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