summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkevlo <kevlo@FreeBSD.org>2011-07-09 07:43:56 +0000
committerkevlo <kevlo@FreeBSD.org>2011-07-09 07:43:56 +0000
commit6f8c220e0e43c7b456458ffc2e43cb9d4ba57a83 (patch)
tree64581e8087eb90c6fc59f796e640f68468722595 /lib
parentd825d95c9f901b258aba68040422df5daa0aeea0 (diff)
downloadFreeBSD-src-6f8c220e0e43c7b456458ffc2e43cb9d4ba57a83.zip
FreeBSD-src-6f8c220e0e43c7b456458ffc2e43cb9d4ba57a83.tar.gz
- Add xdr_sizeof(3) to libc
- Document xdr_sizeof(3); from NetBSD Discussed with: kib
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/xdr/Makefile.inc4
-rw-r--r--lib/libc/xdr/Symbol.map5
-rw-r--r--lib/libc/xdr/xdr.313
-rw-r--r--lib/libc/xdr/xdr_sizeof.c4
4 files changed, 22 insertions, 4 deletions
diff --git a/lib/libc/xdr/Makefile.inc b/lib/libc/xdr/Makefile.inc
index 2d360ac..d1bb208 100644
--- a/lib/libc/xdr/Makefile.inc
+++ b/lib/libc/xdr/Makefile.inc
@@ -3,7 +3,8 @@
.PATH: ${.CURDIR}/xdr ${.CURDIR}/.
SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \
- xdr_rec.c xdr_reference.c xdr_stdio.c
+ xdr_rec.c xdr_reference.c xdr_sizeof.c \
+ xdr_stdio.c
SYM_MAPS+= ${.CURDIR}/xdr/Symbol.map
@@ -39,6 +40,7 @@ MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 \
xdr.3 xdr_reference.3 \
xdr.3 xdr_setpos.3 \
xdr.3 xdr_short.3 \
+ xdr.3 xdr_sizeof.3 \
xdr.3 xdrstdio_create.3 \
xdr.3 xdr_string.3 \
xdr.3 xdr_u_char.3 \
diff --git a/lib/libc/xdr/Symbol.map b/lib/libc/xdr/Symbol.map
index 0739b7b..a8eb3a1 100644
--- a/lib/libc/xdr/Symbol.map
+++ b/lib/libc/xdr/Symbol.map
@@ -42,7 +42,6 @@ FBSD_1.0 {
xdrrec_endofrecord;
xdr_reference;
xdr_pointer;
- /* xdr_sizeof; */ /* Why is xdr_sizeof.c not included in Makefileinc? */
xdrstdio_create;
};
@@ -51,3 +50,7 @@ FBSD_1.1 {
xdr_uint32_t;
xdr_uint64_t;
};
+
+FBSD_1.2 {
+ xdr_sizeof;
+};
diff --git a/lib/libc/xdr/xdr.3 b/lib/libc/xdr/xdr.3
index 19c7e57..8998d06 100644
--- a/lib/libc/xdr/xdr.3
+++ b/lib/libc/xdr/xdr.3
@@ -31,6 +31,7 @@
.Nm xdr_reference ,
.Nm xdr_setpos ,
.Nm xdr_short ,
+.Nm xdr_sizeof,
.Nm xdrstdio_create ,
.Nm xdr_string ,
.Nm xdr_u_char ,
@@ -561,6 +562,18 @@ A filter primitive that translates between C
integers and their external representations.
This routine returns one if it succeeds, zero otherwise.
.Pp
+.It Xo
+.Ft unsigned long
+.Xc
+.It Xo
+.Fn xdr_sizeof "xdrproc_t func" "void *data"
+.Xc
+.Pp
+This routine returns the amount of memory required to encode
+.Fa data
+using filter
+.Fa func .
+.Pp
.It Li "#ifdef _STDIO_H_"
.It Li "/* XDR using stdio library */"
.It Xo
diff --git a/lib/libc/xdr/xdr_sizeof.c b/lib/libc/xdr/xdr_sizeof.c
index 20f1c3a..f33c613 100644
--- a/lib/libc/xdr/xdr_sizeof.c
+++ b/lib/libc/xdr/xdr_sizeof.c
@@ -94,7 +94,7 @@ x_inline(xdrs, len)
if (xdrs->x_op != XDR_ENCODE) {
return (NULL);
}
- if (len < (u_int)xdrs->x_base) {
+ if (len < (u_int)(uintptr_t)xdrs->x_base) {
/* x_private was already allocated */
xdrs->x_handy += len;
return ((int32_t *) xdrs->x_private);
@@ -106,7 +106,7 @@ x_inline(xdrs, len)
xdrs->x_base = 0;
return (NULL);
}
- xdrs->x_base = (caddr_t) len;
+ xdrs->x_base = (caddr_t)(uintptr_t)len;
xdrs->x_handy += len;
return ((int32_t *) xdrs->x_private);
}
OpenPOWER on IntegriCloud