]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (c) 1998-2019 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> |
82f43dd2 | 25 | #include <shlib-compat.h> |
5713a71e | 26 | |
50f301a8 AS |
27 | /* XDR 64bit integers */ |
28 | bool_t | |
29 | xdr_int64_t (XDR *xdrs, int64_t *ip) | |
30 | { | |
9cfe5381 | 31 | int32_t t1, t2; |
50f301a8 AS |
32 | |
33 | switch (xdrs->x_op) | |
34 | { | |
35 | case XDR_ENCODE: | |
36 | t1 = (int32_t) ((*ip) >> 32); | |
37 | t2 = (int32_t) (*ip); | |
38 | return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, &t2)); | |
39 | case XDR_DECODE: | |
40 | if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, &t2)) | |
7b57bfe5 | 41 | return FALSE; |
50f301a8 | 42 | *ip = ((int64_t) t1) << 32; |
9cfe5381 | 43 | *ip |= (uint32_t) t2; /* Avoid sign extension. */ |
50f301a8 AS |
44 | return TRUE; |
45 | case XDR_FREE: | |
46 | return TRUE; | |
47 | default: | |
48 | return FALSE; | |
49 | } | |
50 | } | |
021db4be | 51 | libc_hidden_nolink_sunrpc (xdr_int64_t, GLIBC_2_1_1) |
7b57bfe5 UD |
52 | |
53 | bool_t | |
54 | xdr_quad_t (XDR *xdrs, quad_t *ip) | |
55 | { | |
56 | return xdr_int64_t (xdrs, (int64_t *) ip); | |
57 | } | |
021db4be | 58 | libc_hidden_nolink_sunrpc (xdr_quad_t, GLIBC_2_3_4) |
50f301a8 AS |
59 | |
60 | /* XDR 64bit unsigned integers */ | |
61 | bool_t | |
62 | xdr_uint64_t (XDR *xdrs, uint64_t *uip) | |
63 | { | |
64 | uint32_t t1; | |
65 | uint32_t t2; | |
66 | ||
67 | switch (xdrs->x_op) | |
68 | { | |
69 | case XDR_ENCODE: | |
70 | t1 = (uint32_t) ((*uip) >> 32); | |
71 | t2 = (uint32_t) (*uip); | |
72 | return (XDR_PUTINT32 (xdrs, (int32_t *) &t1) && | |
73 | XDR_PUTINT32(xdrs, (int32_t *) &t2)); | |
74 | case XDR_DECODE: | |
75 | if (!XDR_GETINT32(xdrs, (int32_t *) &t1) || | |
76 | !XDR_GETINT32(xdrs, (int32_t *) &t2)) | |
7b57bfe5 | 77 | return FALSE; |
50f301a8 AS |
78 | *uip = ((uint64_t) t1) << 32; |
79 | *uip |= t2; | |
80 | return TRUE; | |
81 | case XDR_FREE: | |
82 | return TRUE; | |
83 | default: | |
84 | return FALSE; | |
85 | } | |
86 | } | |
021db4be | 87 | libc_hidden_nolink_sunrpc (xdr_uint64_t, GLIBC_2_1_1) |
7b57bfe5 UD |
88 | |
89 | bool_t | |
90 | xdr_u_quad_t (XDR *xdrs, u_quad_t *ip) | |
91 | { | |
92 | return xdr_uint64_t (xdrs, (uint64_t *) ip); | |
93 | } | |
021db4be | 94 | libc_hidden_nolink_sunrpc (xdr_u_quad_t, GLIBC_2_3_4) |
50f301a8 | 95 | |
5713a71e UD |
96 | /* XDR 32bit integers */ |
97 | bool_t | |
98 | xdr_int32_t (XDR *xdrs, int32_t *lp) | |
99 | { | |
100 | switch (xdrs->x_op) | |
101 | { | |
102 | case XDR_ENCODE: | |
103 | return XDR_PUTINT32 (xdrs, lp); | |
104 | case XDR_DECODE: | |
105 | return XDR_GETINT32 (xdrs, lp); | |
106 | case XDR_FREE: | |
107 | return TRUE; | |
108 | default: | |
109 | return FALSE; | |
110 | } | |
111 | } | |
021db4be | 112 | libc_hidden_nolink_sunrpc (xdr_int32_t, GLIBC_2_1) |
5713a71e UD |
113 | |
114 | /* XDR 32bit unsigned integers */ | |
115 | bool_t | |
116 | xdr_uint32_t (XDR *xdrs, uint32_t *ulp) | |
117 | { | |
118 | switch (xdrs->x_op) | |
119 | { | |
5713a71e UD |
120 | case XDR_ENCODE: |
121 | return XDR_PUTINT32 (xdrs, (int32_t *) ulp); | |
50f301a8 AS |
122 | case XDR_DECODE: |
123 | return XDR_GETINT32 (xdrs, (int32_t *) ulp); | |
5713a71e UD |
124 | case XDR_FREE: |
125 | return TRUE; | |
126 | default: | |
127 | return FALSE; | |
128 | } | |
129 | } | |
7b57bfe5 UD |
130 | #ifdef EXPORT_RPC_SYMBOLS |
131 | libc_hidden_def (xdr_uint32_t) | |
132 | #else | |
021db4be | 133 | libc_hidden_nolink_sunrpc (xdr_uint32_t, GLIBC_2_1) |
7b57bfe5 | 134 | #endif |
5713a71e UD |
135 | |
136 | /* XDR 16bit integers */ | |
137 | bool_t | |
138 | xdr_int16_t (XDR *xdrs, int16_t *ip) | |
139 | { | |
140 | int32_t t; | |
141 | ||
142 | switch (xdrs->x_op) | |
143 | { | |
144 | case XDR_ENCODE: | |
145 | t = (int32_t) *ip; | |
146 | return XDR_PUTINT32 (xdrs, &t); | |
147 | case XDR_DECODE: | |
148 | if (!XDR_GETINT32 (xdrs, &t)) | |
149 | return FALSE; | |
150 | *ip = (int16_t) t; | |
151 | return TRUE; | |
152 | case XDR_FREE: | |
153 | return TRUE; | |
154 | default: | |
155 | return FALSE; | |
156 | } | |
157 | } | |
021db4be | 158 | libc_hidden_nolink_sunrpc (xdr_int16_t, GLIBC_2_1) |
5713a71e UD |
159 | |
160 | /* XDR 16bit unsigned integers */ | |
161 | bool_t | |
162 | xdr_uint16_t (XDR *xdrs, uint16_t *uip) | |
163 | { | |
164 | uint32_t ut; | |
165 | ||
166 | switch (xdrs->x_op) | |
167 | { | |
5713a71e | 168 | case XDR_ENCODE: |
bdd5fccd UD |
169 | ut = (uint32_t) *uip; |
170 | return XDR_PUTINT32 (xdrs, (int32_t *) &ut); | |
171 | case XDR_DECODE: | |
172 | if (!XDR_GETINT32 (xdrs, (int32_t *) &ut)) | |
5713a71e UD |
173 | return FALSE; |
174 | *uip = (uint16_t) ut; | |
175 | return TRUE; | |
176 | case XDR_FREE: | |
177 | return TRUE; | |
178 | default: | |
179 | return FALSE; | |
180 | } | |
181 | } | |
021db4be | 182 | libc_hidden_nolink_sunrpc (xdr_uint16_t, GLIBC_2_1) |
5713a71e UD |
183 | |
184 | /* XDR 8bit integers */ | |
185 | bool_t | |
186 | xdr_int8_t (XDR *xdrs, int8_t *ip) | |
187 | { | |
188 | int32_t t; | |
189 | ||
190 | switch (xdrs->x_op) | |
191 | { | |
192 | case XDR_ENCODE: | |
193 | t = (int32_t) *ip; | |
194 | return XDR_PUTINT32 (xdrs, &t); | |
195 | case XDR_DECODE: | |
196 | if (!XDR_GETINT32 (xdrs, &t)) | |
197 | return FALSE; | |
198 | *ip = (int8_t) t; | |
199 | return TRUE; | |
200 | case XDR_FREE: | |
201 | return TRUE; | |
202 | default: | |
203 | return FALSE; | |
204 | } | |
205 | } | |
021db4be | 206 | libc_hidden_nolink_sunrpc (xdr_int8_t, GLIBC_2_1) |
5713a71e UD |
207 | |
208 | /* XDR 8bit unsigned integers */ | |
209 | bool_t | |
210 | xdr_uint8_t (XDR *xdrs, uint8_t *uip) | |
211 | { | |
212 | uint32_t ut; | |
213 | ||
214 | switch (xdrs->x_op) | |
215 | { | |
5713a71e | 216 | case XDR_ENCODE: |
446e763b AJ |
217 | ut = (uint32_t) *uip; |
218 | return XDR_PUTINT32 (xdrs, (int32_t *) &ut); | |
219 | case XDR_DECODE: | |
220 | if (!XDR_GETINT32 (xdrs, (int32_t *) &ut)) | |
5713a71e UD |
221 | return FALSE; |
222 | *uip = (uint8_t) ut; | |
223 | return TRUE; | |
224 | case XDR_FREE: | |
225 | return TRUE; | |
226 | default: | |
227 | return FALSE; | |
228 | } | |
229 | } | |
021db4be | 230 | libc_hidden_nolink_sunrpc (xdr_uint8_t, GLIBC_2_1) |