From e083c5f8899a75452400b65cb7b99de5c76d7b13 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Tue, 24 Nov 2009 20:15:46 +0000 Subject: [PATCH] added: const char * UInt::LibTypeStr() const char * Big::LibTypeStr() LibTypeCode UInt::LibType() LibTypeCode Big::LibType() returning a string/enum represents the currect type of the library we have following types: asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) asm_gcc_32 - with asm code designed for GCC (32 bits) asm_vc_64 - with asm for VC (64 bit) asm_gcc_64 - with asm for GCC (64 bit) no_asm_32 - pure C++ version (32 bit) - without any asm code no_asm_64 - pure C++ version (64 bit) - without any asm code changed: another compilers than MS VC or GCC by default use no asm version (TTMATH_NOASM) git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@247 e52654a7-88a9-db11-a3e9-0013d4bc506e --- CHANGELOG | 15 ++++++++++++- ttmath/ttmathbig.h | 26 ++++++++++++++++++++++ ttmath/ttmathtypes.h | 29 +++++++++++++++++++++++++ ttmath/ttmathuint.h | 2 ++ ttmath/ttmathuint_noasm.h | 43 +++++++++++++++++++++++++++++++++++++ ttmath/ttmathuint_x86.h | 44 ++++++++++++++++++++++++++++++++++++++ ttmath/ttmathuint_x86_64.h | 42 ++++++++++++++++++++++++++++++++++++ 7 files changed, 200 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e201916..a118850 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -47,7 +47,19 @@ Version 0.9.0 prerelease (2009.11.24): * added: UInt::Sqrt() - a new algorithm for calculating the square root * added: to the parser: function frac() - returns a value without the integer part (only fraction remains) - * added: Int::DivInt(int divisor, int * remainder) + * added: Int::DivInt(sint divisor, sint * remainder) + * added: const char * UInt::LibTypeStr() + const char * Big::LibTypeStr() + LibTypeCode UInt::LibType() + LibTypeCode Big::LibType() + returning a string/enum represents the currect type of the library + we have following types: + asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) + asm_gcc_32 - with asm code designed for GCC (32 bits) + asm_vc_64 - with asm for VC (64 bit) + asm_gcc_64 - with asm for GCC (64 bit) + no_asm_32 - pure C++ version (32 bit) - without any asm code + no_asm_64 - pure C++ version (64 bit) - without any asm code * changed: Factorial() is using the Gamma() function now * changed: Big::Div(ss2) Big::Mod(ss2) @@ -70,6 +82,7 @@ Version 0.9.0 prerelease (2009.11.24): base 16: 1.FFFFFFEA * changed: in Big::ToString() some additional rounding (base_round) is now made only when the value is not an integer + * changed: another compilers than MS VC or GCC by default use no asm version (TTMATH_NOASM) * removed: Parser<>::SetFactorialMax() method the factorial() is such a fast now that we don't need the method longer * removed: ErrorCode::err_too_big_factorial diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index 1a6fb19..b35fbd5 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -132,6 +132,32 @@ unsigned char info; public: + /*! + returning the string represents the currect type of the library + we have following types: + asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) + asm_gcc_32 - with asm code designed for GCC (32 bits) + asm_vc_64 - with asm for VC (64 bit) + asm_gcc_64 - with asm for GCC (64 bit) + no_asm_32 - pure C++ version (32 bit) - without any asm code + no_asm_64 - pure C++ version (64 bit) - without any asm code + */ + static const char * LibTypeStr() + { + return UInt::LibTypeStr(); + } + + + /*! + returning the currect type of the library + */ + static LibTypeCode LibType() + { + return UInt::LibType(); + } + + + /*! this method moves all bits from mantissa into its left side (suitably changes the exponent) or if the mantissa is zero diff --git a/ttmath/ttmathtypes.h b/ttmath/ttmathtypes.h index c497c58..bb02744 100644 --- a/ttmath/ttmathtypes.h +++ b/ttmath/ttmathtypes.h @@ -112,6 +112,15 @@ namespace ttmath +/*! + another compilers than MS VC or GCC by default use no asm version (TTMATH_NOASM) +*/ +#if !defined _MSC_VER && !defined __GNUC__ + #define TTMATH_NOASM +#endif + + + #ifdef TTMATH_PLATFORM32 /*! @@ -284,6 +293,26 @@ namespace ttmath namespace ttmath { + /*! + lib type codes: + asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) + asm_gcc_32 - with asm code designed for GCC (32 bits) + asm_vc_64 - with asm for VC (64 bit) + asm_gcc_64 - with asm for GCC (64 bit) + no_asm_32 - pure C++ version (32 bit) - without any asm code + no_asm_64 - pure C++ version (64 bit) - without any asm code + */ + enum LibTypeCode + { + asm_vc_32 = 0, + asm_gcc_32, + asm_vc_64, + asm_gcc_64, + no_asm_32, + no_asm_64 + }; + + /*! error codes */ diff --git a/ttmath/ttmathuint.h b/ttmath/ttmathuint.h index 7c6e5a8..da92ff3 100644 --- a/ttmath/ttmathuint.h +++ b/ttmath/ttmathuint.h @@ -3373,6 +3373,8 @@ private: uint Rcr2(uint bits, uint c); public: + static const char * LibTypeStr(); + static LibTypeCode LibType(); uint Add(const UInt & ss2, uint c=0); uint AddInt(uint value, uint index = 0); uint AddTwoInts(uint x2, uint x1, uint index); diff --git a/ttmath/ttmathuint_noasm.h b/ttmath/ttmathuint_noasm.h index a425514..9bda34e 100644 --- a/ttmath/ttmathuint_noasm.h +++ b/ttmath/ttmathuint_noasm.h @@ -52,6 +52,49 @@ namespace ttmath { + /*! + returning the string represents the currect type of the library + we have following types: + asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) + asm_gcc_32 - with asm code designed for GCC (32 bits) + asm_vc_64 - with asm for VC (64 bit) + asm_gcc_64 - with asm for GCC (64 bit) + no_asm_32 - pure C++ version (32 bit) - without any asm code + no_asm_64 - pure C++ version (64 bit) - without any asm code + */ + template + const char * UInt::LibTypeStr() + { + #ifdef TTMATH_PLATFORM32 + static const char info[] = "no_asm_32"; + #endif + + #ifdef TTMATH_PLATFORM64 + static const char info[] = "no_asm_64"; + #endif + + return info; + } + + + /*! + returning the currect type of the library + */ + template + LibTypeCode UInt::LibType() + { + #ifdef TTMATH_PLATFORM32 + LibTypeCode info = no_asm_32; + #endif + + #ifdef TTMATH_PLATFORM64 + LibTypeCode info = no_asm_64; + #endif + + return info; + } + + /*! this method adds two words together returns carry diff --git a/ttmath/ttmathuint_x86.h b/ttmath/ttmathuint_x86.h index c26f287..1b91ce4 100644 --- a/ttmath/ttmathuint_x86.h +++ b/ttmath/ttmathuint_x86.h @@ -60,6 +60,50 @@ namespace ttmath { + /*! + returning the string represents the currect type of the library + we have following types: + asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) + asm_gcc_32 - with asm code designed for GCC (32 bits) + asm_vc_64 - with asm for VC (64 bit) + asm_gcc_64 - with asm for GCC (64 bit) + no_asm_32 - pure C++ version (32 bit) - without any asm code + no_asm_64 - pure C++ version (64 bit) - without any asm code + */ + template + const char * UInt::LibTypeStr() + { + #ifndef __GNUC__ + static const char info[] = "asm_vc_32"; + #endif + + #ifdef __GNUC__ + static const char info[] = "asm_gcc_32"; + #endif + + return info; + } + + + /*! + returning the currect type of the library + */ + template + LibTypeCode UInt::LibType() + { + #ifndef __GNUC__ + LibTypeCode info = asm_vc_32; + #endif + + #ifdef __GNUC__ + LibTypeCode info = asm_gcc_32; + #endif + + return info; + } + + + /*! * * basic mathematic functions diff --git a/ttmath/ttmathuint_x86_64.h b/ttmath/ttmathuint_x86_64.h index 44552d7..7660b20 100644 --- a/ttmath/ttmathuint_x86_64.h +++ b/ttmath/ttmathuint_x86_64.h @@ -79,6 +79,48 @@ namespace ttmath #endif + /*! + returning the string represents the currect type of the library + we have following types: + asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) + asm_gcc_32 - with asm code designed for GCC (32 bits) + asm_vc_64 - with asm for VC (64 bit) + asm_gcc_64 - with asm for GCC (64 bit) + no_asm_32 - pure C++ version (32 bit) - without any asm code + no_asm_64 - pure C++ version (64 bit) - without any asm code + */ + template + const char * UInt::LibTypeStr() + { + #ifdef _MSC_VER + static const char info[] = "asm_vc_64"; + #endif + + #ifdef __GNUC__ + static const char info[] = "asm_gcc_64"; + #endif + + return info; + } + + + /*! + returning the currect type of the library + */ + template + LibTypeCode UInt::LibType() + { + #ifdef _MSC_VER + LibTypeCode info = asm_vc_64; + #endif + + #ifdef __GNUC__ + LibTypeCode info = asm_gcc_64; + #endif + + return info; + } + /*! *