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 by bird, 14 years ago

Component: baselayoutlibc
Milestone: libc-0.7

comment:2 by bird, 14 years ago

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

comment:3 by Yuri Dario, 11 years ago

Milestone: libc-0.7libc-0.6.6

comment:4 by Yuri Dario, 11 years ago

Owner: changed from bird to Yuri Dario
Status: newaccepted

comment:5 by bird, 11 years ago

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 by dmik, 6 years ago

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.