Re: [avr-gcc-list] Cicrular Buffer routines
On Tuesday 16 August 2005 03:40 pm, Dave Hylands wrote: but size of compiled code. The best I have done is using powers of two with masks on the indexes (32 byte buffer being a convenient size). I have one that's just in a .h file. It also works for powers of 2, You can test to make sure that you do have a power of two buffer size with the following: #define myQ_SIZE64 #define myQ_MASK ( myQ__SIZE - 1 ) #if ( myQ__SIZE myQ__MASK ) #error myQ_SIZE buffer size is not a power of 2 #endif The effect is to check if only one, and only one, bit is set in myQ_SIZE. -- http://www.softwaresafety.net/ http://www.unusualresearch.com/ http://www.bpaddock.com/ ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Cicrular Buffer routines
On Aug 16, 2005, at 6:07 PM, Bob Paddock wrote: You can test to make sure that you do have a power of two buffer size with the following: #define myQ_SIZE64 #define myQ_MASK ( myQ__SIZE - 1 ) #if ( myQ__SIZE myQ__MASK ) #error myQ_SIZE buffer size is not a power of 2 #endif Wouldn't it be easier to simply define the size like this: #define myQ_SIZE(16) If you shift a 1 then it must be a power of 2. -- David Kelly N4HHE, [EMAIL PROTECTED] Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list