* mpicoder.c, mpi-inline.h, mpi-inv.c, mpiutil.c, mpih-div.c,

mpi-internal.h, mpi-scan.c: Edit all preprocessor instructions to remove
whitespace before the '#'.  This is not required by C89, but there are
some compilers out there that don't like it.
This commit is contained in:
David Shaw 2003-05-24 17:54:56 +00:00
parent c84fdfbe62
commit e152598106
8 changed files with 83 additions and 85 deletions

View File

@ -1,3 +1,10 @@
2003-05-24 David Shaw <dshaw@jabberwocky.com>
* mpicoder.c, mpi-inline.h, mpi-inv.c, mpiutil.c, mpih-div.c,
mpi-internal.h, mpi-scan.c: Edit all preprocessor instructions to
remove whitespace before the '#'. This is not required by C89,
but there are some compilers out there that don't like it.
2003-04-25 David Shaw <dshaw@jabberwocky.com>
* config.links: Re-disable assembler on Darwin. Darwin 6.5 broke

View File

@ -30,7 +30,7 @@
#define G10_MPI_INLINE_H
#ifndef G10_MPI_INLINE_DECL
#define G10_MPI_INLINE_DECL extern __inline__
#define G10_MPI_INLINE_DECL extern __inline__
#endif
G10_MPI_INLINE_DECL mpi_limb_t
@ -124,5 +124,4 @@ mpihelp_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
return cy;
}
#endif /*G10_MPI_INLINE_H*/

View File

@ -39,13 +39,13 @@
* checking a 768 and a 1024 bit ElGamal signature.
* (wk 22.12.97) */
#ifndef KARATSUBA_THRESHOLD
#define KARATSUBA_THRESHOLD 16
#define KARATSUBA_THRESHOLD 16
#endif
/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
#if KARATSUBA_THRESHOLD < 2
#undef KARATSUBA_THRESHOLD
#define KARATSUBA_THRESHOLD 2
#undef KARATSUBA_THRESHOLD
#define KARATSUBA_THRESHOLD 2
#endif
@ -151,8 +151,8 @@ typedef int mpi_size_t; /* (must be a signed type) */
/*-- mpiutil.c --*/
#ifdef M_DEBUG
#define mpi_alloc_limb_space(n,f) mpi_debug_alloc_limb_space((n),(f), M_DBGINFO( __LINE__ ) )
#define mpi_free_limb_space(n) mpi_debug_free_limb_space((n), M_DBGINFO( __LINE__ ) )
#define mpi_alloc_limb_space(n,f) mpi_debug_alloc_limb_space((n),(f), M_DBGINFO( __LINE__ ) )
#define mpi_free_limb_space(n) mpi_debug_free_limb_space((n), M_DBGINFO( __LINE__ ) )
mpi_ptr_t mpi_debug_alloc_limb_space( unsigned nlimbs, int sec, const char *info );
void mpi_debug_free_limb_space( mpi_ptr_t a, const char *info );
#else
@ -253,7 +253,7 @@ mpi_limb_t mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
#endif
#ifdef __GNUC__
#include "mpi-inline.h"
#include "mpi-inline.h"
#endif
#endif /*G10_MPI_INTERNAL_H*/

View File

@ -32,7 +32,7 @@
void
mpi_invm( MPI x, MPI a, MPI n )
{
#if 0
#if 0
MPI u, v, u1, u2, u3, v1, v2, v3, q, t1, t2, t3;
MPI ta, tb, tc;
@ -76,7 +76,7 @@ mpi_invm( MPI x, MPI a, MPI n )
mpi_free(t3);
mpi_free(u);
mpi_free(v);
#elif 0
#elif 0
/* Extended Euclid's algorithm (See TAOPC Vol II, 4.5.2, Alg X)
* modified according to Michael Penk's solution for Exercice 35 */
@ -157,7 +157,7 @@ mpi_invm( MPI x, MPI a, MPI n )
mpi_free(t1);
mpi_free(t2);
mpi_free(t3);
#else
#else
/* Extended Euclid's algorithm (See TAOPC Vol II, 4.5.2, Alg X)
* modified according to Michael Penk's solution for Exercice 35
* with further enhancement */
@ -263,8 +263,5 @@ mpi_invm( MPI x, MPI a, MPI n )
mpi_free(u);
mpi_free(v);
#endif
#endif
}

View File

@ -67,7 +67,7 @@ mpi_putbyte( MPI a, unsigned idx, int xc )
limb = ap[i];
for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
if( n == idx ) {
#if BYTES_PER_MPI_LIMB == 4
#if BYTES_PER_MPI_LIMB == 4
if( j == 0 )
limb = (limb & 0xffffff00) | c;
else if( j == 1 )
@ -76,7 +76,7 @@ mpi_putbyte( MPI a, unsigned idx, int xc )
limb = (limb & 0xff00ffff) | (c<<16);
else
limb = (limb & 0x00ffffff) | (c<<24);
#elif BYTES_PER_MPI_LIMB == 8
#elif BYTES_PER_MPI_LIMB == 8
if( j == 0 )
limb = (limb & 0xffffffffffffff00) | c;
else if( j == 1 )
@ -93,9 +93,9 @@ mpi_putbyte( MPI a, unsigned idx, int xc )
limb = (limb & 0xff00ffffffffffff) | (c<<48);
else
limb = (limb & 0x00ffffffffffffff) | (c<<56);
#else
#error please enhance this function, its ugly - i know.
#endif
#else
#error please enhance this function, its ugly - i know.
#endif
if( a->nlimbs <= i )
a->nlimbs = i+1;
ap[i] = limb;

View File

@ -31,7 +31,7 @@
#include "util.h"
#ifdef M_DEBUG
#undef mpi_read
#undef mpi_read
#endif
#define MAX_EXTERN_MPI_BITS 16384
@ -92,13 +92,13 @@ mpi_read(IOBUF inp, unsigned *ret_nread, int secure)
nbytes = (nbits+7) / 8;
nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
#ifdef M_DEBUG
#ifdef M_DEBUG
val = secure? mpi_debug_alloc_secure( nlimbs, info )
: mpi_debug_alloc( nlimbs, info );
#else
#else
val = secure? mpi_alloc_secure( nlimbs )
: mpi_alloc( nlimbs );
#endif
#endif
i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
i %= BYTES_PER_MPI_LIMB;
val->nbits = nbits;
@ -314,7 +314,7 @@ mpi_get_keyid( MPI a, u32 *keyid )
}
return a->nlimbs? (u32)(a->d[0] & 0xffffffff) : 0;
#else
#error Make this function work with other LIMB sizes
#error Make this function work with other LIMB sizes
#endif
}
@ -402,12 +402,12 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
a->sign = sign;
for(i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; ) {
#if BYTES_PER_MPI_LIMB == 4
#if BYTES_PER_MPI_LIMB == 4
alimb = (mpi_limb_t)*p-- ;
alimb |= (mpi_limb_t)*p-- << 8 ;
alimb |= (mpi_limb_t)*p-- << 16 ;
alimb |= (mpi_limb_t)*p-- << 24 ;
#elif BYTES_PER_MPI_LIMB == 8
#elif BYTES_PER_MPI_LIMB == 8
alimb = (mpi_limb_t)*p-- ;
alimb |= (mpi_limb_t)*p-- << 8 ;
alimb |= (mpi_limb_t)*p-- << 16 ;
@ -416,18 +416,18 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
alimb |= (mpi_limb_t)*p-- << 40 ;
alimb |= (mpi_limb_t)*p-- << 48 ;
alimb |= (mpi_limb_t)*p-- << 56 ;
#else
#error please implement for this limb size.
#endif
#else
#error please implement for this limb size.
#endif
a->d[i++] = alimb;
}
if( p >= buffer ) {
#if BYTES_PER_MPI_LIMB == 4
#if BYTES_PER_MPI_LIMB == 4
alimb = *p-- ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ;
#elif BYTES_PER_MPI_LIMB == 8
#elif BYTES_PER_MPI_LIMB == 8
alimb = (mpi_limb_t)*p-- ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
@ -436,12 +436,11 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 40 ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 48 ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 56 ;
#else
#error please implement for this limb size.
#endif
#else
#error please implement for this limb size.
#endif
a->d[i++] = alimb;
}
a->nlimbs = i;
assert( i == nlimbs );
}

View File

@ -34,10 +34,10 @@
#include "longlong.h"
#ifndef UMUL_TIME
#define UMUL_TIME 1
#define UMUL_TIME 1
#endif
#ifndef UDIV_TIME
#define UDIV_TIME UMUL_TIME
#define UDIV_TIME UMUL_TIME
#endif
/* FIXME: We should be using invert_limb (or invert_normalized_limb)
@ -533,5 +533,3 @@ mpihelp_divmod_1( mpi_ptr_t quot_ptr,
return r;
}
}

View File

@ -31,9 +31,9 @@
#ifdef M_DEBUG
#undef mpi_alloc
#undef mpi_alloc_secure
#undef mpi_free
#undef mpi_alloc
#undef mpi_alloc_secure
#undef mpi_free
#endif
/****************
@ -54,13 +54,13 @@ mpi_alloc( unsigned nlimbs )
if( DBG_MEMORY )
log_debug("mpi_alloc(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
#ifdef M_DEBUG
#ifdef M_DEBUG
a = m_debug_alloc( sizeof *a, info );
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 0, info ) : NULL;
#else
#else
a = m_alloc( sizeof *a );
a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
#endif
#endif
a->alloced = nlimbs;
a->nlimbs = 0;
a->sign = 0;
@ -87,13 +87,13 @@ mpi_alloc_secure( unsigned nlimbs )
if( DBG_MEMORY )
log_debug("mpi_alloc_secure(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
#ifdef M_DEBUG
#ifdef M_DEBUG
a = m_debug_alloc( sizeof *a, info );
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 1, info ) : NULL;
#else
#else
a = m_alloc( sizeof *a );
a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 1 ) : NULL;
#endif
#endif
a->alloced = nlimbs;
a->flags = 1;
a->nlimbs = 0;
@ -121,7 +121,7 @@ mpi_alloc_limb_space( unsigned nlimbs, int secure )
if( DBG_MEMORY )
log_debug("mpi_alloc_limb_space(%u)\n", (unsigned)len*8 );
#if 0
#if 0
if( !secure ) {
if( nlimbs == 5 && unused_limbs_5 ) { /* DSA 160 bits */
p = unused_limbs_5;
@ -139,13 +139,13 @@ mpi_alloc_limb_space( unsigned nlimbs, int secure )
return p;
}
}
#endif
#endif
#ifdef M_DEBUG
#ifdef M_DEBUG
p = secure? m_debug_alloc_secure(len, info):m_debug_alloc( len, info );
#else
#else
p = secure? m_alloc_secure( len ):m_alloc( len );
#endif
#endif
return p;
}
@ -162,7 +162,7 @@ mpi_free_limb_space( mpi_ptr_t a )
if( DBG_MEMORY )
log_debug("mpi_free_limb_space of size %lu\n", (ulong)m_size(a)*8 );
#if 0
#if 0
if( !m_is_secure(a) ) {
size_t nlimbs = m_size(a) / 4 ;
void *p = a;
@ -183,8 +183,7 @@ mpi_free_limb_space( mpi_ptr_t a )
return;
}
}
#endif
#endif
m_free(a);
}
@ -218,17 +217,17 @@ mpi_resize( MPI a, unsigned nlimbs )
* and rely on a mpi_is_secure function, which would be
* a wrapper around m_is_secure
*/
#ifdef M_DEBUG
#ifdef M_DEBUG
if( a->d )
a->d = m_debug_realloc(a->d, nlimbs * sizeof(mpi_limb_t), info );
else
a->d = m_debug_alloc_clear( nlimbs * sizeof(mpi_limb_t), info );
#else
#else
if( a->d )
a->d = m_realloc(a->d, nlimbs * sizeof(mpi_limb_t) );
else
a->d = m_alloc_clear( nlimbs * sizeof(mpi_limb_t) );
#endif
#endif
a->alloced = nlimbs;
}
@ -255,11 +254,11 @@ mpi_free( MPI a )
if( a->flags & 4 )
m_free( a->d );
else {
#ifdef M_DEBUG
#ifdef M_DEBUG
mpi_debug_free_limb_space(a->d, info);
#else
#else
mpi_free_limb_space(a->d);
#endif
#endif
}
if( a->flags & ~7 )
log_bug("invalid flag value in mpi\n");
@ -280,18 +279,18 @@ mpi_set_secure( MPI a )
assert(!ap);
return;
}
#ifdef M_DEBUG
#ifdef M_DEBUG
bp = mpi_debug_alloc_limb_space( a->nlimbs, 1, "set_secure" );
#else
#else
bp = mpi_alloc_limb_space( a->nlimbs, 1 );
#endif
#endif
MPN_COPY( bp, ap, a->nlimbs );
a->d = bp;
#ifdef M_DEBUG
#ifdef M_DEBUG
mpi_debug_free_limb_space(ap, "set_secure");
#else
#else
mpi_free_limb_space(ap);
#endif
#endif
}
@ -299,21 +298,21 @@ MPI
mpi_set_opaque( MPI a, void *p, int len )
{
if( !a ) {
#ifdef M_DEBUG
#ifdef M_DEBUG
a = mpi_debug_alloc(0,"alloc_opaque");
#else
#else
a = mpi_alloc(0);
#endif
#endif
}
if( a->flags & 4 )
m_free( a->d );
else {
#ifdef M_DEBUG
#ifdef M_DEBUG
mpi_debug_free_limb_space(a->d, "alloc_opaque");
#else
#else
mpi_free_limb_space(a->d);
#endif
#endif
}
a->d = p;
@ -357,13 +356,13 @@ mpi_copy( MPI a )
b = mpi_set_opaque( NULL, p, a->nbits );
}
else if( a ) {
#ifdef M_DEBUG
#ifdef M_DEBUG
b = mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info )
: mpi_debug_alloc( a->nlimbs, info );
#else
#else
b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
: mpi_alloc( a->nlimbs );
#endif
#endif
b->nlimbs = a->nlimbs;
b->sign = a->sign;
b->flags = a->flags;
@ -398,13 +397,13 @@ mpi_alloc_like( MPI a )
b = mpi_set_opaque( NULL, p, a->nbits );
}
else if( a ) {
#ifdef M_DEBUG
#ifdef M_DEBUG
b = mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info )
: mpi_debug_alloc( a->nlimbs, info );
#else
#else
b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
: mpi_alloc( a->nlimbs );
#endif
#endif
b->nlimbs = 0;
b->sign = 0;
b->flags = a->flags;
@ -449,11 +448,11 @@ mpi_set_ui( MPI w, unsigned long u)
MPI
mpi_alloc_set_ui( unsigned long u)
{
#ifdef M_DEBUG
#ifdef M_DEBUG
MPI w = mpi_debug_alloc(1,"alloc_set_ui");
#else
#else
MPI w = mpi_alloc(1);
#endif
#endif
w->d[0] = u;
w->nlimbs = u? 1:0;
w->sign = 0;
@ -468,4 +467,3 @@ mpi_swap( MPI a, MPI b)
tmp = *a; *a = *b; *b = tmp;
}