[ntpsec commit] Enhance check_types. Use it to detect some IPv6-related structures.
Eric S. Raymond
esr at ntpsec.org
Sat Oct 3 16:22:15 UTC 2015
Module: ntpsec
Branch: master
Commit: d9d45a8b621979ab47c77d8af0d12dc087dcadaf
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=d9d45a8b621979ab47c77d8af0d12dc087dcadaf
Author: Eric S. Raymond <esr at thyrsus.com>
Date: Sat Oct 3 12:21:25 2015 -0400
Enhance check_types. Use it to detect some IPv6-related structures.
---
lib/isc/unix/ifiter_ioctl.c | 8 ++++----
pylib/check_type.py | 15 ++++++++-------
pylib/configure.py | 9 ++++++++-
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c
index 7f221c9..9e87f3f 100644
--- a/lib/isc/unix/ifiter_ioctl.c
+++ b/lib/isc/unix/ifiter_ioctl.c
@@ -22,7 +22,7 @@
*/
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
-#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF
+#ifdef HAVE_STRUCT_IF_LADDRCONF
#define lifc_len iflc_len
#define lifc_buf iflc_buf
#define lifc_req iflc_req
@@ -33,7 +33,7 @@
#define LIFCONF lifconf
#endif
-#ifdef ISC_PLATFORM_HAVEIF_LADDRREQ
+#ifdef HAVE_STRUCT_IF_LADDRREQ
#define lifr_addr iflr_addr
#define lifr_name iflr_name
#define lifr_dstaddr iflr_dstaddr
@@ -385,7 +385,7 @@ internal_current4(isc_interfaceiter_t *iter) {
struct ifreq ifreq;
int family;
char strbuf[BUFSIZ];
-#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
+#if !defined(HAVE_STRUCT_IF_LADDRREQ) && defined(SIOCGLIFADDR)
struct lifreq lifreq;
#else
char sabuf[256];
@@ -484,7 +484,7 @@ internal_current4(isc_interfaceiter_t *iter) {
if (family == AF_INET)
goto inet;
-#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
+#if !defined(HAVE_STRUCT_IF_LADDRREQ) && defined(SIOCGLIFADDR)
memset(&lifreq, 0, sizeof(lifreq));
memcpy(lifreq.lifr_name, iter->current.name, sizeof(lifreq.lifr_name));
memcpy(&lifreq.lifr_addr, &iter->current.address.type.in6,
diff --git a/pylib/check_type.py b/pylib/check_type.py
index f842813..c20fb43 100644
--- a/pylib/check_type.py
+++ b/pylib/check_type.py
@@ -1,8 +1,6 @@
from waflib.Configure import conf
TYPE_FRAG = """
-#include <stdint.h>
-#include <sys/types.h>
int main () {
if (sizeof (%s))
return 0;
@@ -11,13 +9,16 @@ int main () {
"""
@conf
-def check_type(ctx, type, mandatory=False):
- name = "HAVE_%s" % type.upper()
-
+def check_type(ctx, typename, headers=[], mandatory=False):
+ import os
+ name = "HAVE_%s" % typename.upper().replace(" ", "_")
+ src = ""
+ for hdr in headers:
+ src += "#include <%s>\n" % hdr
ctx.check_cc(
- fragment = TYPE_FRAG % (type),
+ fragment = src + TYPE_FRAG % (typename),
define_name = name,
execute = False,
- msg = "Checking for type %s" % (type),
+ msg = "Checking for type %s" % (typename),
mandatory = mandatory
)
diff --git a/pylib/configure.py b/pylib/configure.py
index 245c6d0..9423612 100644
--- a/pylib/configure.py
+++ b/pylib/configure.py
@@ -95,7 +95,14 @@ def cmd_configure(ctx):
types = ["int32", "int32_t", "uint32_t", "int64_t", "uint64_t", "uint_t", "size_t", "wint_t", "pid_t", "intptr_t", "uintptr_t"]
for type in sorted(types):
- ctx.check_type(type)
+ ctx.check_type(type, ["stdint.h", "sys/types.h"])
+
+ net_types = (
+ ("struct if_laddrconf", ["sys/types.h", "net/if6.h"]),
+ ("struct if_laddrreq", ["sys/types.h", "net/if6.h"]),
+ )
+ for (f, h) in net_types:
+ ctx.check_type(f, h)
structure_fields = (
("time_tick", "timex", "sys/timex.h"),
More information about the vc
mailing list