build: Do not require funopen() to be ported This function cannot be easily and (more importantly) correctly ported without cooperation from the libc stdio layer. We already document that users should be prepared to have the function not available on some platforms and that they should ideally switch their code to other more portable and better interfaces. Instead of making the build fail, and requiring porters to add exceptions for something that most probably cannot be ported correctly anyway, simply print a warning and let it build. This will not be a regression because on those systems libbsd would have never been built before. Prompted-by: Jens Finkhaeuser <jens@finkhaeuser.de>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/configure.ac b/configure.ac
index 842f5d6..95a4be3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,6 +247,7 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
getauxval getentropy getexecname getline \
pstat_getproc sysconf])
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
+AM_CONDITIONAL([HAVE_FOPENCOOKIE], [test "x$ac_cv_func_fopencookie" = "xyes"])
AC_SUBST([MD5_LIBS])
AC_SUBST([LIBBSD_LIBS])
diff --git a/man/funopen.3bsd b/man/funopen.3bsd
index 6ff61fd..0f5ac06 100644
--- a/man/funopen.3bsd
+++ b/man/funopen.3bsd
@@ -170,7 +170,11 @@ The
.Fn funopen
function
may not be portable to systems other than
-.Bx .
+.Bx
+and glibc-based (as the libbsd implementation is only provided when the
+system has
+.Fn fopencookie
+available).
.Pp
On
.Fx ,
diff --git a/src/funopen.c b/src/funopen.c
index 1e6f43a..01b63b3 100644
--- a/src/funopen.c
+++ b/src/funopen.c
@@ -137,12 +137,6 @@ funopen(const void *cookie,
return fopencookie(cookiewrap, mode, funcswrap);
}
-#elif defined(__MUSL__)
-/*
- * This is unimplementable on musl based systems, and upstream has stated
- * they will not add the needed support to implement it. Just ignore this
- * interface there, as it has never been provided anyway.
- */
#else
-#error "Function funopen() needs to be ported or disabled."
+#warning "Function funopen() is not provided on this platform."
#endif
diff --git a/test/Makefile.am b/test/Makefile.am
index 64faaec..458a4e9 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -39,7 +39,6 @@ check_PROGRAMS = \
explicit_bzero \
humanize \
fgetln \
- funopen \
fparseln \
fpurge \
md5 \
@@ -56,6 +55,10 @@ check_PROGRAMS = \
vis-openbsd \
# EOL
+if HAVE_FOPENCOOKIE
+check_PROGRAMS += funopen
+endif
+
if HAVE_LIBTESTU01
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)