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: David Kelly
Subject: Re: [avr-gcc-list] Cicrular Buffer routines
Date: Tue, 16 Aug 2005 20:11:17 -0500


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_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

Wouldn't it be easier to simply define the size like this:

#define myQ_SIZE    (1<<6)

If you shift a 1 then it must be a power of 2.

--
David Kelly N4HHE, address@hidden
========================================================================
Whom computers would destroy, they must first drive mad.





reply via email to

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