__rotatel4, __builtin_rotateleft32, __rotatel8, __builtin_rotateleft64
Purpose
Rotate Left Word, Rotate Left Doubleword
Rotates rs left shift bits.
Prototype
unsigned int __builtin_rotateleft32 (unsigned int rs, unsigned int shift);
unsigned long long __builtin_rotateleft64 (unsigned long long rs, unsigned long long shift);
unsigned int __rotatel4 (unsigned int rs, unsigned int shift);
unsigned long long __rotatel8 (unsigned long long rs, unsigned long long shift);
Note:
- The built-in function
__rotatel4is a synonym of__builtin_rotateleft32and the built-in function__rotatel8is a synonym of__builtin_rotateleft64. - The built-in functions
__rotatel4and__rotatel8are provided for compatibility with IBM® XL C/C++ for AIX® 16.1 or earlier releases. This built-in function may be deprecated in the future.
Example
#include <stdio.h>
#include <builtins.h>
int main() {
unsigned int a, b, c;
a = 0xabcdef01;
for (int i=0; i < 8; ++i) {
b = __rotatel4(a, 4 * i);
printf("0x%08x\n", b);
}
return 0;
} The
output is 0xabcdef01 0xbcdef01a 0xcdef01ab 0xdef01abc 0xef01abcd 0xf01abcde 0x01abcdef
0x1abcdef0.