]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/ndr.h
2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
32 unsigned char mig_vers
;
33 unsigned char if_vers
;
34 unsigned char reserved1
;
35 unsigned char mig_encoding
;
36 unsigned char int_rep
;
37 unsigned char char_rep
;
38 unsigned char float_rep
;
39 unsigned char reserved2
;
43 * MIG supported protocols for Network Data Representation
45 #define NDR_PROTOCOL_2_0 0
48 * NDR 2.0 format flag type definition and values.
50 #define NDR_INT_BIG_ENDIAN 0
51 #define NDR_INT_LITTLE_ENDIAN 1
52 #define NDR_FLOAT_IEEE 0
53 #define NDR_FLOAT_VAX 1
54 #define NDR_FLOAT_CRAY 2
55 #define NDR_FLOAT_IBM 3
56 #define NDR_CHAR_ASCII 0
57 #define NDR_CHAR_EBCDIC 1
59 extern NDR_record_t NDR_record
;
61 #ifndef __NDR_convert__
62 #define __NDR_convert__ 1
63 #endif /* __NDR_convert__ */
65 #ifndef __NDR_convert__int_rep__
66 #define __NDR_convert__int_rep__ 1
67 #endif /* __NDR_convert__int_rep__ */
69 #ifndef __NDR_convert__char_rep__
70 #define __NDR_convert__char_rep__ 0
71 #endif /* __NDR_convert__char_rep__ */
73 #ifndef __NDR_convert__float_rep__
74 #define __NDR_convert__float_rep__ 0
75 #endif /* __NDR_convert__float_rep__ */
79 #define __NDR_convert__NOOP do ; while (0)
80 #define __NDR_convert__UNKNOWN(s) __NDR_convert__NOOP
81 #define __NDR_convert__SINGLE(a, f, r) do { r((a), (f)); } while (0)
82 #define __NDR_convert__ARRAY(a, f, c, r) \
83 do { int __i__, __C__ = (c); \
84 for (__i__ = 0; __i__ < __C__; __i__++) \
85 r(&(a)[__i__], f); } while (0)
86 #define __NDR_convert__2DARRAY(a, f, s, c, r) \
87 do { int __i__, __C__ = (c), __S__ = (s); \
88 for (__i__ = 0; __i__ < __C__; __i__++) \
89 r(&(a)[__i__ * __S__], f, __S__); } while (0)
91 #if __NDR_convert__int_rep__
93 #include <libkern/OSByteOrder.h>
95 #define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0)
97 #define __NDR_READSWAP__uint16_t(a) OSReadSwapInt16((void *)a, 0)
98 #define __NDR_READSWAP__int16_t(a) (int16_t)OSReadSwapInt16((void *)a, 0)
99 #define __NDR_READSWAP__uint32_t(a) OSReadSwapInt32((void *)a, 0)
100 #define __NDR_READSWAP__int32_t(a) (int32_t)OSReadSwapInt32((void *)a, 0)
101 #define __NDR_READSWAP__uint64_t(a) OSReadSwapInt64((void *)a, 0)
102 #define __NDR_READSWAP__int64_t(a) (int64_t)OSReadSwapInt64((void *)a, 0)
104 static __inline__
float __NDR_READSWAP__float(float *argp
) {
109 result
.ull
= __NDR_READSWAP__uint32_t((uint32_t *)argp
);
113 static __inline__
double __NDR_READSWAP__double(double *argp
) {
118 result
.ull
= __NDR_READSWAP__uint64_t((uint64_t *)argp
);
122 #define __NDR_convert__int_rep__int16_t__defined
123 #define __NDR_convert__int_rep__int16_t(v,f) \
124 __NDR_READSWAP_assign(v, __NDR_READSWAP__int16_t)
126 #define __NDR_convert__int_rep__uint16_t__defined
127 #define __NDR_convert__int_rep__uint16_t(v,f) \
128 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint16_t)
130 #define __NDR_convert__int_rep__int32_t__defined
131 #define __NDR_convert__int_rep__int32_t(v,f) \
132 __NDR_READSWAP_assign(v, __NDR_READSWAP__int32_t)
134 #define __NDR_convert__int_rep__uint32_t__defined
135 #define __NDR_convert__int_rep__uint32_t(v,f) \
136 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint32_t)
138 #define __NDR_convert__int_rep__int64_t__defined
139 #define __NDR_convert__int_rep__int64_t(v,f) \
140 __NDR_READSWAP_assign(v, __NDR_READSWAP__int64_t)
142 #define __NDR_convert__int_rep__uint64_t__defined
143 #define __NDR_convert__int_rep__uint64_t(v,f) \
144 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint64_t)
146 #define __NDR_convert__int_rep__float__defined
147 #define __NDR_convert__int_rep__float(v,f) \
148 __NDR_READSWAP_assign(v, __NDR_READSWAP__float)
150 #define __NDR_convert__int_rep__double__defined
151 #define __NDR_convert__int_rep__double(v,f) \
152 __NDR_READSWAP_assign(v, __NDR_READSWAP__double)
154 #define __NDR_convert__int_rep__boolean_t__defined
155 #define __NDR_convert__int_rep__boolean_t(v, f) \
156 __NDR_convert__int_rep__int32_t(v,f)
158 #define __NDR_convert__int_rep__kern_return_t__defined
159 #define __NDR_convert__int_rep__kern_return_t(v,f) \
160 __NDR_convert__int_rep__int32_t(v,f)
162 #define __NDR_convert__int_rep__mach_port_name_t__defined
163 #define __NDR_convert__int_rep__mach_port_name_t(v,f) \
164 __NDR_convert__int_rep__uint32_t(v,f)
166 #define __NDR_convert__int_rep__mach_msg_type_number_t__defined
167 #define __NDR_convert__int_rep__mach_msg_type_number_t(v,f) \
168 __NDR_convert__int_rep__uint32_t(v,f)
170 #endif /* __NDR_convert__int_rep__ */
172 #if __NDR_convert__char_rep__
174 #warning NDR character representation conversions not implemented yet!
175 #define __NDR_convert__char_rep__char(v,f) __NDR_convert__NOOP
176 #define __NDR_convert__char_rep__string(v,f,l) __NDR_convert__NOOP
178 #endif /* __NDR_convert__char_rep__ */
180 #if __NDR_convert__float_rep__
182 #warning NDR floating point representation conversions not implemented yet!
183 #define __NDR_convert__float_rep__float(v,f) __NDR_convert__NOOP
184 #define __NDR_convert__float_rep__double(v,f) __NDR_convert__NOOP
186 #endif /* __NDR_convert__float_rep__ */
188 #endif /* __NDR_convert__ */
190 #endif /* _MACH_NDR_H_ */