]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
55e303ae | 2 | * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
e5568f75 A |
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. | |
1c79356b | 11 | * |
e5568f75 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
e5568f75 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * @OSF_COPYRIGHT@ | |
24 | */ | |
1c79356b | 25 | |
55e303ae A |
26 | #ifndef _MACH_NDR_H_ |
27 | #define _MACH_NDR_H_ | |
28 | ||
29 | #include <stdint.h> | |
1c79356b A |
30 | |
31 | typedef struct { | |
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; | |
40 | } NDR_record_t; | |
41 | ||
42 | /* | |
43 | * MIG supported protocols for Network Data Representation | |
44 | */ | |
45 | #define NDR_PROTOCOL_2_0 0 | |
46 | ||
47 | /* | |
48 | * NDR 2.0 format flag type definition and values. | |
49 | */ | |
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 | |
58 | ||
59 | extern NDR_record_t NDR_record; | |
60 | ||
55e303ae A |
61 | #ifndef __NDR_convert__ |
62 | #define __NDR_convert__ 1 | |
63 | #endif /* __NDR_convert__ */ | |
64 | ||
65 | #ifndef __NDR_convert__int_rep__ | |
66 | #define __NDR_convert__int_rep__ 1 | |
67 | #endif /* __NDR_convert__int_rep__ */ | |
68 | ||
69 | #ifndef __NDR_convert__char_rep__ | |
70 | #define __NDR_convert__char_rep__ 0 | |
71 | #endif /* __NDR_convert__char_rep__ */ | |
72 | ||
73 | #ifndef __NDR_convert__float_rep__ | |
74 | #define __NDR_convert__float_rep__ 0 | |
75 | #endif /* __NDR_convert__float_rep__ */ | |
76 | ||
77 | #if __NDR_convert__ | |
78 | ||
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) | |
90 | ||
91 | #if __NDR_convert__int_rep__ | |
92 | ||
93 | #include <libkern/OSByteOrder.h> | |
94 | ||
95 | #define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0) | |
96 | ||
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) | |
103 | ||
104 | static __inline__ float __NDR_READSWAP__float(float *argp) { | |
105 | union { | |
106 | float sv; | |
107 | uint32_t ull; | |
108 | } result; | |
109 | result.ull = __NDR_READSWAP__uint32_t((uint32_t *)argp); | |
110 | return result.sv; | |
111 | } | |
112 | ||
113 | static __inline__ double __NDR_READSWAP__double(double *argp) { | |
114 | union { | |
115 | double sv; | |
116 | uint64_t ull; | |
117 | } result; | |
118 | result.ull = __NDR_READSWAP__uint64_t((uint64_t *)argp); | |
119 | return result.sv; | |
120 | } | |
121 | ||
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) | |
125 | ||
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) | |
129 | ||
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) | |
133 | ||
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) | |
137 | ||
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) | |
141 | ||
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) | |
145 | ||
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) | |
149 | ||
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) | |
153 | ||
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) | |
157 | ||
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) | |
161 | ||
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) | |
165 | ||
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) | |
169 | ||
170 | #endif /* __NDR_convert__int_rep__ */ | |
171 | ||
172 | #if __NDR_convert__char_rep__ | |
173 | ||
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 | |
177 | ||
178 | #endif /* __NDR_convert__char_rep__ */ | |
179 | ||
180 | #if __NDR_convert__float_rep__ | |
181 | ||
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 | |
185 | ||
186 | #endif /* __NDR_convert__float_rep__ */ | |
187 | ||
188 | #endif /* __NDR_convert__ */ | |
189 | ||
190 | #endif /* _MACH_NDR_H_ */ |