mirror of
https://git.freebsd.org/ports.git
synced 2025-04-28 09:36:41 -04:00
archivers/libunrar: Support crc and crypto flags on aarch64
If CPU flags crc or crytpo are set, e.g. -march=armv8-a+crc+crypto, build would fail with missing headers because this was only implemented for glibc and Apple.
This commit is contained in:
parent
071dc53c21
commit
96e53c0c65
3 changed files with 74 additions and 15 deletions
22
archivers/libunrar/files/patch-crc.cpp
Normal file
22
archivers/libunrar/files/patch-crc.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
--- crc.cpp.orig 2025-02-12 14:05:26 UTC
|
||||
+++ crc.cpp
|
||||
@@ -42,12 +42,18 @@ void InitCRC32(uint *CRCTab)
|
||||
}
|
||||
|
||||
#ifdef USE_NEON_CRC32
|
||||
- #ifdef _APPLE
|
||||
+ #if defined(_APPLE)
|
||||
// getauxval isn't available in OS X
|
||||
uint Value=0;
|
||||
size_t Size=sizeof(Value);
|
||||
int RetCode=sysctlbyname("hw.optional.armv8_crc32",&Value,&Size,NULL,0);
|
||||
CRC_Neon=RetCode==0 && Value!=0;
|
||||
+ #elif defined(__FreeBSD__)
|
||||
+ // getauxval isn't available on FreeBSD
|
||||
+ uint64 Reg=READ_SPECIALREG(id_aa64isar0_el1);
|
||||
+ if (ID_AA64ISAR0_CRC32_VAL(Reg) == ID_AA64ISAR0_CRC32_BASE) {
|
||||
+ CRC_Neon=true;
|
||||
+ }
|
||||
#else
|
||||
CRC_Neon=(getauxval(AT_HWCAP) & HWCAP_CRC32)!=0;
|
||||
#endif
|
|
@ -1,13 +1,28 @@
|
|||
--- os.hpp.orig 2024-05-12 10:19:01 UTC
|
||||
--- os.hpp.orig 2025-02-12 14:05:27 UTC
|
||||
+++ os.hpp
|
||||
@@ -166,6 +166,10 @@
|
||||
#endif
|
||||
#endif
|
||||
@@ -158,10 +158,13 @@
|
||||
|
||||
#if defined(__aarch64__) && (defined(__ARM_FEATURE_CRYPTO) || defined(__ARM_FEATURE_CRC32))
|
||||
#include <arm_neon.h>
|
||||
-#ifndef _APPLE
|
||||
+#if !defined(_APPLE) && !defined(__FreeBSD__)
|
||||
#include <sys/auxv.h>
|
||||
#include <asm/hwcap.h>
|
||||
#endif
|
||||
+#ifdef __FreeBSD__
|
||||
+#include <machine/armreg.h>
|
||||
+#endif
|
||||
#ifdef __ARM_FEATURE_CRYPTO
|
||||
#define USE_NEON_AES
|
||||
#endif
|
||||
@@ -169,6 +172,10 @@
|
||||
#define USE_NEON_CRC32
|
||||
#endif
|
||||
#endif
|
||||
+
|
||||
+#if defined(OPENSSL_AES)
|
||||
+#include <openssl/evp.h>
|
||||
+#endif // OPENSSL_AES
|
||||
+
|
||||
|
||||
#ifdef S_IFLNK
|
||||
#define SAVE_LINKS
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
--- rijndael.cpp.orig 2024-05-12 10:19:02 UTC
|
||||
--- rijndael.cpp.orig 2025-02-12 14:05:27 UTC
|
||||
+++ rijndael.cpp
|
||||
@@ -3,6 +3,7 @@
|
||||
**************************************************************************/
|
||||
|
@ -67,7 +67,29 @@
|
|||
// Check SIMD here instead of constructor, so if object is a part of some
|
||||
// structure memset'ed before use, these variables are not lost.
|
||||
#if defined(USE_SSE)
|
||||
@@ -166,6 +197,7 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint
|
||||
@@ -116,7 +147,7 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint
|
||||
#endif
|
||||
|
||||
#elif defined(USE_NEON_AES)
|
||||
- #ifdef _APPLE
|
||||
+ #if defined(_APPLE)
|
||||
// getauxval isn't available in OS X
|
||||
uint Value=0;
|
||||
size_t Size=sizeof(Value);
|
||||
@@ -126,6 +157,12 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint
|
||||
// because "hw.optional.arm.FEAT_AES" was missing in OS X 11, but AES
|
||||
// still was supported by Neon.
|
||||
AES_Neon=RetCode!=0 || Value!=0;
|
||||
+ #elif defined(__FreeBSD__)
|
||||
+ // getauxval isn't available on FreeBSD
|
||||
+ uint64 Reg=READ_SPECIALREG(id_aa64isar0_el1);
|
||||
+ if (ID_AA64ISAR0_AES_VAL(Reg) == ID_AA64ISAR0_AES_BASE) {
|
||||
+ AES_Neon=true;
|
||||
+ }
|
||||
#else
|
||||
AES_Neon=(getauxval(AT_HWCAP) & HWCAP_AES)!=0;
|
||||
#endif
|
||||
@@ -166,6 +203,7 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint
|
||||
|
||||
if(!Encrypt)
|
||||
keyEncToDec();
|
||||
|
@ -75,7 +97,7 @@
|
|||
}
|
||||
|
||||
|
||||
@@ -174,6 +206,15 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
|
||||
@@ -174,6 +212,15 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
|
||||
if (inputLen <= 0)
|
||||
return;
|
||||
|
||||
|
@ -91,7 +113,7 @@
|
|||
size_t numBlocks = inputLen/16;
|
||||
#if defined(USE_SSE)
|
||||
if (AES_NI)
|
||||
@@ -238,9 +279,11 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
|
||||
@@ -238,9 +285,11 @@ void Rijndael::blockEncrypt(const byte *input,size_t i
|
||||
input += 16;
|
||||
}
|
||||
Copy128(m_initVector,prevBlock);
|
||||
|
@ -103,7 +125,7 @@
|
|||
#ifdef USE_SSE
|
||||
void Rijndael::blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffer)
|
||||
{
|
||||
@@ -306,6 +349,7 @@ void Rijndael::blockEncryptNeon(const byte *input,size
|
||||
@@ -306,6 +355,7 @@ void Rijndael::blockEncryptNeon(const byte *input,size
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -111,7 +133,7 @@
|
|||
|
||||
|
||||
void Rijndael::blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer)
|
||||
@@ -313,6 +357,15 @@ void Rijndael::blockDecrypt(const byte *input, size_t
|
||||
@@ -313,6 +363,15 @@ void Rijndael::blockDecrypt(const byte *input, size_t
|
||||
if (inputLen <= 0)
|
||||
return;
|
||||
|
||||
|
@ -127,7 +149,7 @@
|
|||
size_t numBlocks=inputLen/16;
|
||||
#if defined(USE_SSE)
|
||||
if (AES_NI)
|
||||
@@ -381,9 +434,11 @@ void Rijndael::blockDecrypt(const byte *input, size_t
|
||||
@@ -381,9 +440,11 @@ void Rijndael::blockDecrypt(const byte *input, size_t
|
||||
}
|
||||
|
||||
memcpy(m_initVector,iv,16);
|
||||
|
@ -139,7 +161,7 @@
|
|||
#ifdef USE_SSE
|
||||
void Rijndael::blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer)
|
||||
{
|
||||
@@ -450,8 +505,10 @@ void Rijndael::blockDecryptNeon(const byte *input, siz
|
||||
@@ -450,8 +511,10 @@ void Rijndael::blockDecryptNeon(const byte *input, siz
|
||||
memcpy(m_initVector,iv,16);
|
||||
}
|
||||
#endif
|
||||
|
@ -150,7 +172,7 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ALGORITHM
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -580,6 +637,7 @@ void Rijndael::GenerateTables()
|
||||
@@ -580,6 +643,7 @@ void Rijndael::GenerateTables()
|
||||
U1[b][0]=U2[b][1]=U3[b][2]=U4[b][3]=T5[I][0]=T6[I][1]=T7[I][2]=T8[I][3]=gmul(b,0xe);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue