xref: /titanic_50/usr/src/uts/common/fs/smbclnt/netsmb/smb_osdep.h (revision 4bff34e37def8a90f9194d81bc345c52ba20086a)
1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
2 
3 /*
4  * Code corresponding to smb_apple.h
5  * XXX: Could merge this into smb_subr.h
6  * as long as that doesn't break smbfs
7  */
8 
9 #ifndef _NETSMB_SMB_OSDEP_H_
10 #define	_NETSMB_SMB_OSDEP_H_
11 
12 #ifndef PRIVSYM
13 #define PRIVSYM
14 #endif
15 
16 #ifndef min
17 #define	min(a, b)	(((a) < (b)) ? (a) : (b))
18 #endif
19 
20 #define	CAST_DOWN(type, addr)  (((type)((uintptr_t)(addr))))
21 #define	USER_ADDR_NULL  ((user_addr_t)0)
22 #define	CAST_USER_ADDR_T(a_ptr)   ((user_addr_t)(a_ptr))
23 
24 /*
25  * flags to (BSD) malloc
26  */
27 #define	M_WAITOK	0x0000
28 #define	M_NOWAIT	0x0001
29 #define	M_ZERO		0x0004		/* bzero the allocation */
30 
31 /* Iconv stuff */
32 
33 /*
34  * Some UTF Related stuff. Will be deleting this once compiled and using
35  * ienup's code.
36  */
37 /*
38  * UTF-8 encode/decode flags
39  */
40 #define	UTF_REVERSE_ENDIAN	0x01    /* reverse UCS-2 byte order */
41 #define	UTF_NO_NULL_TERM	0x02    /* do not add null termination */
42 #define	UTF_DECOMPOSED		0x04    /* generate fully decomposed UCS-2 */
43 #define	UTF_PRECOMPOSED		0x08    /* generate precomposed UCS-2 */
44 
45 /*
46  * These are actually included in sunddi.h. I am getting compilation
47  * errors right now. Adding the induvidual defines here again from sunddi.h
48  * Unicode encoding conversion functions and their macros.
49  */
50 #define	UCONV_IN_BIG_ENDIAN		0x0001
51 #define	UCONV_OUT_BIG_ENDIAN		0x0002
52 #define	UCONV_IN_SYSTEM_ENDIAN		0x0004
53 #define	UCONV_OUT_SYSTEM_ENDIAN		0x0008
54 #define	UCONV_IN_LITTLE_ENDIAN		0x0010
55 #define	UCONV_OUT_LITTLE_ENDIAN		0x0020
56 #define	UCONV_IGNORE_NULL		0x0040
57 #define	UCONV_IN_ACCEPT_BOM		0x0080
58 #define	UCONV_OUT_EMIT_BOM		0x0100
59 
60 extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int);
61 
62 /* Legacy type names for Solaris. */
63 typedef uint64_t u_int64_t;
64 typedef uint32_t u_int32_t;
65 typedef uint16_t u_int16_t;
66 typedef uint8_t u_int8_t;
67 
68 typedef const char * c_caddr_t;
69 typedef uint64_t 	user_addr_t;
70 
71 /*
72  * Time related calls.
73  */
74 
75 /* BEGIN CSTYLED */
76 #define	timespeccmp(tvp, uvp, cmp)                                      \
77 	(((tvp)->tv_sec == (uvp)->tv_sec) ?                             \
78 	((tvp)->tv_nsec cmp (uvp)->tv_nsec) :		               	\
79 	((tvp)->tv_sec cmp (uvp)->tv_sec))
80 /* END CSTYLED */
81 
82 #define	timespecadd(vvp, uvp)						\
83 	{								\
84 		(vvp)->tv_sec += (uvp)->tv_sec;				\
85 		(vvp)->tv_nsec += (uvp)->tv_nsec;			\
86 		if ((vvp)->tv_nsec >= 1000000000) {			\
87 			(vvp)->tv_sec++;				\
88 			(vvp)->tv_nsec -= 1000000000;			\
89 		}							\
90 	}
91 
92 #define	timespecsub(vvp, uvp)                                           \
93 	{								\
94 		(vvp)->tv_sec -= (uvp)->tv_sec;				\
95 		(vvp)->tv_nsec -= (uvp)->tv_nsec;			\
96 		if ((vvp)->tv_nsec < 0) {				\
97 			(vvp)->tv_sec--;				\
98 			(vvp)->tv_nsec += 1000000000;			\
99 		}							\
100 	}
101 
102 #endif /* _NETSMB_SMB_OSDEP_H_ */
103