xref: /illumos-gate/usr/src/lib/smbclnt/libfknsmb/common/sys/sunddi.h (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 #ifndef	_SYS_SUNDDI_H
28 #define	_SYS_SUNDDI_H
29 
30 /*
31  * Sun Specific DDI definitions (fakekernel version)
32  * The real sunddi.h has become a "kitchen sink" full of
33  * includes we don't want, and lots of places include it.
34  * Rather than fight that battle now,  provide this one
35  * with just the str*, mem*, and kiconv* functions.
36  * Some day, re-factor: sunddi.h, systm.h
37  */
38 
39 #include <sys/isa_defs.h>
40 #include <sys/dditypes.h>
41 #include <sys/time.h>
42 #include <sys/cmn_err.h>
43 
44 #include <sys/kmem.h>
45 #include <sys/nvpair.h>
46 #include <sys/thread.h>
47 #include <sys/stream.h>
48 
49 #include <sys/u8_textprep.h>
50 #include <sys/kiconv.h>
51 
52 #ifdef	__cplusplus
53 extern "C" {
54 #endif
55 
56 #define	DDI_SUCCESS	(0)	/* successful return */
57 #define	DDI_FAILURE	(-1)	/* unsuccessful return */
58 
59 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
60 
61 extern char *ddi_strdup(const char *str, int flag);
62 extern char *strdup(const char *str);
63 extern void strfree(char *str);
64 
65 extern size_t strlen(const char *) __PURE;
66 extern size_t strnlen(const char *, size_t) __PURE;
67 extern char *strcpy(char *, const char *);
68 extern char *strncpy(char *, const char *, size_t);
69 
70 /* Need to be consistent with <string.h> C++ definition for strchr() */
71 #if __cplusplus >= 199711L
72 extern const char *strchr(const char *, int);
73 #else
74 extern char *strchr(const char *, int);
75 #endif	/* __cplusplus >= 199711L */
76 
77 #define	DDI_STRSAME(s1, s2)	((*(s1) == *(s2)) && (strcmp((s1), (s2)) == 0))
78 extern int strcmp(const char *, const char *) __PURE;
79 extern int strncmp(const char *, const char *, size_t) __PURE;
80 extern char *strncat(char *, const char *, size_t);
81 extern size_t strlcat(char *, const char *, size_t);
82 extern size_t strlcpy(char *, const char *, size_t);
83 extern size_t strspn(const char *, const char *);
84 extern size_t strcspn(const char *, const char *);
85 extern int bcmp(const void *, const void *, size_t) __PURE;
86 extern int stoi(char **);
87 extern void numtos(ulong_t, char *);
88 extern void bcopy(const void *, void *, size_t);
89 extern void bzero(void *, size_t);
90 
91 extern void *memcpy(void *, const  void  *, size_t);
92 extern void *memset(void *, int, size_t);
93 extern void *memmove(void *, const void *, size_t);
94 extern int memcmp(const void *, const void *, size_t) __PURE;
95 
96 /* Need to be consistent with <string.h> C++ definition for memchr() */
97 #if __cplusplus >= 199711L
98 extern const void *memchr(const void *, int, size_t);
99 #else
100 extern void *memchr(const void *, int, size_t);
101 #endif /* __cplusplus >= 199711L */
102 
103 extern int ddi_strtol(const char *, char **, int, long *);
104 extern int ddi_strtoul(const char *, char **, int, unsigned long *);
105 extern int ddi_strtoll(const char *, char **, int, longlong_t *);
106 extern int ddi_strtoull(const char *, char **, int, u_longlong_t *);
107 
108 extern int ddi_copyin(const void *, void *, size_t, int);
109 extern int ddi_copyout(const void *, void *, size_t, int);
110 
111 /*
112  * kiconv functions and their macros.
113  */
114 #define	KICONV_IGNORE_NULL	(0x0001)
115 #define	KICONV_REPLACE_INVALID	(0x0002)
116 
117 extern kiconv_t kiconv_open(const char *, const char *);
118 extern size_t kiconv(kiconv_t, char **, size_t *, char **, size_t *, int *);
119 extern int kiconv_close(kiconv_t);
120 extern size_t kiconvstr(const char *, const char *, char *, size_t *, char *,
121 	size_t *, int, int *);
122 
123 int
124 ddi_soft_state_init(void **state_p, size_t size, size_t n_items);
125 int
126 ddi_soft_state_zalloc(void *state, int item);
127 void *
128 ddi_get_soft_state(void *state, int item);
129 void
130 ddi_soft_state_free(void *state, int item);
131 void
132 ddi_soft_state_fini(void **state_p);
133 
134 
135 #endif	/* _KERNEL */
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_SUNDDI_H */
142