CommonFuncs.h: use inline functions instead of macros

This commit is contained in:
oltolm committed 2025-06-09 12:21:40 +02:00
1 parent ce4415eeed
commit 1061304b9f
2 files changed
+52 -34

No files matched your search

+52 -26
View File
@@ -46,28 +46,6 @@
#define Crash() {kill(getpid(), SIGINT);}
#endif
inline u32 __rotl(u32 x, int shift) {
shift &= 31;
if (!shift) return x;
return (x << shift) | (x >> (32 - shift));
}
inline u64 __rotl64(u64 x, unsigned int shift){
unsigned int n = shift % 64;
return (x << n) | (x >> (64 - n));
}
inline u32 __rotr(u32 x, int shift) {
shift &= 31;
if (!shift) return x;
return (x >> shift) | (x << (32 - shift));
}
inline u64 __rotr64(u64 x, unsigned int shift){
unsigned int n = shift % 64;
return (x >> n) | (x << (64 - n));
}
#else // WIN32
// Function Cross-Compatibility
@@ -78,10 +56,6 @@ inline u64 __rotr64(u64 x, unsigned int shift){
#ifndef __MINGW32__
#define unlink _unlink
#define __rotl _rotl
#define __rotl64 _rotl64
#define __rotr _rotr
#define __rotr64 _rotr64
#endif
// 64 bit offsets for windows
@@ -92,3 +66,55 @@ inline u64 __rotr64(u64 x, unsigned int shift){
#endif
#define Crash() {__debugbreak();}
#endif // WIN32 ndef
#if defined(_MSC_VER)
#include <cstdlib>
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
#include <x86intrin.h>
#endif
inline u32 __rotl(u32 x, int shift) {
#if defined(_MSC_VER)
return _rotl(x, shift);
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
return __rold(x, shift);
#else
shift &= 31;
if (!shift) return x;
return (x << shift) | (x >> (32 - shift));
#endif
}
inline u64 __rotl64(u64 x, unsigned int shift){
#if defined(_MSC_VER)
return _rotl64(x, shift);
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
return __rolq(x, shift);
#else
unsigned int n = shift % 64;
return (x << n) | (x >> (64 - n));
#endif
}
inline u32 __rotr(u32 x, int shift) {
#if defined(_MSC_VER)
return _rotr(x, shift);
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
return __rord(x, shift);
#else
shift &= 31;
if (!shift) return x;
return (x >> shift) | (x << (32 - shift));
#endif
}
inline u64 __rotr64(u64 x, unsigned int shift){
#if defined(_MSC_VER)
return _rotr64(x, shift);
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
return __rorq(x, shift);
#else
unsigned int n = shift % 64;
return (x >> n) | (x << (64 - n));
#endif
}
-8
View File
@@ -715,11 +715,7 @@ namespace MIPSInt
}
else if (_RS == 1) //rotr
{
#ifdef __MINGW32__
R(rd) = _rotr(R(rt), sa);
#else
R(rd) = __rotr(R(rt), sa);
#endif
break;
}
else
@@ -735,11 +731,7 @@ namespace MIPSInt
}
else if (_FD == 1) // rotrv
{
#ifdef __MINGW32__
R(rd) = _rotr(R(rt), R(rs));
#else
R(rd) = __rotr(R(rt), R(rs));
#endif
break;
}
else goto wrong;