Add xdr support

Charles Wilson
Sat Feb 13 06:44:00 GMT 2010

The attached patch(es) add XDR support to cygwin. eXternal Data
Representation (XDR) is a standard data encoding mechanism (RFC 1832,
4506) most frequently seen in the implementation of the SunRPC protocol.
 XDR allows binary data structures to be encoded in an architecture
independent manner for communication between heterogeneous computer systems.

For years, the Sun RPC code, and the XDR implementation, was in legal
license limbo
as its license terms were of debatable compatibility with the GPL. In
February of 2009, that changed:

As documented in the libtirpc rpm.spec file from Fedora 11:
* Tue May 19 2009 Tom "spot" Callaway <> 0.1.10-7
- Replace the Sun RPC license with the BSD license, with the explicit
  permission of Sun Microsystems

So, the attached implementations were taken from Fedora 11's libtirpc
package, after the modifications by Tom Callaway. Thus, each file
carries the (3-clause) BSD license, and not the old "SunRPC" license.

Last year, I worked on it some to get it to compile cleanly under cygwin
(1.5,1.7), mingw, msvc80, and linux (32bit, 64bit), while being careful
to maintain the BSD license.  I also wrote a whole slew of tests to
guarantee correct operation and identical representation on all of these
platforms (these carry the MIT/X license). I won't say it has full test
coverage, but it's awfully close.  Anyway, I finally got around to
uploading that package to googlecode this week:

The attached patch is basically a fork of that bsd-xdr core code. I
removed all the #ifdefs that made msvc80 and mingw happy, as they aren't
needed in newlib and would complicate any attempt to expand the use of
the new code to other newlib targets other than cygwin.  I reworked both
the headers and implementation files to follow newlib-isms like using
_EXFUN() and _DEFUN macros and such.  I did not, however, attempt to add
'chew'-able documentation to the various files.

This fork, rather than relying on <byteorder.h> (which isn't available
inside newlib), uses its own private ntohl/htonl implementations. Also,
while most xdr implementations print errors to stderr using the
BSD-flavor warnx() function, this version allows the caller to configure
an error reporting function (more below).

I did not include the test suite; it would take quite a bit of effort to
translate the bsd-xdr/test/ code into cygwin's testsuite framework --
newlib/libc/ itself doesn't appear to have a test suite AFAICT.  I'm not
sure it's worth the effort, actually -- none of the BSD's or glibc or
linux's include test code for XDR, which is why I had to code tests from
the ground up for my bsd-xdr package.  I did link my test suite against
this implementation inside a newly-built cygwin1.dll, and it passed with
flying colors.

Most of the code goes in newlib, but is only built for $host cygwin.
However, I post it here first for review and comments; rev 2 will go to
the newlib list.  The cygwin components are basically just adding the
new exports, and providing a callback function for the error reporting
framework in the xdr implementation, that uses (in effect) debug_printf().

Note that the newlib patches depend on the ones I posted earlier today
to the newlib list, concerning compatibility with the src/libtool.m4 and
src/ files which were recently updated, as well as
compatibility with ac-2.64 and am-1.11.1:

So, apply those two patches first, then these three.  Yes, three: (1)
newlib 'primary' changes, (2) newlib 're-autotool' changes, and (3)
cygwin changes.  I had to compress the first two, because they are too
large to include as inline attachments.

Obviously, the newlib contributions can retain their BSD (or MIT/X, for
two internal files) license, like all the other such files in newlib.
The cygwin components are GPL, and fall under my existing copyright
assignment to Red Hat.

Patch#1: newlib primary
2010-02-12  Charles Wilson  <...>

        Add eXtensible Data Record (XDR) support for cygwin
	* Build libc/xdr only on cygwin.
	* Install xdr headers.
	* libc/ Support new libc/xdr subdirectory.
	* libc/ Support new libc/xdr subdirectory.
	* libc/include/rpc/types.h: New.
	* libc/include/rpc/xdr.h: New.
	* libc/xdr/ New.
	* libc/xdr/dummy.c: New.
	* libc/xdr/xdr.c: New.
	* libc/xdr/xdr_array.c: New.
	* libc/xdr/xdr_float.c: New.
	* libc/xdr/xdr_mem.c: New.
	* libc/xdr/xdr_private.c: New.
	* libc/xdr/xdr_private.h: New.
	* libc/xdr/xdr_rec.c: New.
	* libc/xdr/xdr_reference.c: New.
	* libc/xdr/xdr_sizeof.c: New.
	* libc/xdr/xdr_stdio.c: New.

Patch#2: newlib auto
2010-02-12  Charles Wilson  <...>

	Regenerate using ac-2.64 and am-1.11.1
	* Regenerate.
	* libc/configure: Regenerate.
	* libc/ Regenerate.
	* libc/argz/ Regenerate.
	* libc/ctype/ Regenerate.
	* libc/errno/ Regenerate.
	* libc/iconv/ccs/binary/ Regenerate.
	* libc/iconv/ccs/ Regenerate.
	* libc/iconv/ces/ Regenerate.
	* libc/iconv/lib/ Regenerate.
	* libc/iconv/ Regenerate.
	* libc/locale/ Regenerate.
	* libc/misc/ Regenerate.
	* libc/posix/ Regenerate.
	* libc/reent/ Regenerate.
	* libc/search/ Regenerate.
	* libc/signal/ Regenerate.
	* libc/stdio/ Regenerate.
	* libc/stdio64/ Regenerate.
	* libc/stdlib/ Regenerate.
	* libc/string/ Regenerate.
	* libc/syscalls/ Regenerate.
	* libc/time/ Regenerate.
	* libc/unix/ Regenerate.
	* libc/xdr/ Regenerate.

Patch #3: cygwin
2010-02-12  Charles Wilson  <...>

	Add XDR support.
	* cygwin.din: Export xdr functions.
	* include/cygwin/version.h: Bump version.
	* New.
	* cygxdr.h: New.
	* Ensure that xdr functions use an approximation
	to debug_print for warnings, rather than stderr.
	* Add cygxdr.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: xdr-cygwin.patch
Type: text/x-patch
Size: 4841 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xdr-newlib-primary.patch.lzma
Type: application/octet-stream
Size: 20184 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xdr-newlib-auto.patch.lzma
Type: application/octet-stream
Size: 7090 bytes
Desc: not available
URL: <>

More information about the Cygwin-patches mailing list