From be4aced4c50e3125f95b090c3b6d78f9ccb217a1 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 11 Feb 2024 23:55:40 +0100 Subject: [PATCH] build: Make almost all exposed interfaces use the new ABI selection Explicitly select what to include as part of the target ABI, instead of letting autoconfiguration potentially break ABI if the system grows functionality provided by the library. Make almost all the library selectable per target. Do not install manual pages for interfaces not included in the library. Control inclusion of symbols in map file via pre-processor macros, and move the comments describing the ABI selection to configure.ac. For now the header files are included as is and filtered through pre-processor conditionals. Eventually they might get switched to be autogenerated at build time. --- configure.ac | 168 +++++++++++++++++++++++++++++++- include/Makefile.am | 51 ++++++++-- man/Makefile.am | 228 ++++++++++++++++++++++++++++++++++---------- src/Makefile.am | 196 ++++++++++++++++++++++++++++++------- src/libbsd.map.in | 122 +++++++++++++++++++++--- test/Makefile.am | 88 ++++++++++++++--- 6 files changed, 732 insertions(+), 121 deletions(-) diff --git a/configure.ac b/configure.ac index ef79d0a..a761d9c 100644 --- a/configure.ac +++ b/configure.ac @@ -41,85 +41,212 @@ LIBBSD_LINKER_VERSION_SCRIPT is_windows=no +abi_accmode=unknown abi_arc4random=unknown +abi_arc4random_stir=unknown abi_bsd_getopt=unknown +abi_closefrom=unknown abi_err=unknown abi_errc=unknown +abi_expand_number=unknown +abi_explicit_bzero=unknown +abi_fgetln=unknown +abi_flopen=unknown +abi_fmtcheck=unknown abi_fpurge=unknown +abi_freezero=unknown abi_funopen=unknown +abi_getbsize=unknown +abi_getpeereid=unknown +abi_humanize_number=unknown +abi_id_from_name=unknown +abi_inet_net_pton=unknown abi_md5=unknown abi_name_from_id=unknown abi_nlist=unknown +abi_pidfile=unknown +abi_proctitle=unknown abi_progname=unknown +abi_readpassphrase=unknown +abi_reallocarray=unknown +abi_reallocf=unknown +abi_recallocarray=unknown +abi_stringlist=unknown +abi_sort=unknown abi_strl=unknown abi_strmode=unknown +abi_strnstr=unknown +abi_strtonum=unknown +abi_strtox=unknown +abi_timeconv=unknown +abi_vis=unknown abi_wcsl=unknown AS_CASE([$host_os], [*-gnu*], [ - # DROP: On glibc >= 2.36, parts the arc4random() API got added. + abi_accmode=yes + # DROP: On glibc >= 2.36. #abi_arc4random=no abi_arc4random=yes + abi_arc4random_stir=yes abi_bsd_getopt=yes + # DROP: On glibc >= 2.34. + #abi_closefrom=no + abi_closefrom=yes abi_err=no abi_errc=yes + abi_expand_number=yes + # DROP: On glibc >= 2.25. + #abi_explicit_bzero=no + abi_explicit_bzero=yes + abi_fgetln=yes + abi_flopen=yes + abi_fmtcheck=yes abi_fpurge=yes + abi_freezero=yes abi_funopen=yes + abi_getbsize=yes + abi_getpeereid=yes + abi_humanize_number=yes + abi_id_from_name=yes + # DROP: On glibc. + #abi_inet_net_pton=no + abi_inet_net_pton=yes # DROP: On libmd. #abi_md5=no abi_md5=yes abi_name_from_id=yes abi_nlist=yes + abi_pidfile=yes + abi_proctitle=yes abi_progname=yes + abi_readpassphrase=yes + # DROP: On glibc >= 2.26. + #abi_reallocarray=no + abi_reallocarray=yes + abi_reallocf=yes + abi_recallocarray=yes + abi_stringlist=yes + abi_sort=yes # DROP: On glibc >= 2.38. #abi_strl=no abi_strl=yes abi_strmode=yes + abi_strnstr=yes + abi_strtonum=yes + abi_strtox=yes + abi_timeconv=yes + # DROP: On libmd. + abi_transparent_libmd=yes + abi_vis=yes abi_wcsl=yes ], [*-musl*], [ + abi_accmode=yes abi_arc4random=yes + abi_arc4random_stir=yes # DROP: On musl >= 0.9.7, optreset got implemented. #abi_bsd_getopt=no abi_bsd_getopt=yes + abi_closefrom=yes abi_err=no abi_errc=yes + abi_expand_number=yes + # DROP: On musl >= 1.1.20. + #abi_explicit_bzero=no + abi_explicit_bzero=yes + # DROP: On musl >= 0.9.4. + #abi_fgetln=no + abi_fgetln=yes + abi_flopen=yes + abi_fmtcheck=yes abi_fpurge=yes + abi_freezero=yes # On musl >= 1.1.19, fopencookie() got implemented, and because we were # checking for its presence to decide whether to build funopen(), it got # included in builds even when previously it had not been included, which # is partially an ABI issue, but given that disabling it now would be # worse, we'll ignore this as this is only a problem with downgrades. And # enable it explicitly + #abi_funopen=no abi_funopen=yes + abi_getbsize=yes + abi_getpeereid=yes + abi_humanize_number=yes + abi_id_from_name=yes + abi_inet_net_pton=yes # DROP: On libmd. #abi_md5=no abi_md5=yes abi_name_from_id=yes abi_nlist=yes + abi_pidfile=yes + abi_proctitle=yes abi_progname=yes + abi_readpassphrase=yes + # DROP: On musl >= 1.2.2. + #abi_reallocarray=no + abi_reallocarray=yes + abi_reallocf=ues + abi_recallocarray=yes + abi_stringlist=yes + abi_sort=yes # DROP: On musl >= 0.5.0, strlcpy() and strlcat() were already implemented. #abi_strl=no abi_strl=yes abi_strmode=yes + abi_strnstr=yes + abi_strtonum=yes + abi_strtox=yes + abi_timeconv=yes + # DROP: On libmd. + abi_transparent_libmd=yes + abi_vis=yes abi_wcsl=yes ], [darwin*], [ - # On macOS these are provided by the system, and libbsd has never built - # there, so we can avoid providing these with no ABI breakage. + abi_accmode=no abi_arc4random=no + abi_arc4random_stir=no abi_bsd_getopt=no + abi_closefrom=yes abi_err=no abi_errc=no + abi_expand_number=yes + abi_explicit_bzero=yes + abi_fgetln=no + abi_flopen=yes + abi_fmtcheck=no abi_fpurge=no + abi_freezero=yes abi_funopen=no + abi_getbsize=yes + abi_getpeereid=no + abi_humanize_number=yes + abi_id_from_name=yes + abi_inet_net_pton=no + # On libmd. abi_md5=no abi_name_from_id=no abi_nlist=no + abi_pidfile=yes + abi_proctitle=yes abi_progname=no + abi_readpassphrase=no + abi_reallocarray=yes + abi_reallocf=no + abi_recallocarray=yes + abi_stringlist=no + abi_sort=no abi_strl=no abi_strmode=no + abi_strnstr=no + abi_strtonum=no + abi_strtox=yes + abi_timeconv=no + # On libmd. abi_transparent_libmd=no + abi_vis=no abi_wcsl=no ], [mingw*], [ @@ -127,6 +254,13 @@ AS_CASE([$host_os], ], ) +# Handle artificial ABI selections that are combinations of others. +AS_IF([test "$abi_name_from_id" = "yes" || test "$abi_id_from_name" = "yes"], [ + abi_pwcache=yes +], [ + abi_pwcache=no +]) + AM_CONDITIONAL([OS_WINDOWS], [test "x$is_windows" = "xyes"]) # Checks for programs. @@ -308,19 +442,47 @@ AC_CHECK_FUNCS([\ AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"]) # ABI selection +LIBBSD_SELECT_ABI([accmode], [setmode()/getmode()]) LIBBSD_SELECT_ABI([arc4random], [arc4random() API]) +LIBBSD_SELECT_ABI([arc4random_stir], [arc4random_stir()/arc4random_addrandom()]) LIBBSD_SELECT_ABI([bsd_getopt], [BSD getopt()]) +LIBBSD_SELECT_ABI([closefrom], [closefrom()]) LIBBSD_SELECT_ABI([err], [err API]) LIBBSD_SELECT_ABI([errc], [errc API]) +LIBBSD_SELECT_ABI([expand_number], [expand_number()]) +LIBBSD_SELECT_ABI([explicit_bzero], [explicit_bzero()]) +LIBBSD_SELECT_ABI([fgetln], [fgetln/fgetwln()]) +LIBBSD_SELECT_ABI([flopen], [flopen()/flopenat()]) +LIBBSD_SELECT_ABI([fmtcheck], [fmtcheck()]) LIBBSD_SELECT_ABI([fpurge], [fpurge()]) +LIBBSD_SELECT_ABI([freezero], [freezero()]) LIBBSD_SELECT_ABI([funopen], [funopen()]) +LIBBSD_SELECT_ABI([getbsize], [getbsize()]) +LIBBSD_SELECT_ABI([getpeereid], [getpeereid()]) +LIBBSD_SELECT_ABI([humanize_number], [humanize_number()/dehumanize_number()]) +LIBBSD_SELECT_ABI([id_from_name], [uid_from_user()/gid_from_user()]) +LIBBSD_SELECT_ABI([inet_net_pton], [inet_net_pton()]) LIBBSD_SELECT_ABI([md5], [MD5 digest functions]) LIBBSD_SELECT_ABI([name_from_id], [user_from_uid()/group_from_gid()]) LIBBSD_SELECT_ABI([nlist], [nlist()]) +LIBBSD_SELECT_ABI([pidfile], [pidfile API]) +LIBBSD_SELECT_ABI([proctitle], [setproctitle() API]) LIBBSD_SELECT_ABI([progname], [setprogname()/getprogname()]) +LIBBSD_SELECT_ABI([pwcache], [password cache API]) +LIBBSD_SELECT_ABI([readpassphrase], [readpassphrase()]) +LIBBSD_SELECT_ABI([reallocarray], [reallocarray()]) +LIBBSD_SELECT_ABI([reallocf], [reallocf()]) +LIBBSD_SELECT_ABI([recallocarray], [recallocarray()]) +LIBBSD_SELECT_ABI([stringlist], [stringlist sl_*() API]) +LIBBSD_SELECT_ABI([sort], [BSD sort functions]) LIBBSD_SELECT_ABI([strl], [strlcpy()/strlcat()]) LIBBSD_SELECT_ABI([strmode], [strmode()]) +LIBBSD_SELECT_ABI([strnstr], [strnstr()]) +LIBBSD_SELECT_ABI([strtonum], [strtonum()]) +LIBBSD_SELECT_ABI([strtox], [strtoi()/strtou()]) +LIBBSD_SELECT_ABI([timeconv], [timeconf.h API]) LIBBSD_SELECT_ABI([transparent_libmd], [transparent libmd support]) +LIBBSD_SELECT_ABI([vis], [vis API]) LIBBSD_SELECT_ABI([wcsl], [wcslcpy()/wcslcat()]) AS_IF([test "x$abi_funopen" = "xno" && \ diff --git a/include/Makefile.am b/include/Makefile.am index 46925b6..9a75b97 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -12,23 +12,27 @@ nobase_include_HEADERS = \ bsd/netinet/ip_icmp.h \ bsd/bitstring.h \ bsd/bsd.h \ - bsd/err.h \ - bsd/getopt.h \ - bsd/grp.h \ bsd/inttypes.h \ bsd/libutil.h \ - bsd/pwd.h \ - bsd/readpassphrase.h \ bsd/stdio.h \ bsd/stdlib.h \ bsd/string.h \ - bsd/stringlist.h \ - bsd/timeconv.h \ bsd/unistd.h \ - bsd/vis.h \ bsd/wchar.h \ # EOL +if ABI_ERR +nobase_include_HEADERS += \ + bsd/err.h \ + # EOL +endif + +if ABI_BSD_GETOPT +nobase_include_HEADERS += \ + bsd/getopt.h \ + # EOL +endif + if ABI_MD5 nobase_include_HEADERS += \ bsd/md5.h \ @@ -40,3 +44,34 @@ nobase_include_HEADERS += \ bsd/nlist.h \ # EOL endif + +if ABI_READPASSPHRASE +nobase_include_HEADERS += \ + bsd/readpassphrase.h \ + # EOL +endif + +if ABI_PWCACHE +nobase_include_HEADERS += \ + bsd/grp.h \ + bsd/pwd.h \ + # EOL +endif + +if ABI_STRINGLIST +nobase_include_HEADERS += \ + bsd/stringlist.h \ + # EOL +endif + +if ABI_TIMECONV +nobase_include_HEADERS += \ + bsd/timeconv.h \ + # EOL +endif + +if ABI_VIS +nobase_include_HEADERS += \ + bsd/vis.h \ + # EOL +endif diff --git a/man/Makefile.am b/man/Makefile.am index ed55988..27aae67 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -143,11 +143,6 @@ dist_man_MANS = \ TAILQ_SWAP.3bsd \ TIMESPEC_TO_TIMEVAL.3bsd \ TIMEVAL_TO_TIMESPEC.3bsd \ - arc4random.3bsd \ - arc4random_addrandom.3bsd \ - arc4random_buf.3bsd \ - arc4random_stir.3bsd \ - arc4random_uniform.3bsd \ be16dec.3bsd \ be16enc.3bsd \ be32dec.3bsd \ @@ -166,21 +161,6 @@ dist_man_MANS = \ bitstr_size.3bsd \ bitstring.3bsd \ byteorder.3bsd \ - closefrom.3bsd \ - dehumanize_number.3bsd \ - expand_number.3bsd \ - explicit_bzero.3bsd \ - fgetln.3bsd \ - fgetwln.3bsd \ - flopen.3bsd \ - fmtcheck.3bsd \ - fparseln.3bsd \ - freezero.3bsd \ - getbsize.3bsd \ - getmode.3bsd \ - getpeereid.3bsd \ - heapsort.3bsd \ - humanize_number.3bsd \ le16dec.3bsd \ le16enc.3bsd \ le32dec.3bsd \ @@ -188,38 +168,7 @@ dist_man_MANS = \ le64dec.3bsd \ le64enc.3bsd \ libbsd.7 \ - mergesort.3bsd \ - pidfile.3bsd \ - pidfile_close.3bsd \ - pidfile_open.3bsd \ - pidfile_remove.3bsd \ - pidfile_write.3bsd \ - pwcache.3bsd \ queue.3bsd \ - radixsort.3bsd \ - readpassphrase.3bsd \ - reallocarray.3bsd \ - reallocf.3bsd \ - recallocarray.3bsd \ - setmode.3bsd \ - setproctitle.3bsd \ - setproctitle_init.3bsd \ - sl_add.3bsd \ - sl_delete.3bsd \ - sl_find.3bsd \ - sl_free.3bsd \ - sl_init.3bsd \ - sradixsort.3bsd \ - stringlist.3bsd \ - strnstr.3bsd \ - strnunvis.3bsd \ - strnvis.3bsd \ - strtoi.3bsd \ - strtonum.3bsd \ - strtou.3bsd \ - strunvis.3bsd \ - strvis.3bsd \ - strvisx.3bsd \ timeradd.3bsd \ timerclear.3bsd \ timercmp.3bsd \ @@ -233,28 +182,106 @@ dist_man_MANS = \ timespecsub.3bsd \ timeval.3bsd \ tree.3bsd \ - unvis.3bsd \ - vis.3bsd \ # EOL +if ABI_ACCMODE +dist_man_MANS += \ + getmode.3bsd \ + setmode.3bsd \ + # EOL +endif + +if ABI_ARC4RANDOM +dist_man_MANS += \ + arc4random.3bsd \ + arc4random_addrandom.3bsd \ + arc4random_buf.3bsd \ + arc4random_stir.3bsd \ + arc4random_uniform.3bsd \ + # EOL +endif + +if ABI_CLOSEFROM +dist_man_MANS += \ + closefrom.3bsd \ + # EOL +endif + if ABI_ERRC dist_man_MANS += \ errc.3bsd \ # EOL endif +if ABI_EXPAND_NUMBER +dist_man_MANS += \ + expand_number.3bsd \ + # EOL +endif + +if ABI_EXPLICIT_BZERO +dist_man_MANS += \ + explicit_bzero.3bsd \ + # EOL +endif + +if ABI_FGETLN +dist_man_MANS += \ + fgetln.3bsd \ + fgetwln.3bsd \ + fparseln.3bsd \ + # EOL +endif + +if ABI_FLOPEN +dist_man_MANS += \ + flopen.3bsd \ + # EOL +endif + +if ABI_FMTCHECK +dist_man_MANS += \ + fmtcheck.3bsd \ + # EOL +endif + if ABI_FPURGE dist_man_MANS += \ fpurge.3bsd \ # EOL endif +if ABI_FREEZERO +dist_man_MANS += \ + freezero.3bsd \ + # EOL +endif + if ABI_FUNOPEN dist_man_MANS += \ funopen.3bsd \ # EOL endif +if ABI_GETBSIZE +dist_man_MANS += \ + getbsize.3bsd \ + # EOL +endif + +if ABI_GETPEEREID +dist_man_MANS += \ + getpeereid.3bsd \ + # EOL +endif + +if ABI_HUMANIZE_NUMBER +dist_man_MANS += \ + dehumanize_number.3bsd \ + humanize_number.3bsd \ + # EOL +endif + if ABI_MD5 dist_man_MANS += \ md5.3bsd \ @@ -267,6 +294,23 @@ dist_man_MANS += \ # EOL endif +if ABI_PIDFILE +dist_man_MANS += \ + pidfile.3bsd \ + pidfile_close.3bsd \ + pidfile_open.3bsd \ + pidfile_remove.3bsd \ + pidfile_write.3bsd \ + # EOL +endif + +if ABI_PROCTITLE +dist_man_MANS += \ + setproctitle.3bsd \ + setproctitle_init.3bsd \ + # EOL +endif + if ABI_PROGNAME dist_man_MANS += \ getprogname.3bsd \ @@ -274,7 +318,9 @@ dist_man_MANS += \ # EOL endif +if ABI_PWCACHE dist_man_MANS += \ + pwcache.3bsd \ gid_from_group.3bsd \ uid_from_user.3bsd \ # EOL @@ -285,6 +331,51 @@ dist_man_MANS += \ user_from_uid.3bsd \ # EOL endif +endif + +if ABI_READPASSPHRASE +dist_man_MANS += \ + readpassphrase.3bsd \ + # EOL +endif + +if ABI_REALLOCARRAY +dist_man_MANS += \ + reallocarray.3bsd \ + # EOL +endif + +if ABI_REALLOCF +dist_man_MANS += \ + reallocf.3bsd \ + # EOL +endif + +if ABI_RECALLOCARRAY +dist_man_MANS += \ + recallocarray.3bsd \ + # EOL +endif + +if ABI_SORT +dist_man_MANS += \ + heapsort.3bsd \ + mergesort.3bsd \ + radixsort.3bsd \ + sradixsort.3bsd \ + # EOL +endif + +if ABI_STRINGLIST +dist_man_MANS += \ + sl_add.3bsd \ + sl_delete.3bsd \ + sl_find.3bsd \ + sl_free.3bsd \ + sl_init.3bsd \ + stringlist.3bsd \ + # EOL +endif if ABI_STRL dist_man_MANS += \ @@ -299,6 +390,37 @@ dist_man_MANS += \ # EOL endif +if ABI_STRNSTR +dist_man_MANS += \ + strnstr.3bsd \ + # EOL +endif + +if ABI_STRTOX +dist_man_MANS += \ + strtoi.3bsd \ + strtou.3bsd \ + # EOL +endif + +if ABI_STRTONUM +dist_man_MANS += \ + strtonum.3bsd \ + # EOL +endif + +if ABI_VIS +dist_man_MANS += \ + strnunvis.3bsd \ + strnvis.3bsd \ + strunvis.3bsd \ + strvis.3bsd \ + strvisx.3bsd \ + unvis.3bsd \ + vis.3bsd \ + # EOL +endif + if ABI_WCSL dist_man_MANS += \ wcslcat.3bsd \ diff --git a/src/Makefile.am b/src/Makefile.am index 21ed1c7..a85b705 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,43 +76,16 @@ EXTRA_libbsd_la_DEPENDENCIES += \ # EOL endif libbsd_la_SOURCES = \ - closefrom.c \ - dehumanize_number.c \ - expand_number.c \ - explicit_bzero.c \ - fgetln.c \ - fgetwln.c \ - flopen.c \ - fmtcheck.c \ - fparseln.c \ - freezero.c \ - getbsize.c \ - getpeereid.c \ - heapsort.c \ - humanize_number.c \ - inet_net_pton.c \ local-elf.h \ local-link.h \ - merge.c \ - pidfile.c \ - pwcache.c \ - radixsort.c \ - readpassphrase.c \ - reallocarray.c \ - reallocf.c \ - recallocarray.c \ - setmode.c \ - setproctitle.c \ - stringlist.c \ - strnstr.c \ - strtoi.c \ - strtonum.c \ - strtou.c \ - timeconv.c \ - unvis.c \ - vis.c \ # EOL +if ABI_ACCMODE +libbsd_la_SOURCES += \ + setmode.c \ + # EOL +endif + if ABI_ARC4RANDOM if !HAVE_GETENTROPY libbsd_la_SOURCES += \ @@ -136,6 +109,12 @@ libbsd_la_SOURCES += \ # EOL endif +if ABI_CLOSEFROM +libbsd_la_SOURCES += \ + closefrom.c \ + # EOL +endif + if ABI_ERR libbsd_la_SOURCES += \ err.c \ @@ -148,18 +127,81 @@ libbsd_la_SOURCES += \ # EOL endif +if ABI_EXPAND_NUMBER +libbsd_la_SOURCES += \ + expand_number.c \ + # EOL +endif + +if ABI_EXPLICIT_BZERO +libbsd_la_SOURCES += \ + explicit_bzero.c \ + # EOL +endif + +if ABI_FGETLN +libbsd_la_SOURCES += \ + fgetln.c \ + fgetwln.c \ + fparseln.c \ + # EOL +endif + +if ABI_FLOPEN +libbsd_la_SOURCES += \ + flopen.c \ + # EOL +endif + +if ABI_FMTCHECK +libbsd_la_SOURCES += \ + fmtcheck.c \ + # EOL +endif + if ABI_FPURGE libbsd_la_SOURCES += \ fpurge.c \ # EOL endif +if ABI_FREEZERO +libbsd_la_SOURCES += \ + freezero.c \ + # EOL +endif + if ABI_FUNOPEN libbsd_la_SOURCES += \ funopen.c \ # EOL endif +if ABI_GETBSIZE +libbsd_la_SOURCES += \ + getbsize.c \ + # EOL +endif + +if ABI_GETPEEREID +libbsd_la_SOURCES += \ + getpeereid.c \ + # EOL +endif + +if ABI_HUMANIZE_NUMBER +libbsd_la_SOURCES += \ + dehumanize_number.c \ + humanize_number.c \ + # EOL +endif + +if ABI_INET_NET_PTON +libbsd_la_SOURCES += \ + inet_net_pton.c \ + # EOL +endif + if ABI_MD5 libbsd_la_SOURCES += \ md5.c \ @@ -172,12 +214,68 @@ libbsd_la_SOURCES += \ # EOL endif +if ABI_PIDFILE +libbsd_la_SOURCES += \ + pidfile.c \ + # EOL +endif + +if ABI_PROCTITLE +libbsd_la_SOURCES += \ + setproctitle.c \ + # EOL +endif + if ABI_PROGNAME libbsd_la_SOURCES += \ progname.c \ # EOL endif +if ABI_PWCACHE +libbsd_la_SOURCES += \ + pwcache.c \ + # EOL +endif + +if ABI_READPASSPHRASE +libbsd_la_SOURCES += \ + readpassphrase.c \ + # EOL +endif + +if ABI_REALLOCARRAY +libbsd_la_SOURCES += \ + reallocarray.c \ + # EOL +endif + +if ABI_REALLOCF +libbsd_la_SOURCES += \ + reallocf.c \ + # EOL +endif + +if ABI_RECALLOCARRAY +libbsd_la_SOURCES += \ + recallocarray.c \ + # EOL +endif + +if ABI_SORT +libbsd_la_SOURCES += \ + heapsort.c \ + merge.c \ + radixsort.c \ + # EOL +endif + +if ABI_STRINGLIST +libbsd_la_SOURCES += \ + stringlist.c \ + # EOL +endif + if ABI_STRL libbsd_la_SOURCES += \ strlcat.c \ @@ -191,6 +289,38 @@ libbsd_la_SOURCES += \ # EOL endif +if ABI_STRNSTR +libbsd_la_SOURCES += \ + strnstr.c \ + # EOL +endif + +if ABI_STRTONUM +libbsd_la_SOURCES += \ + strtonum.c \ + # EOL +endif + +if ABI_STRTOX +libbsd_la_SOURCES += \ + strtoi.c \ + strtou.c \ + # EOL +endif + +if ABI_TIMECONV +libbsd_la_SOURCES += \ + timeconv.c \ + # EOL +endif + +if ABI_VIS +libbsd_la_SOURCES += \ + unvis.c \ + vis.c \ + # EOL +endif + if ABI_WCSL libbsd_la_SOURCES += \ wcslcat.c \ diff --git a/src/libbsd.map.in b/src/libbsd.map.in index 06550ea..81e431f 100644 --- a/src/libbsd.map.in +++ b/src/libbsd.map.in @@ -2,44 +2,71 @@ LIBBSD_0.0 { global: +#if LIBBSD_ABI_ARC4RANDOM arc4random; +#endif +#if LIBBSD_ABI_ARC4RANDOM_STIR arc4random_stir; arc4random_addrandom; +#endif +#if LIBBSD_ABI_BSD_GETOPT bsd_getopt; optreset; +#endif +#if LIBBSD_ABI_ERRC errc; warnc; verrc; vwarnc; +#endif +#if LIBBSD_ABI_FGETLN fgetln; +#endif + +#if LIBBSD_ABI_FMTCHECK fmtcheck; +#endif + +#if LIBBSD_ABI_SORT heapsort; +#endif + +#if LIBBSD_ABI_HUMANIZE_NUMBER humanize_number; +#endif - /* XXX: Already provided by glibc, remove. */ +#if LIBBSD_ABI_INET_NET_PTON inet_net_pton; +#endif +#if LIBBSD_ABI_PROGNAME getprogname; setprogname; +#endif +#if LIBBSD_ABI_STRL strlcpy; strlcat; +#endif +#if LIBBSD_ABI_ACCMODE setmode; getmode; +#endif +#if LIBBSD_ABI_VIS vis; strvis; strvisx; unvis; strunvis; strunvisx; +#endif - /* The following functions are provided via the system libc or libmd - * implementations. */ +#if LIBBSD_ABI_MD5 MD5Init; MD5Update; MD5Pad; @@ -49,89 +76,138 @@ LIBBSD_0.0 { MD5File; MD5FileChunk; MD5Data; +#endif local: *; }; LIBBSD_0.1 { +#if LIBBSD_ABI_STRMODE strmode; +#endif +#if LIBBSD_ABI_NLIST /* Private symbol, but libkvm uses it. */ __fdnlist; nlist; +#endif } LIBBSD_0.0; LIBBSD_0.2 { +#if LIBBSD_ABI_STRTONUM strtonum; +#endif +#if LIBBSD_ABI_VIS strnvis; strnunvis; +#endif +#if LIBBSD_ABI_HUMANIZE_NUMBER dehumanize_number; +#endif +#if LIBBSD_ABI_READPASSPHRASE readpassphrase; +#endif +#if LIBBSD_ABI_FLOPEN flopen; +#endif +#if LIBBSD_ABI_PIDFILE pidfile_open; pidfile_write; pidfile_close; pidfile_remove; +#endif +#if LIBBSD_ABI_ARC4RANDOM arc4random_buf; arc4random_uniform; +#endif } LIBBSD_0.1; LIBBSD_0.3 { +#if LIBBSD_ABI_REALLOCF reallocf; - getpeereid; +#endif +#if LIBBSD_ABI_GETPEEREID + getpeereid; +#endif + +#if LIBBSD_ABI_SORT mergesort; radixsort; sradixsort; +#endif +#if LIBBSD_ABI_FPURGE fpurge; +#endif } LIBBSD_0.2; LIBBSD_0.4 { +#if LIBBSD_ABI_CLOSEFROM closefrom; +#endif + +#if LIBBSD_ABI_EXPAND_NUMBER expand_number; +#endif } LIBBSD_0.3; LIBBSD_0.5 { +#if LIBBSD_ABI_FGETLN fgetwln; fparseln; +#endif +#if LIBBSD_ABI_PROCTITLE /* Introduced in 0.2 as a stub, implemented in 0.5. */ setproctitle; +#endif +#if LIBBSD_ABI_STRNSTR strnstr; +#endif +#if LIBBSD_ABI_WCSL wcslcat; wcslcpy; +#endif } LIBBSD_0.4; LIBBSD_0.6 { +#if LIBBSD_ABI_PROCTITLE /* Exported to cope with the constructor+dlopen+threads mess. */ setproctitle_init; +#endif } LIBBSD_0.5; LIBBSD_0.7 { +#if LIBBSD_ABI_GETBSIZE getbsize; +#endif - /* This symbol might not be present on some specific systems, such - * as musl based ones. It might need to be removed on SOVERSION bump, - * as it cannot be portabily implemented everywhere. */ +#if LIBBSD_ABI_FUNOPEN funopen; +#endif +#if LIBBSD_ABI_REALLOCARRAY reallocarray; +#endif +#if LIBBSD_ABI_STRINGLIST sl_init; sl_add; sl_free; sl_find; +#endif +#if LIBBSD_ABI_TIMECONV _time32_to_time; _time_to_time32; _time64_to_time; @@ -140,20 +216,30 @@ LIBBSD_0.7 { _long_to_time; _time_to_int; _int_to_time; +#endif } LIBBSD_0.6; LIBBSD_0.8 { +#if LIBBSD_ABI_EXPLICIT_BZERO explicit_bzero; +#endif } LIBBSD_0.7; LIBBSD_0.9 { +#if LIBBSD_ABI_FLOPEN flopenat; +#endif +#if LIBBSD_ABI_PIDFILE pidfile_fileno; +#endif +#if LIBBSD_ABI_STRTOX strtoi; strtou; +#endif +#if LIBBSD_ABI_VIS nvis; snvis; stravis; @@ -165,19 +251,21 @@ LIBBSD_0.9 { strsvis; strsvisx; svis; +#endif } LIBBSD_0.8; LIBBSD_0.9.1 { +#if LIBBSD_ABI_VIS /* The strnvis() and strnunvis() symbols changed prototype to match * the NetBSD implementation. Provided as versioned nodes in 0.9.1, and * exposed here explicitly so that we can redirect at compile-time. */ strnvis_netbsd; strnunvis_netbsd; +#endif } LIBBSD_0.9; LIBBSD_0.10.0 { - /* These BSD extensions are available on GNU systems, but not on other - * systems such as Windows or musl libc based ones. */ +#if LIBBSD_ABI_ERR vwarn; vwarnx; warn; @@ -186,16 +274,28 @@ LIBBSD_0.10.0 { verrx; err; errx; +#endif } LIBBSD_0.9.1; LIBBSD_0.11.0 { +#if LIBBSD_ABI_VIS strnvisx; +#endif +#if LIBBSD_ABI_RECALLOCARRAY recallocarray; - freezero; +#endif +#if LIBBSD_ABI_FREEZERO + freezero; +#endif + +#if LIBBSD_ABI_ID_FROM_NAME gid_from_group; - group_from_gid; uid_from_user; +#endif +#if LIBBSD_ABI_NAME_FROM_ID user_from_uid; + group_from_gid; +#endif } LIBBSD_0.10.0; diff --git a/test/Makefile.am b/test/Makefile.am index 64c6610..1c64abb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -33,22 +33,15 @@ check_SCRIPTS = \ check_PROGRAMS = \ overlay \ - bzero \ - closefrom \ endian \ - explicit_bzero \ - humanize \ - fgetln \ - fparseln \ - proctitle-init \ - pwcache \ - setmode \ - strnstr \ - strtonum \ - vis \ - vis-openbsd \ # EOL +if ABI_ACCMODE +check_PROGRAMS += \ + setmode \ + # EOL +endif + if ABI_ARC4RANDOM if HAVE_LIBTESTU01 check_PROGRAMS += arc4random @@ -57,6 +50,25 @@ arc4random_LDADD = $(LDADD) $(TESTU01_LIBS) endif endif +if ABI_CLOSEFROM +check_PROGRAMS += \ + closefrom \ + # EOL +endif + +if ABI_EXPLICIT_BZERO +check_PROGRAMS += \ + bzero \ + explicit_bzero \ + # EOL +endif + +if ABI_FGETLN +check_PROGRAMS += \ + fgetln \ + fparseln \ + # EOL + fgetln_SOURCES = \ test-stream.c \ test-stream.h \ @@ -70,6 +82,21 @@ fparseln_SOURCES = \ test-stream.h \ fparseln.c \ # EOL +endif + +if ABI_FPURGE +check_PROGRAMS += fpurge +endif + +if ABI_FUNOPEN +check_PROGRAMS += funopen +endif + +if ABI_HUMANIZE_NUMBER +check_PROGRAMS += \ + humanize \ + # EOL +endif if ABI_FPURGE check_PROGRAMS += fpurge @@ -92,6 +119,15 @@ if ABI_NLIST check_PROGRAMS += nlist endif +if ABI_PROGNAME +check_PROGRAMS += progname +endif + +if ABI_PROCTITLE +check_PROGRAMS += \ + proctitle-init \ + # EOL + proctitle_init_SOURCES = \ proctitle.c \ # EOL @@ -107,6 +143,13 @@ proctitle_LDFLAGS = \ $(top_builddir)/src/libbsd.la \ # EOL endif +endif + +if ABI_PWCACHE +check_PROGRAMS += \ + pwcache \ + # EOL +endif if ABI_PROGNAME check_PROGRAMS += progname @@ -120,4 +163,23 @@ if ABI_STRMODE check_PROGRAMS += strmode endif +if ABI_STRNSTR +check_PROGRAMS += \ + strnstr \ + # EOL +endif + +if ABI_STRTONUM +check_PROGRAMS += \ + strtonum \ + # EOL +endif + +if ABI_VIS +check_PROGRAMS += \ + vis \ + vis-openbsd \ + # EOL +endif + TESTS = $(check_SCRIPTS) $(check_PROGRAMS)