From ad97f0ae4302f99b3266169344f4487bcbe3bf6d Mon Sep 17 00:00:00 2001 From: Sven Kirmess Date: Sat, 6 Jun 2026 19:36:53 +0200 Subject: [PATCH] portability: fix build on Solaris/illumos (OmniOS) Five issues prevented building on Solaris/illumos: - configure.ac: add AC_SEARCH_LIBS for socket and gethostbyname. On Solaris/illumos these functions are in libsocket and libnsl rather than libc. - configure.ac: test whether groff can actually produce HTML output before enabling HTML man page generation. On systems where groff is installed without the grohtml driver, the build would fail when trying to generate HTML man pages. - qdevices/utils.c: include config.h so that AC_USE_SYSTEM_EXTENSIONS takes effect. Without it, _POSIX_PTHREAD_SEMANTICS is not defined and the compiler sees the old 4-argument Solaris form of getgrnam_r instead of the POSIX 5-argument form. - qdevices/unix-socket.c: add '#undef sun' after the system includes. GCC on Solaris/illumos predefines 'sun' as a numeric macro for platform detection, which conflicts with the local variable of the same name used for struct sockaddr_un. - qdevices/tlv.c: include on Solaris/illumos for htobe64() and be64toh(). Solaris/illumos provides these functions in , the same header as Linux. Co-Authored-By: Claude Sonnet 4.6 --- configure.ac | 14 ++++++++++++++ qdevices/tlv.c | 2 +- qdevices/unix-socket.c | 5 +++++ qdevices/utils.c | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8628588..be62b51 100644 --- a/configure.ac +++ b/configure.ac @@ -85,6 +85,15 @@ AC_ARG_WITH([bash], [BASHPATH="$withval"], [AC_PATH_PROG([BASHPATH], [bash])]) AC_CHECK_PROGS([GROFF], [groff]) +if test -n "$GROFF"; then + AC_MSG_CHECKING([whether groff supports HTML output]) + if echo '.TH test 1' | $GROFF -mandoc -Thtml >/dev/null 2>&1; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + GROFF="" + fi +fi # Checks for typedefs. AC_TYPE_UID_T @@ -100,6 +109,11 @@ AC_TYPE_SIZE_T AC_TYPE_SSIZE_T # Checks for libraries. + +# On Solaris/illumos, socket functions live in libsocket and gethostbyname in libnsl +AC_SEARCH_LIBS([socket], [socket]) +AC_SEARCH_LIBS([gethostbyname], [nsl]) + PKG_CHECK_MODULES([nss],[nss]) PKG_CHECK_MODULES([corosync_common], [libcorosync_common]) PKG_CHECK_MODULES([cmap], [libcmap]) diff --git a/qdevices/tlv.c b/qdevices/tlv.c index c741359..ba3973e 100644 --- a/qdevices/tlv.c +++ b/qdevices/tlv.c @@ -43,7 +43,7 @@ /* * 64-bit variant of ntoh is not exactly standard... */ -#if defined(__linux__) +#if defined(__linux__) || defined(__sun) #include #elif defined(__FreeBSD__) || defined(__NetBSD__) #include diff --git a/qdevices/unix-socket.c b/qdevices/unix-socket.c index 611101c..31cd426 100644 --- a/qdevices/unix-socket.c +++ b/qdevices/unix-socket.c @@ -44,6 +44,11 @@ #include "unix-socket.h" #include "utils.h" +/* On Solaris/illumos, GCC predefines "sun" as a numeric macro for platform + * detection, which conflicts with the local variable name "sun" used for + * struct sockaddr_un. */ +#undef sun + int unix_socket_server_create(const char *path, int set_socket_umask, mode_t socket_umask, gid_t socket_gid, int non_blocking, int backlog) diff --git a/qdevices/utils.c b/qdevices/utils.c index 5cbc7ee..fdf893f 100644 --- a/qdevices/utils.c +++ b/qdevices/utils.c @@ -32,6 +32,10 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include