[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Nbd] [PATCH] compat: Define AI_NUMERICSERV as `0' if necessary



Date: Sat, 19 May 2012 11:00:00 -0000

AI_NUMERICSERV as a value for the `ai_flags' member
of `struct addrinfo' of header <netdb.h> has only
been available since:

  POSIX 1003.1-2008, Issue 7
  glibc 2.3.4
  Mac OS X 10.6
  etc.

Fortunately, its main purpose seems to be only
to optimize calls of `getaddrinfo', and because it
is meant to be a bit flag, it can therefore be
[relatively] safely ignored by defining it to have
the value zero.

Signed-off-by: Michael Witten <mfwitten@...17...>
---
 nbd-client.c   |  1 +
 nbd-server.c   |  1 +
 netdb-compat.h | 24 ++++++++++++++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 netdb-compat.h

diff --git a/nbd-client.c b/nbd-client.c
index 0e62821..81e0afa 100644
--- a/nbd-client.c
+++ b/nbd-client.c
@@ -28,6 +28,7 @@
 #include <netinet/tcp.h>
 #include <netinet/in.h>
 #include <netdb.h>
+#include "netdb-compat.h"
 #include <stdio.h>
 #include <fcntl.h>
 #include <syslog.h>
diff --git a/nbd-server.c b/nbd-server.c
index f2e611f..2c0e9bb 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -77,6 +77,7 @@
 #include <netinet/tcp.h>
 #include <netinet/in.h>
 #include <netdb.h>
+#include "netdb-compat.h"
 #include <syslog.h>
 #include <unistd.h>
 #include <stdbool.h>
diff --git a/netdb-compat.h b/netdb-compat.h
new file mode 100644
index 0000000..7389ea7
--- /dev/null
+++ b/netdb-compat.h
@@ -0,0 +1,24 @@
+#ifndef NETDB COMPAT_H
+#define NETDB_COMPAT_H
+
+/* AI_NUMERICSERV as a value for the `ai_flags' member
+ * of `struct addrinfo' of header <netdb.h> has only
+ * been available since:
+ *
+ *   POSIX 1003.1-2008, Issue 7
+ *   glibc 2.3.4
+ *   Mac OS X 10.6
+ *   etc.
+ *
+ * Fortunately, its main purpose seems to be only
+ * to optimize calls of `getaddrinfo', and because it
+ * is meant to be a bit flag, it can therefore be
+ * [relatively] safely ignored by defining it to have
+ * the value zero.
+ */
+
+#ifndef AI_NUMERICSERV
+#define AI_NUMERICSERV 0
+#endif
+
+#endif
-- 
1.7.10.2.484.gcd07cc5




Reply to: