*.c: Use the new `Py_hash_t' type.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 20 Oct 2019 23:33:22 +0000 (00:33 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:44:14 +0000 (12:44 +0100)
catacomb-python.h
ec.c
field.c
group.c
mp.c
pyke/pyke.h

index cae27c5..c3b120d 100644 (file)
@@ -180,7 +180,7 @@ extern mp *getgf(PyObject *);
 extern int convgf(PyObject *, void *);
 extern PyObject *mp_pywrap(mp *);
 extern PyObject *gf_pywrap(mp *);
-extern long mphash(mp *);
+extern Py_hash_t mphash(mp *);
 extern mp *mp_frompyobject(PyObject *, int);
 extern PyObject *mp_topystring(mp *, int,
                               const char *, const char *, const char *);
diff --git a/ec.c b/ec.c
index 82fc1a8..858aeaa 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -192,7 +192,7 @@ static PyObject *ecpt_pymul(PyObject *x, PyObject *y)
   return (ecpt_pywrap(ECPT_COBJ(y), &zz));
 }
 
-static long ecpt_pyhash(PyObject *me)
+static Py_hash_t ecpt_pyhash(PyObject *me)
 {
   uint32 h;
   ec p = EC_INIT;
diff --git a/field.c b/field.c
index 907913d..8088d9f 100644 (file)
--- a/field.c
+++ b/field.c
@@ -218,7 +218,7 @@ end:
   return (rc);
 }
 
-static long fe_pyhash(PyObject *me)
+static Py_hash_t fe_pyhash(PyObject *me)
   { return (mphash(FE_X(me))); }
 
 static int fe_pycoerce(PyObject **x, PyObject **y)
diff --git a/group.c b/group.c
index 51e0fd9..8dadb7a 100644 (file)
--- a/group.c
+++ b/group.c
@@ -912,7 +912,7 @@ static PyObject *gget_g(PyObject *me, void *hunoz)
   G_COPY(g, x, g->g); return (ge_pywrap(me, x));
 }
 
-static long ge_pyhash(PyObject *me)
+static Py_hash_t ge_pyhash(PyObject *me)
 {
   buf b;
   size_t sz = GE_G(me)->noctets + 4;
diff --git a/mp.c b/mp.c
index 93dd137..99a84d1 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -545,14 +545,14 @@ end:
   return ((PyObject *)zz);
 }
 
-long mphash(mp *x)
+Py_hash_t mphash(mp *x)
 {
   PyObject *l = mp_topylong(x);
-  long h = PyObject_Hash(l);
+  Py_hash_t h = PyObject_Hash(l);
   Py_DECREF(l); return (h);
 }
 
-static long mp_pyhash(PyObject *me) { return (mphash(MP_X(me))); }
+static Py_hash_t mp_pyhash(PyObject *me) { return (mphash(MP_X(me))); }
 
 static PyObject *mpmeth_jacobi(PyObject *me, PyObject *arg)
 {
index b6a5d8d..6c4e4e1 100644 (file)
@@ -82,6 +82,13 @@ PRIVATE_SYMBOLS;
 #  define PyVarObject_HEAD_INIT(super, sz) PyObject_HEAD_INIT(super) sz,
 #endif
 
+/* Python 3.2 changed the type of hash values, so paper over this annoying
+ * difference.
+ */
+#if PY_VERSION_HEX < 0x03020000
+  typedef long Py_hash_t;
+#endif
+
 /*----- Utilities for returning values and exceptions ---------------------*/
 
 /* Returning values. */