summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-04-22 19:53:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-04-22 19:53:02 -0700
commitb59969be0d3254e336abcde112528a4fc4179880 (patch)
tree4531cf6a0fee66f140bfcd8195d0a351a3d61261
parentb7a14e042d13adb8bee95c1d1d18ceb30436055d (diff)
downloadtxr-b59969be0d3254e336abcde112528a4fc4179880.tar.gz
txr-b59969be0d3254e336abcde112528a4fc4179880.tar.bz2
txr-b59969be0d3254e336abcde112528a4fc4179880.zip
config-types patch
* mpi/mpi-types.h: Rewritten by hand to use make use of information produced by TXR's configure script into config/config.h. * mpi/mpi.c, mpi/mplogic.c: Include the config.h header, now needed by mpi-types.h.
-rw-r--r--mpi/mpi-types.h65
-rw-r--r--mpi/mpi.c1
-rw-r--r--mpi/mplogic.c1
3 files changed, 54 insertions, 13 deletions
diff --git a/mpi/mpi-types.h b/mpi/mpi-types.h
index e222d68d..d8d1a718 100644
--- a/mpi/mpi-types.h
+++ b/mpi/mpi-types.h
@@ -1,17 +1,56 @@
-/* Type definitions generated by 'types.pl' */
+/*
+ * Universal. We can further tweak these by making them
+ * bitfields inside the mp_int struct.
+ */
+typedef int mp_sign;
+typedef int mp_size;
-typedef char mp_sign;
-typedef unsigned short mp_digit; /* 2 byte type */
-typedef unsigned int mp_word; /* 4 byte type */
-typedef unsigned int mp_size;
-typedef int mp_err;
+/*
+ * Universal. Does not need platform configuration.
+ */
+typedef int mp_err;
-#define MP_DIGIT_BIT (CHAR_BIT*sizeof(mp_digit))
-#define MP_DIGIT_MAX USHRT_MAX
-#define MP_WORD_BIT (CHAR_BIT*sizeof(mp_word))
-#define MP_WORD_MAX UINT_MAX
+#if HAVE_USUPERLONG_T && HAVE_ULONGLONG_T && \
+ SIZEOF_SUPERLONG_T / 2 == SIZEOF_LONGLONG_T && \
+ SIZEOF_PTR >= SIZEOF_LONGLONG_T
+ typedef ulonglong_t mp_digit;
+ typedef usuperlong_t mp_word;
+ #define MP_DIGIT_SIZE SIZEOF_LONGLONG_T
+ #define DIGIT_FMT "%" #SIZEOF_SUPERLONG_T "llx"
+#elif HAVE_ULONGLONG_T && SIZEOF_LONGLONG_T / 2 == SIZEOF_LONG && \
+ SIZEOF_PTR >= SIZEOF_LONG
+ typedef unsigned long mp_digit;
+ typedef ulonglong_t mp_word;
+ #define MP_DIGIT_SIZE SIZEOF_LONG
+ #define DIGIT_FMT "%" #SIZEOF_LONGLONG_T "lx"
+#elif HAVE_ULONGLONG_T && SIZEOF_LONGLONG_T / 2 == SIZEOF_INT && \
+ SIZEOF_PTR >= SIZEOF_INT
+ typedef unsigned int mp_digit;
+ typedef ulonglong_t mp_word;
+ #define MP_DIGIT_SIZE SIZEOF_INT
+ #define DIGIT_FMT "%" #SIZEOF_LONGLONG_T "lx"
+#elif SIZEOF_LONG / 2 == SIZEOF_INT && SIZEOF_PTR >= SIZEOF_INT
+ typedef unsigned int mp_digit;
+ typedef unsigned long mp_word;
+ #define MP_DIGIT_SIZE SIZEOF_INT
+ #define DIGIT_FMT "%" #SIZEOF_LONG "x"
+#elif SIZEOF_INT / 2 == SIZEOF_SHORT
+ typedef unsigned short mp_digit;
+ typedef unsigned int mp_word;
+ #define MP_DIGIT_SIZE SIZEOF_SHORT
+ #define DIGIT_FMT "%" #SIZEOF_INT "x"
+#elif SIZEOF_SHORT == 2
+ typedef unsigned char mp_digit;
+ typedef unsigned short mp_word;
+ #define MP_DIGIT_SIZE 1
+ #define DIGIT_FMT "%" #SIZEOF_SHORT "x"
+#else
+ #error Failure to configure MPI types on this target platform
+#endif
-#define RADIX (MP_DIGIT_MAX+1)
+#define MP_DIGIT_BIT ((int) (CHAR_BIT*sizeof(mp_digit)))
+#define MP_DIGIT_MAX ((mp_digit) -1)
+#define MP_WORD_BIT ((int) (CHAR_BIT*sizeof(mp_word)))
+#define MP_WORD_MAX ((mp_word) -1)
-#define MP_DIGIT_SIZE 2
-#define DIGIT_FMT "%04X"
+#define RADIX (((mp_word) MP_DIGIT_MAX) + 1)
diff --git a/mpi/mpi.c b/mpi/mpi.c
index e754ed2d..52346301 100644
--- a/mpi/mpi.c
+++ b/mpi/mpi.c
@@ -9,6 +9,7 @@
$Id: mpi.c,v 1.1 2004/02/08 04:29:29 sting Exp $
*/
+#include "config.h"
#include "mpi.h"
#include <stdlib.h>
#include <string.h>
diff --git a/mpi/mplogic.c b/mpi/mplogic.c
index 32df307a..5e647b88 100644
--- a/mpi/mplogic.c
+++ b/mpi/mplogic.c
@@ -9,6 +9,7 @@
$Id: mplogic.c,v 1.1 2004/02/08 04:29:29 sting Exp $
*/
+#include "config.h"
#include "mplogic.h"
#include <stdlib.h>