baresip / re

Generic library for real-time communications with async IO support
BSD 3-Clause "New" or "Revised" License
136 stars 83 forks source link

rtcp: avoid bitfields in struct rtcp_hdr #1108

Closed alfredh closed 6 months ago

sreimers commented 6 months ago

Should we close this, if bit-field support is now working for re_printf https://github.com/baresip/re/pull/1110?

struct rtcp_hdr {
        unsigned int               version:2;            /*     0: 0  4 */
        unsigned int               p:1;                  /*     0: 2  4 */
        unsigned int               count:5;              /*     0: 3  4 */
        unsigned int               pt:8;                 /*     0: 8  4 */

        /* Bitfield combined with next fields */

        uint16_t                   length;               /*     2     2 */

        /* size: 4, cachelines: 1, members: 5 */
        /* last cacheline: 4 bytes */
};
struct rtcp_hdr {
        uint8_t                    version;              /*     0     1 */
        _Bool                      p;                    /*     1     1 */
        uint8_t                    count;                /*     2     1 */

        /* XXX 1 byte hole, try to pack */

        enum rtcp_type             pt;                   /*     4     4 */
        uint16_t                   length;               /*     8     2 */

        /* size: 12, cachelines: 1, members: 5 */
        /* sum members: 9, holes: 1, sum holes: 1 */
        /* padding: 2 */
        /* last cacheline: 12 bytes */
};
alfredh commented 6 months ago

Thanks.

The "version" field can also in theory be removed, since we only support RTP version 2.