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