lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] [lwip] MEM_ALIGNMENT and mem.c


From: Recker, John
Subject: [lwip-users] [lwip] MEM_ALIGNMENT and mem.c
Date: Wed, 08 Jan 2003 23:53:11 -0000

I started looking at the CVS code, and
noticed the following code in src/core/mem.c:


        struct mem {
          mem_size_t next, prev;
          u8_t used;
        #if MEM_ALIGNMENT == 2
          u8_t dummy;
        #endif /* MEM_ALIGNEMNT == 2 */
        };

        static struct mem *ram_end;
        static u8_t ram[MEM_SIZE + sizeof(struct mem) + MEM_ALIGNMENT];



I use MEM_ALIGNMENT == 4, for which the above
code fails. (What do other people use on an ARM?)
Also note that if one is going to use the "dummy"
variable approach, or compute sizes that presume
packing, one should probably also pack the structure.

I would therefore propose the following code instead:

        struct mem {
          mem_size_t next, prev;
        #if MEM_ALIGNMENT == 1
          u8_t used;
        #elif MEM_ALIGNMENT == 2
          u16_t used;
        #elif MEM_ALIGNMENT == 4
          u32_t used;
        #else
        #error "unhandled MEM_ALIGNMENT size"
        #endif /* MEM_ALIGNMENT */
        };

        static struct mem *ram_end;
        static u8_t ram[MEM_ALIGN_SIZE(MEM_SIZE + sizeof(struct mem))];



jr
[This message was sent through the lwip discussion list.]




reply via email to

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