1 : /*
2 : * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 : *
4 : * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 : *
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.
14 : *
15 : * Please obtain a copy of the License at
16 : * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 : *
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.
25 : *
26 : * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 : */
28 : /*
29 : * @OSF_COPYRIGHT@
30 : */
31 :
32 : #ifndef _MACH_NDR_H_
33 : #define _MACH_NDR_H_
34 :
35 : #include <stdint.h>
36 : #include <sys/cdefs.h>
37 :
38 : typedef struct {
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;
47 : } NDR_record_t;
48 :
49 : /*
50 : * MIG supported protocols for Network Data Representation
51 : */
52 : #define NDR_PROTOCOL_2_0 0
53 :
54 : /*
55 : * NDR 2.0 format flag type definition and values.
56 : */
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
65 :
66 : extern NDR_record_t NDR_record;
67 :
68 : #if defined(BSMALL)
69 : #define __NDR_convert__ 0
70 : #define __NDR_convert__int_rep__ 0
71 : #else
72 : #ifndef __NDR_convert__
73 : #define __NDR_convert__ 1
74 : #endif /* __NDR_convert__ */
75 :
76 : #ifndef __NDR_convert__int_rep__
77 : #define __NDR_convert__int_rep__ 1
78 : #endif /* __NDR_convert__int_rep__ */
79 :
80 : #endif /* defined(BSMALL) */
81 :
82 : #ifndef __NDR_convert__char_rep__
83 : #define __NDR_convert__char_rep__ 0
84 : #endif /* __NDR_convert__char_rep__ */
85 :
86 : #ifndef __NDR_convert__float_rep__
87 : #define __NDR_convert__float_rep__ 0
88 : #endif /* __NDR_convert__float_rep__ */
89 :
90 : #if __NDR_convert__
91 :
92 : #define __NDR_convert__NOOP do ; while (0)
93 : #define __NDR_convert__UNKNOWN(s) __NDR_convert__NOOP
94 : #define __NDR_convert__SINGLE(a, f, r) do { r((a), (f)); } while (0)
95 : #define __NDR_convert__ARRAY(a, f, c, r) \
96 : do { int __i__, __C__ = (c); \
97 : for (__i__ = 0; __i__ < __C__; __i__++) \
98 : r(&(a)[__i__], f); } while (0)
99 : #define __NDR_convert__2DARRAY(a, f, s, c, r) \
100 : do { int __i__, __C__ = (c), __S__ = (s); \
101 : for (__i__ = 0; __i__ < __C__; __i__++) \
102 : r(&(a)[__i__ * __S__], f, __S__); } while (0)
103 :
104 : #if __NDR_convert__int_rep__
105 :
106 : #include <libkern/OSByteOrder.h>
107 :
108 : #define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0)
109 :
110 : #define __NDR_READSWAP__uint16_t(a) OSReadSwapInt16((void *)a, 0)
111 : #define __NDR_READSWAP__int16_t(a) (int16_t)OSReadSwapInt16((void *)a, 0)
112 : #define __NDR_READSWAP__uint32_t(a) OSReadSwapInt32((void *)a, 0)
113 : #define __NDR_READSWAP__int32_t(a) (int32_t)OSReadSwapInt32((void *)a, 0)
114 : #define __NDR_READSWAP__uint64_t(a) OSReadSwapInt64((void *)a, 0)
115 : #define __NDR_READSWAP__int64_t(a) (int64_t)OSReadSwapInt64((void *)a, 0)
116 :
117 : __BEGIN_DECLS
118 :
119 0 : static __inline__ float __NDR_READSWAP__float(float *argp) {
120 : union {
121 : float sv;
122 : uint32_t ull;
123 : } result;
124 0 : result.ull = __NDR_READSWAP__uint32_t((uint32_t *)argp);
125 0 : return result.sv;
126 : }
127 :
128 0 : static __inline__ double __NDR_READSWAP__double(double *argp) {
129 : union {
130 : double sv;
131 : uint64_t ull;
132 : } result;
133 0 : result.ull = __NDR_READSWAP__uint64_t((uint64_t *)argp);
134 0 : return result.sv;
135 : }
136 :
137 : __END_DECLS
138 :
139 : #define __NDR_convert__int_rep__int16_t__defined
140 : #define __NDR_convert__int_rep__int16_t(v,f) \
141 : __NDR_READSWAP_assign(v, __NDR_READSWAP__int16_t)
142 :
143 : #define __NDR_convert__int_rep__uint16_t__defined
144 : #define __NDR_convert__int_rep__uint16_t(v,f) \
145 : __NDR_READSWAP_assign(v, __NDR_READSWAP__uint16_t)
146 :
147 : #define __NDR_convert__int_rep__int32_t__defined
148 : #define __NDR_convert__int_rep__int32_t(v,f) \
149 : __NDR_READSWAP_assign(v, __NDR_READSWAP__int32_t)
150 :
151 : #define __NDR_convert__int_rep__uint32_t__defined
152 : #define __NDR_convert__int_rep__uint32_t(v,f) \
153 : __NDR_READSWAP_assign(v, __NDR_READSWAP__uint32_t)
154 :
155 : #define __NDR_convert__int_rep__int64_t__defined
156 : #define __NDR_convert__int_rep__int64_t(v,f) \
157 : __NDR_READSWAP_assign(v, __NDR_READSWAP__int64_t)
158 :
159 : #define __NDR_convert__int_rep__uint64_t__defined
160 : #define __NDR_convert__int_rep__uint64_t(v,f) \
161 : __NDR_READSWAP_assign(v, __NDR_READSWAP__uint64_t)
162 :
163 : #define __NDR_convert__int_rep__float__defined
164 : #define __NDR_convert__int_rep__float(v,f) \
165 : __NDR_READSWAP_assign(v, __NDR_READSWAP__float)
166 :
167 : #define __NDR_convert__int_rep__double__defined
168 : #define __NDR_convert__int_rep__double(v,f) \
169 : __NDR_READSWAP_assign(v, __NDR_READSWAP__double)
170 :
171 : #define __NDR_convert__int_rep__boolean_t__defined
172 : #define __NDR_convert__int_rep__boolean_t(v, f) \
173 : __NDR_convert__int_rep__int32_t(v,f)
174 :
175 : #define __NDR_convert__int_rep__kern_return_t__defined
176 : #define __NDR_convert__int_rep__kern_return_t(v,f) \
177 : __NDR_convert__int_rep__int32_t(v,f)
178 :
179 : #define __NDR_convert__int_rep__mach_port_name_t__defined
180 : #define __NDR_convert__int_rep__mach_port_name_t(v,f) \
181 : __NDR_convert__int_rep__uint32_t(v,f)
182 :
183 : #define __NDR_convert__int_rep__mach_msg_type_number_t__defined
184 : #define __NDR_convert__int_rep__mach_msg_type_number_t(v,f) \
185 : __NDR_convert__int_rep__uint32_t(v,f)
186 :
187 : #endif /* __NDR_convert__int_rep__ */
188 :
189 : #if __NDR_convert__char_rep__
190 :
191 : #warning NDR character representation conversions not implemented yet!
192 : #define __NDR_convert__char_rep__char(v,f) __NDR_convert__NOOP
193 : #define __NDR_convert__char_rep__string(v,f,l) __NDR_convert__NOOP
194 :
195 : #endif /* __NDR_convert__char_rep__ */
196 :
197 : #if __NDR_convert__float_rep__
198 :
199 : #warning NDR floating point representation conversions not implemented yet!
200 : #define __NDR_convert__float_rep__float(v,f) __NDR_convert__NOOP
201 : #define __NDR_convert__float_rep__double(v,f) __NDR_convert__NOOP
202 :
203 : #endif /* __NDR_convert__float_rep__ */
204 :
205 : #endif /* __NDR_convert__ */
206 :
207 : #endif /* _MACH_NDR_H_ */
|