Skip to content

Commit 1061304

Browse files
committed
CommonFuncs.h: use inline functions instead of macros
1 parent ce4415e commit 1061304

File tree

2 files changed

+51
-33
lines changed

2 files changed

+51
-33
lines changed

Common/CommonFuncs.h

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,49 +46,75 @@
4646
#define Crash() {kill(getpid(), SIGINT);}
4747
#endif
4848

49+
#else // WIN32
50+
51+
// Function Cross-Compatibility
52+
#ifndef __MINGW32__
53+
#define strcasecmp _stricmp
54+
#define strncasecmp _strnicmp
55+
#endif
56+
57+
#ifndef __MINGW32__
58+
#define unlink _unlink
59+
#endif
60+
61+
// 64 bit offsets for windows
62+
#ifndef __MINGW32__
63+
#define fseeko _fseeki64
64+
#define ftello _ftelli64
65+
#define atoll _atoi64
66+
#endif
67+
#define Crash() {__debugbreak();}
68+
#endif // WIN32 ndef
69+
70+
#if defined(_MSC_VER)
71+
#include <cstdlib>
72+
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
73+
#include <x86intrin.h>
74+
#endif
75+
4976
inline u32 __rotl(u32 x, int shift) {
77+
#if defined(_MSC_VER)
78+
return _rotl(x, shift);
79+
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
80+
return __rold(x, shift);
81+
#else
5082
shift &= 31;
5183
if (!shift) return x;
5284
return (x << shift) | (x >> (32 - shift));
85+
#endif
5386
}
5487

5588
inline u64 __rotl64(u64 x, unsigned int shift){
89+
#if defined(_MSC_VER)
90+
return _rotl64(x, shift);
91+
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
92+
return __rolq(x, shift);
93+
#else
5694
unsigned int n = shift % 64;
5795
return (x << n) | (x >> (64 - n));
96+
#endif
5897
}
5998

6099
inline u32 __rotr(u32 x, int shift) {
100+
#if defined(_MSC_VER)
101+
return _rotr(x, shift);
102+
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
103+
return __rord(x, shift);
104+
#else
61105
shift &= 31;
62106
if (!shift) return x;
63107
return (x >> shift) | (x << (32 - shift));
108+
#endif
64109
}
65110

66111
inline u64 __rotr64(u64 x, unsigned int shift){
112+
#if defined(_MSC_VER)
113+
return _rotr64(x, shift);
114+
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64))
115+
return __rorq(x, shift);
116+
#else
67117
unsigned int n = shift % 64;
68118
return (x >> n) | (x << (64 - n));
69-
}
70-
71-
#else // WIN32
72-
73-
// Function Cross-Compatibility
74-
#ifndef __MINGW32__
75-
#define strcasecmp _stricmp
76-
#define strncasecmp _strnicmp
77-
#endif
78-
79-
#ifndef __MINGW32__
80-
#define unlink _unlink
81-
#define __rotl _rotl
82-
#define __rotl64 _rotl64
83-
#define __rotr _rotr
84-
#define __rotr64 _rotr64
85119
#endif
86-
87-
// 64 bit offsets for windows
88-
#ifndef __MINGW32__
89-
#define fseeko _fseeki64
90-
#define ftello _ftelli64
91-
#define atoll _atoi64
92-
#endif
93-
#define Crash() {__debugbreak();}
94-
#endif // WIN32 ndef
120+
}

Core/MIPS/MIPSInt.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,7 @@ namespace MIPSInt
715715
}
716716
else if (_RS == 1) //rotr
717717
{
718-
#ifdef __MINGW32__
719-
R(rd) = _rotr(R(rt), sa);
720-
#else
721718
R(rd) = __rotr(R(rt), sa);
722-
#endif
723719
break;
724720
}
725721
else
@@ -735,11 +731,7 @@ namespace MIPSInt
735731
}
736732
else if (_FD == 1) // rotrv
737733
{
738-
#ifdef __MINGW32__
739-
R(rd) = _rotr(R(rt), R(rs));
740-
#else
741734
R(rd) = __rotr(R(rt), R(rs));
742-
#endif
743735
break;
744736
}
745737
else goto wrong;

0 commit comments

Comments
 (0)