On Thu, 16 Oct 2025 at 20:40, Sevan Janiyan <venture37+openssh at geeklan.co.uk> wrote:> Hi, > Managed to get OpenSSH 10.2p1 built on OS X 10.3 with OpenSSL 3.2.x, > pretty much built out of the box with just one change needed for poll(2). > [...] > /usr/include/poll.h: > 95 #if (__STDC__ > 0) || defined(__cplusplus) > 96 extern int poll (struct pollfd *pArray, unsigned long n_fds, int > [...] > OS doesn't come with nfds_t defined. > I changed the signature in bsd-poll.c so nfds is unsigned long insteadUnfortunately we can't take such a change as it'll break things that implement poll() as specified by POSIX ( https://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.html).> of nfds_t to match system header (bsd-poll.h, typedefs it to unsigned > int if nfds_t is not available) and the build succeeded without issue. >If the system doesn't have it, the compat headers will define it as: #ifndef HAVE_NFDS_T typedef unsigned int nfds_t; #endif Does changing "unsigned int" to "unsigned long" make it compile? The only requirements specified for nfds_t is "An unsigned integral type used for the number of file descriptors." so we could either change it unconditionally (although I'd worry about breaking something in the opposite direction) or have configure try to figure out which it is and use that. -- Darren Tucker (dtucker at dtucker.net) GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860 37F4 9357 ECEF 11EA A6FA Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
On Thu, Oct 16, 2025 at 09:24:24PM +1100, Darren Tucker wrote: [...]> or have configure try to figure out which it is and use that.I think this should do it. Note that you will need to run "autoreconf" to rebuild configure before running it. diff --git a/configure.ac b/configure.ac index db5211013..0c237ac78 100644 --- a/configure.ac +++ b/configure.ac @@ -3773,6 +3773,24 @@ AC_CHECK_TYPES([nfds_t], , , [ #endif ]) +if test "x$ac_cv_type_nfds_t" != "xyes"; then + AC_MSG_CHECKING([if poll nfds_t is unsigned long]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <sys/types.h> +#ifdef HAVE_POLL_H +#include <poll.h> +#endif +#ifdef HAVE_SYS_POLL_H +#include <sys/poll.h> +#endif + int poll(struct pollfd *, unsigned long, int timeout); + ]], [[return poll(0, 0, 0);]])], + AC_MSG_RESULT([yes]), + [AC_DEFINE(POLL_NFDS_T_ULONG, 1, [Define if poll 2nd arg is ulong]) + AC_MSG_RESULT([no])] + ) +fi + # Decide which sandbox style to use sandbox_arg="" AC_ARG_WITH([sandbox], diff --git a/openbsd-compat/bsd-poll.h b/openbsd-compat/bsd-poll.h index 67fd8c66f..bebd5d87d 100644 --- a/openbsd-compat/bsd-poll.h +++ b/openbsd-compat/bsd-poll.h @@ -72,7 +72,11 @@ typedef struct pollfd { #endif /* !HAVE_STRUCT_POLLFD_FD */ #ifndef HAVE_NFDS_T +# ifdef POLL_NFDS_T_ULONG +typedef unsigned long nfds_t; +# else typedef unsigned int nfds_t; +# endif #endif #ifndef HAVE_POLL -- Darren Tucker (dtucker at dtucker.net) GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860 37F4 9357 ECEF 11EA A6FA Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
On 16/10/2025 11:24, Darren Tucker wrote:>> I changed the signature in bsd-poll.c so nfds is unsigned long instead > > Unfortunately we can't take such a change as it'll break things that > implement poll() as specified by POSIX ( > https://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.html).Understood.>> of nfds_t to match system header (bsd-poll.h, typedefs it to unsigned >> int if nfds_t is not available) and the build succeeded without issue. >> > If the system doesn't have it, the compat headers will define it as: > > #ifndef HAVE_NFDS_T > typedef unsigned int nfds_t; > #endif > > Does changing "unsigned int" to "unsigned long" make it compile?It does. I made the following change and 'make tests' built successfully. The run of regress will take some hours to complete on the G3. --- openbsd-compat/bsd-poll.h.orig Fri Oct 10 03:38:31 2025 +++ openbsd-compat/bsd-poll.h Thu Oct 16 12:02:42 2025 @@ -72,7 +72,7 @@ #endif /* !HAVE_STRUCT_POLLFD_FD */ #ifndef HAVE_NFDS_T -typedef unsigned int nfds_t; +typedef unsigned long nfds_t; #endif #ifndef HAVE_POLL> The only requirements specified for nfds_t is "An unsigned integral type > used for the number of file descriptors." so we could either change it > unconditionally (although I'd worry about breaking something in the > opposite direction) or have configure try to figure out which it is and use > that.I'll give the patch in the follow up email you sent a try & reply back. Sincerely, Sevan