1 /* Copyright (c) 1998, 1999, 2000, 2004, 2005 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #include <rpc/types.h>
22 /* We play dirty tricks with aliases. */
23 #define xdr_quad_t Xdr_quad_t
24 #define xdr_u_quad_t Xdr_u_quad_t
30 /* XDR 64bit integers */
32 xdr_int64_t (XDR
*xdrs
, int64_t *ip
)
39 t1
= (int32_t) ((*ip
) >> 32);
41 return (XDR_PUTINT32(xdrs
, &t1
) && XDR_PUTINT32(xdrs
, &t2
));
43 if (!XDR_GETINT32(xdrs
, &t1
) || !XDR_GETINT32(xdrs
, &t2
))
45 *ip
= ((int64_t) t1
) << 32;
46 *ip
|= (uint32_t) t2
; /* Avoid sign extension. */
54 strong_alias (xdr_int64_t
, xdr_quad_t
)
56 /* XDR 64bit unsigned integers */
58 xdr_uint64_t (XDR
*xdrs
, uint64_t *uip
)
66 t1
= (uint32_t) ((*uip
) >> 32);
67 t2
= (uint32_t) (*uip
);
68 return (XDR_PUTINT32 (xdrs
, (int32_t *) &t1
) &&
69 XDR_PUTINT32(xdrs
, (int32_t *) &t2
));
71 if (!XDR_GETINT32(xdrs
, (int32_t *) &t1
) ||
72 !XDR_GETINT32(xdrs
, (int32_t *) &t2
))
74 *uip
= ((uint64_t) t1
) << 32;
83 strong_alias (xdr_int64_t
, xdr_u_quad_t
)
85 /* XDR 32bit integers */
87 xdr_int32_t (XDR
*xdrs
, int32_t *lp
)
92 return XDR_PUTINT32 (xdrs
, lp
);
94 return XDR_GETINT32 (xdrs
, lp
);
102 /* XDR 32bit unsigned integers */
104 xdr_uint32_t (XDR
*xdrs
, uint32_t *ulp
)
109 return XDR_PUTINT32 (xdrs
, (int32_t *) ulp
);
111 return XDR_GETINT32 (xdrs
, (int32_t *) ulp
);
119 /* XDR 16bit integers */
121 xdr_int16_t (XDR
*xdrs
, int16_t *ip
)
129 return XDR_PUTINT32 (xdrs
, &t
);
131 if (!XDR_GETINT32 (xdrs
, &t
))
142 /* XDR 16bit unsigned integers */
144 xdr_uint16_t (XDR
*xdrs
, uint16_t *uip
)
151 ut
= (uint32_t) *uip
;
152 return XDR_PUTINT32 (xdrs
, (int32_t *) &ut
);
154 if (!XDR_GETINT32 (xdrs
, (int32_t *) &ut
))
156 *uip
= (uint16_t) ut
;
165 /* XDR 8bit integers */
167 xdr_int8_t (XDR
*xdrs
, int8_t *ip
)
175 return XDR_PUTINT32 (xdrs
, &t
);
177 if (!XDR_GETINT32 (xdrs
, &t
))
188 /* XDR 8bit unsigned integers */
190 xdr_uint8_t (XDR
*xdrs
, uint8_t *uip
)
197 ut
= (uint32_t) *uip
;
198 return XDR_PUTINT32 (xdrs
, (int32_t *) &ut
);
200 if (!XDR_GETINT32 (xdrs
, (int32_t *) &ut
))