| 22 Dec 2025 |
Randy Eckenrode | The implication in the Darwin headers seems to suggest that it’s using a 64-bit type, which is a lot of fds. | 17:40:36 |
Randy Eckenrode | Yeah. | 17:40:45 |
Ihar Hrachyshka | not sure I understand. the fds are passed by caller. it's up to caller. | 17:41:44 |
Ihar Hrachyshka | complete macos g_poll:
gint
g_poll (GPollFD *fds,
guint nfds,
gint timeout)
{
struct timeval tv;
fd_set rset, wset, xset;
GPollFD *f;
int ready;
int maxfd = 0;
FD_ZERO (&rset);
FD_ZERO (&wset);
FD_ZERO (&xset);
for (f = fds; f < &fds[nfds]; ++f)
if (f->fd >= 0)
{
if (f->events & G_IO_IN)
FD_SET (f->fd, &rset);
if (f->events & G_IO_OUT)
FD_SET (f->fd, &wset);
if (f->events & G_IO_PRI)
FD_SET (f->fd, &xset);
if (f->fd > maxfd && (f->events & (G_IO_IN|G_IO_OUT|G_IO_PRI)))
maxfd = f->fd;
}
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
ready = select (maxfd + 1, &rset, &wset, &xset,
timeout == -1 ? NULL : &tv);
if (ready > 0)
for (f = fds; f < &fds[nfds]; ++f)
{
f->revents = 0;
if (f->fd >= 0)
{
if (FD_ISSET (f->fd, &rset))
f->revents |= G_IO_IN;
if (FD_ISSET (f->fd, &wset))
f->revents |= G_IO_OUT;
if (FD_ISSET (f->fd, &xset))
f->revents |= G_IO_PRI;
}
}
return ready;
}
| 17:42:17 |
Ihar Hrachyshka | you mean fd_sets? | 17:43:04 |
Randy Eckenrode | Yeah. | 17:43:51 |
Randy Eckenrode | That comment about where the sets are allocated doesn’t make sense to me. | 17:44:42 |
Ihar Hrachyshka | guess I should just test and see. I have a reproducer, just need to recompile glib to qemu and see. | 17:44:57 |
Randy Eckenrode | * | 17:44:59 |
Ihar Hrachyshka | source == hacker news nobody | 17:45:27 |
Randy Eckenrode | https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/_types/_fd_def.h#L52_L54 | 17:46:06 |
Randy Eckenrode | Fish shell developer? | 17:47:01 |
Ihar Hrachyshka | I was actually also looking at the same struct def. so looks like we may need to also define the __DARWIN_FD_SETSIZE otherwise we write past the end of the struct (I think) | 17:47:57 |
Randy Eckenrode | Or malloc it based on the size of the incoming set. | 17:49:12 |
Randy Eckenrode | Glib supports using cleanup functions to make that less messy. | 17:49:27 |
Randy Eckenrode | Though if it’s a mask for all fds, you don’t really know the needed size. | 17:50:00 |
Randy Eckenrode | https://man.freebsd.org/cgi/man.cgi?select | 17:52:21 |
Randy Eckenrode | Apple mentioned FreeBSD being unlimited. I agree we should probably increase the amount of memory it’s using (either by defining FD_SETSIZE or some other way). | 17:53:19 |
Randy Eckenrode | Looks like (unsurprisingly) FreeBSD has a similar implementation.
https://github.com/freebsd/freebsd-src/blob/f51e9d0e0988df58c94db586ab5c8b5fd091c004/sys/sys/select.h#L65
| 17:55:17 |
Randy Eckenrode | I guess FreeBSD doesn’t enforce the limit if you define it to something non-default. | 17:55:46 |
Ihar Hrachyshka | so darwin just broke the api to pass posix | 17:56:22 |
Ihar Hrachyshka | well, broke -> adjusted to standard | 17:56:33 |
hexa | Randy Eckenrode, emily any reason I should not update the darwin buildfarm to tahoe? | 21:45:40 |
| @-chi:matrix.org left the room. | 21:48:15 |
Randy Eckenrode | Not that I can think of. It hasn’t broken Nix or Nixpkgs like updates have in the past. | 21:48:50 |
Alyssa Ross | poll usability flip-flopping every macOS release is a sort of famous example of macOS POSIX-noncompliance: https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/ | 21:49:59 |
Alyssa Ross | * poll usability flip-flopping between macOS releases is a sort of famous example of macOS POSIX-noncompliance: https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/ | 21:50:19 |
Alyssa Ross | it might well presently work, but the track record is not confidence-inspiring | 21:50:48 |
Alyssa Ross | and since you couldn't tell at build time whether the built program would end up being run on a macOS with broken poll, hardcoding not to use it on macOS was the only sensible solution | 21:52:12 |
Alyssa Ross | (assuming the complexity of detecting it at runtime isn't worth it) | 21:52:55 |