Mail Archives: djgpp/1998/07/25/20:01:21
Vladimir Ignatov wrote:
>
> Hello
>
> I have some Visual C C++ sources with _lrotl function (cyclic
> rotate left). Seem it is MS extension to standart C library. Which
> replacement can i use with GCC 2.8.1 ?
Assuming it does something similar to what it did in Turbo C:
/* Non-portable version */
inline unsigned long _lrotl(unsigned long n, int c)
{
asm("roll %b2, %0"
: "=g" (n)
: "0" (n), "ci" (c));
return n;
}
/* More portable version */
/* For constant `c', GCC should optimize it into a single `roll'
instruction (!) */
#include <limits.h>
inline unsigned long _lrotl(unsigned long n, int c)
{
return (n << c) | (n >> ((sizeof(unsigned long) * CHAR_BIT) - c));
}
HTH
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -