aboutsummaryrefslogtreecommitdiff
path: root/src/ext/csiphash.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-03-14 14:20:15 -0400
committerNick Mathewson <nickm@torproject.org>2017-03-14 14:20:15 -0400
commit9014dc111a46ae7e9443eb4f41969cfc20e79acc (patch)
tree74d1475880b345255e58b66bf2fc1a6050bb0c7a /src/ext/csiphash.c
parentf38f9b33d0bf52583491cdea6f41eb51819c627b (diff)
downloadtor-9014dc111a46ae7e9443eb4f41969cfc20e79acc.tar.gz
tor-9014dc111a46ae7e9443eb4f41969cfc20e79acc.zip
Improve keccak-tiny performance by 15% on LE intel
The 64-bit load and store code was generating pretty bad output with my compiler, so I extracted the code from csiphash and used that instead. Close ticket 21737
Diffstat (limited to 'src/ext/csiphash.c')
-rw-r--r--src/ext/csiphash.c36
1 files changed, 1 insertions, 35 deletions
diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c
index 8348c66048..1029bbbad3 100644
--- a/src/ext/csiphash.c
+++ b/src/ext/csiphash.c
@@ -35,41 +35,7 @@
#include "util.h"
/* for memcpy */
#include <string.h>
-
-#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
- __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-# define _le64toh(x) ((uint64_t)(x))
-#elif defined(_WIN32)
-/* Windows is always little endian, unless you're on xbox360
- http://msdn.microsoft.com/en-us/library/b0084kay(v=vs.80).aspx */
-# define _le64toh(x) ((uint64_t)(x))
-#elif defined(__APPLE__)
-# include <libkern/OSByteOrder.h>
-# define _le64toh(x) OSSwapLittleToHostInt64(x)
-#elif defined(sun) || defined(__sun)
-# include <sys/byteorder.h>
-# define _le64toh(x) LE_64(x)
-
-#else
-
-/* See: http://sourceforge.net/p/predef/wiki/Endianness/ */
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(OpenBSD)
-# include <sys/endian.h>
-# else
-# include <endian.h>
-# endif
-# if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
- __BYTE_ORDER == __LITTLE_ENDIAN
-# define _le64toh(x) ((uint64_t)(x))
-# else
-# if defined(OpenBSD)
-# define _le64toh(x) letoh64(x)
-# else
-# define _le64toh(x) le64toh(x)
-# endif
-# endif
-
-#endif
+#include "byteorder.h"
#define ROTATE(x, b) (uint64_t)( ((x) << (b)) | ( (x) >> (64 - (b))) )