diff options
author | Werner Koch <wk@gnupg.org> | 2013-10-22 14:26:53 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-12-05 08:27:48 +0100 |
commit | 7bacf1812b55fa78db63abaa1f5a9220e9c6cccc (patch) | |
tree | 4141585ef24a83e22e411355585784f24b78f58f /mpi/mpi-bit.c | |
parent | 85bb0a98ea5add0296cbcc415d557eaa1f6bd294 (diff) | |
download | libgcrypt-7bacf1812b55fa78db63abaa1f5a9220e9c6cccc.tar.gz |
Remove macro hacks for internal vs. external functions. Part 1.
* src/visibility.h: Remove almost all define/undef hacks for symbol
visibility. Add macros to detect the use of the public functions.
Change all affected functions by prefixing them explicitly with an
underscore and change all internal callers to call the underscore
prefixed versions. Provide convenience macros from sexp and mpi
functions.
* src/visibility.c: Change all functions to use only gpg_err_code_t
and translate to gpg_error_t only in visibility.c.
--
The use of the macro magic made if hard to follow the function calls
in the source. It was not easy to see if an internal or external
function (as defined by visibility.c) was called. The change is quite
large but hopefully makes Libgcrypt easier to maintain. Some
function have not yet been fixed; this will be done soon.
Because Libgcrypt does no make use of any other libgpg-error using
libraries it is useless to always translate between gpg_error_t and
gpg_err_code_t (i.e with and w/o error source identifier). This
translation has no mostly be moved to the function wrappers in
visibility.c. An additional advantage of using gpg_err_code_t is that
comparison can be done without using gpg_err_code().
I am sorry for that large patch, but a series of patches would
actually be more work to audit.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'mpi/mpi-bit.c')
-rw-r--r-- | mpi/mpi-bit.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c index 74042e89..fcafda04 100644 --- a/mpi/mpi-bit.c +++ b/mpi/mpi-bit.c @@ -68,7 +68,7 @@ _gcry_mpi_normalize( gcry_mpi_t a ) * Return the number of bits in A. */ unsigned int -gcry_mpi_get_nbits( gcry_mpi_t a ) +_gcry_mpi_get_nbits (gcry_mpi_t a) { unsigned n; @@ -95,7 +95,7 @@ gcry_mpi_get_nbits( gcry_mpi_t a ) * Test whether bit N is set. */ int -gcry_mpi_test_bit( gcry_mpi_t a, unsigned int n ) +_gcry_mpi_test_bit( gcry_mpi_t a, unsigned int n ) { unsigned int limbno, bitno; mpi_limb_t limb; @@ -114,7 +114,7 @@ gcry_mpi_test_bit( gcry_mpi_t a, unsigned int n ) * Set bit N of A. */ void -gcry_mpi_set_bit( gcry_mpi_t a, unsigned int n ) +_gcry_mpi_set_bit( gcry_mpi_t a, unsigned int n ) { unsigned int limbno, bitno; @@ -139,7 +139,7 @@ gcry_mpi_set_bit( gcry_mpi_t a, unsigned int n ) * Set bit N of A. and clear all bits above */ void -gcry_mpi_set_highbit( gcry_mpi_t a, unsigned int n ) +_gcry_mpi_set_highbit( gcry_mpi_t a, unsigned int n ) { unsigned int limbno, bitno; @@ -167,7 +167,7 @@ gcry_mpi_set_highbit( gcry_mpi_t a, unsigned int n ) * clear bit N of A and all bits above */ void -gcry_mpi_clear_highbit( gcry_mpi_t a, unsigned int n ) +_gcry_mpi_clear_highbit( gcry_mpi_t a, unsigned int n ) { unsigned int limbno, bitno; @@ -192,7 +192,7 @@ gcry_mpi_clear_highbit( gcry_mpi_t a, unsigned int n ) * Clear bit N of A. */ void -gcry_mpi_clear_bit( gcry_mpi_t a, unsigned int n ) +_gcry_mpi_clear_bit( gcry_mpi_t a, unsigned int n ) { unsigned int limbno, bitno; @@ -245,7 +245,7 @@ _gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count ) * Shift A by N bits to the right. */ void -gcry_mpi_rshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) +_gcry_mpi_rshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) { mpi_size_t xsize; unsigned int i; @@ -360,7 +360,7 @@ _gcry_mpi_lshift_limbs (gcry_mpi_t a, unsigned int count) * Shift A by N bits to the left. */ void -gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) +_gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) { unsigned int nlimbs = (n/BITS_PER_MPI_LIMB); unsigned int nbits = (n%BITS_PER_MPI_LIMB); @@ -400,7 +400,7 @@ gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) /* We use a very dump approach: Shift left by the number of limbs plus one and than fix it up by an rshift. */ _gcry_mpi_lshift_limbs (x, nlimbs+1); - gcry_mpi_rshift (x, x, BITS_PER_MPI_LIMB - nbits); + mpi_rshift (x, x, BITS_PER_MPI_LIMB - nbits); } MPN_NORMALIZE (x->d, x->nlimbs); |