]>
Commit | Line | Data |
---|---|---|
f7a9f785 | 1 | /* Copyright (c) 1998-2016 Free Software Foundation, Inc. |
5713a71e UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
5713a71e UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
5713a71e | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
5713a71e UD |
18 | |
19 | #include <rpc/types.h> | |
f20ba032 UD |
20 | |
21 | /* We play dirty tricks with aliases. */ | |
5713a71e | 22 | #include <rpc/xdr.h> |
f20ba032 | 23 | |
e054f494 | 24 | #include <stdint.h> |
5713a71e | 25 | |
50f301a8 AS |
26 | /* XDR 64bit integers */ |
27 | bool_t | |
28 | xdr_int64_t (XDR *xdrs, int64_t *ip) | |
29 | { | |
9cfe5381 | 30 | int32_t t1, t2; |
50f301a8 AS |
31 | |
32 | switch (xdrs->x_op) | |
33 | { | |
34 | case XDR_ENCODE: | |
35 | t1 = (int32_t) ((*ip) >> 32); | |
36 | t2 = (int32_t) (*ip); | |
37 | return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, &t2)); | |
38 | case XDR_DECODE: | |
39 | if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, &t2)) | |
7b57bfe5 | 40 | return FALSE; |
50f301a8 | 41 | *ip = ((int64_t) t1) << 32; |
9cfe5381 | 42 | *ip |= (uint32_t) t2; /* Avoid sign extension. */ |
50f301a8 AS |
43 | return TRUE; |
44 | case XDR_FREE: | |
45 | return TRUE; | |
46 | default: | |
47 | return FALSE; | |
48 | } | |
49 | } | |
021db4be | 50 | libc_hidden_nolink_sunrpc (xdr_int64_t, GLIBC_2_1_1) |
7b57bfe5 UD |
51 | |
52 | bool_t | |
53 | xdr_quad_t (XDR *xdrs, quad_t *ip) | |
54 | { | |
55 | return xdr_int64_t (xdrs, (int64_t *) ip); | |
56 | } | |
021db4be | 57 | libc_hidden_nolink_sunrpc (xdr_quad_t, GLIBC_2_3_4) |
50f301a8 AS |
58 | |
59 | /* XDR 64bit unsigned integers */ | |
60 | bool_t | |
61 | xdr_uint64_t (XDR *xdrs, uint64_t *uip) | |
62 | { | |
63 | uint32_t t1; | |
64 | uint32_t t2; | |
65 | ||
66 | switch (xdrs->x_op) | |
67 | { | |
68 | case XDR_ENCODE: | |
69 | t1 = (uint32_t) ((*uip) >> 32); | |
70 | t2 = (uint32_t) (*uip); | |
71 | return (XDR_PUTINT32 (xdrs, (int32_t *) &t1) && | |
72 | XDR_PUTINT32(xdrs, (int32_t *) &t2)); | |
73 | case XDR_DECODE: | |
74 | if (!XDR_GETINT32(xdrs, (int32_t *) &t1) || | |
75 | !XDR_GETINT32(xdrs, (int32_t *) &t2)) | |
7b57bfe5 | 76 | return FALSE; |
50f301a8 AS |
77 | *uip = ((uint64_t) t1) << 32; |
78 | *uip |= t2; | |
79 | return TRUE; | |
80 | case XDR_FREE: | |
81 | return TRUE; | |
82 | default: | |
83 | return FALSE; | |
84 | } | |
85 | } | |
021db4be | 86 | libc_hidden_nolink_sunrpc (xdr_uint64_t, GLIBC_2_1_1) |
7b57bfe5 UD |
87 | |
88 | bool_t | |
89 | xdr_u_quad_t (XDR *xdrs, u_quad_t *ip) | |
90 | { | |
91 | return xdr_uint64_t (xdrs, (uint64_t *) ip); | |
92 | } | |
021db4be | 93 | libc_hidden_nolink_sunrpc (xdr_u_quad_t, GLIBC_2_3_4) |
50f301a8 | 94 | |
5713a71e UD |
95 | /* XDR 32bit integers */ |
96 | bool_t | |
97 | xdr_int32_t (XDR *xdrs, int32_t *lp) | |
98 | { | |
99 | switch (xdrs->x_op) | |
100 | { | |
101 | case XDR_ENCODE: | |
102 | return XDR_PUTINT32 (xdrs, lp); | |
103 | case XDR_DECODE: | |
104 | return XDR_GETINT32 (xdrs, lp); | |
105 | case XDR_FREE: | |
106 | return TRUE; | |
107 | default: | |
108 | return FALSE; | |
109 | } | |
110 | } | |
021db4be | 111 | libc_hidden_nolink_sunrpc (xdr_int32_t, GLIBC_2_1) |
5713a71e UD |
112 | |
113 | /* XDR 32bit unsigned integers */ | |
114 | bool_t | |
115 | xdr_uint32_t (XDR *xdrs, uint32_t *ulp) | |
116 | { | |
117 | switch (xdrs->x_op) | |
118 | { | |
5713a71e UD |
119 | case XDR_ENCODE: |
120 | return XDR_PUTINT32 (xdrs, (int32_t *) ulp); | |
50f301a8 AS |
121 | case XDR_DECODE: |
122 | return XDR_GETINT32 (xdrs, (int32_t *) ulp); | |
5713a71e UD |
123 | case XDR_FREE: |
124 | return TRUE; | |
125 | default: | |
126 | return FALSE; | |
127 | } | |
128 | } | |
7b57bfe5 UD |
129 | #ifdef EXPORT_RPC_SYMBOLS |
130 | libc_hidden_def (xdr_uint32_t) | |
131 | #else | |
021db4be | 132 | libc_hidden_nolink_sunrpc (xdr_uint32_t, GLIBC_2_1) |
7b57bfe5 | 133 | #endif |
5713a71e UD |
134 | |
135 | /* XDR 16bit integers */ | |
136 | bool_t | |
137 | xdr_int16_t (XDR *xdrs, int16_t *ip) | |
138 | { | |
139 | int32_t t; | |
140 | ||
141 | switch (xdrs->x_op) | |
142 | { | |
143 | case XDR_ENCODE: | |
144 | t = (int32_t) *ip; | |
145 | return XDR_PUTINT32 (xdrs, &t); | |
146 | case XDR_DECODE: | |
147 | if (!XDR_GETINT32 (xdrs, &t)) | |
148 | return FALSE; | |
149 | *ip = (int16_t) t; | |
150 | return TRUE; | |
151 | case XDR_FREE: | |
152 | return TRUE; | |
153 | default: | |
154 | return FALSE; | |
155 | } | |
156 | } | |
021db4be | 157 | libc_hidden_nolink_sunrpc (xdr_int16_t, GLIBC_2_1) |
5713a71e UD |
158 | |
159 | /* XDR 16bit unsigned integers */ | |
160 | bool_t | |
161 | xdr_uint16_t (XDR *xdrs, uint16_t *uip) | |
162 | { | |
163 | uint32_t ut; | |
164 | ||
165 | switch (xdrs->x_op) | |
166 | { | |
5713a71e | 167 | case XDR_ENCODE: |
bdd5fccd UD |
168 | ut = (uint32_t) *uip; |
169 | return XDR_PUTINT32 (xdrs, (int32_t *) &ut); | |
170 | case XDR_DECODE: | |
171 | if (!XDR_GETINT32 (xdrs, (int32_t *) &ut)) | |
5713a71e UD |
172 | return FALSE; |
173 | *uip = (uint16_t) ut; | |
174 | return TRUE; | |
175 | case XDR_FREE: | |
176 | return TRUE; | |
177 | default: | |
178 | return FALSE; | |
179 | } | |
180 | } | |
021db4be | 181 | libc_hidden_nolink_sunrpc (xdr_uint16_t, GLIBC_2_1) |
5713a71e UD |
182 | |
183 | /* XDR 8bit integers */ | |
184 | bool_t | |
185 | xdr_int8_t (XDR *xdrs, int8_t *ip) | |
186 | { | |
187 | int32_t t; | |
188 | ||
189 | switch (xdrs->x_op) | |
190 | { | |
191 | case XDR_ENCODE: | |
192 | t = (int32_t) *ip; | |
193 | return XDR_PUTINT32 (xdrs, &t); | |
194 | case XDR_DECODE: | |
195 | if (!XDR_GETINT32 (xdrs, &t)) | |
196 | return FALSE; | |
197 | *ip = (int8_t) t; | |
198 | return TRUE; | |
199 | case XDR_FREE: | |
200 | return TRUE; | |
201 | default: | |
202 | return FALSE; | |
203 | } | |
204 | } | |
021db4be | 205 | libc_hidden_nolink_sunrpc (xdr_int8_t, GLIBC_2_1) |
5713a71e UD |
206 | |
207 | /* XDR 8bit unsigned integers */ | |
208 | bool_t | |
209 | xdr_uint8_t (XDR *xdrs, uint8_t *uip) | |
210 | { | |
211 | uint32_t ut; | |
212 | ||
213 | switch (xdrs->x_op) | |
214 | { | |
5713a71e | 215 | case XDR_ENCODE: |
446e763b AJ |
216 | ut = (uint32_t) *uip; |
217 | return XDR_PUTINT32 (xdrs, (int32_t *) &ut); | |
218 | case XDR_DECODE: | |
219 | if (!XDR_GETINT32 (xdrs, (int32_t *) &ut)) | |
5713a71e UD |
220 | return FALSE; |
221 | *uip = (uint8_t) ut; | |
222 | return TRUE; | |
223 | case XDR_FREE: | |
224 | return TRUE; | |
225 | default: | |
226 | return FALSE; | |
227 | } | |
228 | } | |
021db4be | 229 | libc_hidden_nolink_sunrpc (xdr_uint8_t, GLIBC_2_1) |