22 #include "runtime.hpp"
34 #include "algorithm.hpp"
37 namespace STL = STL_NAMESPACE;
42 void*
operator new(
size_t sz, TaoCrypt::new_t)
44 void* ptr = malloc(sz ? sz : 1);
51 void operator delete(
void* ptr, TaoCrypt::new_t)
57 void*
operator new[](
size_t sz, TaoCrypt::new_t nt)
59 return ::operator
new(sz, nt);
63 void operator delete[](
void* ptr, TaoCrypt::new_t nt)
65 ::operator
delete(ptr, nt);
97 #if defined(__ICC) || defined(__INTEL_COMPILER) || (__GNUC__ > 2)
101 int __cxa_pure_virtual() {
109 #endif // YASSL_PURE_C
115 inline void XorWords(
word* r,
const word* a,
unsigned int n)
117 for (
unsigned int i=0;
i<
n;
i++)
122 void xorbuf(byte*
buf,
const byte* mask,
unsigned int count)
124 if (((
size_t)buf | (
size_t)mask | count) % WORD_SIZE == 0)
125 XorWords((
word *)buf, (
const word *)mask, count/WORD_SIZE);
128 for (
unsigned int i=0;
i<count;
i++)
134 unsigned int BytePrecision(
word value)
137 for (i=
sizeof(value);
i; --
i)
138 if (value >> (i-1)*8)
145 unsigned int BitPrecision(
word value)
151 h = 8 *
sizeof(value);
155 unsigned int t = (l+h)/2;
168 if (size < 8*
sizeof(value))
169 return (value & ((1L << size) - 1));
176 #ifdef TAOCRYPT_X86ASM_AVAILABLE
214 :
"=r" (eax),
"=r" (ebx)
226 void CpuId(word32 input, word32 *output)
232 "push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx"
233 :
"=a" (output[0]),
"=D" (output[1]),
"=c" (output[2]),
"=d"(output[3])
259 STL::swap(cpuid[2], cpuid[3]);
260 if (memcmp(cpuid+1,
"GenuineIntel", 12) != 0)
264 byte family = ((cpuid[0] >> 8) & 0xf);
281 if ((cpuid[3] & (1 << 23)) == 0)
288 bool isMMX = IsMmx();
291 #endif // TAOCRYPT_X86ASM_AVAILABLE