From a3732bb6b798b7e4979938729f9047ebf6191027 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sat, 26 Feb 2022 17:37:09 +0000 Subject: [PATCH] portable: support NetBSD This adds support for NetBSD, using the following external dependencies: libuuid ncursesw There is no CI (yet) as enabling that on Cirrus-CI requires some work, so for now, these builds will be run manually before releases. The test suite will also need tweaking to be fully supported but the key tests are supported for now. --- compat/Makefile.am | 4 ++++ compat/bsd-poll.c | 4 ++++ compat/recallocarray.c | 2 ++ configure.ac | 12 ++++++++++++ 4 files changed, 22 insertions(+) diff --git a/compat/Makefile.am b/compat/Makefile.am index ce2d4cc8..4ba02d32 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -34,6 +34,10 @@ if HOST_DARWIN libopenbsd_compat_a_SOURCES += uuid.c bsd-poll.c bsd-poll.h endif +if HOST_NETBSD +libopenbsd_compat_a_SOURCES += bsd-poll.c bsd-poll.h +endif + if HOST_LINUX libopenbsd_compat_a_SOURCES += uuid.c endif diff --git a/compat/bsd-poll.c b/compat/bsd-poll.c index 62762869..f8fad91e 100644 --- a/compat/bsd-poll.c +++ b/compat/bsd-poll.c @@ -27,6 +27,10 @@ #define MAX(_a,_b) ((_a) > (_b) ? (_a) : (_b)) #endif +#ifndef howmany +#define howmany(x,y) (((x)+((y)-1))/(y)) +#endif + /* * A minimal implementation of ppoll(2), built on top of pselect(2). * diff --git a/compat/recallocarray.c b/compat/recallocarray.c index 02490499..be4faec4 100644 --- a/compat/recallocarray.c +++ b/compat/recallocarray.c @@ -75,6 +75,8 @@ recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size) #ifdef __APPLE__ memset_s(ptr, oldsize, 0, oldsize); +#elif defined(__NetBSD__) + explicit_memset(ptr, oldsize, 0); #else explicit_bzero(ptr, oldsize); #endif diff --git a/configure.ac b/configure.ac index c1dadc78..9768907e 100644 --- a/configure.ac +++ b/configure.ac @@ -161,6 +161,10 @@ case "$host_os" in AC_MSG_RESULT(darwin) PLATFORM=darwin ;; + *netbsd*) + AC_MSG_RESULT(netbsd) + PLATFORM=netbsd + ;; *) AC_MSG_RESULT(unknown) PLATFORM=unknown @@ -170,6 +174,7 @@ AC_SUBST(PLATFORM) AM_CONDITIONAL([HOST_FREEBSD], [test "$PLATFORM" = "freebsd"]) AM_CONDITIONAL([HOST_LINUX], [test "$PLATFORM" = "linux"]) AM_CONDITIONAL([HOST_DARWIN], [test "$PLATFORM" = "darwin"]) +AM_CONDITIONAL([HOST_NETBSD], [test "$PLATFORM" = "netbsd"]) # Landlock detection. AC_MSG_CHECKING([for landlock]) @@ -383,6 +388,13 @@ if test "$PLATFORM" = "linux"; then found_panel=yes, AC_MSG_ERROR("*** couldn't find -lpanel from ncurses") ) +elif test "$PLATFORM" = "netbsd"; then + PKG_CHECK_MODULES( + LIBPANELW, + gnupanelw, + found_panel=yes, + AC_MSG_ERROR("*** couldn't find -lgnupanelw from ncurses") + ) else AC_CHECK_LIB(panelw, update_panels,, AC_MSG_ERROR([ "*** panelw not found for ncurses. ***"]) -- 2.11.4.GIT