Port: Add Solaris compat for netdb
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 15 Oct 2015 16:17:43 +0000 (12:17 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 19 Oct 2015 18:54:21 +0000 (14:54 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
src/common/compat/Makefile.am
src/common/compat/netdb.h [new file with mode: 0644]
src/common/uri.c

index 5d286beb0c2103ffef3fb394c58fd54fb03d2a95..c2f49d52d29c3662aa117d69f395fcbb05b21f57 100644 (file)
@@ -53,6 +53,8 @@ LIBS="$PTHREAD_LIBS $LIBS"
 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 CC="$PTHREAD_CC"
 
+AX_LIB_SOCKET_NSL
+
 # Compute minor/major/patchlevel version numbers
 major_version=$(echo AC_PACKAGE_VERSION | $SED 's/^\([[0-9]]\)*\.[[0-9]]*\.[[0-9]]*.*$/\1/')
 minor_version=$(echo AC_PACKAGE_VERSION | $SED 's/^[[0-9]]*\.\([[0-9]]*\)\.[[0-9]]*.*$/\1/')
@@ -111,7 +113,7 @@ AC_CHECK_FUNCS([ \
        gethostbyname gethostname getpagesize localtime_r memchr memset \
        mkdir munmap putenv realpath rmdir socket strchr strcspn strdup \
        strncasecmp strndup strnlen strpbrk strrchr strstr strtol strtoul \
-       strtoull dirfd \
+       strtoull dirfd gethostbyname2 getipnodebyname \
 ])
 
 # Babeltrace viewer check
@@ -403,8 +405,6 @@ else
 
 fi
 
-AX_LIB_SOCKET_NSL
-
 # Epoll check. If not present, the build will fallback on poll() API
 AX_HAVE_EPOLL(
        [AX_CONFIG_FEATURE_ENABLE(epoll)],
index 69e2dc590bd54c5a6de3e11a7d6dabca3eaf244d..865fd7f70c3e84a13d25e279051bddc78c09152f 100644 (file)
@@ -10,4 +10,4 @@ endif
 
 libcompat_la_SOURCES = poll.h fcntl.h endian.h mman.h dirent.h \
                socket.h compat-fcntl.c uuid.h tid.h \
-               getenv.h string.h prctl.h paths.h $(COMPAT)
+               getenv.h string.h prctl.h paths.h netdb.h $(COMPAT)
diff --git a/src/common/compat/netdb.h b/src/common/compat/netdb.h
new file mode 100644 (file)
index 0000000..477058b
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _COMPAT_NETDB_H
+#define _COMPAT_NETDB_H
+
+#include <netdb.h>
+
+#ifdef HAVE_GETHOSTBYNAME2
+static inline
+struct hostent *lttng_gethostbyname2(const char *name, int af) {
+       return gethostbyname2(name, af);
+}
+#elif HAVE_GETIPNODEBYNAME
+static inline
+struct hostent *lttng_gethostbyname2(const char *name, int af) {
+       int unused;
+
+       return getipnodebyname(name, af, AI_DEFAULT, &unused);
+}
+#else
+# error "Missing compat for gethostbyname2()"
+#endif
+
+#endif /* _COMPAT_NETDB_H */
index dd2d9e4eea4bd0379eac739d9589b7b55727a91b..ef68cd4fad28be8f3a26e82db2f8e10812739f46 100644 (file)
@@ -18,7 +18,7 @@
 #define _LGPL_SOURCE
 #include <assert.h>
 #include <arpa/inet.h>
-#include <netdb.h>
+#include <common/compat/netdb.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
@@ -115,7 +115,7 @@ static int set_ip_address(const char *addr, int af, char *dst, size_t size)
        ret = inet_pton(af, addr, buf);
        if (ret < 1) {
                /* We consider the dst to be an hostname or an invalid IP char */
-               record = gethostbyname2(addr, af);
+               record = lttng_gethostbyname2(addr, af);
                if (record == NULL) {
                        /* At this point, the IP or the hostname is bad */
                        ERR("URI parse bad hostname %s for af %d", addr, af);
This page took 0.029155 seconds and 5 git commands to generate.