[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SV: [lwip-users] Alignment problem i pbuf_alloc()
From: |
Lars Thorup |
Subject: |
SV: [lwip-users] Alignment problem i pbuf_alloc() |
Date: |
Tue, 25 May 2004 08:05:10 +0200 |
Fra: K.J. Mansley [mailto:address@hidden
> Looks like it, but I'm not sure which bit is wrong. Out of
> interest, where does the "6" bytes in the offset come from?
> I'm guessing some physical layer header?
Yes, we are running on top of an ARCNET, and we use a 6 byte header on the
physical layer.
> I can think of a number of work-arounds, but does anyone have
> a suggestion for a solid fix?
This is the original code from pbuf_alloc():
case PBUF_RAM:
/* If pbuf is to be allocated in RAM, allocate memory for it. */
p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + length + offset));
I have changed the third line to
p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + offset) +
MEM_ALIGN_SIZE(length));
In this part of the code a single buffer is allocated to hold two parts. The
second part is put on an alignment boundary, so the size of the first part
must be rounded up with a call to MEM_ALIGN_SIZE(sizeof(struct
pbuf)+offset). To make sure the size of the entire buffer is aligned, also
the size of the second part must be rounded up with a call to
MEM_ALIGN_SIZE(length).
And that seems to solve our problem. Can you confirm this fix and make sure
it gets into CVS?
Best regards
Lars Thorup
Re: SV: SV: [lwip-users] Alignment problem i pbuf_alloc(), 刘良, 2004/05/25
[lwip-users] Alignment problem i pbuf_alloc(), Lars Thorup, 2004/05/25