security/palisade: fix build on powerpc64* and libomp-less architectures

This commit is contained in:
Piotr Kubaj 2022-12-06 03:51:49 +00:00
parent 908640ce34
commit df3e7be9ff
2 changed files with 24 additions and 5 deletions

View File

@ -11,11 +11,6 @@ LICENSE= BSD2CLAUSE
LICENSE_FILE= ${WRKSRC}/LICENSE
BROKEN_i386= fails to build: a declaration of 'Mul128' must be available
BROKEN_powerpc64= fails to build: math/native_int/binint.h:510:11: error: Architecture not supported for MultD()
BROKEN_riscv64= fails to build: math/bigintnat/ubintnat.h:2250:2: error: Architecture not supported for MultD()
.if !exists(/usr/include/omp.h)
BROKEN= requires OpenMP support that is missing on this architecture
.endif
BUILD_DEPENDS= autoconf:devel/autoconf # possibly a mistake in the project
@ -43,7 +38,9 @@ BINARY_ALIAS= git=false
LDFLAGS+= -pthread # only for tests: see https://gitlab.com/palisade/palisade-release/-/issues/23
OPTIONS_DEFINE= OPENMP HEXL
.if exists(/usr/include/omp.h)
OPTIONS_DEFAULT= OPENMP
.endif
HEXL_DESC= Use Intel Hexl Library

View File

@ -0,0 +1,22 @@
--- src/core/include/math/bigintnat/ubintnat.h.orig 2022-01-28 23:16:29 UTC
+++ src/core/include/math/bigintnat/ubintnat.h
@@ -2218,12 +2218,17 @@ class NativeIntegerT
res.lo = x.lo * y;
asm("umulh %0, %1, %2\n\t" : "=r"(res.hi) : "r"(x.lo), "r"(y));
res.hi += x.hi * y;
-#elif defined(__arm__) // 32 bit processor
+#elif defined(__powerpc64__) || defined(__riscv)
+ U128BITS wres(0), wa(a), wb(b);
+ wres = wa * wb; // should give us 128 bits of 64 * 64
+ res.hi = (uint64_t)(wres >> 64);
+ res.lo = (uint64_t)wres;
+#elif defined(__arm__) || defined(__powerpc__) // 32 bit processor
uint64_t wres(0), wa(a), wb(b);
wres = wa * wb; // should give us the lower 64 bits of 32*32
res.hi = wres >> 32;
- res.lo = (uint32_t)wres && 0xFFFFFFFF;
+ res.lo = (uint32_t)wres & 0xFFFFFFFF;
#elif defined(__EMSCRIPTEN__) // web assembly
U64BITS a1 = a >> 32;
U64BITS a2 = (uint32_t)a;