summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-rw-r--r--daemon/.gitignore1
-rw-r--r--daemon/Makefile.am1
-rw-r--r--daemon/configure.ac4
-rw-r--r--daemon/htonl.c82
-rw-r--r--daemon/m4/gnulib-cache.m43
5 files changed, 90 insertions, 1 deletions
diff --git a/daemon/.gitignore b/daemon/.gitignore
index ac1b47bf..0d9dac70 100644
--- a/daemon/.gitignore
+++ b/daemon/.gitignore
@@ -4,6 +4,7 @@ link-warning.h
m4/00gnulib.m4
m4/alloca.m4
m4/arpa_inet_h.m4
+m4/byteswap.m4
m4/canonicalize-lgpl.m4
m4/chdir-long.m4
m4/chown.m4
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 103e49d9..2f434487 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -91,6 +91,7 @@ guestfsd_SOURCES = \
guestfsd.c \
headtail.c \
hexdump.c \
+ htonl.c \
initrd.c \
inotify.c \
link.c \
diff --git a/daemon/configure.ac b/daemon/configure.ac
index bd0bdbea..1d335b11 100644
--- a/daemon/configure.ac
+++ b/daemon/configure.ac
@@ -171,6 +171,8 @@ AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
dnl Functions which may not be available in older distributions.
AC_CHECK_FUNCS([\
getxattr \
+ htonl \
+ htons \
inotify_init1 \
lgetxattr \
listxattr \
@@ -178,6 +180,8 @@ AC_CHECK_FUNCS([\
lsetxattr \
lremovexattr \
mknod \
+ ntohl \
+ ntohs \
posix_fallocate \
removexattr \
setxattr \
diff --git a/daemon/htonl.c b/daemon/htonl.c
new file mode 100644
index 00000000..c9f1af0a
--- /dev/null
+++ b/daemon/htonl.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 1993,97,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Windows lacks htonl, htons, ntohl, ntohs. It defines them in
+ * header files, but doesn't have them in any library. However
+ * because it defined them we can end up with conflicting
+ * definitions, which is why here we are careful to avoid
+ * including any Windows header file.
+ */
+
+#include <config.h>
+
+#include <stdint.h>
+#include <sys/param.h>
+#include <byteswap.h>
+
+#ifndef HAVE_NTOHL
+
+#undef htonl
+#undef ntohl
+
+uint32_t
+htonl (x)
+ uint32_t x;
+{
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
+#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
+#else
+#error "BYTE_ORDER/BIG_ENDIAN/LITTLE_ENDIAN are not defined"
+#endif
+}
+
+uint32_t ntohl (uint32_t x) { return htonl (x); }
+
+#endif /* !HAVE_NTOHL */
+
+#ifndef HAVE_NTOHS
+
+#undef htons
+#undef ntohs
+
+uint16_t
+htons (x)
+ uint16_t x;
+{
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
+#if BYTE_ORDER == BIG_ENDIAN
+ return x;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ return bswap_16 (x);
+#else
+# error "What kind of system is this?"
+#endif
+#else
+#error "BYTE_ORDER/BIG_ENDIAN/LITTLE_ENDIAN are not defined"
+#endif
+}
+
+uint16_t ntohs (uint16_t x) { return htons (x); }
+
+#endif /* !HAVE_NTOHS */
diff --git a/daemon/m4/gnulib-cache.m4 b/daemon/m4/gnulib-cache.m4
index 01da897a..e8b9edf1 100644
--- a/daemon/m4/gnulib-cache.m4
+++ b/daemon/m4/gnulib-cache.m4
@@ -15,11 +15,12 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl c-ctype fsusage futimens getaddrinfo getline glob hash ignore-value manywarnings mkdtemp netdb openat perror pread readlink select sleep strchrnul strndup sys_select sys_wait vasprintf warnings
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl byteswap c-ctype fsusage futimens getaddrinfo getline glob hash ignore-value manywarnings mkdtemp netdb openat perror pread readlink select sleep strchrnul strndup sys_select sys_wait vasprintf warnings
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([
+ byteswap
c-ctype
fsusage
futimens