Opened 9 years ago

Last modified 15 months ago

#228 accepted defect

CMSG_LEN and CMSG_SPACE missing

Reported by: diver Owned by: ydario
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 9 years ago by bird

  • Component changed from baselayout to libc
  • Milestone set to libc-0.7

comment:2 Changed 9 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 6 years ago by ydario

  • Milestone changed from libc-0.7 to libc-0.6.6

comment:4 Changed 6 years ago by ydario

  • Owner changed from bird to ydario
  • Status changed from new to accepted

comment:5 Changed 6 years ago by bird

  • Milestone changed from libc-0.6.6 to libc-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 15 months 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.