]> git.ipfire.org Git - thirdparty/glibc.git/blame - sunrpc/xdr_intXX_t.c
Remove "Contributed by" lines
[thirdparty/glibc.git] / sunrpc / xdr_intXX_t.c
CommitLineData
2b778ceb 1/* Copyright (c) 1998-2021 Free Software Foundation, Inc.
5713a71e 2 This file is part of the GNU C Library.
5713a71e
UD
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
5713a71e
UD
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
5713a71e 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
5713a71e
UD
17
18#include <rpc/types.h>
f20ba032
UD
19
20/* We play dirty tricks with aliases. */
5713a71e 21#include <rpc/xdr.h>
f20ba032 22
e054f494 23#include <stdint.h>
82f43dd2 24#include <shlib-compat.h>
5713a71e 25
50f301a8
AS
26/* XDR 64bit integers */
27bool_t
28xdr_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 50libc_hidden_nolink_sunrpc (xdr_int64_t, GLIBC_2_1_1)
7b57bfe5
UD
51
52bool_t
53xdr_quad_t (XDR *xdrs, quad_t *ip)
54{
55 return xdr_int64_t (xdrs, (int64_t *) ip);
56}
021db4be 57libc_hidden_nolink_sunrpc (xdr_quad_t, GLIBC_2_3_4)
50f301a8
AS
58
59/* XDR 64bit unsigned integers */
60bool_t
61xdr_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 86libc_hidden_nolink_sunrpc (xdr_uint64_t, GLIBC_2_1_1)
7b57bfe5
UD
87
88bool_t
89xdr_u_quad_t (XDR *xdrs, u_quad_t *ip)
90{
91 return xdr_uint64_t (xdrs, (uint64_t *) ip);
92}
021db4be 93libc_hidden_nolink_sunrpc (xdr_u_quad_t, GLIBC_2_3_4)
50f301a8 94
5713a71e
UD
95/* XDR 32bit integers */
96bool_t
97xdr_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 111libc_hidden_nolink_sunrpc (xdr_int32_t, GLIBC_2_1)
5713a71e
UD
112
113/* XDR 32bit unsigned integers */
114bool_t
115xdr_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
130libc_hidden_def (xdr_uint32_t)
131#else
021db4be 132libc_hidden_nolink_sunrpc (xdr_uint32_t, GLIBC_2_1)
7b57bfe5 133#endif
5713a71e
UD
134
135/* XDR 16bit integers */
136bool_t
137xdr_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 157libc_hidden_nolink_sunrpc (xdr_int16_t, GLIBC_2_1)
5713a71e
UD
158
159/* XDR 16bit unsigned integers */
160bool_t
161xdr_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 181libc_hidden_nolink_sunrpc (xdr_uint16_t, GLIBC_2_1)
5713a71e
UD
182
183/* XDR 8bit integers */
184bool_t
185xdr_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 205libc_hidden_nolink_sunrpc (xdr_int8_t, GLIBC_2_1)
5713a71e
UD
206
207/* XDR 8bit unsigned integers */
208bool_t
209xdr_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 229libc_hidden_nolink_sunrpc (xdr_uint8_t, GLIBC_2_1)