Skip to content
Snippets Groups Projects
Commit dbb7e640 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel :man_dancing:
Browse files

Introduce new SIZEOF_MP_LIMB_T derived constant


This allows to simplify code in `float.c` and to encode the
"sizeof(mp_limb_t) != sizeof(W_)" assumption as a compile-time
assertion.

Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
parent fbf7ee1c
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
/* #include "PosixSource.h" */ /* #include "PosixSource.h" */
#include "Rts.h" #include "Rts.h"
#include "gmp.h" #include "gmp.h"
#include "GmpDerivedConstants.h"
#include <math.h> #include <math.h>
...@@ -21,15 +22,7 @@ ...@@ -21,15 +22,7 @@
* (lib/fltcode.c). * (lib/fltcode.c).
*/ */
#ifdef _SHORT_LIMB #define SIZEOF_LIMB_T SIZEOF_MP_LIMB_T
#define SIZEOF_LIMB_T SIZEOF_UNSIGNED_INT
#else
#ifdef _LONG_LONG_LIMB
#define SIZEOF_LIMB_T SIZEOF_UNSIGNED_LONG_LONG
#else
#define SIZEOF_LIMB_T SIZEOF_UNSIGNED_LONG
#endif
#endif
#if SIZEOF_LIMB_T == 4 #if SIZEOF_LIMB_T == 4
#define GMP_BASE 4294967296.0 #define GMP_BASE 4294967296.0
......
...@@ -80,6 +80,10 @@ import "rts" stg_INTLIKE_closure; ...@@ -80,6 +80,10 @@ import "rts" stg_INTLIKE_closure;
the case for all the platforms that GHC supports, currently. the case for all the platforms that GHC supports, currently.
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#if SIZEOF_MP_LIMB_T != SIZEOF_W
#error "sizeof(mp_limb_t) != sizeof(W_)"
#endif
/* This is used when a dummy pointer is needed for a ByteArray# return value /* This is used when a dummy pointer is needed for a ByteArray# return value
Ideally this would be a statically allocated 'ByteArray#' Ideally this would be a statically allocated 'ByteArray#'
......
...@@ -69,6 +69,7 @@ main(int argc, char *argv[]) ...@@ -69,6 +69,7 @@ main(int argc, char *argv[])
struct_field(MP_INT,_mp_alloc); struct_field(MP_INT,_mp_alloc);
struct_field(MP_INT,_mp_size); struct_field(MP_INT,_mp_size);
struct_field(MP_INT,_mp_d); struct_field(MP_INT,_mp_d);
def_size("MP_LIMB_T", sizeof(mp_limb_t));
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment