]>
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_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
36 #include <sys/cdefs.h>
39 unsigned char mig_vers
;
40 unsigned char if_vers
;
41 unsigned char reserved1
;
42 unsigned char mig_encoding
;
43 unsigned char int_rep
;
44 unsigned char char_rep
;
45 unsigned char float_rep
;
46 unsigned char reserved2
;
50 * MIG supported protocols for Network Data Representation
52 #define NDR_PROTOCOL_2_0 0
55 * NDR 2.0 format flag type definition and values.
57 #define NDR_INT_BIG_ENDIAN 0
58 #define NDR_INT_LITTLE_ENDIAN 1
59 #define NDR_FLOAT_IEEE 0
60 #define NDR_FLOAT_VAX 1
61 #define NDR_FLOAT_CRAY 2
62 #define NDR_FLOAT_IBM 3
63 #define NDR_CHAR_ASCII 0
64 #define NDR_CHAR_EBCDIC 1
66 extern NDR_record_t NDR_record
;
68 #ifndef __NDR_convert__
69 #define __NDR_convert__ 1
70 #endif /* __NDR_convert__ */
72 #ifndef __NDR_convert__int_rep__
73 #define __NDR_convert__int_rep__ 1
74 #endif /* __NDR_convert__int_rep__ */
76 #ifndef __NDR_convert__char_rep__
77 #define __NDR_convert__char_rep__ 0
78 #endif /* __NDR_convert__char_rep__ */
80 #ifndef __NDR_convert__float_rep__
81 #define __NDR_convert__float_rep__ 0
82 #endif /* __NDR_convert__float_rep__ */
86 #define __NDR_convert__NOOP do ; while (0)
87 #define __NDR_convert__UNKNOWN(s) __NDR_convert__NOOP
88 #define __NDR_convert__SINGLE(a, f, r) do { r((a), (f)); } while (0)
89 #define __NDR_convert__ARRAY(a, f, c, r) \
90 do { int __i__, __C__ = (c); \
91 for (__i__ = 0; __i__ < __C__; __i__++) \
92 r(&(a)[__i__], f); } while (0)
93 #define __NDR_convert__2DARRAY(a, f, s, c, r) \
94 do { int __i__, __C__ = (c), __S__ = (s); \
95 for (__i__ = 0; __i__ < __C__; __i__++) \
96 r(&(a)[__i__ * __S__], f, __S__); } while (0)
98 #if __NDR_convert__int_rep__
100 #include <libkern/OSByteOrder.h>
102 #define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0)
104 #define __NDR_READSWAP__uint16_t(a) OSReadSwapInt16((void *)a, 0)
105 #define __NDR_READSWAP__int16_t(a) (int16_t)OSReadSwapInt16((void *)a, 0)
106 #define __NDR_READSWAP__uint32_t(a) OSReadSwapInt32((void *)a, 0)
107 #define __NDR_READSWAP__int32_t(a) (int32_t)OSReadSwapInt32((void *)a, 0)
108 #define __NDR_READSWAP__uint64_t(a) OSReadSwapInt64((void *)a, 0)
109 #define __NDR_READSWAP__int64_t(a) (int64_t)OSReadSwapInt64((void *)a, 0)
113 static __inline__
float __NDR_READSWAP__float(float *argp
) {
118 result
.ull
= __NDR_READSWAP__uint32_t((uint32_t *)argp
);
122 static __inline__
double __NDR_READSWAP__double(double *argp
) {
127 result
.ull
= __NDR_READSWAP__uint64_t((uint64_t *)argp
);
133 #define __NDR_convert__int_rep__int16_t__defined
134 #define __NDR_convert__int_rep__int16_t(v,f) \
135 __NDR_READSWAP_assign(v, __NDR_READSWAP__int16_t)
137 #define __NDR_convert__int_rep__uint16_t__defined
138 #define __NDR_convert__int_rep__uint16_t(v,f) \
139 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint16_t)
141 #define __NDR_convert__int_rep__int32_t__defined
142 #define __NDR_convert__int_rep__int32_t(v,f) \
143 __NDR_READSWAP_assign(v, __NDR_READSWAP__int32_t)
145 #define __NDR_convert__int_rep__uint32_t__defined
146 #define __NDR_convert__int_rep__uint32_t(v,f) \
147 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint32_t)
149 #define __NDR_convert__int_rep__int64_t__defined
150 #define __NDR_convert__int_rep__int64_t(v,f) \
151 __NDR_READSWAP_assign(v, __NDR_READSWAP__int64_t)
153 #define __NDR_convert__int_rep__uint64_t__defined
154 #define __NDR_convert__int_rep__uint64_t(v,f) \
155 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint64_t)
157 #define __NDR_convert__int_rep__float__defined
158 #define __NDR_convert__int_rep__float(v,f) \
159 __NDR_READSWAP_assign(v, __NDR_READSWAP__float)
161 #define __NDR_convert__int_rep__double__defined
162 #define __NDR_convert__int_rep__double(v,f) \
163 __NDR_READSWAP_assign(v, __NDR_READSWAP__double)
165 #define __NDR_convert__int_rep__boolean_t__defined
166 #define __NDR_convert__int_rep__boolean_t(v, f) \
167 __NDR_convert__int_rep__int32_t(v,f)
169 #define __NDR_convert__int_rep__kern_return_t__defined
170 #define __NDR_convert__int_rep__kern_return_t(v,f) \
171 __NDR_convert__int_rep__int32_t(v,f)
173 #define __NDR_convert__int_rep__mach_port_name_t__defined
174 #define __NDR_convert__int_rep__mach_port_name_t(v,f) \
175 __NDR_convert__int_rep__uint32_t(v,f)
177 #define __NDR_convert__int_rep__mach_msg_type_number_t__defined
178 #define __NDR_convert__int_rep__mach_msg_type_number_t(v,f) \
179 __NDR_convert__int_rep__uint32_t(v,f)
181 #endif /* __NDR_convert__int_rep__ */
183 #if __NDR_convert__char_rep__
185 #warning NDR character representation conversions not implemented yet!
186 #define __NDR_convert__char_rep__char(v,f) __NDR_convert__NOOP
187 #define __NDR_convert__char_rep__string(v,f,l) __NDR_convert__NOOP
189 #endif /* __NDR_convert__char_rep__ */
191 #if __NDR_convert__float_rep__
193 #warning NDR floating point representation conversions not implemented yet!
194 #define __NDR_convert__float_rep__float(v,f) __NDR_convert__NOOP
195 #define __NDR_convert__float_rep__double(v,f) __NDR_convert__NOOP
197 #endif /* __NDR_convert__float_rep__ */
199 #endif /* __NDR_convert__ */
201 #endif /* _MACH_NDR_H_ */