Opened 14 years ago

Last modified 6 years ago

#228 accepted defect

CMSG_LEN and CMSG_SPACE missing

Reported by: Silvan Scherrer Owned by: Yuri Dario
Priority: normal Milestone: libc-0.7
Component: libc Version:
Severity: normal Keywords:
Cc:

Description

in sys/socket.h the below defie are missing:

#ifndef CMSG_LEN
/* CMSG_LEN and CMSG_SPACE are defined by RFC 2292, but missing on
 * some older platforms.
 */
#define CMSG_LEN(len) ((size_t)CMSG_DATA((struct cmsghdr *)NULL) + (len))

/* CMSG_SPACE must add at least as much padding as CMSG_NXTHDR()
 * adds. We overestimate here.
 */
#define ALIGN_TO_SIZEOF(len, obj) (((len) + sizeof (obj) - 1) & ~(sizeof (obj)
- 1))
#define CMSG_SPACE(len) ALIGN_TO_SIZEOF (CMSG_LEN (len), struct cmsghdr)
#endif

Change History (6)

comment:1 Changed 13 years ago by bird

Component: baselayoutlibc
Milestone: libc-0.7

comment:2 Changed 13 years ago by bird

Unless these are present in the OS/2 toolkit, they will have to wait for the next libc version.

comment:3 Changed 10 years ago by Yuri Dario

Milestone: libc-0.7libc-0.6.6

comment:4 Changed 10 years ago by Yuri Dario

Owner: changed from bird to Yuri Dario
Status: newaccepted

comment:5 Changed 10 years ago by bird

Milestone: libc-0.6.6libc-0.7

This will have to wait for libc-0.7 as already stated. It will be part of an effort to resync socket.h and other with BSD.

comment:6 Changed 6 years ago by dmik

BTW, this is the version of these macros I did for chromium (here):

#ifndef CMSG_SPACE
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
#endif
#ifndef CMSG_LEN
#define CMSG_LEN(l)             (_ALIGN(sizeof(struct cmsghdr)) + (l))
#endif

Looks a bit simpler than the one in the description and uses _ALIGN which is already used by other CMSG defines.

Note: See TracTickets for help on using tickets.