]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/ndr.h
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
38 #include <sys/cdefs.h>
41 unsigned char mig_vers
;
42 unsigned char if_vers
;
43 unsigned char reserved1
;
44 unsigned char mig_encoding
;
45 unsigned char int_rep
;
46 unsigned char char_rep
;
47 unsigned char float_rep
;
48 unsigned char reserved2
;
52 * MIG supported protocols for Network Data Representation
54 #define NDR_PROTOCOL_2_0 0
57 * NDR 2.0 format flag type definition and values.
59 #define NDR_INT_BIG_ENDIAN 0
60 #define NDR_INT_LITTLE_ENDIAN 1
61 #define NDR_FLOAT_IEEE 0
62 #define NDR_FLOAT_VAX 1
63 #define NDR_FLOAT_CRAY 2
64 #define NDR_FLOAT_IBM 3
65 #define NDR_CHAR_ASCII 0
66 #define NDR_CHAR_EBCDIC 1
68 extern NDR_record_t NDR_record
;
70 #ifndef __NDR_convert__
71 #define __NDR_convert__ 1
72 #endif /* __NDR_convert__ */
74 #ifndef __NDR_convert__int_rep__
75 #define __NDR_convert__int_rep__ 1
76 #endif /* __NDR_convert__int_rep__ */
78 #ifndef __NDR_convert__char_rep__
79 #define __NDR_convert__char_rep__ 0
80 #endif /* __NDR_convert__char_rep__ */
82 #ifndef __NDR_convert__float_rep__
83 #define __NDR_convert__float_rep__ 0
84 #endif /* __NDR_convert__float_rep__ */
88 #define __NDR_convert__NOOP do ; while (0)
89 #define __NDR_convert__UNKNOWN(s) __NDR_convert__NOOP
90 #define __NDR_convert__SINGLE(a, f, r) do { r((a), (f)); } while (0)
91 #define __NDR_convert__ARRAY(a, f, c, r) \
92 do { int __i__, __C__ = (c); \
93 for (__i__ = 0; __i__ < __C__; __i__++) \
94 r(&(a)[__i__], f); } while (0)
95 #define __NDR_convert__2DARRAY(a, f, s, c, r) \
96 do { int __i__, __C__ = (c), __S__ = (s); \
97 for (__i__ = 0; __i__ < __C__; __i__++) \
98 r(&(a)[__i__ * __S__], f, __S__); } while (0)
100 #if __NDR_convert__int_rep__
102 #include <libkern/OSByteOrder.h>
104 #define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0)
106 #define __NDR_READSWAP__uint16_t(a) OSReadSwapInt16((void *)a, 0)
107 #define __NDR_READSWAP__int16_t(a) (int16_t)OSReadSwapInt16((void *)a, 0)
108 #define __NDR_READSWAP__uint32_t(a) OSReadSwapInt32((void *)a, 0)
109 #define __NDR_READSWAP__int32_t(a) (int32_t)OSReadSwapInt32((void *)a, 0)
110 #define __NDR_READSWAP__uint64_t(a) OSReadSwapInt64((void *)a, 0)
111 #define __NDR_READSWAP__int64_t(a) (int64_t)OSReadSwapInt64((void *)a, 0)
115 static __inline__
float __NDR_READSWAP__float(float *argp
) {
120 result
.ull
= __NDR_READSWAP__uint32_t((uint32_t *)argp
);
124 static __inline__
double __NDR_READSWAP__double(double *argp
) {
129 result
.ull
= __NDR_READSWAP__uint64_t((uint64_t *)argp
);
135 #define __NDR_convert__int_rep__int16_t__defined
136 #define __NDR_convert__int_rep__int16_t(v,f) \
137 __NDR_READSWAP_assign(v, __NDR_READSWAP__int16_t)
139 #define __NDR_convert__int_rep__uint16_t__defined
140 #define __NDR_convert__int_rep__uint16_t(v,f) \
141 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint16_t)
143 #define __NDR_convert__int_rep__int32_t__defined
144 #define __NDR_convert__int_rep__int32_t(v,f) \
145 __NDR_READSWAP_assign(v, __NDR_READSWAP__int32_t)
147 #define __NDR_convert__int_rep__uint32_t__defined
148 #define __NDR_convert__int_rep__uint32_t(v,f) \
149 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint32_t)
151 #define __NDR_convert__int_rep__int64_t__defined
152 #define __NDR_convert__int_rep__int64_t(v,f) \
153 __NDR_READSWAP_assign(v, __NDR_READSWAP__int64_t)
155 #define __NDR_convert__int_rep__uint64_t__defined
156 #define __NDR_convert__int_rep__uint64_t(v,f) \
157 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint64_t)
159 #define __NDR_convert__int_rep__float__defined
160 #define __NDR_convert__int_rep__float(v,f) \
161 __NDR_READSWAP_assign(v, __NDR_READSWAP__float)
163 #define __NDR_convert__int_rep__double__defined
164 #define __NDR_convert__int_rep__double(v,f) \
165 __NDR_READSWAP_assign(v, __NDR_READSWAP__double)
167 #define __NDR_convert__int_rep__boolean_t__defined
168 #define __NDR_convert__int_rep__boolean_t(v, f) \
169 __NDR_convert__int_rep__int32_t(v,f)
171 #define __NDR_convert__int_rep__kern_return_t__defined
172 #define __NDR_convert__int_rep__kern_return_t(v,f) \
173 __NDR_convert__int_rep__int32_t(v,f)
175 #define __NDR_convert__int_rep__mach_port_name_t__defined
176 #define __NDR_convert__int_rep__mach_port_name_t(v,f) \
177 __NDR_convert__int_rep__uint32_t(v,f)
179 #define __NDR_convert__int_rep__mach_msg_type_number_t__defined
180 #define __NDR_convert__int_rep__mach_msg_type_number_t(v,f) \
181 __NDR_convert__int_rep__uint32_t(v,f)
183 #endif /* __NDR_convert__int_rep__ */
185 #if __NDR_convert__char_rep__
187 #warning NDR character representation conversions not implemented yet!
188 #define __NDR_convert__char_rep__char(v,f) __NDR_convert__NOOP
189 #define __NDR_convert__char_rep__string(v,f,l) __NDR_convert__NOOP
191 #endif /* __NDR_convert__char_rep__ */
193 #if __NDR_convert__float_rep__
195 #warning NDR floating point representation conversions not implemented yet!
196 #define __NDR_convert__float_rep__float(v,f) __NDR_convert__NOOP
197 #define __NDR_convert__float_rep__double(v,f) __NDR_convert__NOOP
199 #endif /* __NDR_convert__float_rep__ */
201 #endif /* __NDR_convert__ */
203 #endif /* _MACH_NDR_H_ */