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-gcd.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-gcd.c')
-rw-r--r-- | mpi/mpi-gcd.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mpi/mpi-gcd.c b/mpi/mpi-gcd.c index 5cbefa12..77ca05a6 100644 --- a/mpi/mpi-gcd.c +++ b/mpi/mpi-gcd.c @@ -28,7 +28,7 @@ * Return: true if this 1, false in all other cases */ int -gcry_mpi_gcd( gcry_mpi_t g, gcry_mpi_t xa, gcry_mpi_t xb ) +_gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t xa, gcry_mpi_t xb) { gcry_mpi_t a, b; @@ -38,14 +38,15 @@ gcry_mpi_gcd( gcry_mpi_t g, gcry_mpi_t xa, gcry_mpi_t xb ) /* TAOCP Vol II, 4.5.2, Algorithm A */ a->sign = 0; b->sign = 0; - while( gcry_mpi_cmp_ui( b, 0 ) ) { - _gcry_mpi_fdiv_r( g, a, b ); /* g used as temorary variable */ + while (mpi_cmp_ui (b, 0)) + { + _gcry_mpi_fdiv_r( g, a, b ); /* G is used as temporary variable. */ mpi_set(a,b); mpi_set(b,g); - } + } mpi_set(g, a); mpi_free(a); mpi_free(b); - return !gcry_mpi_cmp_ui( g, 1); + return !mpi_cmp_ui( g, 1); } |