aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-07-27 18:14:32 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-07-27 18:14:32 +0000
commit813505cc1313b7e191b787f93e573acb91fa1464 (patch)
tree4a6de5a8fb3a54a2e68153ee773d6fd93c93769b /util.h
parent520f3673196dd6517982e3f662cf62afda368341 (diff)
downloadbitcoin-813505cc1313b7e191b787f93e573acb91fa1464.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
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@114 1a98c847-1fd6-4fd8-948a-caf3550aa51b
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 366c0e159e..9ec701b9e7 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