]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2026] Detect Py_hash_t in ./configure and define it internally if not
authorMukund Sivaraman <muks@isc.org>
Fri, 10 Jan 2014 05:08:41 +0000 (10:38 +0530)
committerMukund Sivaraman <muks@isc.org>
Fri, 10 Jan 2014 05:21:12 +0000 (10:51 +0530)
configure.ac
src/lib/dns/python/.gitignore
src/lib/dns/python/Makefile.am
src/lib/dns/python/pydnspp_common.h
src/lib/dns/python/pydnspp_config.h.in [new file with mode: 0644]

index 5bfd318b5aa959512b710693ac987090ac3df6e2..afa9ade4577a722870db23fb8423e6c9872d0875 100644 (file)
@@ -410,6 +410,24 @@ fi
 AC_SUBST(PYTHON_LIB)
 LDFLAGS=$LDFLAGS_SAVED
 
+# Python 3.2 changed the return type of internal hash function to
+# Py_hash_t and some platforms (such as Solaris) strictly check for long
+# vs Py_hash_t. So we detect and use the appropriate return type.
+# Remove this test (and associated changes in pydnspp_config.h.in) when
+# we require Python 3.2.
+have_py_hash_t=0
+CPPFLAGS_SAVED="$CPPFLAGS"
+CPPFLAGS=${PYTHON_INCLUDES}
+AC_MSG_CHECKING(for Py_hash_t)
+AC_TRY_COMPILE([#include <Python.h>
+                Py_hash_t h;],,
+    [AC_MSG_RESULT(yes)
+     have_py_hash_t=1],
+    [AC_MSG_RESULT(no)])
+CPPFLAGS="$CPPFLAGS_SAVED"
+HAVE_PY_HASH_T=$have_py_hash_t
+AC_SUBST(HAVE_PY_HASH_T)
+
 # Check for the setproctitle module
 if test "$setproctitle_check" = "yes" ; then
     AC_MSG_CHECKING(for setproctitle module)
@@ -1478,6 +1496,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/lib/dns/gen-rdatacode.py
                  src/lib/dns/Makefile
                  src/lib/dns/python/Makefile
+                 src/lib/dns/python/pydnspp_config.h
                  src/lib/dns/python/tests/Makefile
                  src/lib/dns/tests/Makefile
                  src/lib/dns/tests/testdata/Makefile
index 025ddd1d82a97450b586c5b9c3195ef7df9fd08e..0713cf8c8f68c0b42ecb03d81126b161494d8016 100644 (file)
@@ -1,2 +1,3 @@
 /rrclass_constants_inc.cc
 /rrtype_constants_inc.cc
+/pydnspp_config.h
index a221bfee5147075f2204838cb84be25e72f02ece..96542397a636444f5ec59bb8068d3e843cc1a44c 100644 (file)
@@ -5,7 +5,8 @@ AM_CPPFLAGS += $(BOOST_INCLUDES)
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 
 lib_LTLIBRARIES = libb10-pydnspp.la
-libb10_pydnspp_la_SOURCES = pydnspp_common.cc pydnspp_common.h pydnspp_towire.h
+libb10_pydnspp_la_SOURCES = pydnspp_common.cc pydnspp_common.h
+libb10_pydnspp_la_SOURCES += pydnspp_config.h pydnspp_towire.h
 libb10_pydnspp_la_SOURCES += name_python.cc name_python.h
 libb10_pydnspp_la_SOURCES += nsec3hash_python.cc nsec3hash_python.h
 libb10_pydnspp_la_SOURCES += rrset_python.cc rrset_python.h
index 8e498b3f936049431c25f1d448baf19d171d10d1..9c27cfdae1bcbcc255a288b31d674d78f277603c 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef LIBDNS_PYTHON_COMMON_H
 #define LIBDNS_PYTHON_COMMON_H 1
 
+#include <dns/python/pydnspp_config.h>
+
 #include <Python.h>
 
 #include <boost/static_assert.hpp>
@@ -60,11 +62,6 @@ int addClassVariable(PyTypeObject& c, const char* name, PyObject* obj);
 /// \return true on success, false on failure
 bool initClass(PyTypeObject& type, const char* name, PyObject* mod);
 
-// Short term workaround for unifying the return type of tp_hash
-#if PY_MINOR_VERSION < 2
-typedef long Py_hash_t;
-#endif
-
 /// \brief Convert a hash value of arbitrary type to a Python hash value.
 ///
 /// This templated function is a convenient wrapper to produce a valid hash
diff --git a/src/lib/dns/python/pydnspp_config.h.in b/src/lib/dns/python/pydnspp_config.h.in
new file mode 100644 (file)
index 0000000..6326e8c
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (C) 2014  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef LIBDNS_PYTHON_CONFIG_H
+#define LIBDNS_PYTHON_CONFIG_H 1
+
+// Short term workaround for unifying the return type of tp_hash.
+// Remove this test (and associated changes in configure.ac) when we
+// require Python 3.2.
+#if (!(@HAVE_PY_HASH_T@))
+typedef long Py_hash_t;
+#endif
+
+#endif // LIBDNS_PYTHON_CONFIG_H