]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
build: Do not require funopen() to be ported
authorGuillem Jover <guillem@hadrons.org>
Wed, 23 Nov 2022 22:31:54 +0000 (23:31 +0100)
committerGuillem Jover <guillem@hadrons.org>
Thu, 24 Nov 2022 22:23:33 +0000 (23:23 +0100)
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>
configure.ac
man/funopen.3bsd
src/funopen.c
test/Makefile.am

index 842f5d67145fc8b49b7018f00005a5f95e4c49b9..95a4be3701ba8eeac953a9bf36708e8cdc4233a1 100644 (file)
@@ -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])
index 6ff61fd8fd125454891ca0a3080abd84167cc2d7..0f5ac06fae2255c5fc40ac9fa7398357a8e0db7c 100644 (file)
@@ -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 ,
index 1e6f43aee388f5973d724309a57c47b231536c4f..01b63b3a9790ca71ff1453cfebfbd37ce56d2c40 100644 (file)
@@ -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
index 64faaec509f92d97253031b1760132127a9b79ac..458a4e94da611dbe3cdbf2ece736c454739d6fc1 100644 (file)
@@ -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)