summaryrefslogtreecommitdiff
path: root/mpz
diff options
context:
space:
mode:
Diffstat (limited to 'mpz')
-rw-r--r--mpz/import.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/mpz/import.c b/mpz/import.c
index e40b5ed57..ad909d2f7 100644
--- a/mpz/import.c
+++ b/mpz/import.c
@@ -1,6 +1,6 @@
/* mpz_import -- set mpz from word data.
-Copyright 2002, 2012 Free Software Foundation, Inc.
+Copyright 2002, 2012, 2021 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -64,36 +64,33 @@ mpz_import (mpz_ptr z, size_t count, int order,
/* Can't use these special cases with nails currently, since they don't
mask out the nail bits in the input data. */
- if (nail == 0 && GMP_NAIL_BITS == 0)
+ if (nail == 0 && GMP_NAIL_BITS == 0
+ && size == sizeof (mp_limb_t)
+ && (((char *) data - (char *) NULL) % sizeof (mp_limb_t)) == 0 /* align */)
{
- unsigned align = ((char *) data - (char *) NULL) % sizeof (mp_limb_t);
-
- if (order == -1
- && size == sizeof (mp_limb_t)
- && endian == HOST_ENDIAN
- && align == 0)
+ if (order == -1 && endian == HOST_ENDIAN)
{
MPN_COPY (zp, (mp_srcptr) data, (mp_size_t) count);
goto done;
}
- if (order == -1
- && size == sizeof (mp_limb_t)
- && endian == - HOST_ENDIAN
- && align == 0)
+ if (order == -1 && endian == - HOST_ENDIAN)
{
MPN_BSWAP (zp, (mp_srcptr) data, (mp_size_t) count);
goto done;
}
- if (order == 1
- && size == sizeof (mp_limb_t)
- && endian == HOST_ENDIAN
- && align == 0)
+ if (order == 1 && endian == HOST_ENDIAN)
{
MPN_REVERSE (zp, (mp_srcptr) data, (mp_size_t) count);
goto done;
}
+
+ if (order == 1 && endian == -HOST_ENDIAN)
+ {
+ MPN_BSWAP_REVERSE (zp, (mp_srcptr) data, (mp_size_t) count);
+ goto done;
+ }
}
{