Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nettle
nettle
Commits
38859630
Commit
38859630
authored
Mar 23, 2013
by
Martin Storsjö
Committed by
Niels Möller
Apr 04, 2013
Browse files
Add fallback functions for mpn_copyd, mpn_copyi and mpn_zero.
parent
0d039117
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
38859630
2013-04-04 Niels Möller <nisse@lysator.liu.se>
From Martin Storsjö. Fallback functions for older GMP releases.
* gmp-glue.c (mpn_copyd, mpn_copyi, mpn_zero): New functions.
* gmp-glue.h: Declare them.
* gmp-glue.h (cnd_add_n, cnd_sub_n): Moved here, define in terms
of mpn_cnd_add_n and mpn_sub_n if available, otherwise in terms of
mpn_addmul_1 and mpn_submul_1. This seems to be an improvement for
...
...
gmp-glue.c
View file @
38859630
...
...
@@ -106,6 +106,32 @@ mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs)
}
#endif
/* !GMP_HAVE_mpz_limbs_read */
#if !GMP_HAVE_mpn_copyd
void
mpn_copyd
(
mp_ptr
dst
,
mp_srcptr
src
,
mp_size_t
n
)
{
mp_size_t
i
;
for
(
i
=
n
-
1
;
i
>=
0
;
i
--
)
dst
[
i
]
=
src
[
i
];
}
void
mpn_copyi
(
mp_ptr
dst
,
mp_srcptr
src
,
mp_size_t
n
)
{
mp_size_t
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
dst
[
i
]
=
src
[
i
];
}
void
mpn_zero
(
mp_ptr
ptr
,
mp_size_t
n
)
{
mp_size_t
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
ptr
[
i
]
=
0
;
}
#endif
/* !GMP_HAVE_mpn_copyd */
/* Additional convenience functions. */
int
...
...
gmp-glue.h
View file @
38859630
...
...
@@ -33,6 +33,12 @@
#define GMP_HAVE_mpz_limbs_read 0
#endif
#ifdef mpn_copyd
#define GMP_HAVE_mpn_copyd 1
#else
#define GMP_HAVE_mpn_copyd 0
#endif
/* Name mangling. */
#if !GMP_HAVE_mpz_limbs_read
#define mpz_limbs_read _nettle_mpz_limbs_read
...
...
@@ -42,6 +48,12 @@
#define mpz_roinit_n _nettle_mpz_roinit_n
#endif
#if !GMP_HAVE_mpn_copyd
#define mpn_copyd _nettle_mpn_copyd
#define mpn_copyi _nettle_mpn_copyi
#define mpn_zero _nettle_mpn_zero
#endif
#define mpz_limbs_cmp _nettle_mpz_limbs_cmp
#define mpz_limbs_read_n _nettle_mpz_limbs_read_n
#define mpz_limbs_copy _nettle_mpz_limbs_copy
...
...
@@ -92,6 +104,20 @@ mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs);
#endif
/* !GMP_HAVE_mpz_limbs_read */
#if !GMP_HAVE_mpn_copyd
/* Copy elements, backwards */
void
mpn_copyd
(
mp_ptr
dst
,
mp_srcptr
src
,
mp_size_t
n
);
/* Copy elements, forwards */
void
mpn_copyi
(
mp_ptr
dst
,
mp_srcptr
src
,
mp_size_t
n
);
/* Zero elements */
void
mpn_zero
(
mp_ptr
ptr
,
mp_size_t
n
);
#endif
/* !GMP_HAVE_mpn_copyd */
/* Convenience functions */
int
mpz_limbs_cmp
(
mpz_srcptr
a
,
const
mp_limb_t
*
bp
,
mp_size_t
bn
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment