Add XDR support (only built #if cygwin, for now)

Charles Wilson
Fri Feb 26 14:16:00 GMT 2010

Ralf Corsepius wrote:
> Neither did I have a look into the code, but some general
> remarks/comments from the RTEMS side:
> - RTEMS has an xdr port of its own (Originally derived from Sun RPC's
> original code, but heavily modified since).

Really? Where? I didn't see anything like xdr in it a
standalone library?

> - XDR in general has a lot of portability issues, esp. wrt. "exotic
> targets". Have these exotic targets been taken into account?

Yes -- in the sense that I chose to enable building libc/xdr/* only on
cygwin.  So, "exotic" targets should be unaffected (*, **) by this new
code, until/unless THEY choose to enable building it.

(*) except that, like stdio.h, rpc/types.h and rpc/xdr.h will be
installed by 'make install' regardless of whether stdio/ or xdr/ is
actually built.

(**) linux has a libc/sys/linux/include/rpc/xdr.h, even though the linux
port doesn't provide the xdr routines. IIUC, machine specific headers
will clobber generic ones, on make install. So, there's no real issue
here for $host==linux until/unless the new xdr implementation is
activated for that host.  In which case, it would probably make sense
simply to remove libc/sys/linux/include/rpc/xdr.h (ditto rpc/types.h).

> - XDR is hardly useful for systems without networking support.
> Has this consideration been taken into account (E.g. XDR not depending
> on "networking routines".)

I disagree. My original motivation for investigating xdr was for
platform-independent binary data storage, not networking.  But this
implementation of XDR has been scrubbed of reliance on stuff like
htons() (sometimes declared in asm/byteorder.h, or netinet/in.h, or

While often used (and provided alongside) RPC routines, XDR and RPC are
actually quite well separated.  The only entanglement appears to be the
following #defines, which I have removed from this version rpc/xdr.h:

#define xdr_rpcvers(xdrs, versp) xdr_u_int32(xdrs, versp)
#define xdr_rpcprog(xdrs, progp) xdr_u_int32(xdrs, progp)
#define xdr_rpcproc(xdrs, procp) xdr_u_int32(xdrs, procp)
#define xdr_rpcprot(xdrs, protp) xdr_u_int32(xdrs, protp)
#define xdr_rpcport(xdrs, portp) xdr_u_int32(xdrs, portp)

(Now, maybe those #defines should be added back, so that this xdr.h can
be used without modification by naive RPC implementations which expect
them...but that's a decision for another day).

> That said, I'd see your XDR works disabled for RTEMS at least for now
> and/or to be optional (Preferably defaulting to off).

It is, and does.  (If not, it's a bug and I want to fix it).


More information about the Newlib mailing list