Skip to content

[ABI BREAK] abis: Fix definition of fd_set#1658

Open
Dennisbonke wants to merge 1 commit into
managarm:masterfrom
Dennisbonke:mlibc-linux-2
Open

[ABI BREAK] abis: Fix definition of fd_set#1658
Dennisbonke wants to merge 1 commit into
managarm:masterfrom
Dennisbonke:mlibc-linux-2

Conversation

@Dennisbonke

Copy link
Copy Markdown
Member

No description provided.

@Mathewnd Mathewnd changed the title abis: Fix definition of fd_set [ABI BREAK] abis: Fix definition of fd_set Jan 11, 2026
@Dennisbonke Dennisbonke force-pushed the mlibc-linux-2 branch 3 times, most recently from f826ec3 to 62b86ad Compare January 11, 2026 21:55
Comment thread abis/linux/fd_set.h
Comment thread abis/linux/fd_set.h
@Dennisbonke Dennisbonke force-pushed the mlibc-linux-2 branch 3 times, most recently from c92cf08 to 859e25b Compare January 12, 2026 20:13
@Dennisbonke Dennisbonke force-pushed the mlibc-linux-2 branch 3 times, most recently from eb3f878 to afb2571 Compare January 29, 2026 20:42
Comment thread abis/linux/fd_set.h
Comment thread abis/linux/fd_set.h
Comment thread abis/ironclad/fd_set.h
Comment thread options/posix/generic/sys-select.cpp Outdated
void __FD_CLR(int fd, fd_set *set) {
__ensure(fd < FD_SETSIZE);
set->fds_bits[fd / 8] &= ~(1 << (fd % 8));
set->fds_bits[fd / NFDBITS] &= std::bit_cast<fd_mask>(~FD_MASK(fd % NFDBITS));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modulo could be replaced by fd & (NFDBITS-1). We should then also add a static_assert(std::has_single_bit(NFDBITS)); to make sure that NFDBITS is a power of two.

Comment thread options/posix/generic/sys-select.cpp Outdated
int __FD_ISSET(int fd, fd_set *set) {
__ensure(fd < FD_SETSIZE);
return set->fds_bits[fd / 8] & (1 << (fd % 8));
return (std::bit_cast<fd_mask_unsigned>(set->fds_bits[fd / NFDBITS]) & FD_MASK(fd % NFDBITS)) != 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo.

Comment thread options/posix/generic/sys-select.cpp Outdated
void __FD_SET(int fd, fd_set *set) {
__ensure(fd < FD_SETSIZE);
set->fds_bits[fd / 8] |= 1 << (fd % 8);
set->fds_bits[fd / NFDBITS] = std::bit_cast<fd_mask>(std::bit_cast<fd_mask_unsigned>(set->fds_bits[fd / NFDBITS]) | FD_MASK(fd % NFDBITS));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants