summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-12-06 23:27:53 +0900
committerChristian Grothoff <grothoff@gnunet.org>2023-12-06 23:27:53 +0900
commitdf7144108f8a1436e5d4ce57ade488d832ac99c3 (patch)
tree8cd2143d1574cdb46ea752945d194c3381db5b9c
parent6753b2378c3607c88622edd1ee6d88168c861ded (diff)
downloadlibgpuverify-df7144108f8a1436e5d4ce57ade488d832ac99c3.tar.gz
libgpuverify-df7144108f8a1436e5d4ce57ade488d832ac99c3.tar.bz2
libgpuverify-df7144108f8a1436e5d4ce57ade488d832ac99c3.zip
-re-add gmp_die
-rw-r--r--source/montgomery.cl33
1 files changed, 14 insertions, 19 deletions
diff --git a/source/montgomery.cl b/source/montgomery.cl
index 9903fc4..d1ddb5d 100644
--- a/source/montgomery.cl
+++ b/source/montgomery.cl
@@ -201,8 +201,6 @@
#define assert(x){if((x)==0){printf((char __constant *)"assert reached\n");}}
-#define NULL ((void*)0)
-
typedef unsigned MINI_GMP_LIMB_TYPE mp_limb_t;
typedef long mp_size_t;
typedef unsigned long mp_bitcnt_t;
@@ -264,9 +262,6 @@ void
mpz_init2 (mpz_t r, mp_bitcnt_t bits);
void
mpz_init_set_ui (mpz_t r, unsigned long int x);
-void
-gmp_die (const char *msg);
-
mp_size_t mpn_normalized_size (mp_srcptr xp, mp_size_t n);
void
@@ -560,13 +555,13 @@ mpz_init_set_ui (mpz_t r, unsigned long int x)
}
-void
-gmp_die (const char *msg)
-{
- //fprintf (stderr, "%s\n", msg);
- //abort();
-}
-
+#define gmp_die(msg) \
+do \
+{ \
+ printf (msg); \
+ assert(0); \
+} while (0)
+
mp_size_t mpn_normalized_size (mp_srcptr xp, mp_size_t n)
{
while (n > 0 && xp[n-1] == 0)
@@ -811,9 +806,8 @@ mpz_div_qr (mpz_t q, mpz_t r,
ds = d->_mp_size;
if (ds == 0) {
-
+ gmp_die("mpz_div_qr: Divide by zero.");
}
- //gmp_die("mpz_div_qr: Divide by zero.");
if (ns == 0)
{
@@ -1381,9 +1375,9 @@ mpz_powm (mpz_t r, const mpz_t b, const mpz_t e, const mpz_t m)
en = GMP_ABS (e->_mp_size);
mn = GMP_ABS (m->_mp_size);
- if (mn == 0) {}
- //gmp_die ("mpz_powm: Zero modulo.");
-
+ if (mn == 0) {
+ gmp_die ("mpz_powm: Zero modulo.");
+ }
if (en == 0)
{
mpz_set_ui (r, mpz_cmpabs_ui (m, 1));
@@ -1409,8 +1403,9 @@ mpz_powm (mpz_t r, const mpz_t b, const mpz_t e, const mpz_t m)
if (e->_mp_size < 0)
{
- if (!mpz_invert (base, b, m)) {}
- //gmp_die ("mpz_powm: Negative exponent and non-invertible base.");
+ if (!mpz_invert (base, b, m)) {
+ gmp_die ("mpz_powm: Negative exponent and non-invertible base.");
+ }
}
else
{