]>
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_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@
30 #include <sys/cdefs.h>
33 unsigned char mig_vers
;
34 unsigned char if_vers
;
35 unsigned char reserved1
;
36 unsigned char mig_encoding
;
37 unsigned char int_rep
;
38 unsigned char char_rep
;
39 unsigned char float_rep
;
40 unsigned char reserved2
;
44 * MIG supported protocols for Network Data Representation
46 #define NDR_PROTOCOL_2_0 0
49 * NDR 2.0 format flag type definition and values.
51 #define NDR_INT_BIG_ENDIAN 0
52 #define NDR_INT_LITTLE_ENDIAN 1
53 #define NDR_FLOAT_IEEE 0
54 #define NDR_FLOAT_VAX 1
55 #define NDR_FLOAT_CRAY 2
56 #define NDR_FLOAT_IBM 3
57 #define NDR_CHAR_ASCII 0
58 #define NDR_CHAR_EBCDIC 1
60 extern NDR_record_t NDR_record
;
62 #ifndef __NDR_convert__
63 #define __NDR_convert__ 1
64 #endif /* __NDR_convert__ */
66 #ifndef __NDR_convert__int_rep__
67 #define __NDR_convert__int_rep__ 1
68 #endif /* __NDR_convert__int_rep__ */
70 #ifndef __NDR_convert__char_rep__
71 #define __NDR_convert__char_rep__ 0
72 #endif /* __NDR_convert__char_rep__ */
74 #ifndef __NDR_convert__float_rep__
75 #define __NDR_convert__float_rep__ 0
76 #endif /* __NDR_convert__float_rep__ */
80 #define __NDR_convert__NOOP do ; while (0)
81 #define __NDR_convert__UNKNOWN(s) __NDR_convert__NOOP
82 #define __NDR_convert__SINGLE(a, f, r) do { r((a), (f)); } while (0)
83 #define __NDR_convert__ARRAY(a, f, c, r) \
84 do { int __i__, __C__ = (c); \
85 for (__i__ = 0; __i__ < __C__; __i__++) \
86 r(&(a)[__i__], f); } while (0)
87 #define __NDR_convert__2DARRAY(a, f, s, c, r) \
88 do { int __i__, __C__ = (c), __S__ = (s); \
89 for (__i__ = 0; __i__ < __C__; __i__++) \
90 r(&(a)[__i__ * __S__], f, __S__); } while (0)
92 #if __NDR_convert__int_rep__
94 #include <libkern/OSByteOrder.h>
96 #define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0)
98 #define __NDR_READSWAP__uint16_t(a) OSReadSwapInt16((void *)a, 0)
99 #define __NDR_READSWAP__int16_t(a) (int16_t)OSReadSwapInt16((void *)a, 0)
100 #define __NDR_READSWAP__uint32_t(a) OSReadSwapInt32((void *)a, 0)
101 #define __NDR_READSWAP__int32_t(a) (int32_t)OSReadSwapInt32((void *)a, 0)
102 #define __NDR_READSWAP__uint64_t(a) OSReadSwapInt64((void *)a, 0)
103 #define __NDR_READSWAP__int64_t(a) (int64_t)OSReadSwapInt64((void *)a, 0)
107 static __inline__
float __NDR_READSWAP__float(float *argp
) {
112 result
.ull
= __NDR_READSWAP__uint32_t((uint32_t *)argp
);
116 static __inline__
double __NDR_READSWAP__double(double *argp
) {
121 result
.ull
= __NDR_READSWAP__uint64_t((uint64_t *)argp
);
127 #define __NDR_convert__int_rep__int16_t__defined
128 #define __NDR_convert__int_rep__int16_t(v,f) \
129 __NDR_READSWAP_assign(v, __NDR_READSWAP__int16_t)
131 #define __NDR_convert__int_rep__uint16_t__defined
132 #define __NDR_convert__int_rep__uint16_t(v,f) \
133 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint16_t)
135 #define __NDR_convert__int_rep__int32_t__defined
136 #define __NDR_convert__int_rep__int32_t(v,f) \
137 __NDR_READSWAP_assign(v, __NDR_READSWAP__int32_t)
139 #define __NDR_convert__int_rep__uint32_t__defined
140 #define __NDR_convert__int_rep__uint32_t(v,f) \
141 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint32_t)
143 #define __NDR_convert__int_rep__int64_t__defined
144 #define __NDR_convert__int_rep__int64_t(v,f) \
145 __NDR_READSWAP_assign(v, __NDR_READSWAP__int64_t)
147 #define __NDR_convert__int_rep__uint64_t__defined
148 #define __NDR_convert__int_rep__uint64_t(v,f) \
149 __NDR_READSWAP_assign(v, __NDR_READSWAP__uint64_t)
151 #define __NDR_convert__int_rep__float__defined
152 #define __NDR_convert__int_rep__float(v,f) \
153 __NDR_READSWAP_assign(v, __NDR_READSWAP__float)
155 #define __NDR_convert__int_rep__double__defined
156 #define __NDR_convert__int_rep__double(v,f) \
157 __NDR_READSWAP_assign(v, __NDR_READSWAP__double)
159 #define __NDR_convert__int_rep__boolean_t__defined
160 #define __NDR_convert__int_rep__boolean_t(v, f) \
161 __NDR_convert__int_rep__int32_t(v,f)
163 #define __NDR_convert__int_rep__kern_return_t__defined
164 #define __NDR_convert__int_rep__kern_return_t(v,f) \
165 __NDR_convert__int_rep__int32_t(v,f)
167 #define __NDR_convert__int_rep__mach_port_name_t__defined
168 #define __NDR_convert__int_rep__mach_port_name_t(v,f) \
169 __NDR_convert__int_rep__uint32_t(v,f)
171 #define __NDR_convert__int_rep__mach_msg_type_number_t__defined
172 #define __NDR_convert__int_rep__mach_msg_type_number_t(v,f) \
173 __NDR_convert__int_rep__uint32_t(v,f)
175 #endif /* __NDR_convert__int_rep__ */
177 #if __NDR_convert__char_rep__
179 #warning NDR character representation conversions not implemented yet!
180 #define __NDR_convert__char_rep__char(v,f) __NDR_convert__NOOP
181 #define __NDR_convert__char_rep__string(v,f,l) __NDR_convert__NOOP
183 #endif /* __NDR_convert__char_rep__ */
185 #if __NDR_convert__float_rep__
187 #warning NDR floating point representation conversions not implemented yet!
188 #define __NDR_convert__float_rep__float(v,f) __NDR_convert__NOOP
189 #define __NDR_convert__float_rep__double(v,f) __NDR_convert__NOOP
191 #endif /* __NDR_convert__float_rep__ */
193 #endif /* __NDR_convert__ */
195 #endif /* _MACH_NDR_H_ */