Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix 32bit Linux. GCC's lrotl/lrotr instrinsic functions are 32bit whe…
…n building for 32bit, we require 64bit at all times, so keep using our own instead.
  • Loading branch information
Sonicadvance1 committed Apr 3, 2013
1 parent 61c327b commit d06379f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Source/Core/Common/Src/CommonFuncs.h
Expand Up @@ -67,32 +67,30 @@ _mm_shuffle_epi8(__m128i a, __m128i mask)
#endif
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
// GCC 4.8 defines all the rotate functions now
#ifdef _rotl
#define _rotl64 _lrotl
#define _rotr64 _lrotr
#else
// Small issue with GCC's lrotl/lrotr intrinsics is they are still 32bit while we require 64bit
#ifndef _rotl
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));
}
#endif

inline u64 _rotl64(u64 x, unsigned int shift){
unsigned int n = shift % 64;
return (x << n) | (x >> (64 - n));
}

inline u64 _rotr64(u64 x, unsigned int shift){
unsigned int n = shift % 64;
return (x >> n) | (x << (64 - n));
}
#endif

#else // WIN32
// Function Cross-Compatibility
Expand Down

0 comments on commit d06379f

Please sign in to comment.