[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Cicrular Buffer routines
From: |
Dave Hylands |
Subject: |
[avr-gcc-list] Cicrular Buffer routines |
Date: |
Tue, 16 Aug 2005 12:40:30 -0700 |
Larry Barello made a post which I believe he meant to go to this list.
I replied (unfortunately just to Larry).
Here's my reply to the list (I'm assuming Larry will repost his
original message).
Hi Larry,
On 8/16/05, Larry Barello <address@hidden> wrote:
> So, who has the tiniest fifo routine in C? I don't mean lack of text, 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,
but requires that there be one more bit in the index than the power of
two for the buffer. So an 8 bit index is restricted to 128 entries.
No wasted entries. Can tell the difference between full and empty. Can
mix types/size of buffers.
See: http://www.DaveHylands.com/Misc/CBUF.h
I realized that I can even get rid of the SIZE macro requirement by
using sizeof's.
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/
- [avr-gcc-list] Cicrular Buffer routines,
Dave Hylands <=