aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
author--author=Satoshi Nakamoto <satoshin@gmx.com>2010-07-27 20:43:55 +0000
committerGavin Andresen <gavinandresen@gmail.com>2010-07-27 20:43:55 +0000
commit3dd20ff2f87958a440c9dceae8abe3967aa48fcf (patch)
tree5cf88b4e9ba89460a83488561d9fd23feaa87365 /util.h
parent9f35575ca34eb15b20d1d5374b56ac9d4c8cc2bf (diff)
downloadbitcoin-3dd20ff2f87958a440c9dceae8abe3967aa48fcf.tar.xz
added a subset of Crypto++ 5.6.0 with 48% faster ASM SHA-256, combined speedup 2.5x faster vs 0.3.3, thanks BlackEye for figuring out the alignment problem
Diffstat (limited to 'util.h')
-rw-r--r--util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.h b/util.h
index d05ab695cd..1981ec95e9 100644
--- a/util.h
+++ b/util.h
@@ -54,6 +54,20 @@ inline T& REF(const T& val)
return (T&)val;
}
+// Align by increasing pointer, must have extra space at end of buffer
+template <size_t nBytes, typename T>
+T* alignup(T* p)
+{
+ union
+ {
+ T* ptr;
+ size_t n;
+ } u;
+ u.ptr = p;
+ u.n = (u.n + (nBytes-1)) & ~(nBytes-1);
+ return u.ptr;
+}
+
#ifdef __WXMSW__
#define MSG_NOSIGNAL 0
#define MSG_DONTWAIT 0