VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-10-28 22:16:15 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-10-28 22:18:11 (GMT)
commitafe6b2f45b15393026a1159e5f3d165ac7d0b94a (patch)
treeeaa53c471364b0cc95c81d21be8017f69b10a6c0
parent3fa636d477119fff6e372074568edb42d038f508 (diff)
downloadVeraCrypt-afe6b2f45b15393026a1159e5f3d165ac7d0b94a.zip
VeraCrypt-afe6b2f45b15393026a1159e5f3d165ac7d0b94a.tar.gz
Linux: Fix compilation error on non-x86 platform by providing generic implementation for jent_get_nstime function
-rw-r--r--src/Crypto/jitterentropy-base-user.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Crypto/jitterentropy-base-user.h b/src/Crypto/jitterentropy-base-user.h
index 0ebbac5..3502dd4 100644
--- a/src/Crypto/jitterentropy-base-user.h
+++ b/src/Crypto/jitterentropy-base-user.h
@@ -75,6 +75,8 @@ static VC_INLINE void jent_get_nstime(uint64 *out)
#else
+#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
+
/* taken from Linux kernel */
#if CRYPTOPP_BOOL_X64
#define DECLARE_ARGS(val, low, high) unsigned low, high
@@ -93,6 +95,29 @@ VC_INLINE void jent_get_nstime(uint64 *out)
*out = EAX_EDX_VAL(val, low, high);
}
+#else
+
+#include <time.h>
+
+VC_INLINE void jent_get_nstime(uint64 *out)
+{
+ /* we could use CLOCK_MONOTONIC(_RAW), but with CLOCK_REALTIME
+ * we get some nice extra entropy once in a while from the NTP actions
+ * that we want to use as well... though, we do not rely on that
+ * extra little entropy */
+ uint64_t tmp = 0;
+ struct timespec time;
+ if (clock_gettime(CLOCK_REALTIME, &time) == 0)
+ {
+ tmp = time.tv_sec;
+ tmp = tmp << 32;
+ tmp = tmp | time.tv_nsec;
+ }
+ *out = tmp;
+}
+
+#endif
+
#endif
#ifdef _MSC_VER