- fulfills test file log diff (32 and 64 bit)

- macro for issuing the debug output to something else than std::out if specified


git-svn-id: svn://ttmath.org/publicrep/ttmath/branches/chk@134 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Christian Kaiser 2009-05-07 09:33:57 +00:00
parent d7b67e4d47
commit 37379d2f1f
6 changed files with 64 additions and 43 deletions

View File

@ -394,7 +394,7 @@ public:
// (TTMATH_BUILTIN_VARIABLES_SIZE on 32bit platform should have the value 256, // (TTMATH_BUILTIN_VARIABLES_SIZE on 32bit platform should have the value 256,
// and on 64bit platform value 128 (256/2=128)) // and on 64bit platform value 128 (256/2=128))
mantissa.SetFromTable(temp_table, sizeof(temp_table) / sizeof(int)); mantissa.SetFromTable(temp_table, sizeof(temp_table) / sizeof(unsigned int));
exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT); exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT);
info = 0; info = 0;
} }
@ -659,7 +659,7 @@ public:
// there shouldn't be a carry here because // there shouldn't be a carry here because
// (1) (2) guarantee that the mantissa of this // (1) (2) guarantee that the mantissa of this
// is greater than or equal to the mantissa of the ss2 // is greater than or equal to the mantissa of the ss2
TTMATH_ASSERT( mantissa.Sub(ss2.mantissa) == 0 ) TTMATH_VERIFY( mantissa.Sub(ss2.mantissa) == 0 )
} }
c += Standardizing(); c += Standardizing();

View File

@ -135,20 +135,20 @@ namespace ttmath
/*! /*!
the mask for the highest bit in the unsigned 32bit word (2^31) the mask for the highest bit in the unsigned 32bit word (2^31)
*/ */
#define TTMATH_UINT_HIGHEST_BIT 0x80000000ul const uint TTMATH_UINT_HIGHEST_BIT = 0x80000000ul;
/*! /*!
the max value of the unsigned 32bit word (2^32 - 1) the max value of the unsigned 32bit word (2^32 - 1)
(all bits equal one) (all bits equal one)
*/ */
#define TTMATH_UINT_MAX_VALUE 0xfffffffful const uint TTMATH_UINT_MAX_VALUE = 0xfffffffful;
/*! /*!
the number of words (32bit words on 32bit platform) the number of words (32bit words on 32bit platform)
which are kept in built-in variables for a Big<> type which are kept in built-in variables for a Big<> type
(these variables are defined in ttmathbig.h) (these variables are defined in ttmathbig.h)
*/ */
#define TTMATH_BUILTIN_VARIABLES_SIZE 256u const uint TTMATH_BUILTIN_VARIABLES_SIZE = 256u;
#else #else
@ -174,24 +174,25 @@ namespace ttmath
/*! /*!
the mask for the highest bit in the unsigned 64bit word (2^63) the mask for the highest bit in the unsigned 64bit word (2^63)
*/ */
#define TTMATH_UINT_HIGHEST_BIT 0x8000000000000000ul const uint TTMATH_UINT_HIGHEST_BIT = 0x8000000000000000ul;
/*! /*!
the max value of the unsigned 64bit word (2^64 - 1) the max value of the unsigned 64bit word (2^64 - 1)
(all bits equal one) (all bits equal one)
*/ */
#define TTMATH_UINT_MAX_VALUE 0xfffffffffffffffful const uint TTMATH_UINT_MAX_VALUE = 0xfffffffffffffffful;
/*! /*!
the number of words (64bit words on 64bit platforms) the number of words (64bit words on 64bit platforms)
which are kept in built-in variables for a Big<> type which are kept in built-in variables for a Big<> type
(these variables are defined in ttmathbig.h) (these variables are defined in ttmathbig.h)
*/ */
#define TTMATH_BUILTIN_VARIABLES_SIZE 128ul const uint TTMATH_BUILTIN_VARIABLES_SIZE = 128ul;
#endif #endif
#define TTMATH_BITS_PER_UINT (sizeof(uint)*8) const uint TTMATH_BITS_PER_UINT = (sizeof(uint)*8);
} }
@ -343,7 +344,7 @@ namespace ttmath
foo.Add(foo); foo.Add(foo);
but there are only few methods which can do that but there are only few methods which can do that
*/ */
class ReferenceError : public std::logic_error, ExceptionInfo class ReferenceError : public std::logic_error, public ExceptionInfo
{ {
public: public:
@ -375,7 +376,7 @@ namespace ttmath
the name and the line of a file where the macro TTMATH_ASSERT the name and the line of a file where the macro TTMATH_ASSERT
was used) was used)
*/ */
class RuntimeError : public std::runtime_error, ExceptionInfo class RuntimeError : public std::runtime_error, public ExceptionInfo
{ {
public: public:
@ -409,6 +410,9 @@ namespace ttmath
#define TTMATH_ASSERT(expression) \ #define TTMATH_ASSERT(expression) \
if( !(expression) ) throw ttmath::RuntimeError(TTMATH_TEXT(__FILE__), __LINE__); if( !(expression) ) throw ttmath::RuntimeError(TTMATH_TEXT(__FILE__), __LINE__);
#define TTMATH_VERIFY(expression) \
if( !(expression) ) throw ttmath::RuntimeError(TTMATH_TEXT(__FILE__), __LINE__);
#else #else
#define TTMATH_REFERENCE_ASSERT(expression) \ #define TTMATH_REFERENCE_ASSERT(expression) \
@ -416,19 +420,32 @@ namespace ttmath
#define TTMATH_ASSERT(expression) \ #define TTMATH_ASSERT(expression) \
if( !(expression) ) throw RuntimeError(); if( !(expression) ) throw RuntimeError();
#define TTMATH_VERIFY(expression) \
if( !(expression) ) throw RuntimeError();
#endif #endif
#else #else
#define TTMATH_REFERENCE_ASSERT(expression) #define TTMATH_REFERENCE_ASSERT(expression)
#define TTMATH_ASSERT(expression) #define TTMATH_ASSERT(expression)
#define TTMATH_VERIFY(expression) (void)(expression);
#endif #endif
#if !defined(LOG_PRINTF)
#define LOG_PRINTF printf
#endif
#ifdef TTMATH_DEBUG_LOG #ifdef TTMATH_DEBUG_LOG
#define TTMATH_LOG(msg) \ #define TTMATH_LOG(pszMsg) \
PrintLog(msg, std::cout); { \
ttmath::tostrstrm_t ss; \
PrintLog(TTMATH_TEXT(pszMsg),ss); \
LOG_PRINTF(TTMATH_TEXT("%s"),ss.str().c_str()); \
}
//#define TTMATH_LOG(msg) \
// PrintLog(msg, std::cout);
#else #else

View File

@ -1923,7 +1923,7 @@ public:
*/ */
bool IsTheLowestBitSet() const bool IsTheLowestBitSet() const
{ {
return (*table & 1) != 0; return (table[0] & 1) != 0;
} }
@ -2017,12 +2017,12 @@ public:
10 -> A 10 -> A
15 -> F 15 -> F
*/ */
static uint DigitToChar(uint digit) static tchar_t DigitToChar(uint digit)
{ {
if( digit < 10 ) if( digit < 10 )
return digit + '0'; return (tchar_t)(digit + '0');
return digit - 10 + 'A'; return((tchar_t)(digit - 10 + 'A'));
} }

View File

@ -54,7 +54,7 @@
namespace ttmath namespace ttmath
{ {
#if defined(_M_IX64) #if defined(_M_X64)
#include <intrin.h> #include <intrin.h>
extern "C" extern "C"
@ -100,7 +100,7 @@ namespace ttmath
// this algorithm doesn't require it // this algorithm doesn't require it
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = adc_x64(p1,p2,b,c); c = adc_x64(p1,p2,b,c);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -170,7 +170,7 @@ namespace ttmath
TTMATH_ASSERT( index < value_size ) TTMATH_ASSERT( index < value_size )
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = addindexed_x64(p1,b,index,value); c = addindexed_x64(p1,b,index,value);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -252,7 +252,7 @@ namespace ttmath
TTMATH_ASSERT( index < value_size - 1 ) TTMATH_ASSERT( index < value_size - 1 )
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = addindexed2_x64(p1,b,index,x2,x1); c = addindexed2_x64(p1,b,index,x2,x1);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -319,7 +319,7 @@ namespace ttmath
// this algorithm doesn't require it // this algorithm doesn't require it
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = sbb_x64(p1,p2,b,c); c = sbb_x64(p1,p2,b,c);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -386,7 +386,7 @@ namespace ttmath
TTMATH_ASSERT( index < value_size ) TTMATH_ASSERT( index < value_size )
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = subindexed_x64(p1,b,index,value); c = subindexed_x64(p1,b,index,value);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -446,7 +446,7 @@ namespace ttmath
uint * p1 = table; uint * p1 = table;
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = rcl_x64(p1,b,c); c = rcl_x64(p1,b,c);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -503,7 +503,7 @@ namespace ttmath
uint * p1 = table; uint * p1 = table;
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = rcr_x64(p1,b,c); c = rcr_x64(p1,b,c);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -561,7 +561,7 @@ namespace ttmath
uint * p1 = table; uint * p1 = table;
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = rcl2_x64(p1,b,bits,c); c = rcl2_x64(p1,b,bits,c);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -637,7 +637,7 @@ namespace ttmath
uint * p1 = table; uint * p1 = table;
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_M_IX64) #if defined(_M_X64)
c = rcr2_x64(p1,b,bits,c); c = rcr2_x64(p1,b,bits,c);
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
@ -761,7 +761,11 @@ namespace ttmath
#ifndef __GNUC__ #ifndef __GNUC__
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if defined(TTMATH_PLATFORM64)
old_bit = _bittestandset64((__int64*)&value,bit) != 0;
#else
old_bit = _bittestandset((long*)&value,bit) != 0; old_bit = _bittestandset((long*)&value,bit) != 0;
#endif
#else #else
#error "another compiler than GCC is currently not supported in 64bit mode" #error "another compiler than GCC is currently not supported in 64bit mode"
#endif #endif

View File

@ -11,7 +11,7 @@ PUBLIC rcr_x64
PUBLIC rcl2_x64 PUBLIC rcl2_x64
PUBLIC rcr2_x64 PUBLIC rcr2_x64
public div_x64 PUBLIC div_x64
; ;
; "rax, rcx, rdx, r8-r11 are volatile." ; "rax, rcx, rdx, r8-r11 are volatile."