summaryrefslogtreecommitdiffstats
path: root/libc/inet/rpc
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-12-03 14:04:03 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-12-03 14:04:03 +0000
commitd5c32667ad11ff38dc46be527266297b38a341d1 (patch)
treeb3ce68f179d97e6e25e5c8e7ace845c4a561322b /libc/inet/rpc
parent329ef3196b396a70eecd5a4789845d368b488ab7 (diff)
downloaduClibc-alpine-d5c32667ad11ff38dc46be527266297b38a341d1.tar.bz2
uClibc-alpine-d5c32667ad11ff38dc46be527266297b38a341d1.tar.xz
Synch with trunk @ 24242
Step 18: some more synch: hidden_proto, size reduction and signal handling changes.
Diffstat (limited to 'libc/inet/rpc')
-rw-r--r--libc/inet/rpc/clnt_raw.c2
-rw-r--r--libc/inet/rpc/clnt_tcp.c2
-rw-r--r--libc/inet/rpc/clnt_udp.c2
-rw-r--r--libc/inet/rpc/clnt_unix.c4
-rw-r--r--libc/inet/rpc/create_xid.c3
-rw-r--r--libc/inet/rpc/xdr.c20
-rw-r--r--libc/inet/rpc/xdr_intXX_t.c4
-rw-r--r--libc/inet/rpc/xdr_rec.c103
8 files changed, 59 insertions, 81 deletions
diff --git a/libc/inet/rpc/clnt_raw.c b/libc/inet/rpc/clnt_raw.c
index 91340d85a..792796a5f 100644
--- a/libc/inet/rpc/clnt_raw.c
+++ b/libc/inet/rpc/clnt_raw.c
@@ -84,7 +84,7 @@ static bool_t clntraw_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clntraw_control (CLIENT *, int, char *);
static void clntraw_destroy (CLIENT *);
-static struct clnt_ops client_ops =
+static const struct clnt_ops client_ops =
{
clntraw_call,
clntraw_abort,
diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c
index 622d44552..42bef0793 100644
--- a/libc/inet/rpc/clnt_tcp.c
+++ b/libc/inet/rpc/clnt_tcp.c
@@ -117,7 +117,7 @@ static bool_t clnttcp_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clnttcp_control (CLIENT *, int, char *);
static void clnttcp_destroy (CLIENT *);
-static struct clnt_ops tcp_ops =
+static const struct clnt_ops tcp_ops =
{
clnttcp_call,
clnttcp_abort,
diff --git a/libc/inet/rpc/clnt_udp.c b/libc/inet/rpc/clnt_udp.c
index 84eb5ed10..e7e816c39 100644
--- a/libc/inet/rpc/clnt_udp.c
+++ b/libc/inet/rpc/clnt_udp.c
@@ -98,7 +98,7 @@ static bool_t clntudp_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clntudp_control (CLIENT *, int, char *);
static void clntudp_destroy (CLIENT *);
-static struct clnt_ops udp_ops =
+static const struct clnt_ops udp_ops =
{
clntudp_call,
clntudp_abort,
diff --git a/libc/inet/rpc/clnt_unix.c b/libc/inet/rpc/clnt_unix.c
index b412ccb7d..3a1e13c05 100644
--- a/libc/inet/rpc/clnt_unix.c
+++ b/libc/inet/rpc/clnt_unix.c
@@ -116,7 +116,7 @@ static bool_t clntunix_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clntunix_control (CLIENT *, int, char *);
static void clntunix_destroy (CLIENT *);
-static struct clnt_ops unix_ops =
+static const struct clnt_ops unix_ops =
{
clntunix_call,
clntunix_abort,
@@ -474,7 +474,7 @@ __msgread (int sock, void *data, size_t cnt)
struct iovec iov;
struct msghdr msg;
#ifdef SCM_CREDENTIALS
- static char cm[CMSG_SPACE(sizeof (struct ucred))];
+ /*static -why??*/ char cm[CMSG_SPACE(sizeof (struct ucred))];
#endif
int len;
diff --git a/libc/inet/rpc/create_xid.c b/libc/inet/rpc/create_xid.c
index be24d660c..0f045b9c1 100644
--- a/libc/inet/rpc/create_xid.c
+++ b/libc/inet/rpc/create_xid.c
@@ -34,14 +34,13 @@
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-
static smallint is_initialized;
static struct drand48_data __rpc_lrand48_data;
u_long _create_xid (void) attribute_hidden;
u_long _create_xid (void)
{
- unsigned long res;
+ long res;
__UCLIBC_MUTEX_LOCK(mylock);
diff --git a/libc/inet/rpc/xdr.c b/libc/inet/rpc/xdr.c
index 11e52136d..f76cc6a88 100644
--- a/libc/inet/rpc/xdr.c
+++ b/libc/inet/rpc/xdr.c
@@ -104,7 +104,6 @@ libc_hidden_def(xdr_void)
bool_t
xdr_long (XDR *xdrs, long *lp)
{
-
if (xdrs->x_op == XDR_ENCODE
&& (sizeof (int32_t) == sizeof (long)
|| (int32_t) *lp == *lp))
@@ -237,10 +236,10 @@ xdr_u_int (XDR *xdrs, u_int *up)
{
case XDR_ENCODE:
l = (u_long) * up;
- return XDR_PUTLONG (xdrs, &l);
+ return XDR_PUTLONG (xdrs, (long *) &l);
case XDR_DECODE:
- if (!XDR_GETLONG (xdrs, &l))
+ if (!XDR_GETLONG (xdrs, (long *) &l))
{
return FALSE;
}
@@ -268,19 +267,20 @@ bool_t
xdr_hyper (XDR *xdrs, quad_t *llp)
{
long t1;
- unsigned long int t2;
+ unsigned long t2;
if (xdrs->x_op == XDR_ENCODE)
{
t1 = (long) ((*llp) >> 32);
t2 = (long) (*llp);
- return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2));
+ return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, (long *) &t2));
}
if (xdrs->x_op == XDR_DECODE)
{
- if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2))
+ if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, (long *) &t2))
return FALSE;
+ /* t2 must be unsigned for this to work */
*llp = ((quad_t) t1) << 32;
*llp |= t2;
return TRUE;
@@ -309,12 +309,12 @@ xdr_u_hyper (XDR *xdrs, u_quad_t *ullp)
{
t1 = (unsigned long) ((*ullp) >> 32);
t2 = (unsigned long) (*ullp);
- return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2));
+ return (XDR_PUTLONG(xdrs, (long *) &t1) && XDR_PUTLONG(xdrs, (long *) &t2));
}
if (xdrs->x_op == XDR_DECODE)
{
- if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2))
+ if (!XDR_GETLONG(xdrs, (long *) &t1) || !XDR_GETLONG(xdrs, (long *) &t2))
return FALSE;
*ullp = ((u_quad_t) t1) << 32;
*ullp |= t2;
@@ -353,10 +353,10 @@ xdr_u_short (XDR *xdrs, u_short *usp)
{
case XDR_ENCODE:
l = (u_long) * usp;
- return XDR_PUTLONG (xdrs, &l);
+ return XDR_PUTLONG (xdrs, (long *) &l);
case XDR_DECODE:
- if (!XDR_GETLONG (xdrs, &l))
+ if (!XDR_GETLONG (xdrs, (long *) &l))
{
return FALSE;
}
diff --git a/libc/inet/rpc/xdr_intXX_t.c b/libc/inet/rpc/xdr_intXX_t.c
index d36d1623b..ff2177584 100644
--- a/libc/inet/rpc/xdr_intXX_t.c
+++ b/libc/inet/rpc/xdr_intXX_t.c
@@ -34,9 +34,9 @@ xdr_int64_t (XDR *xdrs, int64_t *ip)
case XDR_ENCODE:
t1 = (int32_t) ((*ip) >> 32);
t2 = (int32_t) (*ip);
- return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, &t2));
+ return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, (int32_t *) &t2));
case XDR_DECODE:
- if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, &t2))
+ if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, (int32_t *) &t2))
return FALSE;
*ip = ((int64_t) t1) << 32;
*ip |= t2;
diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c
index af5eb5217..b010ab446 100644
--- a/libc/inet/rpc/xdr_rec.c
+++ b/libc/inet/rpc/xdr_rec.c
@@ -64,20 +64,27 @@
/* libc_hidden_proto(fputs) */
/* libc_hidden_proto(lseek) */
-static bool_t xdrrec_getlong (XDR *, long *);
-static bool_t xdrrec_putlong (XDR *, const long *);
static bool_t xdrrec_getbytes (XDR *, caddr_t, u_int);
static bool_t xdrrec_putbytes (XDR *, const char *, u_int);
+static bool_t xdrrec_getint32 (XDR *, int32_t *);
+static bool_t xdrrec_putint32 (XDR *, const int32_t *);
+#if ULONG_MAX != 0xffffffff
+static bool_t xdrrec_getlong (XDR *, long *);
+static bool_t xdrrec_putlong (XDR *, const long *);
+#endif
static u_int xdrrec_getpos (const XDR *);
static bool_t xdrrec_setpos (XDR *, u_int);
static int32_t *xdrrec_inline (XDR *, u_int);
static void xdrrec_destroy (XDR *);
-static bool_t xdrrec_getint32 (XDR *, int32_t *);
-static bool_t xdrrec_putint32 (XDR *, const int32_t *);
static const struct xdr_ops xdrrec_ops = {
+#if ULONG_MAX == 0xffffffff
+ (bool_t (*)(XDR *, long *)) xdrrec_getint32,
+ (bool_t (*)(XDR *, const long *)) xdrrec_putint32,
+#else
xdrrec_getlong,
xdrrec_putlong,
+#endif
xdrrec_getbytes,
xdrrec_putbytes,
xdrrec_getpos,
@@ -218,35 +225,46 @@ libc_hidden_def(xdrrec_create)
*/
static bool_t
-xdrrec_getlong (XDR *xdrs, long *lp)
+xdrrec_getint32 (XDR *xdrs, int32_t *ip)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *buflp = (int32_t *) rstrm->in_finger;
+ int32_t *bufip = (int32_t *) rstrm->in_finger;
int32_t mylong;
/* first try the inline, fast case */
if (rstrm->fbtbc >= BYTES_PER_XDR_UNIT &&
- rstrm->in_boundry - (char *) buflp >= BYTES_PER_XDR_UNIT)
+ rstrm->in_boundry - (char *) bufip >= BYTES_PER_XDR_UNIT)
{
- *lp = (int32_t) ntohl (*buflp);
+ *ip = ntohl (*bufip);
rstrm->fbtbc -= BYTES_PER_XDR_UNIT;
rstrm->in_finger += BYTES_PER_XDR_UNIT;
}
else
{
- if (!xdrrec_getbytes (xdrs, (caddr_t) & mylong,
+ if (!xdrrec_getbytes (xdrs, (caddr_t) &mylong,
BYTES_PER_XDR_UNIT))
return FALSE;
- *lp = (int32_t) ntohl (mylong);
+ *ip = ntohl (mylong);
}
return TRUE;
}
+#if ULONG_MAX != 0xffffffff
static bool_t
-xdrrec_putlong (XDR *xdrs, const long *lp)
+xdrrec_getlong (XDR *xdrs, long *lp)
+{
+ int32_t v;
+ bool_t r = xdrrec_getint32 (xdrs, &v);
+ *lp = v;
+ return r;
+}
+#endif
+
+static bool_t
+xdrrec_putint32 (XDR *xdrs, const int32_t *ip)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *dest_lp = (int32_t *) rstrm->out_finger;
+ int32_t *dest_ip = (int32_t *) rstrm->out_finger;
if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry)
{
@@ -258,13 +276,22 @@ xdrrec_putlong (XDR *xdrs, const long *lp)
rstrm->frag_sent = TRUE;
if (!flush_out (rstrm, FALSE))
return FALSE;
- dest_lp = (int32_t *) rstrm->out_finger;
+ dest_ip = (int32_t *) rstrm->out_finger;
rstrm->out_finger += BYTES_PER_XDR_UNIT;
}
- *dest_lp = htonl (*lp);
+ *dest_ip = htonl (*ip);
return TRUE;
}
+#if ULONG_MAX != 0xffffffff
+static bool_t
+xdrrec_putlong (XDR *xdrs, const long *lp)
+{
+ int32_t v = *lp;
+ return xdrrec_putint32 (xdrs, &v);
+}
+#endif
+
static bool_t /* must manage buffers, fragments, and records */
xdrrec_getbytes (XDR *xdrs, caddr_t addr, u_int len)
{
@@ -425,54 +452,6 @@ xdrrec_destroy (XDR *xdrs)
mem_free ((caddr_t) rstrm, sizeof (RECSTREAM));
}
-static bool_t
-xdrrec_getint32 (XDR *xdrs, int32_t *ip)
-{
- RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *bufip = (int32_t *) rstrm->in_finger;
- int32_t mylong;
-
- /* first try the inline, fast case */
- if (rstrm->fbtbc >= BYTES_PER_XDR_UNIT &&
- rstrm->in_boundry - (char *) bufip >= BYTES_PER_XDR_UNIT)
- {
- *ip = ntohl (*bufip);
- rstrm->fbtbc -= BYTES_PER_XDR_UNIT;
- rstrm->in_finger += BYTES_PER_XDR_UNIT;
- }
- else
- {
- if (!xdrrec_getbytes (xdrs, (caddr_t) &mylong,
- BYTES_PER_XDR_UNIT))
- return FALSE;
- *ip = ntohl (mylong);
- }
- return TRUE;
-}
-
-static bool_t
-xdrrec_putint32 (XDR *xdrs, const int32_t *ip)
-{
- RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *dest_ip = (int32_t *) rstrm->out_finger;
-
- if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry)
- {
- /*
- * this case should almost never happen so the code is
- * inefficient
- */
- rstrm->out_finger -= BYTES_PER_XDR_UNIT;
- rstrm->frag_sent = TRUE;
- if (!flush_out (rstrm, FALSE))
- return FALSE;
- dest_ip = (int32_t *) rstrm->out_finger;
- rstrm->out_finger += BYTES_PER_XDR_UNIT;
- }
- *dest_ip = htonl (*ip);
- return TRUE;
-}
-
/*
* Exported routines to manage xdr records
*/