]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/ndr.h
xnu-792.6.76.tar.gz
[apple/xnu.git] / osfmk / mach / ndr.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
37839358
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 *
37839358
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,
37839358
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>
91447636 30#include <sys/cdefs.h>
1c79356b
A
31
32typedef struct {
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;
41} NDR_record_t;
42
43/*
44 * MIG supported protocols for Network Data Representation
45 */
46#define NDR_PROTOCOL_2_0 0
47
48/*
49 * NDR 2.0 format flag type definition and values.
50 */
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
59
60extern NDR_record_t NDR_record;
61
55e303ae
A
62#ifndef __NDR_convert__
63#define __NDR_convert__ 1
64#endif /* __NDR_convert__ */
65
66#ifndef __NDR_convert__int_rep__
67#define __NDR_convert__int_rep__ 1
68#endif /* __NDR_convert__int_rep__ */
69
70#ifndef __NDR_convert__char_rep__
71#define __NDR_convert__char_rep__ 0
72#endif /* __NDR_convert__char_rep__ */
73
74#ifndef __NDR_convert__float_rep__
75#define __NDR_convert__float_rep__ 0
76#endif /* __NDR_convert__float_rep__ */
77
78#if __NDR_convert__
79
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)
91
92#if __NDR_convert__int_rep__
93
94#include <libkern/OSByteOrder.h>
95
96#define __NDR_READSWAP_assign(a, rs) do { *(a) = rs(a); } while (0)
97
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)
104
91447636
A
105__BEGIN_DECLS
106
55e303ae
A
107static __inline__ float __NDR_READSWAP__float(float *argp) {
108 union {
109 float sv;
110 uint32_t ull;
111 } result;
112 result.ull = __NDR_READSWAP__uint32_t((uint32_t *)argp);
113 return result.sv;
114}
115
116static __inline__ double __NDR_READSWAP__double(double *argp) {
117 union {
118 double sv;
119 uint64_t ull;
120 } result;
121 result.ull = __NDR_READSWAP__uint64_t((uint64_t *)argp);
122 return result.sv;
123}
124
91447636
A
125__END_DECLS
126
55e303ae
A
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)
130
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)
134
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)
138
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)
142
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)
146
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)
150
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)
154
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)
158
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)
162
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)
166
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)
170
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)
174
175#endif /* __NDR_convert__int_rep__ */
176
177#if __NDR_convert__char_rep__
178
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
182
183#endif /* __NDR_convert__char_rep__ */
184
185#if __NDR_convert__float_rep__
186
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
190
191#endif /* __NDR_convert__float_rep__ */
192
193#endif /* __NDR_convert__ */
194
195#endif /* _MACH_NDR_H_ */