Sender: nate AT cartsys DOT com Message-ID: <35BA6D01.3293CF2C@cartsys.com> Date: Sat, 25 Jul 1998 16:40:49 -0700 From: Nate Eldredge MIME-Version: 1.0 To: Vladimir Ignatov CC: djgpp AT delorie DOT com Subject: Re: _lrotl replacement References: <35b9deda DOT 40014807 AT news DOT deol DOT ru> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk 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 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