[libvirt] [PATCH] Missing htonl (etc) on MinGW

With the attached patch you can get all the way through a compile of libvirt using the MinGW cross-compiler. Basically MinGW lacks the htonl/ntohl/htons/ntohs functions. This simply adds the same functions from glibc (which has a compatible license) in a single file called "byteswap.h". The reason it worked previously was that PortableXDR used to provide these functions by linking to winsock2. However I have now removed that dependency from PortableXDR because it prevented a DLL being built of PortableXDR. This doesn't fully resolve dynamic linking of libvirt yet, but it is one step (or rather, one library) closer to happening. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my OCaml programming blog: http://camltastic.blogspot.com/ Fedora now supports 59 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora

"Richard W.M. Jones" <rjones@redhat.com> wrote:
With the attached patch you can get all the way through a compile of libvirt using the MinGW cross-compiler. ... Index: configure.in =================================================================== ... -AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity]) +AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity ntohl htonl ntohs htons])
Hi Rich, That looks fine. Two suggestions and a question: If you add those on a separate line, not only will these related checks be all by themselves (less risk of eventual conflict, however small), you'll also avoid going over the 80-col line-length limit ;-) AC_CHECK_FUNCS([ntohl htonl ntohs htons]) ...
Index: include/byteswap.h =================================================================== ... +#ifndef _PORTABLEXDR_BYTESWAP_H +#define _PORTABLEXDR_BYTESWAP_H 1
A different name file name might be nice, so this file is not confused (by people) with the system-provided <byteswap.h>. Maybe byteswap-pxdr.h or something similar. ...
+#if BYTE_ORDER == BIG_ENDIAN + return x; +#elif BYTE_ORDER == LITTLE_ENDIAN + return __bswap_32 (x); +#else +# error "What kind of system is this?" +#endif
Where is BYTE_ORDER defined? normally in endian.h. More curiosity than anything, since I'm sure it works everywhere you built it. I sort of expected to see an "#include <endian.h>" somewhere.

On Tue, Jul 08, 2008 at 07:43:07PM +0200, Jim Meyering wrote:
+#ifndef _PORTABLEXDR_BYTESWAP_H +#define _PORTABLEXDR_BYTESWAP_H 1
A different name file name might be nice, so this file is not confused (by people) with the system-provided <byteswap.h>. Maybe byteswap-pxdr.h or something similar.
...
+#if BYTE_ORDER == BIG_ENDIAN + return x; +#elif BYTE_ORDER == LITTLE_ENDIAN + return __bswap_32 (x); +#else +# error "What kind of system is this?" +#endif
Where is BYTE_ORDER defined? normally in endian.h. More curiosity than anything, since I'm sure it works everywhere you built it. I sort of expected to see an "#include <endian.h>" somewhere.
Ugh, yes, excessive copy and paste. I think a better approach is to contribute these as a module for Gnulib anyway. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my OCaml programming blog: http://camltastic.blogspot.com/ Fedora now supports 59 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
participants (2)
-
Jim Meyering
-
Richard W.M. Jones