From dba5bc614ead4e0bc9433a7af9ee333f334ab51e Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 19 Jan 2024 06:00:22 +0000 Subject: [PATCH] Make orch(1) buildable on NetBSD as well It uses GCC 7.5.0 by default, which complains enough about conversion issues that aren't an issue in practice. Otherwise, much the same as OpenBSD. Signed-off-by: Kyle Evans --- Makefile | 3 +++ README.md | 1 + orch.c | 6 +++++- orch.h | 3 ++- orch_compat.c | 3 ++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index aa7192b..6edf8cd 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ SRCS= orch.c \ .if defined(.MAKE.OS) && ${.MAKE.OS} == "Linux" CFLAGS+= -D_GNU_SOURCE .endif +.if defined(.MAKE.OS) && ${.MAKE.OS} == "NetBSD" +CWARNFLAGS+= -Wno-conversion -Wno-maybe-uninitialized +.endif SRCS+= orch_compat.c diff --git a/README.md b/README.md index 14ad194..daf0373 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,6 @@ requests and Issues are open on GitHub. orch(1) strives to be portable. Currently supported platforms: - FreeBSD - OpenBSD + - NetBSD - macOS - Linux (tested on Ubuntu only) diff --git a/orch.c b/orch.c index 062f214..70cb586 100644 --- a/orch.c +++ b/orch.c @@ -22,6 +22,10 @@ #define POSIX_OPENPT_FLAGS (O_RDWR | O_NOCTTY | O_CLOEXEC) #endif +#ifndef __dead2 +#define __dead2 __attribute__((noreturn)) +#endif + extern char **environ; static void orch_exec(int argc, const char *argv[], int cmdsock); @@ -31,7 +35,7 @@ static void orch_usept(pid_t sess, int termctl); static void orch_wait(int cmdsock); static void orch_release(int cmdsock); -static void +static void __dead2 usage(const char *name, int error) { FILE *f; diff --git a/orch.h b/orch.h index 5bb199d..b5c6d6c 100644 --- a/orch.h +++ b/orch.h @@ -51,6 +51,7 @@ int luaopen_orch(lua_State *); size_t strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize); size_t strlcat(char * __restrict dst, const char * __restrict src, size_t dsize); #endif -#if defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) +#if defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || \ + defined(__NetBSD__) int tcsetsid(int tty, int sess); #endif diff --git a/orch_compat.c b/orch_compat.c index 09efe65..53508bc 100644 --- a/orch_compat.c +++ b/orch_compat.c @@ -97,7 +97,8 @@ strlcat(char * __restrict dst, const char * __restrict src, size_t dsize) return(dlen + (src - osrc)); /* count does not include NUL */ } #endif /* __linux__ */ -#if defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) +#if defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || \ + defined(__NetBSD__) /* Not associated with the above... incredibly simple. */ int