Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/configure.ac b/configure.ac
- index dc437ed..9a8dba8 100644
- --- lash/configure.ac
- +++ lash/configure.ac
- @@ -11,6 +11,9 @@ AM_PROG_CC_C_O
- AC_PROG_LIBTOOL
- +### Check for headers ###
- +AC_CHECK_HEADERS([rpc/xdr.h])
- +
- ######################
- ### --enable-debug ###
- ######################
- diff --git a/liblash/lash.c b/liblash/lash.c
- index cd01576..5a3cedc 100644
- --- lash/liblash/lash.c
- +++ lash/liblash/lash.c
- @@ -33,7 +33,6 @@
- #include <arpa/inet.h>
- #include <unistd.h>
- #include <sys/param.h>
- -#include <rpc/xdr.h>
- #include "common/safety.h"
- #include "common/debug.h"
- diff --git a/liblash/lash_config.c b/liblash/lash_config.c
- index f6e182e..2f72ca0 100644
- --- lash/liblash/lash_config.c
- +++ lash/liblash/lash_config.c
- @@ -21,7 +21,25 @@
- #include <string.h>
- #include <arpa/inet.h>
- +#ifdef HAVE_RPC_XDR_H
- #include <rpc/xdr.h>
- +#else
- +/* FIXME : define our own 64-bit host <=> network byte order functions */
- +/* copied mostly from <netinet/in.h> */
- +
- +# if __BYTE_ORDER == __BIG_ENDIAN
- +/* The host byte order is the same as network byte order,
- + so these functions are all just identity. */
- +# define _ntohll(x) (x)
- +# define _htonll(x) (x)
- +# else
- +# if __BYTE_ORDER == __LITTLE_ENDIAN
- +# define _ntohll(x) __bswap_64 (x)
- +# define _htonll(x) __bswap_64 (x)
- +# endif
- +# endif
- +
- +#endif
- #include "common/debug.h"
- @@ -51,12 +69,16 @@ lash_config_write(lash_config_handle_t *handle,
- }
- if (type == LASH_TYPE_DOUBLE) {
- +#ifdef HAVE_RPC_XDR_H
- XDR x;
- xdrmem_create(&x, (char *) buf, 8, XDR_ENCODE);
- if (!xdr_double (&x, (double *) value)) {
- lash_error("Failed to encode floating point value");
- return false;
- }
- +#else
- + *((uint64_t *) buf) = _htonll(*((uint64_t *) value));
- +#endif
- value_ptr = buf;
- } else if (type == LASH_TYPE_INTEGER) {
- *((uint32_t *) buf) = htonl(*((uint32_t *) value));
- @@ -135,6 +157,7 @@ lash_config_read(lash_config_handle_t *handle,
- dbus_message_iter_next(handle->iter);
- if (*type_ptr == LASH_TYPE_DOUBLE) {
- +#ifdef HAVE_RPC_XDR_H
- XDR x;
- double d;
- xdrmem_create(&x, (char *) value_ptr, 8, XDR_DECODE);
- @@ -143,6 +166,10 @@ lash_config_read(lash_config_handle_t *handle,
- return -1;
- }
- *((double *) value_ptr) = d;
- +#else
- + uint64_t d = *((uint64_t *) value_ptr);
- + *((double *) value_ptr) = _ntohll(d);
- +#endif
- size = sizeof(double);
- } else if (*type_ptr == LASH_TYPE_INTEGER) {
- uint32_t u = *((uint32_t *) value_ptr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement