git: 154cb0fbb0b4 - main - security/gostsum: Fix build on armv7

From: Nuno Teixeira <eduardo_at_FreeBSD.org>
Date: Sun, 05 Feb 2023 14:50:36 UTC
The branch main has been updated by eduardo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=154cb0fbb0b42ccbbf26a17dd9a2c43ed268cf06

commit 154cb0fbb0b42ccbbf26a17dd9a2c43ed268cf06
Author:     Robert Clausecker <fuz@fuz.su>
AuthorDate: 2023-02-05 14:48:18 +0000
Commit:     Nuno Teixeira <eduardo@FreeBSD.org>
CommitDate: 2023-02-05 14:50:10 +0000

    security/gostsum: Fix build on armv7
    
     The build is fixed by adding some missing bits of assembly code.
     Add some more assembly code for arm64 for good measure.
     While we are at it, fix a warning due to a missing include file.
    
    PR:             269267
    Approved by:    portmgr blanket
    MFH:            2023Q1 (build fixes)
---
 security/gostsum/Makefile               |  1 +
 security/gostsum/files/patch-gosthash.c | 68 +++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/security/gostsum/Makefile b/security/gostsum/Makefile
index 5d14ce027b94..1bf5776c9de2 100644
--- a/security/gostsum/Makefile
+++ b/security/gostsum/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	gostsum
 PORTVERSION=	20221213
+PORTREVISION=	1
 CATEGORIES=	security
 
 MAINTAINER=	rozhuk.im@gmail.com
diff --git a/security/gostsum/files/patch-gosthash.c b/security/gostsum/files/patch-gosthash.c
new file mode 100644
index 000000000000..211dab17ad28
--- /dev/null
+++ b/security/gostsum/files/patch-gosthash.c
@@ -0,0 +1,68 @@
+--- gosthash.c.orig	2022-12-13 13:51:25 UTC
++++ gosthash.c
+@@ -26,9 +26,8 @@ echo -n "8JaanTcVv6ndF8Xp/N011Lp46e68LjaUT9FhnEyQGs8="
+ #if defined(__sun__) || defined(__linux__) || defined(__FreeBSD__)
+ #define _aligned_malloc(size, align) memalign(align, size)
+ #define _aligned_free(ptr) free(ptr)
+-#else
+-#include <malloc.h>
+ #endif // __sun__ __linux__ __FreeBSD__
++#include <malloc.h>
+ 
+ typedef char v16qi __attribute__((__vector_size__(16)));
+ //typedef uint8_t v4qi __attribute__((__vector_size__(4)));
+@@ -141,7 +140,53 @@ static inline void XOR(v256 *x, const v256 *a)
+     x->q[1] ^= a->q[1];
+ }
+ #if defined(__arm__)
+-extern void UADD(v256 *a, v256 *b);
++static inline
++void UADD(v256 *a, v256 *b)
++{
++    __asm volatile (
++    "   ldmia %0, {r0, r1, r2, r3}\n"
++    "   ldmia %1!, {r4, r5, r6, r7}\n"
++    "   adds  r0, r0, r4\n"
++    "   adcs  r1, r1, r5\n"
++    "   adcs  r2, r2, r6\n"
++    "   adcs  r3, r3, r7\n"
++    "   stmia %0!, {r0, r1, r2, r3}\n"
++
++    "   ldmia %0, {r0, r1, r2, r3}\n"
++    "   ldmia %1!, {r4, r5, r6, r7}\n"
++    "   adcs  r0, r0, r4\n"
++    "   adcs  r1, r1, r5\n"
++    "   adcs  r2, r2, r6\n"
++    "   adcs  r3, r3, r7\n"
++    "   stmia %0!, {r0, r1, r2, r3}\n"
++
++    "   sub   %0, %0, #64\n"
++    "   sub   %1, %1, #64\n"
++
++    :: "r"(a), "r"(b) : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "memory");
++}
++#elif defined(__aarch64__)
++static inline
++void UADD(v256 *a, v256 *b)
++{
++    uint64_t a0, a1, b0, b1;
++
++    __asm volatile (
++    "   ldp   %0, %1, [%4, #0]\n"
++    "   ldp   %2, %3, [%5, #0]\n"
++    "   adds  %0, %0, %2\n"
++    "   adcs  %1, %1, %3\n"
++    "   stp   %0, %1, [%4, #0]\n"
++
++    "   ldp   %0, %1, [%4, #16]\n"
++    "   ldp   %2, %3, [%5, #16]\n"
++    "   adcs  %0, %0, %2\n"
++    "   adcs  %1, %1, %3\n"
++    "   stp   %0, %1, [%4, #16]\n"
++
++    : "=r"(a0), "=r"(a1), "=r"(b0), "=r"(b1)
++    : "r"(a), "r"(b) : "memory");
++}
+ 
+ #elif defined(__x86_64__)//0
+ static inline