diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-09-05 13:28:20 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-09-05 13:28:20 +0000 |
commit | b37f75f7e385e7a84066a2f3d5235af8f8a9e76d (patch) | |
tree | dea73fa02b58c4e49a2255042ad6e3514a31aaaa /mpfr-gmp.h | |
parent | 6ca09f1465cee45788d94557322b4c0f078719d3 (diff) | |
download | mpfr-b37f75f7e385e7a84066a2f3d5235af8f8a9e76d.tar.gz |
MPN_COPY now calls memcpy only if dst != src (otherwise this is an
undefined behavior), and if WANT_ASSERT is defined, it checks that
there is no overlap.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3779 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'mpfr-gmp.h')
-rw-r--r-- | mpfr-gmp.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/mpfr-gmp.h b/mpfr-gmp.h index f68c5d5f7..14a9324c5 100644 --- a/mpfr-gmp.h +++ b/mpfr-gmp.h @@ -94,7 +94,19 @@ extern "C" { #define MPN_ZERO(dst, n) memset((dst), 0, (n)*BYTES_PER_MP_LIMB) #define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB) #define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB) -#define MPN_COPY(dst,src,n) memcpy((dst),(src),(n)*BYTES_PER_MP_LIMB) +#define MPN_COPY(dst,src,n) \ + do \ + { \ + if ((dst) != (src)) \ + { \ + MPFR_ASSERTD ((char *) (dst) >= (char *) (src) + \ + (n) * BYTES_PER_MP_LIMB || \ + (char *) (src) >= (char *) (dst) + \ + (n) * BYTES_PER_MP_LIMB); \ + memcpy ((dst), (src), (n) * BYTES_PER_MP_LIMB); \ + } \ + } \ + while (0) /* MPN macros taken from gmp-impl.h */ #define MPN_NORMALIZE(DST, NLIMBS) \ |