adjust inline asm requiring constants

In order to ensure that the shift is within range, convert the inline assembly
routines into macros with compound statements.
This commit is contained in:
Saleem Abdulrasool 2015-01-04 22:53:08 -08:00 committed by Steffen Jaeckel
parent e9f9c6fa55
commit 62878de0c5

View File

@ -264,21 +264,22 @@ static inline ulong32 ROR(ulong32 word, int i)
#ifndef LTC_NO_ROLC #ifndef LTC_NO_ROLC
static inline ulong32 ROLc(ulong32 word, const int i) #define ROLc(word,i) ({ \
{ ulong32 __ROLc_tmp = word; \
asm ("roll %2,%0" __asm__ ("roll %2, %0" : \
:"=r" (word) "=r" (__ROLc_tmp) : \
:"0" (word),"I" (i)); "0" (__ROLc_tmp), \
return word; "I" (i)); \
} __ROLc_tmp; \
})
static inline ulong32 RORc(ulong32 word, const int i) #define RORc(word,i) ({ \
{ ulong32 __RORc_tmp = word; \
asm ("rorl %2,%0" __asm__ ("rorl %2, %0" : \
:"=r" (word) "=r" (__RORc_tmp) : \
:"0" (word),"I" (i)); "0" (__RORc_tmp), \
return word; "I" (i)); \
} __RORc_tmp; \
})
#else #else
@ -363,21 +364,22 @@ static inline ulong64 ROR64(ulong64 word, int i)
#ifndef LTC_NO_ROLC #ifndef LTC_NO_ROLC
static inline ulong64 ROL64c(ulong64 word, const int i) #define ROL64c(word,i) ({ \
{ ulong64 __ROL64c_tmp = word; \
asm("rolq %2,%0" __asm__ ("rolq %2, %0" : \
:"=r" (word) "=r" (__ROL64c_tmp) : \
:"0" (word),"J" (i)); "0" (__ROL64c_tmp), \
return word; "J" (i)); \
} __ROL64c_tmp; \
})
static inline ulong64 ROR64c(ulong64 word, const int i) #define ROR64c(word,i) ({ \
{ ulong64 __ROR64c_tmp = word; \
asm("rorq %2,%0" __asm__ ("rorq %2, %0" : \
:"=r" (word) "=r" (__ROR64c_tmp) : \
:"0" (word),"J" (i)); "0" (__ROR64c_tmp), \
return word; "J" (i)); \
} __ROR64c_tmp; \
})
#else /* LTC_NO_ROLC */ #else /* LTC_NO_ROLC */