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>
This commit is contained in:
Guillem Jover 2022-11-23 23:31:54 +01:00
parent 00b538ffa3
commit e50896286c
4 changed files with 11 additions and 9 deletions

View File

@ -247,6 +247,7 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
getauxval getentropy getexecname getline \ getauxval getentropy getexecname getline \
pstat_getproc sysconf]) pstat_getproc sysconf])
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"]) 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([MD5_LIBS])
AC_SUBST([LIBBSD_LIBS]) AC_SUBST([LIBBSD_LIBS])

View File

@ -170,7 +170,11 @@ The
.Fn funopen .Fn funopen
function function
may not be portable to systems other than 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 .Pp
On On
.Fx , .Fx ,

View File

@ -137,12 +137,6 @@ funopen(const void *cookie,
return fopencookie(cookiewrap, mode, funcswrap); 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 #else
#error "Function funopen() needs to be ported or disabled." #warning "Function funopen() is not provided on this platform."
#endif #endif

View File

@ -39,7 +39,6 @@ check_PROGRAMS = \
explicit_bzero \ explicit_bzero \
humanize \ humanize \
fgetln \ fgetln \
funopen \
fparseln \ fparseln \
fpurge \ fpurge \
md5 \ md5 \
@ -56,6 +55,10 @@ check_PROGRAMS = \
vis-openbsd \ vis-openbsd \
# EOL # EOL
if HAVE_FOPENCOOKIE
check_PROGRAMS += funopen
endif
if HAVE_LIBTESTU01 if HAVE_LIBTESTU01
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS) arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)