更新libclamav库1.0.0版本
This commit is contained in:
98
clamav/libclamav/tomsfastmath/misc/fp_ident.c
Normal file
98
clamav/libclamav/tomsfastmath/misc/fp_ident.c
Normal file
@@ -0,0 +1,98 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
const char *fp_ident(void)
|
||||
{
|
||||
static char buf[1024];
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"TomsFastMath " TFM_VERSION_S "\n"
|
||||
#if defined(TFM_IDENT_BUILD_DATE)
|
||||
"Built on " __DATE__ " at " __TIME__ "\n"
|
||||
#endif
|
||||
"\n"
|
||||
"Sizeofs\n"
|
||||
"\tfp_digit = %lu\n"
|
||||
"\tfp_word = %lu\n"
|
||||
"\n"
|
||||
"FP_MAX_SIZE = %u\n"
|
||||
"\n"
|
||||
"Defines: \n"
|
||||
#ifdef __i386__
|
||||
" __i386__ "
|
||||
#endif
|
||||
#ifdef __x86_64__
|
||||
" __x86_64__ "
|
||||
#endif
|
||||
#ifdef TFM_X86
|
||||
" TFM_X86 "
|
||||
#endif
|
||||
#ifdef TFM_X86_64
|
||||
" TFM_X86_64 "
|
||||
#endif
|
||||
#ifdef TFM_SSE2
|
||||
" TFM_SSE2 "
|
||||
#endif
|
||||
#ifdef TFM_ARM
|
||||
" TFM_ARM "
|
||||
#endif
|
||||
#ifdef TFM_PPC32
|
||||
" TFM_PPC32 "
|
||||
#endif
|
||||
#ifdef TFM_AVR32
|
||||
" TFM_AVR32 "
|
||||
#endif
|
||||
#ifdef TFM_ECC192
|
||||
" TFM_ECC192 "
|
||||
#endif
|
||||
#ifdef TFM_ECC224
|
||||
" TFM_ECC224 "
|
||||
#endif
|
||||
#ifdef TFM_ECC384
|
||||
" TFM_ECC384 "
|
||||
#endif
|
||||
#ifdef TFM_ECC521
|
||||
" TFM_ECC521 "
|
||||
#endif
|
||||
|
||||
#ifdef TFM_NO_ASM
|
||||
" TFM_NO_ASM "
|
||||
#endif
|
||||
#ifdef FP_64BIT
|
||||
" FP_64BIT "
|
||||
#endif
|
||||
#ifdef TFM_HUGE
|
||||
" TFM_HUGE "
|
||||
#endif
|
||||
"\n", (unsigned long)sizeof(fp_digit), (unsigned long)sizeof(fp_word), FP_MAX_SIZE);
|
||||
|
||||
if (sizeof(fp_digit) == sizeof(fp_word)) {
|
||||
strncat(buf, "WARNING: sizeof(fp_digit) == sizeof(fp_word), this build is likely to not work properly.\n",
|
||||
sizeof(buf) - strlen(buf) - 1);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifdef STANDALONE
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("%s\n", fp_ident());
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
65
clamav/libclamav/tomsfastmath/misc/fp_rand.c
Normal file
65
clamav/libclamav/tomsfastmath/misc/fp_rand.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
#if FP_GEN_RANDOM_MAX == 0xffffffff
|
||||
#define FP_GEN_RANDOM_SHIFT 32
|
||||
#elif FP_GEN_RANDOM_MAX == 32767
|
||||
/* SHRT_MAX */
|
||||
#define FP_GEN_RANDOM_SHIFT 15
|
||||
#elif FP_GEN_RANDOM_MAX == 2147483647
|
||||
/* INT_MAX */
|
||||
#define FP_GEN_RANDOM_SHIFT 31
|
||||
#elif !defined(FP_GEN_RANDOM_SHIFT)
|
||||
#error Thou shalt define their own valid FP_GEN_RANDOM_SHIFT
|
||||
#endif
|
||||
|
||||
/* makes a pseudo-random int of a given size */
|
||||
static fp_digit fp_gen_random(void)
|
||||
{
|
||||
fp_digit d = 0, msk = 0;
|
||||
do {
|
||||
d <<= FP_GEN_RANDOM_SHIFT;
|
||||
d |= ((fp_digit) FP_GEN_RANDOM());
|
||||
msk <<= FP_GEN_RANDOM_SHIFT;
|
||||
msk |= FP_GEN_RANDOM_MAX;
|
||||
} while ((FP_MASK & msk) != FP_MASK);
|
||||
d &= FP_MASK;
|
||||
return d;
|
||||
}
|
||||
|
||||
void fp_rand(fp_int *a, int digits)
|
||||
{
|
||||
fp_digit d;
|
||||
|
||||
fp_zero(a);
|
||||
if (digits <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* first place a random non-zero digit */
|
||||
do {
|
||||
d = fp_gen_random();
|
||||
} while (d == 0);
|
||||
|
||||
fp_add_d (a, d, a);
|
||||
|
||||
while (--digits > 0) {
|
||||
fp_lshd (a, 1);
|
||||
fp_add_d (a, fp_gen_random(), a);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
21
clamav/libclamav/tomsfastmath/misc/fp_set.c
Normal file
21
clamav/libclamav/tomsfastmath/misc/fp_set.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* TomsFastMath, a fast ISO C bignum library.
|
||||
*
|
||||
* This project is meant to fill in where LibTomMath
|
||||
* falls short. That is speed ;-)
|
||||
*
|
||||
* This project is public domain and free for all purposes.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@gmail.com
|
||||
*/
|
||||
#include <tfm_private.h>
|
||||
|
||||
void fp_set(fp_int *a, fp_digit b)
|
||||
{
|
||||
fp_zero(a);
|
||||
a->dp[0] = b;
|
||||
a->used = a->dp[0] ? 1 : 0;
|
||||
}
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
Reference in New Issue
Block a user