Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for python 3.12 #310

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charm/core/math/elliptic_curve/ecmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include <Python.h>
#include <structmember.h>
#include <longintrepr.h>
#include <cpython/longintrepr.h>
#include <math.h>
#include "benchmarkmodule.h"
#include "base64.h"
Expand Down
14 changes: 7 additions & 7 deletions charm/core/math/integer/integermodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void longObjToMPZ(mpz_t m, PyObject * o) {
}
mpz_set_ui(m, 0);
for (i = 0; i < size; i++) {
mpz_set_ui(temp, p->ob_digit[i]);
mpz_set_ui(temp, p->long_value.ob_digit[i]);
mpz_mul_2exp(temp2, temp, PyLong_SHIFT * i);
mpz_add(m, m, temp2);
}
Expand All @@ -107,7 +107,7 @@ void longObjToMPZ(mpz_t m, PyObject * o) {
// size = -tmp;
// BN_zero(m, 0);
// for (i = 0; i < size; i++) {
// BN_set_word(temp, p->ob_digit[i]);
// BN_set_word(temp, p->long_value.ob_digit[i]);
// mpz_mul_2exp(temp2, temp, PyLong_SHIFT * i);
// mpz_add(m, m, temp2);
// }
Expand Down Expand Up @@ -162,17 +162,17 @@ PyObject *mpzToLongObj(mpz_t m) {
return NULL;
mpz_init_set(temp, m);
for (i = 0; i < size; i++) {
l->ob_digit[i] = (digit)(mpz_get_ui(temp) & PyLong_MASK);
l->long_value.ob_digit[i] = (digit)(mpz_get_ui(temp) & PyLong_MASK);
mpz_fdiv_q_2exp(temp, temp, PyLong_SHIFT);
}
i = size;
while ((i > 0) && (l->ob_digit[i - 1] == 0))
while ((i > 0) && (l->long_value.ob_digit[i - 1] == 0))
i--;
if(isNeg) {
Py_SIZE(l) = -i;
Py_SET_SIZE(l,-i);
}
else {
Py_SIZE(l) = i;
Py_SET_SIZE(l,i);
}
mpz_clear(temp);
return (PyObject *) l;
Expand Down Expand Up @@ -1378,7 +1378,7 @@ static PyObject *genRandomBits(PyObject *self, PyObject *args) {

v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->ob_digit;
digit *p = v->long_value.ob_digit;
while (digitsleft > 1) {
RAND_bytes(buff, sizeof(long));
memcpy(&t, buff, sizeof(long));
Expand Down
2 changes: 1 addition & 1 deletion charm/core/math/integer/integermodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <structmember.h>
#include <longintrepr.h> /* for conversions */
#include <cpython/longintrepr.h> /* for conversions */
#include <math.h>
#include <string.h>
#include <gmp.h>
Expand Down
10 changes: 5 additions & 5 deletions charm/core/math/pairing/pairingmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ PyObject *mpzToLongObj (mpz_t m)
mpz_init_set (temp, m);
for (i = 0; i < size; i++)
{
l->ob_digit[i] = (digit) (mpz_get_ui (temp) & PyLong_MASK);
l->long_value.ob_digit[i] = (digit) (mpz_get_ui (temp) & PyLong_MASK);
mpz_fdiv_q_2exp (temp, temp, PyLong_SHIFT);
}
i = size;
while ((i > 0) && (l->ob_digit[i - 1] == 0))
while ((i > 0) && (l->long_value.ob_digit[i - 1] == 0))
i--;
if(isNeg) {
Py_SIZE(l) = -i;
Py_SET_SIZE(l,-i);
}
else {
Py_SIZE(l) = i;
Py_SET_SIZE(l,i);
}
mpz_clear (temp);
return (PyObject *) l;
Expand All @@ -153,7 +153,7 @@ void longObjToMPZ (mpz_t m, PyLongObject * p)
mpz_set_ui (m, 0);
for (i = 0; i < size; i++)
{
mpz_set_ui (temp, p->ob_digit[i]);
mpz_set_ui (temp, p->long_value.ob_digit[i]);
mpz_mul_2exp (temp2, temp, PyLong_SHIFT * i);
mpz_add (m, m, temp2);
}
Expand Down
2 changes: 1 addition & 1 deletion charm/core/math/pairing/pairingmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include <Python.h>
#include <structmember.h>
#include <longintrepr.h>
#include <cpython/longintrepr.h>
#include <stdlib.h>
#include <gmp.h>
#include <pbc/pbc.h>
Expand Down