Advertisement
h3xx

lash-git_glibc-2.14.1_workaround.patch

Nov 30th, 2011
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.40 KB | None | 0 0
  1. diff --git a/configure.ac b/configure.ac
  2. index dc437ed..9a8dba8 100644
  3. --- lash/configure.ac
  4. +++ lash/configure.ac
  5. @@ -11,6 +11,9 @@ AM_PROG_CC_C_O
  6.  AC_PROG_LIBTOOL
  7.  
  8.  
  9. +### Check for headers ###
  10. +AC_CHECK_HEADERS([rpc/xdr.h])
  11. +
  12.  ######################
  13.  ### --enable-debug ###
  14.  ######################
  15. diff --git a/liblash/lash.c b/liblash/lash.c
  16. index cd01576..5a3cedc 100644
  17. --- lash/liblash/lash.c
  18. +++ lash/liblash/lash.c
  19. @@ -33,7 +33,6 @@
  20.  #include <arpa/inet.h>
  21.  #include <unistd.h>
  22.  #include <sys/param.h>
  23. -#include <rpc/xdr.h>
  24.  
  25.  #include "common/safety.h"
  26.  #include "common/debug.h"
  27. diff --git a/liblash/lash_config.c b/liblash/lash_config.c
  28. index f6e182e..2f72ca0 100644
  29. --- lash/liblash/lash_config.c
  30. +++ lash/liblash/lash_config.c
  31. @@ -21,7 +21,25 @@
  32.  
  33.  #include <string.h>
  34.  #include <arpa/inet.h>
  35. +#ifdef HAVE_RPC_XDR_H
  36.  #include <rpc/xdr.h>
  37. +#else
  38. +/* FIXME : define our own 64-bit host <=> network byte order functions */
  39. +/*         copied mostly from <netinet/in.h> */
  40. +
  41. +# if __BYTE_ORDER == __BIG_ENDIAN
  42. +/* The host byte order is the same as network byte order,
  43. +   so these functions are all just identity.  */
  44. +# define _ntohll(x)    (x)
  45. +# define _htonll(x)    (x)
  46. +# else
  47. +#  if __BYTE_ORDER == __LITTLE_ENDIAN
  48. +#   define _ntohll(x)  __bswap_64 (x)
  49. +#   define _htonll(x)  __bswap_64 (x)
  50. +#  endif
  51. +# endif
  52. +
  53. +#endif
  54.  
  55.  #include "common/debug.h"
  56.  
  57. @@ -51,12 +69,16 @@ lash_config_write(lash_config_handle_t *handle,
  58.     }
  59.  
  60.     if (type == LASH_TYPE_DOUBLE) {
  61. +#ifdef HAVE_RPC_XDR_H
  62.         XDR x;
  63.         xdrmem_create(&x, (char *) buf, 8, XDR_ENCODE);
  64.         if (!xdr_double (&x, (double *) value)) {
  65.             lash_error("Failed to encode floating point value");
  66.             return false;
  67.         }
  68. +#else
  69. +       *((uint64_t *) buf) = _htonll(*((uint64_t *) value));
  70. +#endif
  71.         value_ptr = buf;
  72.     } else if (type == LASH_TYPE_INTEGER) {
  73.         *((uint32_t *) buf) = htonl(*((uint32_t *) value));
  74. @@ -135,6 +157,7 @@ lash_config_read(lash_config_handle_t  *handle,
  75.     dbus_message_iter_next(handle->iter);
  76.  
  77.     if (*type_ptr == LASH_TYPE_DOUBLE) {
  78. +#ifdef HAVE_RPC_XDR_H
  79.         XDR x;
  80.         double d;
  81.         xdrmem_create(&x, (char *) value_ptr, 8, XDR_DECODE);
  82. @@ -143,6 +166,10 @@ lash_config_read(lash_config_handle_t  *handle,
  83.             return -1;
  84.         }
  85.         *((double *) value_ptr) = d;
  86. +#else
  87. +       uint64_t d = *((uint64_t *) value_ptr);
  88. +       *((double *) value_ptr) = _ntohll(d);
  89. +#endif
  90.         size = sizeof(double);
  91.     } else if (*type_ptr == LASH_TYPE_INTEGER) {
  92.         uint32_t u = *((uint32_t *) value_ptr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement