Add riscv64 asm_arch to linux64-riscv64 target

Reviewed-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Signed-off-by: Henry Brausen <henry.brausen@vrull.eu>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18275)
diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index 305cc0d..7735c94 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -816,6 +816,7 @@
     "linux64-riscv64" => {
         inherit_from     => [ "linux-generic64"],
         perlasm_scheme   => "linux64",
+        asm_arch         => 'riscv64',
     },
 
     # loongarch64 below refers to contemporary LOONGARCH Architecture
diff --git a/crypto/sha/sha256.c b/crypto/sha/sha256.c
index 89beaf1..649d25d 100644
--- a/crypto/sha/sha256.c
+++ b/crypto/sha/sha256.c
@@ -132,7 +132,7 @@
 # ifndef PEDANTIC
 #  if defined(__GNUC__) && __GNUC__>=2 && \
       !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
-#   if __riscv_zknh
+#   if defined(__riscv_zknh)
 #    define Sigma0(x) ({ MD32_REG_T ret;            \
                         asm ("sha256sum0 %0, %1"    \
                         : "=r"(ret)                 \
@@ -150,7 +150,7 @@
                         : "=r"(ret)                 \
                         : "r"(x)); ret;             })
 #   endif
-#   if __riscv_zbt || __riscv_zpn
+#   if defined(__riscv_zbt) || defined(__riscv_zpn)
 #    define Ch(x,y,z) ({  MD32_REG_T ret;                           \
                         asm (".insn r4 0x33, 1, 0x3, %0, %2, %1, %3"\
                         : "=r"(ret)                                 \
diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c
index db13565..ee00b55 100644
--- a/crypto/sha/sha512.c
+++ b/crypto/sha/sha512.c
@@ -432,7 +432,7 @@
                                 : "=r"(ret)                     \
                                 : "r"(*((const SHA_LONG64 *)(&(x))))); ret; })
 #    endif
-#   elif (__riscv_zbkb || __riscv_zbb) && __riscv_xlen == 32
+#   elif (defined(__riscv_zbkb) || defined(__riscv_zbb)) && __riscv_xlen == 32
 #    define PULL64(x) ({ SHA_LONG64 ret;                                        \
                         unsigned int *r = (unsigned int *)(&(ret));             \
                         const unsigned int *p = (const unsigned int *)(&(x));   \
@@ -442,13 +442,13 @@
                         asm ("rev8 %0, %1"                                      \
                         : "=r"(r[1])                                            \
                         : "r" (p[0])); ret;                                     })
-#   elif (__riscv_zbkb || __riscv_zbb) && __riscv_xlen == 64
+#   elif (defined(__riscv_zbkb) || defined(__riscv_zbb)) && __riscv_xlen == 64
 #    define PULL64(x) ({ SHA_LONG64 ret;    \
                         asm ("rev8 %0, %1"  \
                         : "=r"(ret)         \
                         : "r"(x)); ret;     })
 #   endif
-#   if __riscv_zknh && __riscv_xlen == 32
+#   if defined(__riscv_zknh) && __riscv_xlen == 32
 #    define Sigma0(x) ({ SHA_LONG64 ret; unsigned int *r = (unsigned int *)(&(ret));    \
                         const unsigned int *p = (const unsigned int *)(&(x));           \
                         asm ("sha512sum0r %0, %1, %2"                                   \
@@ -481,7 +481,7 @@
                         asm ("sha512sig1h %0, %2, %1"                                   \
                         : "=r"(r[1])                                                    \
                         : "r" (p[0]), "r" (p[1])); ret;                                 })
-#   elif __riscv_zknh && __riscv_xlen == 64
+#   elif defined(__riscv_zknh) && __riscv_xlen == 64
 #    define Sigma0(x) ({ SHA_LONG64 ret;            \
                         asm ("sha512sum0 %0, %1"    \
                         : "=r"(ret)                 \
@@ -499,7 +499,7 @@
                         : "=r"(ret)                 \
                         : "r"(x)); ret;             })
 #   endif
-#   if (__riscv_zbt || __riscv_zpn) && __riscv_xlen == 32
+#   if (defined(__riscv_zbt) || defined(__riscv_zpn)) && __riscv_xlen == 32
 #    define Ch(x,y,z) ({  SHA_LONG64 ret; unsigned int *r = (unsigned int *)(&(ret));   \
                         const unsigned int *xp = (const unsigned int *)(&(x));          \
                         const unsigned int *yp = (const unsigned int *)(&(y));          \
@@ -520,7 +520,7 @@
                         asm (".insn r4 0x33, 1, 0x3, %0, %2, %1, %3\n\t"                \
                         : "=r"(r[1])                                                    \
                         : "r"(xp[1]^zp[1]), "r"(yp[1]), "r"(zp[1])); ret;               })
-#   elif (__riscv_zbt || __riscv_zpn) && __riscv_xlen == 64
+#   elif (defined(__riscv_zbt) || defined(__riscv_zpn)) && __riscv_xlen == 64
 #    define Ch(x,y,z) ({  SHA_LONG64 ret;                           \
                         asm (".insn r4 0x33, 1, 0x3, %0, %2, %1, %3"\
                         : "=r"(ret)                                 \