From cdb3c81f36283df4b53f24a374d78c695e9d8b06 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 17 Jun 2002 21:12:16 +0000 Subject: Re-backport all the rpc stuff from glibc 2.2.5. This allows us to make this junk (and I do mean that ;-) thread safe without undue pain. Adds 12k worth to the code size I'm afraid, but since I never use NFS and therefore never include this stuff, I guess thats acceptable. I still need to enable the multi-threaded bits... -Erik --- libc/inet/rpc/xdr_reference.c | 129 +++++++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 52 deletions(-) (limited to 'libc/inet/rpc/xdr_reference.c') diff --git a/libc/inet/rpc/xdr_reference.c b/libc/inet/rpc/xdr_reference.c index 94b8a4bb6..708531bf8 100644 --- a/libc/inet/rpc/xdr_reference.c +++ b/libc/inet/rpc/xdr_reference.c @@ -6,32 +6,33 @@ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ -#define __FORCE_GLIBC -#include +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI"; +#endif /* - * xdr_reference.c, Generic XDR routines impelmentation. + * xdr_reference.c, Generic XDR routines implementation. * * Copyright (C) 1987, Sun Microsystems, Inc. * @@ -39,11 +40,21 @@ * "pointers". See xdr.h for more info on the interface to xdr. */ +#define __FORCE_GLIBC +#define _GNU_SOURCE +#include + #include #include #include #include +#ifdef USE_IN_LIBIO +# include +# include +# define fputs(s, f) _IO_fputs (s, f) +#endif + #define LASTUNSIGNED ((u_int)0-1) /* @@ -52,41 +63,52 @@ * referenced by a pointer inside the structure that is currently being * translated. pp references a pointer to storage. If *pp is null * the necessary storage is allocated. - * size is the sizeof the referneced structure. + * size is the size of the referneced structure. * proc is the routine to handle the referenced structure. */ -bool_t xdr_reference(xdrs, pp, size, proc) -register XDR *xdrs; -caddr_t *pp; /* the pointer to work on */ -u_int size; /* size of the object pointed to */ -xdrproc_t proc; /* xdr routine to handle the object */ +bool_t +xdr_reference (xdrs, pp, size, proc) + XDR *xdrs; + caddr_t *pp; /* the pointer to work on */ + u_int size; /* size of the object pointed to */ + xdrproc_t proc; /* xdr routine to handle the object */ { - register caddr_t loc = *pp; - register bool_t stat; + caddr_t loc = *pp; + bool_t stat; - if (loc == NULL) - switch (xdrs->x_op) { - case XDR_FREE: - return (TRUE); + if (loc == NULL) + switch (xdrs->x_op) + { + case XDR_FREE: + return TRUE; - case XDR_DECODE: - *pp = loc = (caddr_t) mem_alloc(size); - if (loc == NULL) { - (void) fprintf(stderr, "xdr_reference: out of memory\n"); - return (FALSE); - } - bzero(loc, (int) size); - break; - default: /* silence the warnings */ - } + case XDR_DECODE: + *pp = loc = (caddr_t) mem_alloc (size); + if (loc == NULL) + { +#ifdef USE_IN_LIBIO + if (_IO_fwide (stderr, 0) > 0) + (void) __fwprintf (stderr, L"%s", + _("xdr_reference: out of memory\n")); + else +#endif + (void) fputs (_("xdr_reference: out of memory\n"), stderr); + return FALSE; + } + bzero (loc, (int) size); + break; + default: + break; + } - stat = (*proc) (xdrs, loc, LASTUNSIGNED); + stat = (*proc) (xdrs, loc, LASTUNSIGNED); - if (xdrs->x_op == XDR_FREE) { - mem_free(loc, size); - *pp = NULL; - } - return (stat); + if (xdrs->x_op == XDR_FREE) + { + mem_free (loc, size); + *pp = NULL; + } + return stat; } @@ -94,7 +116,7 @@ xdrproc_t proc; /* xdr routine to handle the object */ * xdr_pointer(): * * XDR a pointer to a possibly recursive data structure. This - * differs with xdr_reference in that it can serialize/deserialiaze + * differs with xdr_reference in that it can serialize/deserialize * trees correctly. * * What's sent is actually a union: @@ -109,22 +131,25 @@ xdrproc_t proc; /* xdr routine to handle the object */ * > xdr_obj: routine to XDR an object. * */ -bool_t xdr_pointer(xdrs, objpp, obj_size, xdr_obj) -register XDR *xdrs; -char **objpp; -u_int obj_size; -xdrproc_t xdr_obj; +bool_t +xdr_pointer (xdrs, objpp, obj_size, xdr_obj) + XDR *xdrs; + char **objpp; + u_int obj_size; + xdrproc_t xdr_obj; { - bool_t more_data; + bool_t more_data; - more_data = (*objpp != NULL); - if (!xdr_bool(xdrs, &more_data)) { - return (FALSE); - } - if (!more_data) { - *objpp = NULL; - return (TRUE); - } - return (xdr_reference(xdrs, objpp, obj_size, xdr_obj)); + more_data = (*objpp != NULL); + if (!xdr_bool (xdrs, &more_data)) + { + return FALSE; + } + if (!more_data) + { + *objpp = NULL; + return TRUE; + } + return xdr_reference (xdrs, objpp, obj_size, xdr_obj); } -- cgit v1.2.3