aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python-internal.h
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2015-02-04 20:31:17 +0100
committerJan Kratochvil <jan.kratochvil@redhat.com>2015-02-04 20:31:17 +0100
commit881d5d5db08ee6b343e1f1fc560d785fed29428e (patch)
treede056418d750eb2b8266257e12fe1e8aec435e5a /gdb/python/python-internal.h
parent2abdd192f1ed671c5dcf0d6e52ebee96c8610b40 (diff)
downloadgdb-881d5d5db08ee6b343e1f1fc560d785fed29428e.zip
gdb-881d5d5db08ee6b343e1f1fc560d785fed29428e.tar.gz
gdb-881d5d5db08ee6b343e1f1fc560d785fed29428e.tar.bz2
Fix Python 3 build error on 32-bit hosts
on Fedora Rawhide (==22) i686 using --with-python=/usr/bin/python3 one gets: ./python/py-value.c:1696:3: error: initialization from incompatible pointer type [-Werror] valpy_hash, /*tp_hash*/ ^ ./python/py-value.c:1696:3: error: (near initialization for ‘value_object_type.tp_hash’) [-Werror] cc1: all warnings being treated as errors Makefile:2628: recipe for target 'py-value.o' failed This is because in Python 2 tp_hash was: typedef long (*hashfunc)(PyObject *); while in Python 3 tp_hash is: typedef Py_hash_t (*hashfunc)(PyObject *); Py_hash_t is int for 32-bit hosts and long for 64-bit hosts. While on 32-bit hosts sizeof(long)==sizeof(int) still the hashfunc type is formally incompatible. As this patch should have no compiled code change it is not really necessary for gdb-7.9, it would fix there just this non-fatal compilation warning: ./python/py-value.c:1696:3: warning: initialization from incompatible pointer type valpy_hash, /*tp_hash*/ ^ ./python/py-value.c:1696:3: warning: (near initialization for ‘value_object_type.tp_hash’) gdb/ChangeLog 2015-02-04 Jan Kratochvil <jan.kratochvil@redhat.com> * python/python-internal.h (Py_hash_t): Define it for Python <3.2. * python/py-value.c (valpy_fetch_lazy): Use it. Remove cast to the return type.
Diffstat (limited to 'gdb/python/python-internal.h')
-rw-r--r--gdb/python/python-internal.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 0ee8544..a77f5a6 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -169,6 +169,10 @@ typedef unsigned long gdb_py_ulongest;
#endif /* HAVE_LONG_LONG */
+#if PY_VERSION_HEX < 0x03020000
+typedef long Py_hash_t;
+#endif
+
/* Python 2.6 did not wrap Py_DECREF in 'do {...} while (0)', leading
to 'suggest explicit braces to avoid ambiguous ‘else’' gcc errors.
Wrap it ourselves, so that callers don't need to care. */