refactor indentation of preprocessor directives

This commit is contained in:
Francois Perrad 2017-08-30 05:56:38 +02:00
parent aab1b3d99f
commit 82a2d385db
6 changed files with 743 additions and 742 deletions

View File

@ -24,9 +24,9 @@
*/ */
#ifdef MP_LOW_MEM #ifdef MP_LOW_MEM
#define TAB_SIZE 32 # define TAB_SIZE 32
#else #else
#define TAB_SIZE 256 # define TAB_SIZE 256
#endif #endif
int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode) int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)

View File

@ -15,9 +15,9 @@
* Tom St Denis, tstdenis82@gmail.com, http://libtom.org * Tom St Denis, tstdenis82@gmail.com, http://libtom.org
*/ */
#ifdef MP_LOW_MEM #ifdef MP_LOW_MEM
#define TAB_SIZE 32 # define TAB_SIZE 32
#else #else
#define TAB_SIZE 256 # define TAB_SIZE 256
#endif #endif
int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode) int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)

View File

@ -33,9 +33,9 @@ extern "C" {
defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \ defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \ defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
defined(__LP64__) || defined(_LP64) || defined(__64BIT__) defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
#if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT)) # if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
#define MP_64BIT # define MP_64BIT
#endif # endif
#endif #endif
/* some default configurations. /* some default configurations.
@ -49,31 +49,31 @@ extern "C" {
#ifdef MP_8BIT #ifdef MP_8BIT
typedef uint8_t mp_digit; typedef uint8_t mp_digit;
typedef uint16_t mp_word; typedef uint16_t mp_word;
#define MP_SIZEOF_MP_DIGIT 1 # define MP_SIZEOF_MP_DIGIT 1
#ifdef DIGIT_BIT # ifdef DIGIT_BIT
#error You must not define DIGIT_BIT when using MP_8BIT # error You must not define DIGIT_BIT when using MP_8BIT
#endif # endif
#elif defined(MP_16BIT) #elif defined(MP_16BIT)
typedef uint16_t mp_digit; typedef uint16_t mp_digit;
typedef uint32_t mp_word; typedef uint32_t mp_word;
#define MP_SIZEOF_MP_DIGIT 2 # define MP_SIZEOF_MP_DIGIT 2
#ifdef DIGIT_BIT # ifdef DIGIT_BIT
#error You must not define DIGIT_BIT when using MP_16BIT # error You must not define DIGIT_BIT when using MP_16BIT
#endif # endif
#elif defined(MP_64BIT) #elif defined(MP_64BIT)
/* for GCC only on supported platforms */ /* for GCC only on supported platforms */
typedef uint64_t mp_digit; typedef uint64_t mp_digit;
#if defined(_WIN32) # if defined(_WIN32)
typedef unsigned __int128 mp_word; typedef unsigned __int128 mp_word;
#elif defined(__GNUC__) # elif defined(__GNUC__)
typedef unsigned long mp_word __attribute__ ((mode(TI))); typedef unsigned long mp_word __attribute__ ((mode(TI)));
#else # else
/* it seems you have a problem /* it seems you have a problem
* but we assume you can somewhere define your own uint128_t */ * but we assume you can somewhere define your own uint128_t */
typedef uint128_t mp_word; typedef uint128_t mp_word;
#endif # endif
#define DIGIT_BIT 60 # define DIGIT_BIT 60
#else #else
/* this is the default case, 28-bit digits */ /* this is the default case, 28-bit digits */
@ -81,19 +81,19 @@ extern "C" {
typedef uint32_t mp_digit; typedef uint32_t mp_digit;
typedef uint64_t mp_word; typedef uint64_t mp_word;
#ifdef MP_31BIT # ifdef MP_31BIT
/* this is an extension that uses 31-bit digits */ /* this is an extension that uses 31-bit digits */
#define DIGIT_BIT 31 # define DIGIT_BIT 31
#else # else
/* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */ /* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
#define DIGIT_BIT 28 # define DIGIT_BIT 28
#define MP_28BIT # define MP_28BIT
#endif # endif
#endif #endif
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */ /* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
#ifndef DIGIT_BIT #ifndef DIGIT_BIT
#define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */ # define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
typedef uint_least32_t mp_min_u32; typedef uint_least32_t mp_min_u32;
#else #else
typedef mp_digit mp_min_u32; typedef mp_digit mp_min_u32;
@ -101,14 +101,14 @@ extern "C" {
/* use arc4random on platforms that support it */ /* use arc4random on platforms that support it */
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
#define MP_GEN_RANDOM() arc4random() # define MP_GEN_RANDOM() arc4random()
#define MP_GEN_RANDOM_MAX 0xffffffff # define MP_GEN_RANDOM_MAX 0xffffffff
#endif #endif
/* use rand() as fall-back if there's no better rand function */ /* use rand() as fall-back if there's no better rand function */
#ifndef MP_GEN_RANDOM #ifndef MP_GEN_RANDOM
#define MP_GEN_RANDOM() rand() # define MP_GEN_RANDOM() rand()
#define MP_GEN_RANDOM_MAX RAND_MAX # define MP_GEN_RANDOM_MAX RAND_MAX
#endif #endif
#define MP_DIGIT_BIT DIGIT_BIT #define MP_DIGIT_BIT DIGIT_BIT
@ -149,11 +149,11 @@ extern int KARATSUBA_MUL_CUTOFF,
/* default precision */ /* default precision */
#ifndef MP_PREC #ifndef MP_PREC
#ifndef MP_LOW_MEM # ifndef MP_LOW_MEM
#define MP_PREC 32 /* default digits of precision */ # define MP_PREC 32 /* default digits of precision */
#else # else
#define MP_PREC 8 /* default digits of precision */ # define MP_PREC 8 /* default digits of precision */
#endif # endif
#endif #endif
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */ /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
@ -455,9 +455,9 @@ int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
/* number of primes */ /* number of primes */
#ifdef MP_8BIT #ifdef MP_8BIT
#define PRIME_SIZE 31 # define PRIME_SIZE 31
#else #else
#define PRIME_SIZE 256 # define PRIME_SIZE 256
#endif #endif
/* table of first PRIME_SIZE primes */ /* table of first PRIME_SIZE primes */

File diff suppressed because it is too large Load Diff

View File

@ -42,10 +42,10 @@ extern "C" {
/* define heap macros */ /* define heap macros */
#ifndef XMALLOC #ifndef XMALLOC
/* default to libc stuff */ /* default to libc stuff */
#define XMALLOC malloc # define XMALLOC malloc
#define XFREE free # define XFREE free
#define XREALLOC realloc # define XREALLOC realloc
#define XCALLOC calloc # define XCALLOC calloc
#else #else
/* prototypes for our heap functions */ /* prototypes for our heap functions */
extern void *XMALLOC(size_t n); extern void *XMALLOC(size_t n);

View File

@ -14,60 +14,60 @@
/* Works for RSA only, mpi.o is 68KiB */ /* Works for RSA only, mpi.o is 68KiB */
#ifdef SC_RSA_1 #ifdef SC_RSA_1
#define BN_MP_SHRINK_C # define BN_MP_SHRINK_C
#define BN_MP_LCM_C # define BN_MP_LCM_C
#define BN_MP_PRIME_RANDOM_EX_C # define BN_MP_PRIME_RANDOM_EX_C
#define BN_MP_INVMOD_C # define BN_MP_INVMOD_C
#define BN_MP_GCD_C # define BN_MP_GCD_C
#define BN_MP_MOD_C # define BN_MP_MOD_C
#define BN_MP_MULMOD_C # define BN_MP_MULMOD_C
#define BN_MP_ADDMOD_C # define BN_MP_ADDMOD_C
#define BN_MP_EXPTMOD_C # define BN_MP_EXPTMOD_C
#define BN_MP_SET_INT_C # define BN_MP_SET_INT_C
#define BN_MP_INIT_MULTI_C # define BN_MP_INIT_MULTI_C
#define BN_MP_CLEAR_MULTI_C # define BN_MP_CLEAR_MULTI_C
#define BN_MP_UNSIGNED_BIN_SIZE_C # define BN_MP_UNSIGNED_BIN_SIZE_C
#define BN_MP_TO_UNSIGNED_BIN_C # define BN_MP_TO_UNSIGNED_BIN_C
#define BN_MP_MOD_D_C # define BN_MP_MOD_D_C
#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C # define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
#define BN_REVERSE_C # define BN_REVERSE_C
#define BN_PRIME_TAB_C # define BN_PRIME_TAB_C
/* other modifiers */ /* other modifiers */
#define BN_MP_DIV_SMALL /* Slower division, not critical */ # define BN_MP_DIV_SMALL /* Slower division, not critical */
/* here we are on the last pass so we turn things off. The functions classes are still there /* here we are on the last pass so we turn things off. The functions classes are still there
* but we remove them specifically from the build. This also invokes tweaks in functions * but we remove them specifically from the build. This also invokes tweaks in functions
* like removing support for even moduli, etc... * like removing support for even moduli, etc...
*/ */
#ifdef LTM_LAST # ifdef LTM_LAST
#undef BN_MP_TOOM_MUL_C # undef BN_MP_TOOM_MUL_C
#undef BN_MP_TOOM_SQR_C # undef BN_MP_TOOM_SQR_C
#undef BN_MP_KARATSUBA_MUL_C # undef BN_MP_KARATSUBA_MUL_C
#undef BN_MP_KARATSUBA_SQR_C # undef BN_MP_KARATSUBA_SQR_C
#undef BN_MP_REDUCE_C # undef BN_MP_REDUCE_C
#undef BN_MP_REDUCE_SETUP_C # undef BN_MP_REDUCE_SETUP_C
#undef BN_MP_DR_IS_MODULUS_C # undef BN_MP_DR_IS_MODULUS_C
#undef BN_MP_DR_SETUP_C # undef BN_MP_DR_SETUP_C
#undef BN_MP_DR_REDUCE_C # undef BN_MP_DR_REDUCE_C
#undef BN_MP_REDUCE_IS_2K_C # undef BN_MP_REDUCE_IS_2K_C
#undef BN_MP_REDUCE_2K_SETUP_C # undef BN_MP_REDUCE_2K_SETUP_C
#undef BN_MP_REDUCE_2K_C # undef BN_MP_REDUCE_2K_C
#undef BN_S_MP_EXPTMOD_C # undef BN_S_MP_EXPTMOD_C
#undef BN_MP_DIV_3_C # undef BN_MP_DIV_3_C
#undef BN_S_MP_MUL_HIGH_DIGS_C # undef BN_S_MP_MUL_HIGH_DIGS_C
#undef BN_FAST_S_MP_MUL_HIGH_DIGS_C # undef BN_FAST_S_MP_MUL_HIGH_DIGS_C
#undef BN_FAST_MP_INVMOD_C # undef BN_FAST_MP_INVMOD_C
/* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
* which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
* which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
* trouble. * trouble.
*/ */
#undef BN_S_MP_MUL_DIGS_C # undef BN_S_MP_MUL_DIGS_C
#undef BN_S_MP_SQR_C # undef BN_S_MP_SQR_C
#undef BN_MP_MONTGOMERY_REDUCE_C # undef BN_MP_MONTGOMERY_REDUCE_C
#endif # endif
#endif #endif