Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

sys/socket.h: fix some CMSG_ macros not aligning #728

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ABI_BREAKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This document lists the ABI breaks that were made in each mlibc major version.

## Version 3

- [#728](https://github.com/managarm/mlibc/pull/728):
The macros `CMSG_{LEN,SPACE,DATA}` were not accounting for padding between
`struct cmsghdr` and it's respective data. This manifested itself as some
parts of control data being skipped on platforms where `struct cmsghdr` is
not divisible by `alignof(size_t)`.
- [#452](https://github.com/managarm/mlibc/pull/452): The functions `FD_{CLR,ISSET,SET,ZERO}` were renamed to `__FD_{CLR,ISSET,SET,ZERO}` and replaced by macros to match Wine's assumptions.
- [#511](https://github.com/managarm/mlibc/pull/511): Musl's regex engine was added, implementing `regcomp` and `regexec`. This required some changes to the `regex_t` struct.
- [#504](https://github.com/managarm/mlibc/pull/504): In the Linux ABI, a `domainname` member was added to `struct utsname`, which is a glibc extension.
Expand Down
6 changes: 3 additions & 3 deletions options/posix/include/sys/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ struct sockaddr {
~(__alignof__(size_t) - 1))

// Basic macros to return content and padding size of a control message.
#define CMSG_LEN(s) (sizeof(struct cmsghdr) + (s))
#define CMSG_SPACE(s) (sizeof(struct cmsghdr) + CMSG_ALIGN(s))
#define CMSG_LEN(s) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (s))
#define CMSG_SPACE(s) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(s))

// Provides access to the data of a control message.
#define CMSG_DATA(c) ((char *)(c) + sizeof(struct cmsghdr))
#define CMSG_DATA(c) ((char *)(c) + CMSG_ALIGN(sizeof(struct cmsghdr)))

#define __MLIBC_CMSG_NEXT(c) ((char *)(c) + CMSG_ALIGN((c)->cmsg_len))
#define __MLIBC_MHDR_LIMIT(m) ((char *)(m)->msg_control + (m)->msg_controllen)
Expand Down