problem with "struct m_hdr"

Ralf Corsepius ralf.corsepius at rtems.org
Sat Feb 21 06:09:43 UTC 2009


hsong jiang wrote:
> Hi all:
>   Is anybody found that there maybe problem with "struct m_hdr" in rtems
> 4.9.
> 
> struct m_hdr {
>  struct mbuf *mh_next;  /* next buffer in chain */
>  struct mbuf *mh_nextpkt; /* next chain in queue/record */
>  caddr_t mh_data;  /* location of data */
>  int mh_len;   /* amount of data in this mbuf */
>  int mh_flags;  /* flags; see below */
>  short mh_type;  /* type of data in this mbuf */
> };
> 
> "int mh_flags" should changed to "short mh_flags". Because sizeof(struct
> m_hdr) should be 20Bytes in FreeBSD. however  sizeof(struct m_hdr) are
> 24Bytes in Rtems. I don't know wheather it is a bug. but this indeed a
> question. thanks!

I don't understand what you are asking.

FreeBSD has this

struct m_hdr {
         struct mbuf     *mh_next;       /* next buffer in chain */
         struct mbuf     *mh_nextpkt;    /* next chain in queue/record */
         caddr_t          mh_data;       /* location of data */
         int              mh_len;        /* amount of data in this mbuf */
         int              mh_flags;      /* flags; see below */
         short            mh_type;       /* type of data in this mbuf */
         uint8_t          pad[M_HDR_PAD];/* word align                  */
};

with
#if defined(__LP64__)
#define M_HDR_PAD    6
#else
#define M_HDR_PAD    2
#endif

=> On most 32bit platforms, this results into
5 * 4 bytes + 1 * 2 bytes + 2 * 1 bytes = 24 bytes.

With RTEMS's m_hdr, this gives
5 * 4 bytes + 1 * 2 bytes = 22 bytes.

I.e. except of the pad[] bytes, the structures are identical.

Now, the question to me is: How and where does this impose a problem to you?

Ralf




More information about the users mailing list