Closed magnumripper closed 9 years ago
Why does it break at all?
The intrinsic _mm_insert_epi64 is not a valid instruction under 32 bit (tested cygwin and ubuntu 32 bit)
Also, the intrisic _mm_cvtsi64_si128 is not in 32 bit land.
But it should be very trivial to actually fix it instead.
The fix 'could' be to build our own _mm_insert_epi64 that has #ifdef for 32 bit wrapper around it.
This patch at least allows this file to be built on 32 bit systems. It will fail however. NOTE, I think this will build properly on a < sse4.1 system, but if run there, it will core.
$ git diff gost3411-2012-sse41_plug.c
diff --git a/src/gost3411-2012-sse41_plug.c b/src/gost3411-2012-sse41_plug.c
index 97a91e0..7e16305 100644
--- a/src/gost3411-2012-sse41_plug.c
+++ b/src/gost3411-2012-sse41_plug.c
@@ -22,6 +22,15 @@
#include "gost3411-tables.h"
#include "gost3411-2012-sse41.h"
+#include "arch.h"
+
+#if ARCH_BITS==32
+// this is NOT right, but at least it allows 32 bit to build.
+// NOTE, this file depends upon SSE4.1, so it should NOT be a *plug.c
+static inline __m128i _mm_cvtsi64_si128(uint64_t b) { __m128i a; return a; }
+static inline __m128i _mm_insert_epi64(__m128i a, uint64_t b, int c) { return a; }
+#endif
+
static inline void add512(const union uint512_u* x, const union uint512_u* y, union uint512_u* r)
{
uint_fast8_t i, CF;
NOTE, this file depends upon SSE4.1, so it should NOT be a *plug.c
Plugs can easily depend on things like SSE4.1. Look at rawSHA1_ng_fmt_plug.c just before plugin stanza.
Should be easy to write proper (albeit slow) emulation functions though. With some luck we may already have something usable in pseudo-intrinsics.c
This is proper emulation (works fine):
static inline __m128i _mm_cvtsi64_si128(long long a) {
return _mm_set_epi32(0, 0, (unsigned int)(a >> 32), (unsigned int)a);
}
static inline __m128i _mm_insert_epi64(__m128i a, uint64_t b, int c) {
c <<= 1;
a = _mm_insert_epi32(a, (unsigned int)b, c);
return _mm_insert_epi32(a, (unsigned int)(b >> 32), c + 1);
}
Problem introduced by ebbbfc1a8
One possibility (although not the best) is to just #ifdef the whole file outside of the plugin stanza. Similar to eg. rawSHA1_ng_fmt_plug.c but in this case checking for eg. ARCH_SIZE after including arch.h
But it should be very trivial to actually fix it instead. Why does it break at all?