avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Cicrular Buffer routines


From: Bob Paddock
Subject: Re: [avr-gcc-list] Cicrular Buffer routines
Date: Tue, 16 Aug 2005 19:07:11 -0400
User-agent: KMail/1.7.2

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_SIZE    64

#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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]