mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-20 22:31:34 +02:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
644062da40 | ||
![]() |
32d18dcf47 | ||
![]() |
605614d642 | ||
![]() |
ec7f5ee984 | ||
![]() |
5392f0c1a4 | ||
![]() |
be4aced4c5 | ||
![]() |
27503a1066 | ||
![]() |
99739877be | ||
![]() |
0bdbc0787e | ||
![]() |
de124dcafa | ||
![]() |
1d28729514 | ||
![]() |
a81d0b7113 | ||
![]() |
c8e5338a7c | ||
![]() |
b6d6da4cd4 | ||
![]() |
f8cb9d8b28 | ||
![]() |
154624ab45 | ||
![]() |
9fab225f26 | ||
![]() |
461f10ac57 | ||
![]() |
f050160976 | ||
![]() |
19e06407eb | ||
![]() |
10920c3084 | ||
![]() |
97b0fe84b8 | ||
![]() |
e87ae3be19 | ||
![]() |
9275d134e5 | ||
![]() |
304a1f831c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ ChangeLog
|
|||||||
*.gcda
|
*.gcda
|
||||||
*.gcno
|
*.gcno
|
||||||
*.sym
|
*.sym
|
||||||
|
*.map
|
||||||
.dirstamp
|
.dirstamp
|
||||||
.deps/
|
.deps/
|
||||||
.libs/
|
.libs/
|
||||||
|
2
COPYING
2
COPYING
@@ -3,7 +3,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|||||||
Files:
|
Files:
|
||||||
*
|
*
|
||||||
Copyright:
|
Copyright:
|
||||||
Copyright © 2004-2006, 2008-2022 Guillem Jover <guillem@hadrons.org>
|
Copyright © 2004-2024 Guillem Jover <guillem@hadrons.org>
|
||||||
License: BSD-3-clause
|
License: BSD-3-clause
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
|
501
configure.ac
501
configure.ac
@@ -16,12 +16,12 @@ AM_INIT_AUTOMAKE(
|
|||||||
)
|
)
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
LIBBSD_ABI_MAJOR=0
|
SOVERSION_MAJOR=0
|
||||||
LIBBSD_ABI_MINOR=11
|
SOVERSION_MINOR=12
|
||||||
LIBBSD_ABI_PATCH=8
|
SOVERSION_PATCH=0
|
||||||
|
|
||||||
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
SOVERSION="$SOVERSION_MAJOR:$SOVERSION_MINOR:$SOVERSION_PATCH"
|
||||||
AC_SUBST([LIBBSD_ABI])
|
AC_SUBST([SOVERSION])
|
||||||
|
|
||||||
# Check and store if we got user supplied variables
|
# Check and store if we got user supplied variables
|
||||||
user_CFLAGS=${CFLAGS-unset}
|
user_CFLAGS=${CFLAGS-unset}
|
||||||
@@ -29,17 +29,335 @@ user_CFLAGS=${CFLAGS-unset}
|
|||||||
# Checks for operating system services and capabilities.
|
# Checks for operating system services and capabilities.
|
||||||
AC_USE_SYSTEM_EXTENSIONS
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
|
LIBBSD_SYS_TIME64
|
||||||
|
|
||||||
AM_PROG_AR
|
AM_PROG_AR
|
||||||
LT_INIT
|
LT_INIT
|
||||||
LIBBSD_LINKER_VERSION_SCRIPT
|
LIBBSD_LINKER_VERSION_SCRIPT
|
||||||
|
|
||||||
|
## Select library ABI to expose.
|
||||||
|
#
|
||||||
|
# The systems have DROP comments for interfaces that could be dropped on
|
||||||
|
# the next SOVERSION bump.
|
||||||
|
|
||||||
is_windows=no
|
is_windows=no
|
||||||
|
|
||||||
|
abi_accmode=unknown
|
||||||
|
abi_arc4random=unknown
|
||||||
|
abi_arc4random_stir=unknown
|
||||||
|
abi_asprintf=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],
|
AS_CASE([$host_os],
|
||||||
|
[*-gnu*], [
|
||||||
|
abi_accmode=yes
|
||||||
|
# DROP: On glibc >= 2.36.
|
||||||
|
#abi_arc4random=no
|
||||||
|
abi_arc4random=yes
|
||||||
|
abi_arc4random_stir=yes
|
||||||
|
abi_asprintf=no
|
||||||
|
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
|
||||||
|
abi_asprintf=no
|
||||||
|
# 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*], [
|
||||||
|
abi_accmode=no
|
||||||
|
abi_arc4random=no
|
||||||
|
abi_arc4random_stir=no
|
||||||
|
abi_asprintf=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
|
||||||
|
],
|
||||||
|
[solaris2*], [
|
||||||
|
abi_accmode=yes
|
||||||
|
abi_arc4random=no
|
||||||
|
abi_arc4random_stir=no
|
||||||
|
abi_asprintf=no
|
||||||
|
abi_bsd_getopt=yes
|
||||||
|
abi_closefrom=no
|
||||||
|
abi_err=no
|
||||||
|
abi_errc=yes
|
||||||
|
abi_expand_number=yes
|
||||||
|
abi_explicit_bzero=yes
|
||||||
|
abi_fgetln=yes
|
||||||
|
abi_flopen=yes
|
||||||
|
abi_fmtcheck=no
|
||||||
|
abi_fpurge=yes
|
||||||
|
abi_freezero=yes
|
||||||
|
abi_funopen=no
|
||||||
|
abi_getbsize=yes
|
||||||
|
abi_getpeereid=yes
|
||||||
|
abi_humanize_number=yes
|
||||||
|
abi_id_from_name=yes
|
||||||
|
abi_inet_net_pton=yes
|
||||||
|
# On libmd.
|
||||||
|
abi_md5=no
|
||||||
|
abi_name_from_id=yes
|
||||||
|
abi_nlist=no
|
||||||
|
abi_pidfile=yes
|
||||||
|
abi_proctitle=yes
|
||||||
|
abi_progname=no
|
||||||
|
abi_readpassphrase=yes
|
||||||
|
abi_reallocarray=yes
|
||||||
|
abi_reallocf=no
|
||||||
|
abi_recallocarray=yes
|
||||||
|
abi_stringlist=yes
|
||||||
|
abi_sort=yes
|
||||||
|
abi_strl=no
|
||||||
|
abi_strmode=yes
|
||||||
|
abi_strnstr=no
|
||||||
|
abi_strtonum=no
|
||||||
|
abi_strtox=yes
|
||||||
|
abi_timeconv=yes
|
||||||
|
# On libmd.
|
||||||
|
abi_transparent_libmd=no
|
||||||
|
abi_vis=yes
|
||||||
|
abi_wcsl=yes
|
||||||
|
],
|
||||||
|
[aix*], [
|
||||||
|
abi_accmode=yes
|
||||||
|
abi_arc4random=yes
|
||||||
|
abi_arc4random_stir=yes
|
||||||
|
abi_asprintf=yes
|
||||||
|
abi_bsd_getopt=yes
|
||||||
|
abi_closefrom=yes
|
||||||
|
abi_err=yes
|
||||||
|
abi_errc=yes
|
||||||
|
abi_expand_number=yes
|
||||||
|
abi_explicit_bzero=yes
|
||||||
|
abi_fgetln=yes
|
||||||
|
abi_flopen=yes
|
||||||
|
abi_fmtcheck=yes
|
||||||
|
abi_fpurge=no
|
||||||
|
abi_freezero=yes
|
||||||
|
abi_funopen=no
|
||||||
|
abi_getbsize=yes
|
||||||
|
abi_getpeereid=yes
|
||||||
|
abi_humanize_number=yes
|
||||||
|
abi_id_from_name=yes
|
||||||
|
abi_inet_net_pton=no
|
||||||
|
# On libmd.
|
||||||
|
abi_md5=no
|
||||||
|
abi_name_from_id=yes
|
||||||
|
abi_nlist=no
|
||||||
|
abi_pidfile=yes
|
||||||
|
abi_proctitle=yes
|
||||||
|
abi_progname=yes
|
||||||
|
abi_readpassphrase=yes
|
||||||
|
abi_reallocarray=yes
|
||||||
|
abi_reallocf=yes
|
||||||
|
abi_recallocarray=yes
|
||||||
|
abi_stringlist=yes
|
||||||
|
abi_sort=yes
|
||||||
|
abi_strl=yes
|
||||||
|
abi_strmode=yes
|
||||||
|
abi_strnstr=yes
|
||||||
|
abi_strtonum=yes
|
||||||
|
abi_strtox=yes
|
||||||
|
abi_timeconv=yes
|
||||||
|
# On libmd.
|
||||||
|
abi_transparent_libmd=no
|
||||||
|
abi_vis=yes
|
||||||
|
abi_wcsl=yes
|
||||||
|
],
|
||||||
[mingw*], [
|
[mingw*], [
|
||||||
is_windows=yes
|
is_windows=yes
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 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"])
|
AM_CONDITIONAL([OS_WINDOWS], [test "x$is_windows" = "xyes"])
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
@@ -110,21 +428,29 @@ AM_CONDITIONAL([HAVE_LIBTESTU01],
|
|||||||
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
||||||
|
|
||||||
saved_LIBS="$LIBS"
|
saved_LIBS="$LIBS"
|
||||||
|
AS_IF([test "$abi_md5" = "yes"], [
|
||||||
AC_SEARCH_LIBS([MD5Update], [md], [
|
AC_SEARCH_LIBS([MD5Update], [md], [
|
||||||
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
|
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
|
||||||
MD5_LIBS="$MD5_LIBS $ac_cv_search_MD5Update"
|
MD5_LIBS="$MD5_LIBS $ac_cv_search_MD5Update"
|
||||||
need_transparent_libmd=yes
|
abi_transparent_libmd=yes
|
||||||
])
|
])
|
||||||
], [
|
], [
|
||||||
AC_MSG_ERROR([cannot find required MD5 functions in libc or libmd])
|
AC_MSG_ERROR([cannot find required MD5 functions in libc or libmd])
|
||||||
])
|
])
|
||||||
|
])
|
||||||
|
AS_IF([test "$abi_arc4random" = "yes"], [
|
||||||
|
AC_CHECK_FUNCS([getentropy])
|
||||||
|
|
||||||
|
AS_IF([test "$ac_cv_func_getentropy" != "yes"], [
|
||||||
AC_SEARCH_LIBS([SHA512Update], [md], [
|
AC_SEARCH_LIBS([SHA512Update], [md], [
|
||||||
AS_IF([test "x$ac_cv_search_SHA512Update" != "xnone required"], [
|
AS_IF([test "x$ac_cv_search_SHA512Update" != "xnone required"], [
|
||||||
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_SHA512Update"
|
LIBBSD_LIBS="$SHA512_LIBS $ac_cv_search_SHA512Update"
|
||||||
])
|
])
|
||||||
], [
|
], [
|
||||||
AC_MSG_ERROR([cannot find required SHA-2 functions in libc or libmd])
|
AC_MSG_ERROR([cannot find required SHA-2 functions in libc or libmd])
|
||||||
])
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
LIBS="$saved_LIBS"
|
LIBS="$saved_LIBS"
|
||||||
|
|
||||||
AS_CASE([$host_os],
|
AS_CASE([$host_os],
|
||||||
@@ -187,55 +513,12 @@ AC_CHECK_DECLS([environ], [], [], [[
|
|||||||
LIBBSD_HAS_GNU_INIT_ARRAY
|
LIBBSD_HAS_GNU_INIT_ARRAY
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_MSG_CHECKING([for program_invocation_short_name])
|
LIBBSD_CHECK_PROGNAME
|
||||||
AC_LINK_IFELSE([
|
LIBBSD_CHECK_REGISTER_ATFORK
|
||||||
AC_LANG_PROGRAM([[
|
|
||||||
#include <errno.h>
|
|
||||||
]], [[
|
|
||||||
const char *p = program_invocation_short_name;
|
|
||||||
]])
|
|
||||||
], [
|
|
||||||
AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
|
|
||||||
[Define to 1 if you have program_invocation_short_name])
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
], [
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for __progname])
|
|
||||||
AC_LINK_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([[
|
|
||||||
#include <stdio.h>
|
|
||||||
extern char *__progname;
|
|
||||||
]], [[
|
|
||||||
printf("%s", __progname);
|
|
||||||
]])
|
|
||||||
], [
|
|
||||||
AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
], [
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for __register_atfork])
|
|
||||||
AC_LINK_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([[
|
|
||||||
#include <stddef.h>
|
|
||||||
extern void *__dso_handle;
|
|
||||||
extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void *);
|
|
||||||
]], [[
|
|
||||||
__register_atfork(NULL, NULL, NULL, __dso_handle);
|
|
||||||
]])
|
|
||||||
], [
|
|
||||||
AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
|
||||||
[Define to 1 if you have __register_atfork])
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
], [
|
|
||||||
LIBBSD_LIBS="$LIBBSD_LIBS -pthread"
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_CHECK_FUNCS([\
|
AC_CHECK_FUNCS([\
|
||||||
|
vasprintf \
|
||||||
|
asprintf \
|
||||||
clearenv \
|
clearenv \
|
||||||
dirfd \
|
dirfd \
|
||||||
flock \
|
flock \
|
||||||
@@ -255,72 +538,54 @@ AC_CHECK_FUNCS([\
|
|||||||
group_from_gid \
|
group_from_gid \
|
||||||
])
|
])
|
||||||
|
|
||||||
need_arc4random=yes
|
|
||||||
need_bsd_getopt=yes
|
|
||||||
need_progname=yes
|
|
||||||
need_md5=yes
|
|
||||||
need_nlist=yes
|
|
||||||
need_strl=yes
|
|
||||||
need_wcsl=yes
|
|
||||||
need_strmode=yes
|
|
||||||
need_id_from_name=yes
|
|
||||||
need_fpurge=yes
|
|
||||||
need_funopen=yes
|
|
||||||
AS_CASE([$host_os],
|
|
||||||
[*-gnu*], [
|
|
||||||
# On glibc >= 2.38, strlcpy() and strlcat() got added,
|
|
||||||
# so these could then be dropped on the next SOVERSION bump.
|
|
||||||
#need_strl=no
|
|
||||||
],
|
|
||||||
[*-musl*], [
|
|
||||||
# On musl >= 0.5.0, strlcpy() and strlcat() were already implemented,
|
|
||||||
# so these can then be dropped on the next SOVERSION bump.
|
|
||||||
#need_strl=no
|
|
||||||
# On musl >= 0.9.7, optreset got implemented, so bsd_getopt() can then
|
|
||||||
# be dropped on the next SOVERSION bump.
|
|
||||||
#need_bsd_getopt=no
|
|
||||||
# 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
|
|
||||||
need_funopen=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.
|
|
||||||
need_arc4random=no
|
|
||||||
need_bsd_getopt=no
|
|
||||||
need_progname=no
|
|
||||||
need_transparent_libmd=no
|
|
||||||
need_md5=no
|
|
||||||
need_nlist=no
|
|
||||||
need_strl=no
|
|
||||||
need_wcsl=no
|
|
||||||
need_strmode=no
|
|
||||||
need_id_from_name=no
|
|
||||||
need_fpurge=no
|
|
||||||
# On macOS we do not have fopencookie(), and cannot implement it.
|
|
||||||
need_funopen=no
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
|
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
|
||||||
|
|
||||||
AM_CONDITIONAL([NEED_ARC4RANDOM], [test "x$need_arc4random" = "xyes"])
|
# ABI selection
|
||||||
AM_CONDITIONAL([NEED_BSD_GETOPT], [test "x$need_bsd_getopt" = "xyes"])
|
LIBBSD_SELECT_ABI([accmode], [setmode()/getmode()])
|
||||||
AM_CONDITIONAL([NEED_PROGNAME], [test "x$need_progname" = "xyes"])
|
LIBBSD_SELECT_ABI([arc4random], [arc4random() API])
|
||||||
AM_CONDITIONAL([NEED_TRANSPARENT_LIBMD], [test "x$need_transparent_libmd" = "xyes"])
|
LIBBSD_SELECT_ABI([arc4random_stir], [arc4random_stir()/arc4random_addrandom()])
|
||||||
AM_CONDITIONAL([NEED_MD5], [test "x$need_md5" = "xyes"])
|
LIBBSD_SELECT_ABI([asprintf], [vasprintf()/asprintf()])
|
||||||
AM_CONDITIONAL([NEED_NLIST], [test "x$need_nlist" = "xyes"])
|
LIBBSD_SELECT_ABI([bsd_getopt], [BSD getopt()])
|
||||||
AM_CONDITIONAL([NEED_STRL], [test "x$need_strl" = "xyes"])
|
LIBBSD_SELECT_ABI([closefrom], [closefrom()])
|
||||||
AM_CONDITIONAL([NEED_WCSL], [test "x$need_wcsl" = "xyes"])
|
LIBBSD_SELECT_ABI([err], [err API])
|
||||||
AM_CONDITIONAL([NEED_STRMODE], [test "x$need_strmode" = "xyes"])
|
LIBBSD_SELECT_ABI([errc], [errc API])
|
||||||
AM_CONDITIONAL([NEED_ID_FROM_NAME], [test "x$need_id_from_name" = "xyes"])
|
LIBBSD_SELECT_ABI([expand_number], [expand_number()])
|
||||||
AM_CONDITIONAL([NEED_FPURGE], [test "x$need_fpurge" = "xyes"])
|
LIBBSD_SELECT_ABI([explicit_bzero], [explicit_bzero()])
|
||||||
AM_CONDITIONAL([NEED_FUNOPEN], [test "x$need_funopen" = "xyes"])
|
LIBBSD_SELECT_ABI([fgetln], [fgetln/fgetwln()])
|
||||||
AS_IF([test "x$need_funopen" = "xno" && \
|
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" && \
|
||||||
test "x$ac_cv_func_funopen" != "xyes" && \
|
test "x$ac_cv_func_funopen" != "xyes" && \
|
||||||
test "x$ac_cv_func_fopencookie" = "xyes"], [
|
test "x$ac_cv_func_fopencookie" = "xyes"], [
|
||||||
AC_MSG_WARN([[can implement funopen() now based on newly added fopencooke(), report upstream]])
|
AC_MSG_WARN([[can implement funopen() now based on newly added fopencooke(), report upstream]])
|
||||||
|
@@ -12,31 +12,77 @@ nobase_include_HEADERS = \
|
|||||||
bsd/netinet/ip_icmp.h \
|
bsd/netinet/ip_icmp.h \
|
||||||
bsd/bitstring.h \
|
bsd/bitstring.h \
|
||||||
bsd/bsd.h \
|
bsd/bsd.h \
|
||||||
bsd/err.h \
|
|
||||||
bsd/getopt.h \
|
|
||||||
bsd/grp.h \
|
|
||||||
bsd/inttypes.h \
|
bsd/inttypes.h \
|
||||||
bsd/libutil.h \
|
bsd/libutil.h \
|
||||||
bsd/pwd.h \
|
|
||||||
bsd/readpassphrase.h \
|
|
||||||
bsd/stdio.h \
|
bsd/stdio.h \
|
||||||
bsd/stdlib.h \
|
bsd/stdlib.h \
|
||||||
bsd/string.h \
|
bsd/string.h \
|
||||||
bsd/stringlist.h \
|
|
||||||
bsd/timeconv.h \
|
|
||||||
bsd/unistd.h \
|
bsd/unistd.h \
|
||||||
bsd/vis.h \
|
|
||||||
bsd/wchar.h \
|
bsd/wchar.h \
|
||||||
# EOL
|
# EOL
|
||||||
|
|
||||||
if NEED_MD5
|
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 += \
|
nobase_include_HEADERS += \
|
||||||
bsd/md5.h \
|
bsd/md5.h \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_NLIST
|
if ABI_NLIST
|
||||||
nobase_include_HEADERS += \
|
nobase_include_HEADERS += \
|
||||||
bsd/nlist.h \
|
bsd/nlist.h \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
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
|
||||||
|
|
||||||
|
do_header_subst = $(AM_V_GEN) $(SED) \
|
||||||
|
-e 's:^//\(.define LIBBSD_SYS_TIME_BITS\).*:\1 $(LIBBSD_SYS_TIME_BITS):' \
|
||||||
|
-e 's:^//\(.define LIBBSD_SYS_HAS_TIME64\).*:\1 $(LIBBSD_SYS_HAS_TIME64):' \
|
||||||
|
# EOL
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
$(do_header_subst) <$(DESTDIR)$(includedir)/bsd/sys/cdefs.h \
|
||||||
|
>$(DESTDIR)$(includedir)/bsd/sys/cdefs.h.new
|
||||||
|
mv $(DESTDIR)$(includedir)/bsd/sys/cdefs.h.new \
|
||||||
|
$(DESTDIR)$(includedir)/bsd/sys/cdefs.h
|
||||||
|
@@ -24,8 +24,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _AIX
|
||||||
#ifdef LIBBSD_OVERLAY
|
#ifdef LIBBSD_OVERLAY
|
||||||
#include_next <md5.h>
|
#include_next <md5.h>
|
||||||
#else
|
#else
|
||||||
#include <md5.h>
|
#include <md5.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2004-2005, 2009, 2011-2013 Guillem Jover <guillem@hadrons.org>
|
* Copyright © 2004-2024 Guillem Jover <guillem@hadrons.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -44,8 +44,18 @@
|
|||||||
#include <bsd/sys/cdefs.h>
|
#include <bsd/sys/cdefs.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#if defined(_AIX)
|
||||||
|
#include <stdarg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
#if defined(_AIX)
|
||||||
|
int asprintf(char **strp, char const *fmt, ...)
|
||||||
|
__printflike(2, 3);
|
||||||
|
int vasprintf(char **strp, char const *fmt, va_list args)
|
||||||
|
__printflike(2, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *fmtcheck(const char *, const char *);
|
const char *fmtcheck(const char *, const char *);
|
||||||
|
|
||||||
/* XXX: The function requires cooperation from the system libc to store the
|
/* XXX: The function requires cooperation from the system libc to store the
|
||||||
|
@@ -86,6 +86,10 @@
|
|||||||
#define _SYS_CDEFS_H
|
#define _SYS_CDEFS_H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Define the ABI for the current system. */
|
||||||
|
//#define LIBBSD_SYS_TIME_BITS 0
|
||||||
|
//#define LIBBSD_SYS_HAS_TIME64 0
|
||||||
|
|
||||||
#define LIBBSD_CONCAT(x, y) x ## y
|
#define LIBBSD_CONCAT(x, y) x ## y
|
||||||
#define LIBBSD_STRING(x) #x
|
#define LIBBSD_STRING(x) #x
|
||||||
|
|
||||||
|
@@ -58,4 +58,17 @@ time_t _long_to_time(long tlong);
|
|||||||
int _time_to_int(time_t t);
|
int _time_to_int(time_t t);
|
||||||
time_t _int_to_time(int tint);
|
time_t _int_to_time(int tint);
|
||||||
|
|
||||||
|
#if LIBBSD_SYS_TIME_BITS == 32 && LIBBSD_SYS_HAS_TIME64
|
||||||
|
#if defined _TIME_BITS && _TIME_BITS == 64
|
||||||
|
time_t LIBBSD_REDIRECT(_time32_to_time, (int32_t t32), _time32_to_time_time64);
|
||||||
|
int32_t LIBBSD_REDIRECT(_time_to_time32, (time_t t), _time_to_time32_time64);
|
||||||
|
time_t LIBBSD_REDIRECT(_time64_to_time, (int64_t t64), _time64_to_time_time64);
|
||||||
|
int64_t LIBBSD_REDIRECT(_time_to_time64, (time_t t), _time_to_time64_time64);
|
||||||
|
long LIBBSD_REDIRECT(_time_to_long, (time_t t), _time_to_long_time64);
|
||||||
|
time_t LIBBSD_REDIRECT(_long_to_time, (long tlong), _long_to_time_time64);
|
||||||
|
int LIBBSD_REDIRECT(_time_to_int, (time_t t), _time_to_int_time64);
|
||||||
|
time_t LIBBSD_REDIRECT(_int_to_time, (int tint), _int_to_time_time64);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LIBBSD_TIMECONV_H */
|
#endif /* LIBBSD_TIMECONV_H */
|
||||||
|
@@ -93,7 +93,7 @@
|
|||||||
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
||||||
* for over ten years). Despite this incompatibility being reported during
|
* for over ten years). Despite this incompatibility being reported during
|
||||||
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
||||||
* Even more unfortunately FreeBSD and later MacOS picked up this incompatible
|
* Even more unfortunately FreeBSD and later macOS picked up this incompatible
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* Provide both implementations and default for now on the historical one to
|
* Provide both implementations and default for now on the historical one to
|
||||||
|
@@ -70,3 +70,19 @@ int main() { return rc; }
|
|||||||
AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
|
AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
|
||||||
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# LIBBSD_SELECT_ABI(name, desc)
|
||||||
|
# -----------------
|
||||||
|
AC_DEFUN([LIBBSD_SELECT_ABI], [
|
||||||
|
AS_IF([test -z "$AS_TR_SH([abi_$1])"], [
|
||||||
|
AC_MSG_ERROR([missing ABI selection for $1])
|
||||||
|
], [test "$AS_TR_SH([abi_$1])" = "unknown"], [
|
||||||
|
AC_MSG_ERROR([unknown ABI selection for $1])
|
||||||
|
], [test "$AS_TR_SH([abi_$1])" = "yes"], [
|
||||||
|
AC_DEFINE(AS_TR_CPP([LIBBSD_ABI_$1]), [1], [Provide ABI for $2])
|
||||||
|
], [
|
||||||
|
AC_DEFINE(AS_TR_CPP([LIBBSD_ABI_$1]), [0])
|
||||||
|
])
|
||||||
|
AM_CONDITIONAL(AS_TR_CPP([ABI_$1]),
|
||||||
|
[test "x$AS_TR_SH([abi_$1])" = "xyes"])
|
||||||
|
])
|
||||||
|
57
m4/libbsd-funcs.m4
Normal file
57
m4/libbsd-funcs.m4
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Copyright © 2011-2024 Guillem Jover <guillem@hadrons.org>
|
||||||
|
|
||||||
|
# LIBBSD_CHECK_PROGNAME
|
||||||
|
# ---------------------
|
||||||
|
AC_DEFUN([LIBBSD_CHECK_PROGNAME], [
|
||||||
|
AC_MSG_CHECKING([for program_invocation_short_name])
|
||||||
|
AC_LINK_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[
|
||||||
|
#include <errno.h>
|
||||||
|
]], [[
|
||||||
|
const char *p = program_invocation_short_name;
|
||||||
|
]])
|
||||||
|
], [
|
||||||
|
AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
|
||||||
|
[Define to 1 if you have program_invocation_short_name])
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for __progname])
|
||||||
|
AC_LINK_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[
|
||||||
|
#include <stdio.h>
|
||||||
|
extern char *__progname;
|
||||||
|
]], [[
|
||||||
|
printf("%s", __progname);
|
||||||
|
]])
|
||||||
|
], [
|
||||||
|
AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
# LIBBSD_CHECK_REGISTER_ATFORK
|
||||||
|
# ----------------------------
|
||||||
|
AC_DEFUN([LIBBSD_CHECK_REGISTER_ATFORK], [
|
||||||
|
AC_MSG_CHECKING([for __register_atfork])
|
||||||
|
AC_LINK_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([[
|
||||||
|
#include <stddef.h>
|
||||||
|
extern void *__dso_handle;
|
||||||
|
extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void *);
|
||||||
|
]], [[
|
||||||
|
__register_atfork(NULL, NULL, NULL, __dso_handle);
|
||||||
|
]])
|
||||||
|
], [
|
||||||
|
AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
||||||
|
[Define to 1 if you have __register_atfork])
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
], [
|
||||||
|
LIBBSD_LIBS="$LIBBSD_LIBS -pthread"
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
])
|
||||||
|
])
|
51
m4/libbsd-large.m4
Normal file
51
m4/libbsd-large.m4
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# Copyright © 2024 Guillem Jover <guillem@hadrons.org>
|
||||||
|
|
||||||
|
# LIBBSD_SYS_TIME64
|
||||||
|
# -----------------
|
||||||
|
# Check for availability of time64 support.
|
||||||
|
AC_DEFUN([LIBBSD_SYS_TIME64], [
|
||||||
|
# Check the default time_t size.
|
||||||
|
AC_CHECK_SIZEOF([time_t], [], [[
|
||||||
|
#undef _TIME_BITS
|
||||||
|
#include <time.h>
|
||||||
|
]])
|
||||||
|
AS_IF([test $ac_cv_sizeof_time_t = 8], [
|
||||||
|
libbsd_sys_time_bits=64
|
||||||
|
], [
|
||||||
|
libbsd_sys_time_bits=32
|
||||||
|
])
|
||||||
|
AC_DEFINE_UNQUOTED([LIBBSD_SYS_TIME_BITS], [$libbsd_sys_time_bits],
|
||||||
|
[The number of bits for the default system time_t ABI])
|
||||||
|
AC_SUBST([LIBBSD_SYS_TIME_BITS], [$libbsd_sys_time_bits])
|
||||||
|
AS_UNSET([ac_cv_sizeof_time_t])
|
||||||
|
AM_CONDITIONAL([LIBBSD_SYS_IS_TIME32], [test "$libbsd_sys_time_bits" -eq 32])
|
||||||
|
|
||||||
|
# Check the whether the system supports 64-bit time_t.
|
||||||
|
AC_CHECK_SIZEOF([time_t], [], [[
|
||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#define _TIME_BITS 64
|
||||||
|
#include <time.h>
|
||||||
|
]])
|
||||||
|
AS_IF([test $ac_cv_sizeof_time_t = 8], [
|
||||||
|
libbsd_sys_has_time64=1
|
||||||
|
], [
|
||||||
|
libbsd_sys_has_time64=0
|
||||||
|
])
|
||||||
|
AC_DEFINE_UNQUOTED([LIBBSD_SYS_HAS_TIME64], [$libbsd_sys_has_time64],
|
||||||
|
[Enable if the system supports 64-bit time_t])
|
||||||
|
AC_SUBST([LIBBSD_SYS_HAS_TIME64], [$libbsd_sys_has_time64])
|
||||||
|
AM_CONDITIONAL([LIBBSD_SYS_HAS_TIME64], [test "$libbsd_sys_has_time64" -eq 1])
|
||||||
|
AS_IF([test "$libbsd_sys_time_bits" = 32 && \
|
||||||
|
test "$libbsd_sys_has_time64" -eq 1], [
|
||||||
|
abi_time64=yes
|
||||||
|
], [
|
||||||
|
abi_time64=no
|
||||||
|
])
|
||||||
|
LIBBSD_SELECT_ABI([time64], [explicit time64 time_t support])
|
||||||
|
|
||||||
|
AS_IF([test $ac_cv_sys_file_offset_bits = 64 && \
|
||||||
|
test $libbsd_sys_time_bits = 32 && \
|
||||||
|
test $ac_cv_sizeof_time_t = 8], [
|
||||||
|
AC_DEFINE([_TIME_BITS], [64], [Enable 64-bit time_t support])
|
||||||
|
])
|
||||||
|
])
|
284
man/Makefile.am
284
man/Makefile.am
@@ -143,11 +143,6 @@ dist_man_MANS = \
|
|||||||
TAILQ_SWAP.3bsd \
|
TAILQ_SWAP.3bsd \
|
||||||
TIMESPEC_TO_TIMEVAL.3bsd \
|
TIMESPEC_TO_TIMEVAL.3bsd \
|
||||||
TIMEVAL_TO_TIMESPEC.3bsd \
|
TIMEVAL_TO_TIMESPEC.3bsd \
|
||||||
arc4random.3bsd \
|
|
||||||
arc4random_addrandom.3bsd \
|
|
||||||
arc4random_buf.3bsd \
|
|
||||||
arc4random_stir.3bsd \
|
|
||||||
arc4random_uniform.3bsd \
|
|
||||||
be16dec.3bsd \
|
be16dec.3bsd \
|
||||||
be16enc.3bsd \
|
be16enc.3bsd \
|
||||||
be32dec.3bsd \
|
be32dec.3bsd \
|
||||||
@@ -166,23 +161,6 @@ dist_man_MANS = \
|
|||||||
bitstr_size.3bsd \
|
bitstr_size.3bsd \
|
||||||
bitstring.3bsd \
|
bitstring.3bsd \
|
||||||
byteorder.3bsd \
|
byteorder.3bsd \
|
||||||
closefrom.3bsd \
|
|
||||||
dehumanize_number.3bsd \
|
|
||||||
errc.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 \
|
|
||||||
group_from_gid.3bsd \
|
|
||||||
heapsort.3bsd \
|
|
||||||
humanize_number.3bsd \
|
|
||||||
le16dec.3bsd \
|
le16dec.3bsd \
|
||||||
le16enc.3bsd \
|
le16enc.3bsd \
|
||||||
le32dec.3bsd \
|
le32dec.3bsd \
|
||||||
@@ -190,38 +168,7 @@ dist_man_MANS = \
|
|||||||
le64dec.3bsd \
|
le64dec.3bsd \
|
||||||
le64enc.3bsd \
|
le64enc.3bsd \
|
||||||
libbsd.7 \
|
libbsd.7 \
|
||||||
mergesort.3bsd \
|
|
||||||
pidfile.3bsd \
|
|
||||||
pidfile_close.3bsd \
|
|
||||||
pidfile_open.3bsd \
|
|
||||||
pidfile_remove.3bsd \
|
|
||||||
pidfile_write.3bsd \
|
|
||||||
pwcache.3bsd \
|
|
||||||
queue.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 \
|
timeradd.3bsd \
|
||||||
timerclear.3bsd \
|
timerclear.3bsd \
|
||||||
timercmp.3bsd \
|
timercmp.3bsd \
|
||||||
@@ -235,65 +182,248 @@ dist_man_MANS = \
|
|||||||
timespecsub.3bsd \
|
timespecsub.3bsd \
|
||||||
timeval.3bsd \
|
timeval.3bsd \
|
||||||
tree.3bsd \
|
tree.3bsd \
|
||||||
unvis.3bsd \
|
|
||||||
user_from_uid.3bsd \
|
|
||||||
vis.3bsd \
|
|
||||||
# EOL
|
# EOL
|
||||||
|
|
||||||
if NEED_PROGNAME
|
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 \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_NLIST
|
||||||
|
dist_man_MANS += \
|
||||||
|
nlist.3bsd \
|
||||||
|
# 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 += \
|
dist_man_MANS += \
|
||||||
getprogname.3bsd \
|
getprogname.3bsd \
|
||||||
setprogname.3bsd \
|
setprogname.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_MD5
|
if ABI_PWCACHE
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
md5.3bsd \
|
pwcache.3bsd \
|
||||||
|
gid_from_group.3bsd \
|
||||||
|
uid_from_user.3bsd \
|
||||||
|
# EOL
|
||||||
|
|
||||||
|
if ABI_NAME_FROM_ID
|
||||||
|
dist_man_MANS += \
|
||||||
|
group_from_gid.3bsd \
|
||||||
|
user_from_uid.3bsd \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_READPASSPHRASE
|
||||||
|
dist_man_MANS += \
|
||||||
|
readpassphrase.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_NLIST
|
if ABI_REALLOCARRAY
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
nlist.3bsd \
|
reallocarray.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_STRL
|
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 += \
|
dist_man_MANS += \
|
||||||
strlcat.3bsd \
|
strlcat.3bsd \
|
||||||
strlcpy.3bsd \
|
strlcpy.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_WCSL
|
if ABI_STRMODE
|
||||||
dist_man_MANS += \
|
|
||||||
wcslcat.3bsd \
|
|
||||||
wcslcpy.3bsd \
|
|
||||||
# EOL
|
|
||||||
endif
|
|
||||||
|
|
||||||
if NEED_STRMODE
|
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
strmode.3bsd \
|
strmode.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_ID_FROM_NAME
|
if ABI_STRNSTR
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
uid_from_user.3bsd \
|
strnstr.3bsd \
|
||||||
gid_from_group.3bsd \
|
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_FPURGE
|
if ABI_STRTOX
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
fpurge.3bsd \
|
strtoi.3bsd \
|
||||||
|
strtou.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_FUNOPEN
|
if ABI_STRTONUM
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
funopen.3bsd \
|
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 \
|
||||||
|
wcslcpy.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
@@ -168,11 +168,10 @@ functions first appeared in
|
|||||||
.Sh BUGS
|
.Sh BUGS
|
||||||
The
|
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
|
glibc- and musl-based ones
|
||||||
and glibc-based (as the libbsd implementation is only provided when the
|
(as the libbsd implementation is only provided when the system has
|
||||||
system has
|
|
||||||
.Fn fopencookie
|
.Fn fopencookie
|
||||||
available).
|
available).
|
||||||
.Pp
|
.Pp
|
||||||
|
69
man/libbsd.7
69
man/libbsd.7
@@ -1,6 +1,6 @@
|
|||||||
.\" libbsd man page
|
.\" libbsd man page
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright © 2017-2022 Guillem Jover <guillem@hadrons.org>
|
.\" Copyright © 2017-2024 Guillem Jover <guillem@hadrons.org>
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
.\" modification, are permitted provided that the following conditions
|
.\" modification, are permitted provided that the following conditions
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 3, 2022
|
.Dd January 8, 2024
|
||||||
.Dt libbsd 7
|
.Dt libbsd 7
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -76,7 +76,7 @@ The package also provides a
|
|||||||
.Nm libbsd-ctor
|
.Nm libbsd-ctor
|
||||||
static library that can be used to inject automatic constructors into a
|
static library that can be used to inject automatic constructors into a
|
||||||
program so that the
|
program so that the
|
||||||
.Xr setproctitle_init 3
|
.Xr setproctitle_init 3bsd
|
||||||
function gets invoked automatically at startup time.
|
function gets invoked automatically at startup time.
|
||||||
This can be done with the
|
This can be done with the
|
||||||
.Xr pkgconf 1
|
.Xr pkgconf 1
|
||||||
@@ -136,13 +136,13 @@ at build-time.
|
|||||||
This is the list of functions that provide multiple implementations:
|
This is the list of functions that provide multiple implementations:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width 4m -compact
|
.Bl -tag -width 4m -compact
|
||||||
.It Fn strnvis 3
|
.It Xr strnvis 3bsd
|
||||||
.It Fn strnunvis 3
|
.It Xr strnunvis 3bsd
|
||||||
.Nx
|
.Nx
|
||||||
added
|
added
|
||||||
.Xr strnvis 3
|
.Xr strnvis 3bsd
|
||||||
and
|
and
|
||||||
.Xr strnunvis 3
|
.Xr strnunvis 3bsd
|
||||||
but unfortunately made it incompatible with the existing one in
|
but unfortunately made it incompatible with the existing one in
|
||||||
.Ox
|
.Ox
|
||||||
and Freedesktop's libbsd (the former having existed for over ten years).
|
and Freedesktop's libbsd (the former having existed for over ten years).
|
||||||
@@ -150,13 +150,13 @@ Despite this incompatibility being reported during development (see
|
|||||||
http://gnats.netbsd.org/44977) they still shipped it.
|
http://gnats.netbsd.org/44977) they still shipped it.
|
||||||
Even more unfortunately
|
Even more unfortunately
|
||||||
.Fx
|
.Fx
|
||||||
and later MacOS picked up this incompatible implementation.
|
and later macOS picked up this incompatible implementation.
|
||||||
.Pp
|
.Pp
|
||||||
Provide both implementations and default for now to the historical one to
|
Provide both implementations and default for now to the historical one to
|
||||||
avoid breakage, but we will switch to the
|
avoid breakage, but we will switch to the
|
||||||
.Nx
|
.Nx
|
||||||
one in a later release, which is internally consistent with the other
|
one in a later release, which is internally consistent with the other
|
||||||
.Xr vis 3
|
.Xr vis 3bsd
|
||||||
functions and is now more widespread.
|
functions and is now more widespread.
|
||||||
Define
|
Define
|
||||||
.Dv LIBBSD_NETBSD_VIS
|
.Dv LIBBSD_NETBSD_VIS
|
||||||
@@ -178,7 +178,7 @@ or non-buggy way; or because there are better more portable replacements now.
|
|||||||
.Pp
|
.Pp
|
||||||
This is the list of currently deprecated macros and functions:
|
This is the list of currently deprecated macros and functions:
|
||||||
.Bl -tag -width 4m
|
.Bl -tag -width 4m
|
||||||
.It Fn fgetln 3
|
.It Xr fgetln 3bsd
|
||||||
Unportable, requires assistance from the stdio layer.
|
Unportable, requires assistance from the stdio layer.
|
||||||
An implementation has to choose between leaking buffers or being reentrant
|
An implementation has to choose between leaking buffers or being reentrant
|
||||||
for a limited amount of streams (this implementation chose the latter with
|
for a limited amount of streams (this implementation chose the latter with
|
||||||
@@ -187,7 +187,7 @@ Use
|
|||||||
.Xr getline 3
|
.Xr getline 3
|
||||||
instead, which is available in many systems and required by
|
instead, which is available in many systems and required by
|
||||||
.St -p1003.1-2008 .
|
.St -p1003.1-2008 .
|
||||||
.It Fn fgetwln 3
|
.It Xr fgetwln 3bsd
|
||||||
Unportable, requires assistance from the stdio layer.
|
Unportable, requires assistance from the stdio layer.
|
||||||
An implementation has to choose between leaking buffers or being reentrant
|
An implementation has to choose between leaking buffers or being reentrant
|
||||||
for a limited amount of streams (this implementation chose the latter with
|
for a limited amount of streams (this implementation chose the latter with
|
||||||
@@ -198,9 +198,9 @@ instead, which is available in many systems and required by
|
|||||||
.St -isoC-99
|
.St -isoC-99
|
||||||
and
|
and
|
||||||
.St -p1003.1-2001 .
|
.St -p1003.1-2001 .
|
||||||
.It Fn funopen 3
|
.It Xr funopen 3bsd
|
||||||
Unportable, requires assistance from the stdio layer or some hook framework.
|
Unportable, requires assistance from the stdio layer or some hook framework.
|
||||||
On GNU systems the
|
On glibc- and musl-based systems the
|
||||||
.Xr fopencookie 3
|
.Xr fopencookie 3
|
||||||
function can be used.
|
function can be used.
|
||||||
Otherwise the code needs to be prepared for neither of these functions being
|
Otherwise the code needs to be prepared for neither of these functions being
|
||||||
@@ -215,42 +215,53 @@ are present in all major
|
|||||||
for example.
|
for example.
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width 4m -compact
|
.Bl -tag -width 4m -compact
|
||||||
.It Fn MD5Init 3
|
.It Xr MD5Init 3
|
||||||
.It Fn MD5Update 3
|
.It Xr MD5Update 3
|
||||||
.It Fn MD5Pad 3
|
.It Xr MD5Pad 3
|
||||||
.It Fn MD5Final 3
|
.It Xr MD5Final 3
|
||||||
.It Fn MD5Transform 3
|
.It Xr MD5Transform 3
|
||||||
.It Fn MD5End 3
|
.It Xr MD5End 3
|
||||||
.It Fn MD5File 3
|
.It Xr MD5File 3
|
||||||
.It Fn MD5FileChunk 3
|
.It Xr MD5FileChunk 3
|
||||||
.It Fn MD5Data 3
|
.It Xr MD5Data 3
|
||||||
The set of MD5 digest functions are now proxies for the implementations
|
The set of MD5 digest functions are now proxies for the implementations
|
||||||
provided by the
|
provided by the
|
||||||
.Nm libmd
|
.Nm libmd
|
||||||
companion library, so it is advised to switch to use that directly instead.
|
companion library, so it is advised to switch to use that directly instead.
|
||||||
.It Fn explicit_bzero 3
|
.It Xr explicit_bzero 3bsd
|
||||||
This function is provided by
|
This function is provided by
|
||||||
.Nm glibc
|
.Nm glibc
|
||||||
2.25, and
|
2.25, and
|
||||||
.Nm musl
|
.Nm musl
|
||||||
1.1.20.
|
1.1.20.
|
||||||
.It Fn reallocarray 3
|
.It Xr reallocarray 3bsd
|
||||||
This function is provided by
|
This function is provided by
|
||||||
.Nm glibc
|
.Nm glibc
|
||||||
2.26, and
|
2.26, and
|
||||||
.Nm musl
|
.Nm musl
|
||||||
1.2.2.
|
1.2.2.
|
||||||
.It Xr arc4random 3
|
.It Xr closefrom 3bsd
|
||||||
.It Xr arc4random_buf 3
|
This function is provided by
|
||||||
.It Xr arc4random_uniform 3
|
.Nm glibc
|
||||||
|
2.34.
|
||||||
|
.It Xr arc4random 3bsd
|
||||||
|
.It Xr arc4random_buf 3bsd
|
||||||
|
.It Xr arc4random_uniform 3bsd
|
||||||
These functions are provided by
|
These functions are provided by
|
||||||
.Nm glibc
|
.Nm glibc
|
||||||
2.36.
|
2.36.
|
||||||
Note that it does not provide the
|
Note that it does not provide the
|
||||||
.Xr arc4random_stir 3
|
.Xr arc4random_stir 3bsd
|
||||||
and
|
and
|
||||||
.Xr arc4random_addrandom 3
|
.Xr arc4random_addrandom 3bsd
|
||||||
functions.
|
functions.
|
||||||
|
.It Xr strlcpy 3bsd
|
||||||
|
.It Xr strlcat 3bsd
|
||||||
|
These functions are provided by
|
||||||
|
.Nm glibc
|
||||||
|
2.38, and
|
||||||
|
.Nm musl
|
||||||
|
0.5.0.
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr arc4random 3bsd ,
|
.Xr arc4random 3bsd ,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: strtoi.3,v 1.7 2017/07/03 21:32:50 wiz Exp $
|
.\" $NetBSD: strtoi.3,v 1.10 2024/02/10 18:43:51 andvar Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1990, 1991, 1993
|
.\" Copyright (c) 1990, 1991, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
@@ -36,12 +36,12 @@
|
|||||||
.\" Created by Kamil Rytarowski, based on ID:
|
.\" Created by Kamil Rytarowski, based on ID:
|
||||||
.\" NetBSD: strtol.3,v 1.31 2015/03/11 09:57:35 wiz Exp
|
.\" NetBSD: strtol.3,v 1.31 2015/03/11 09:57:35 wiz Exp
|
||||||
.\"
|
.\"
|
||||||
.Dd November 13, 2015
|
.Dd January 20, 2024
|
||||||
.Dt strtoi 3bsd
|
.Dt strtoi 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strtoi
|
.Nm strtoi
|
||||||
.Nd convert string value to an intmax_t integer
|
.Nd convert a string value to an intmax_t integer
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
|
.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
|
||||||
.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
|
.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
|
||||||
@@ -63,8 +63,7 @@ for include usage.)
|
|||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Fn strtoi
|
.Fn strtoi
|
||||||
function
|
function converts the string in
|
||||||
converts the string in
|
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to an
|
to an
|
||||||
.Ft intmax_t
|
.Ft intmax_t
|
||||||
@@ -77,7 +76,7 @@ and ensures that the result is always in the range [
|
|||||||
.Fa lo ..
|
.Fa lo ..
|
||||||
.Fa hi
|
.Fa hi
|
||||||
].
|
].
|
||||||
In adddition it always places
|
In addition it always places
|
||||||
.Dv 0
|
.Dv 0
|
||||||
on success or a conversion status in the
|
on success or a conversion status in the
|
||||||
.Fa rstatus
|
.Fa rstatus
|
||||||
@@ -122,10 +121,11 @@ is taken as 10 (decimal) unless the next character is
|
|||||||
.Ql 0 ,
|
.Ql 0 ,
|
||||||
in which case it is taken as 8 (octal).
|
in which case it is taken as 8 (octal).
|
||||||
.Pp
|
.Pp
|
||||||
The remainder of the string is converted to a
|
The remainder of the string is converted to an
|
||||||
.Em intmax_t
|
.Em intmax_t
|
||||||
value in the obvious manner,
|
value in the obvious manner,
|
||||||
stopping at the first character which is not a valid digit
|
stopping at the end of the string
|
||||||
|
or at the first character which is not a valid digit
|
||||||
in the given base.
|
in the given base.
|
||||||
(In bases above 10, the letter
|
(In bases above 10, the letter
|
||||||
.Ql A
|
.Ql A
|
||||||
@@ -206,6 +206,12 @@ or the range given was invalid, i.e.
|
|||||||
>
|
>
|
||||||
.Fa hi .
|
.Fa hi .
|
||||||
.El
|
.El
|
||||||
|
.Pp
|
||||||
|
The range check is more important than the unconverted characters check,
|
||||||
|
and it is performed first.
|
||||||
|
If a program needs to know if there were unconverted characters when an
|
||||||
|
out of range number has been provided, it needs to supply and test
|
||||||
|
.Fa endptr.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr atof 3 ,
|
.Xr atof 3 ,
|
||||||
.Xr atoi 3 ,
|
.Xr atoi 3 ,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: strtou.3,v 1.7 2017/07/03 21:32:50 wiz Exp $
|
.\" $NetBSD: strtou.3,v 1.8 2024/01/20 16:13:39 christos Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1990, 1991, 1993
|
.\" Copyright (c) 1990, 1991, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
@@ -36,12 +36,12 @@
|
|||||||
.\" Created by Kamil Rytarowski, based on ID:
|
.\" Created by Kamil Rytarowski, based on ID:
|
||||||
.\" NetBSD: strtoul.3,v 1.29 2015/03/10 13:00:58 christos Exp
|
.\" NetBSD: strtoul.3,v 1.29 2015/03/10 13:00:58 christos Exp
|
||||||
.\"
|
.\"
|
||||||
.Dd November 13, 2015
|
.Dd January 20, 2024
|
||||||
.Dt strtou 3bsd
|
.Dt strtou 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strtou
|
.Nm strtou
|
||||||
.Nd convert a string to an uintmax_t integer
|
.Nd convert a string value to an uintmax_t integer
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
|
.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
|
||||||
.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
|
.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
|
||||||
@@ -76,7 +76,7 @@ and ensures that the result is always in the range [
|
|||||||
.Fa lo ..
|
.Fa lo ..
|
||||||
.Fa hi
|
.Fa hi
|
||||||
].
|
].
|
||||||
In adddition it always places
|
In addition it always places
|
||||||
.Dv 0
|
.Dv 0
|
||||||
on success or a conversion status in the
|
on success or a conversion status in the
|
||||||
.Fa rstatus
|
.Fa rstatus
|
||||||
@@ -125,7 +125,7 @@ The remainder of the string is converted to an
|
|||||||
.Em uintmax_t
|
.Em uintmax_t
|
||||||
value in the obvious manner,
|
value in the obvious manner,
|
||||||
stopping at the end of the string
|
stopping at the end of the string
|
||||||
or at the first character that does not produce a valid digit
|
or at the first character which is not a valid digit
|
||||||
in the given base.
|
in the given base.
|
||||||
(In bases above 10, the letter
|
(In bases above 10, the letter
|
||||||
.Ql A
|
.Ql A
|
||||||
@@ -200,12 +200,18 @@ In this case,
|
|||||||
.Fa endptr
|
.Fa endptr
|
||||||
points to the first unconverted character.
|
points to the first unconverted character.
|
||||||
.It Bq Er ERANGE
|
.It Bq Er ERANGE
|
||||||
The given string was out of range; the value converted has been clamped; or
|
The given string was out of range; the value converted has been clamped;
|
||||||
the range given was invalid, i.e.
|
or the range given was invalid, i.e.
|
||||||
.Fa lo
|
.Fa lo
|
||||||
>
|
>
|
||||||
.Fa hi .
|
.Fa hi .
|
||||||
.El
|
.El
|
||||||
|
.Pp
|
||||||
|
The range check is more important than the unconverted characters check,
|
||||||
|
and it is performed first.
|
||||||
|
If a program needs to know if there were unconverted characters when an
|
||||||
|
out of range number has been provided, it needs to supply and test
|
||||||
|
.Fa endptr.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr atof 3 ,
|
.Xr atof 3 ,
|
||||||
.Xr atoi 3 ,
|
.Xr atoi 3 ,
|
||||||
@@ -220,13 +226,13 @@ the range given was invalid, i.e.
|
|||||||
.Xr strtoull 3 ,
|
.Xr strtoull 3 ,
|
||||||
.Xr strtoumax 3
|
.Xr strtoumax 3
|
||||||
.Sh STANDARDS
|
.Sh STANDARDS
|
||||||
.ds doc-operating-system-NetBSD-7.0 7.0
|
|
||||||
The
|
The
|
||||||
.Fn strtou
|
.Fn strtou
|
||||||
function is a
|
function is a
|
||||||
.Nx
|
.Nx
|
||||||
extension.
|
extension.
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
|
.ds doc-operating-system-NetBSD-7.0 7.0
|
||||||
The
|
The
|
||||||
.Fn strtou
|
.Fn strtou
|
||||||
function first appeared in
|
function first appeared in
|
||||||
|
301
src/Makefile.am
301
src/Makefile.am
@@ -28,7 +28,7 @@ libbsd_la_included_sources = \
|
|||||||
|
|
||||||
CLEANFILES =
|
CLEANFILES =
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
libbsd.map \
|
libbsd.map.in \
|
||||||
libbsd.pc.in \
|
libbsd.pc.in \
|
||||||
libbsd-ctor.pc.in \
|
libbsd-ctor.pc.in \
|
||||||
libbsd-overlay.pc.in \
|
libbsd-overlay.pc.in \
|
||||||
@@ -53,6 +53,7 @@ endif
|
|||||||
EXTRA_libbsd_la_DEPENDENCIES = \
|
EXTRA_libbsd_la_DEPENDENCIES = \
|
||||||
$(libbsd_la_included_sources) \
|
$(libbsd_la_included_sources) \
|
||||||
libbsd.map \
|
libbsd.map \
|
||||||
|
libbsd.map.in \
|
||||||
# EOL
|
# EOL
|
||||||
libbsd_la_LIBADD = \
|
libbsd_la_LIBADD = \
|
||||||
$(MD5_LIBS) \
|
$(MD5_LIBS) \
|
||||||
@@ -60,11 +61,11 @@ libbsd_la_LIBADD = \
|
|||||||
# EOL
|
# EOL
|
||||||
libbsd_la_LDFLAGS = \
|
libbsd_la_LDFLAGS = \
|
||||||
-no-undefined \
|
-no-undefined \
|
||||||
-version-number $(LIBBSD_ABI) \
|
-version-number $(SOVERSION) \
|
||||||
# EOL
|
# EOL
|
||||||
if HAVE_LINKER_VERSION_SCRIPT
|
if HAVE_LINKER_VERSION_SCRIPT
|
||||||
libbsd_la_LDFLAGS += \
|
libbsd_la_LDFLAGS += \
|
||||||
-Wl,--version-script=$(srcdir)/libbsd.map \
|
-Wl,--version-script=libbsd.map \
|
||||||
# EOL
|
# EOL
|
||||||
else
|
else
|
||||||
libbsd_la_LDFLAGS += \
|
libbsd_la_LDFLAGS += \
|
||||||
@@ -75,57 +76,17 @@ EXTRA_libbsd_la_DEPENDENCIES += \
|
|||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
libbsd_la_SOURCES = \
|
libbsd_la_SOURCES = \
|
||||||
closefrom.c \
|
|
||||||
dehumanize_number.c \
|
|
||||||
err.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-elf.h \
|
||||||
local-link.h \
|
local-link.h \
|
||||||
merge.c \
|
# EOL
|
||||||
pidfile.c \
|
|
||||||
pwcache.c \
|
if ABI_ACCMODE
|
||||||
radixsort.c \
|
libbsd_la_SOURCES += \
|
||||||
readpassphrase.c \
|
|
||||||
reallocarray.c \
|
|
||||||
reallocf.c \
|
|
||||||
recallocarray.c \
|
|
||||||
setmode.c \
|
setmode.c \
|
||||||
setproctitle.c \
|
|
||||||
stringlist.c \
|
|
||||||
strnstr.c \
|
|
||||||
strtoi.c \
|
|
||||||
strtonum.c \
|
|
||||||
strtou.c \
|
|
||||||
timeconv.c \
|
|
||||||
unvis.c \
|
|
||||||
vis.c \
|
|
||||||
# EOL
|
|
||||||
|
|
||||||
if NEED_PROGNAME
|
|
||||||
libbsd_la_SOURCES += \
|
|
||||||
progname.c \
|
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_BSD_GETOPT
|
if ABI_ARC4RANDOM
|
||||||
libbsd_la_SOURCES += \
|
|
||||||
bsd_getopt.c \
|
|
||||||
# EOL
|
|
||||||
endif
|
|
||||||
|
|
||||||
if NEED_ARC4RANDOM
|
|
||||||
if !HAVE_GETENTROPY
|
if !HAVE_GETENTROPY
|
||||||
libbsd_la_SOURCES += \
|
libbsd_la_SOURCES += \
|
||||||
getentropy.c \
|
getentropy.c \
|
||||||
@@ -142,51 +103,239 @@ libbsd_la_SOURCES += \
|
|||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_MD5
|
if ABI_ASPRINTF
|
||||||
|
libbsd_la_SOURCES += \
|
||||||
|
asprintf.c \
|
||||||
|
vasprintf.c \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_BSD_GETOPT
|
||||||
|
libbsd_la_SOURCES += \
|
||||||
|
bsd_getopt.c \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_CLOSEFROM
|
||||||
|
libbsd_la_SOURCES += \
|
||||||
|
closefrom.c \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_ERR
|
||||||
|
libbsd_la_SOURCES += \
|
||||||
|
err.c \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_ERRC
|
||||||
|
libbsd_la_SOURCES += \
|
||||||
|
errc.c \
|
||||||
|
# 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 += \
|
libbsd_la_SOURCES += \
|
||||||
md5.c \
|
md5.c \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_NLIST
|
if ABI_NLIST
|
||||||
libbsd_la_SOURCES += \
|
libbsd_la_SOURCES += \
|
||||||
nlist.c \
|
nlist.c \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_STRL
|
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 += \
|
libbsd_la_SOURCES += \
|
||||||
strlcat.c \
|
strlcat.c \
|
||||||
strlcpy.c \
|
strlcpy.c \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_WCSL
|
if ABI_STRMODE
|
||||||
|
libbsd_la_SOURCES += \
|
||||||
|
strmode.c \
|
||||||
|
# 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 += \
|
libbsd_la_SOURCES += \
|
||||||
wcslcat.c \
|
wcslcat.c \
|
||||||
wcslcpy.c \
|
wcslcpy.c \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_STRMODE
|
if ABI_TRANSPARENT_LIBMD
|
||||||
libbsd_la_SOURCES += \
|
|
||||||
strmode.c \
|
|
||||||
# EOL
|
|
||||||
endif
|
|
||||||
|
|
||||||
if NEED_FPURGE
|
|
||||||
libbsd_la_SOURCES += \
|
|
||||||
fpurge.c \
|
|
||||||
# EOL
|
|
||||||
endif
|
|
||||||
|
|
||||||
if NEED_FUNOPEN
|
|
||||||
libbsd_la_SOURCES += \
|
|
||||||
funopen.c \
|
|
||||||
# EOL
|
|
||||||
endif
|
|
||||||
|
|
||||||
if NEED_TRANSPARENT_LIBMD
|
|
||||||
CLEANFILES += \
|
CLEANFILES += \
|
||||||
format.ld \
|
format.ld \
|
||||||
# EOL
|
# EOL
|
||||||
@@ -194,18 +343,24 @@ endif
|
|||||||
|
|
||||||
DISTCLEANFILES = \
|
DISTCLEANFILES = \
|
||||||
libbsd.sym \
|
libbsd.sym \
|
||||||
|
libbsd.map \
|
||||||
# EOL
|
# EOL
|
||||||
|
|
||||||
libbsd_ctor_a_SOURCES = \
|
libbsd_ctor_a_SOURCES = \
|
||||||
setproctitle_ctor.c \
|
setproctitle_ctor.c \
|
||||||
# EOL
|
# EOL
|
||||||
|
|
||||||
|
# Generate the library map file with the pre-processor to selectively include
|
||||||
|
# symbols depending on the host system, otherwise some linkers might fail.
|
||||||
|
libbsd.map: libbsd.map.in
|
||||||
|
$(AM_V_GEN) $(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -P - <$(srcdir)/libbsd.map.in >$@
|
||||||
|
|
||||||
# Generate a simple libtool symbol export list to be used as a fallback if
|
# Generate a simple libtool symbol export list to be used as a fallback if
|
||||||
# there is no version script support.
|
# there is no version script support.
|
||||||
libbsd.sym: libbsd.map
|
libbsd.sym: libbsd.map
|
||||||
$(AM_V_GEN) $(SED) -ne 's/^[[:space:]]\{1,\}\([A-Za-z0-9_]\{1,\}\);/\1/p' libbsd.map >$@
|
$(AM_V_GEN) $(SED) -ne 's/^[[:space:]]\{1,\}\([A-Za-z0-9_]\{1,\}\);/\1/p' libbsd.map >$@
|
||||||
|
|
||||||
if NEED_TRANSPARENT_LIBMD
|
if ABI_TRANSPARENT_LIBMD
|
||||||
TRANSPARENT_LIBMD_DEPENDS = format.ld
|
TRANSPARENT_LIBMD_DEPENDS = format.ld
|
||||||
|
|
||||||
format.ld:
|
format.ld:
|
||||||
@@ -222,7 +377,7 @@ install-exec-hook: $(TRANSPARENT_LIBMD_DEPENDS)
|
|||||||
mv $(DESTDIR)$(libdir)/libbsd*.so.* \
|
mv $(DESTDIR)$(libdir)/libbsd*.so.* \
|
||||||
$(DESTDIR)$(runtimelibdir)/; \
|
$(DESTDIR)$(runtimelibdir)/; \
|
||||||
fi
|
fi
|
||||||
if NEED_TRANSPARENT_LIBMD
|
if ABI_TRANSPARENT_LIBMD
|
||||||
# The "GNU ld script" magic is required so that GNU ldconfig does not complain
|
# The "GNU ld script" magic is required so that GNU ldconfig does not complain
|
||||||
# about an unknown format file.
|
# about an unknown format file.
|
||||||
soname=`readlink $(DESTDIR)$(libdir)/libbsd.so`; \
|
soname=`readlink $(DESTDIR)$(libdir)/libbsd.so`; \
|
||||||
|
43
src/asprintf.c
Normal file
43
src/asprintf.c
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2010-2024 Guillem Jover <guillem@hadrons.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
asprintf(char **strp, char const *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
n = vasprintf(strp, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
50
src/err.c
50
src/err.c
@@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2006 Robert Millan
|
* Copyright © 2019 Guillem Jover <guillem@hadrons.org>
|
||||||
* Copyright © 2011, 2019 Guillem Jover <guillem@hadrons.org>
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -26,58 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#ifdef LIBBSD_NEED_ERR_H_FUNCS
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void
|
|
||||||
vwarnc(int code, const char *format, va_list ap)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: ", getprogname());
|
|
||||||
if (format) {
|
|
||||||
vfprintf(stderr, format, ap);
|
|
||||||
fprintf(stderr, ": ");
|
|
||||||
}
|
|
||||||
fprintf(stderr, "%s\n", strerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
warnc(int code, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, format);
|
|
||||||
vwarnc(code, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
verrc(int status, int code, const char *format, va_list ap)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: ", getprogname());
|
|
||||||
if (format) {
|
|
||||||
vfprintf(stderr, format, ap);
|
|
||||||
fprintf(stderr, ": ");
|
|
||||||
}
|
|
||||||
fprintf(stderr, "%s\n", strerror(code));
|
|
||||||
exit(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
errc(int status, int code, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, format);
|
|
||||||
verrc(status, code, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LIBBSD_NEED_ERR_H_FUNCS
|
|
||||||
void
|
void
|
||||||
vwarn(const char *format, va_list ap)
|
vwarn(const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
@@ -148,4 +101,3 @@ errx(int eval, const char *format, ...)
|
|||||||
verrx(eval, format, ap);
|
verrx(eval, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
75
src/errc.c
Normal file
75
src/errc.c
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2006 Robert Millan
|
||||||
|
* Copyright © 2011, 2019 Guillem Jover <guillem@hadrons.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
vwarnc(int code, const char *format, va_list ap)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: ", getprogname());
|
||||||
|
if (format) {
|
||||||
|
vfprintf(stderr, format, ap);
|
||||||
|
fprintf(stderr, ": ");
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s\n", strerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warnc(int code, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
vwarnc(code, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
verrc(int status, int code, const char *format, va_list ap)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: ", getprogname());
|
||||||
|
if (format) {
|
||||||
|
vfprintf(stderr, format, ap);
|
||||||
|
fprintf(stderr, ": ");
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s\n", strerror(code));
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
errc(int status, int code, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
verrc(status, code, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
@@ -1,43 +1,72 @@
|
|||||||
|
#include "config.h"
|
||||||
|
|
||||||
LIBBSD_0.0 {
|
LIBBSD_0.0 {
|
||||||
global:
|
global:
|
||||||
|
#if LIBBSD_ABI_ARC4RANDOM
|
||||||
arc4random;
|
arc4random;
|
||||||
|
#endif
|
||||||
|
#if LIBBSD_ABI_ARC4RANDOM_STIR
|
||||||
arc4random_stir;
|
arc4random_stir;
|
||||||
arc4random_addrandom;
|
arc4random_addrandom;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_BSD_GETOPT
|
||||||
bsd_getopt;
|
bsd_getopt;
|
||||||
optreset;
|
optreset;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_ERRC
|
||||||
errc;
|
errc;
|
||||||
warnc;
|
warnc;
|
||||||
verrc;
|
verrc;
|
||||||
vwarnc;
|
vwarnc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_FGETLN
|
||||||
fgetln;
|
fgetln;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_FMTCHECK
|
||||||
fmtcheck;
|
fmtcheck;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_SORT
|
||||||
heapsort;
|
heapsort;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_HUMANIZE_NUMBER
|
||||||
humanize_number;
|
humanize_number;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* XXX: Already provided by glibc, remove. */
|
#if LIBBSD_ABI_INET_NET_PTON
|
||||||
inet_net_pton;
|
inet_net_pton;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_PROGNAME
|
||||||
getprogname;
|
getprogname;
|
||||||
setprogname;
|
setprogname;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_STRL
|
||||||
strlcpy;
|
strlcpy;
|
||||||
strlcat;
|
strlcat;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_ACCMODE
|
||||||
setmode;
|
setmode;
|
||||||
getmode;
|
getmode;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_VIS
|
||||||
vis;
|
vis;
|
||||||
strvis;
|
strvis;
|
||||||
strvisx;
|
strvisx;
|
||||||
unvis;
|
unvis;
|
||||||
strunvis;
|
strunvis;
|
||||||
strunvisx;
|
strunvisx;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following functions are provided via the system libc or libmd
|
#if LIBBSD_ABI_MD5
|
||||||
* implementations. */
|
|
||||||
MD5Init;
|
MD5Init;
|
||||||
MD5Update;
|
MD5Update;
|
||||||
MD5Pad;
|
MD5Pad;
|
||||||
@@ -47,89 +76,138 @@ LIBBSD_0.0 {
|
|||||||
MD5File;
|
MD5File;
|
||||||
MD5FileChunk;
|
MD5FileChunk;
|
||||||
MD5Data;
|
MD5Data;
|
||||||
|
#endif
|
||||||
|
|
||||||
local:
|
local:
|
||||||
*;
|
*;
|
||||||
};
|
};
|
||||||
|
|
||||||
LIBBSD_0.1 {
|
LIBBSD_0.1 {
|
||||||
|
#if LIBBSD_ABI_STRMODE
|
||||||
strmode;
|
strmode;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_NLIST
|
||||||
/* Private symbol, but libkvm uses it. */
|
/* Private symbol, but libkvm uses it. */
|
||||||
__fdnlist;
|
__fdnlist;
|
||||||
nlist;
|
nlist;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.0;
|
} LIBBSD_0.0;
|
||||||
|
|
||||||
LIBBSD_0.2 {
|
LIBBSD_0.2 {
|
||||||
|
#if LIBBSD_ABI_STRTONUM
|
||||||
strtonum;
|
strtonum;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_VIS
|
||||||
strnvis;
|
strnvis;
|
||||||
strnunvis;
|
strnunvis;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_HUMANIZE_NUMBER
|
||||||
dehumanize_number;
|
dehumanize_number;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_READPASSPHRASE
|
||||||
readpassphrase;
|
readpassphrase;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_FLOPEN
|
||||||
flopen;
|
flopen;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_PIDFILE
|
||||||
pidfile_open;
|
pidfile_open;
|
||||||
pidfile_write;
|
pidfile_write;
|
||||||
pidfile_close;
|
pidfile_close;
|
||||||
pidfile_remove;
|
pidfile_remove;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_ARC4RANDOM
|
||||||
arc4random_buf;
|
arc4random_buf;
|
||||||
arc4random_uniform;
|
arc4random_uniform;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.1;
|
} LIBBSD_0.1;
|
||||||
|
|
||||||
LIBBSD_0.3 {
|
LIBBSD_0.3 {
|
||||||
|
#if LIBBSD_ABI_REALLOCF
|
||||||
reallocf;
|
reallocf;
|
||||||
getpeereid;
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_GETPEEREID
|
||||||
|
getpeereid;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_SORT
|
||||||
mergesort;
|
mergesort;
|
||||||
radixsort;
|
radixsort;
|
||||||
sradixsort;
|
sradixsort;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_FPURGE
|
||||||
fpurge;
|
fpurge;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.2;
|
} LIBBSD_0.2;
|
||||||
|
|
||||||
LIBBSD_0.4 {
|
LIBBSD_0.4 {
|
||||||
|
#if LIBBSD_ABI_CLOSEFROM
|
||||||
closefrom;
|
closefrom;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_EXPAND_NUMBER
|
||||||
expand_number;
|
expand_number;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.3;
|
} LIBBSD_0.3;
|
||||||
|
|
||||||
LIBBSD_0.5 {
|
LIBBSD_0.5 {
|
||||||
|
#if LIBBSD_ABI_FGETLN
|
||||||
fgetwln;
|
fgetwln;
|
||||||
fparseln;
|
fparseln;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_PROCTITLE
|
||||||
/* Introduced in 0.2 as a stub, implemented in 0.5. */
|
/* Introduced in 0.2 as a stub, implemented in 0.5. */
|
||||||
setproctitle;
|
setproctitle;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_STRNSTR
|
||||||
strnstr;
|
strnstr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_WCSL
|
||||||
wcslcat;
|
wcslcat;
|
||||||
wcslcpy;
|
wcslcpy;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.4;
|
} LIBBSD_0.4;
|
||||||
|
|
||||||
LIBBSD_0.6 {
|
LIBBSD_0.6 {
|
||||||
|
#if LIBBSD_ABI_PROCTITLE
|
||||||
/* Exported to cope with the constructor+dlopen+threads mess. */
|
/* Exported to cope with the constructor+dlopen+threads mess. */
|
||||||
setproctitle_init;
|
setproctitle_init;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.5;
|
} LIBBSD_0.5;
|
||||||
|
|
||||||
LIBBSD_0.7 {
|
LIBBSD_0.7 {
|
||||||
|
#if LIBBSD_ABI_GETBSIZE
|
||||||
getbsize;
|
getbsize;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This symbol might not be present on some specific systems, such
|
#if LIBBSD_ABI_FUNOPEN
|
||||||
* as musl based ones. It might need to be removed on SOVERSION bump,
|
|
||||||
* as it cannot be portabily implemented everywhere. */
|
|
||||||
funopen;
|
funopen;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_REALLOCARRAY
|
||||||
reallocarray;
|
reallocarray;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_STRINGLIST
|
||||||
sl_init;
|
sl_init;
|
||||||
sl_add;
|
sl_add;
|
||||||
sl_free;
|
sl_free;
|
||||||
sl_find;
|
sl_find;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_TIMECONV
|
||||||
_time32_to_time;
|
_time32_to_time;
|
||||||
_time_to_time32;
|
_time_to_time32;
|
||||||
_time64_to_time;
|
_time64_to_time;
|
||||||
@@ -138,20 +216,30 @@ LIBBSD_0.7 {
|
|||||||
_long_to_time;
|
_long_to_time;
|
||||||
_time_to_int;
|
_time_to_int;
|
||||||
_int_to_time;
|
_int_to_time;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.6;
|
} LIBBSD_0.6;
|
||||||
|
|
||||||
LIBBSD_0.8 {
|
LIBBSD_0.8 {
|
||||||
|
#if LIBBSD_ABI_EXPLICIT_BZERO
|
||||||
explicit_bzero;
|
explicit_bzero;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.7;
|
} LIBBSD_0.7;
|
||||||
|
|
||||||
LIBBSD_0.9 {
|
LIBBSD_0.9 {
|
||||||
|
#if LIBBSD_ABI_FLOPEN
|
||||||
flopenat;
|
flopenat;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_PIDFILE
|
||||||
pidfile_fileno;
|
pidfile_fileno;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_STRTOX
|
||||||
strtoi;
|
strtoi;
|
||||||
strtou;
|
strtou;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_VIS
|
||||||
nvis;
|
nvis;
|
||||||
snvis;
|
snvis;
|
||||||
stravis;
|
stravis;
|
||||||
@@ -163,19 +251,21 @@ LIBBSD_0.9 {
|
|||||||
strsvis;
|
strsvis;
|
||||||
strsvisx;
|
strsvisx;
|
||||||
svis;
|
svis;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.8;
|
} LIBBSD_0.8;
|
||||||
|
|
||||||
LIBBSD_0.9.1 {
|
LIBBSD_0.9.1 {
|
||||||
|
#if LIBBSD_ABI_VIS
|
||||||
/* The strnvis() and strnunvis() symbols changed prototype to match
|
/* The strnvis() and strnunvis() symbols changed prototype to match
|
||||||
* the NetBSD implementation. Provided as versioned nodes in 0.9.1, and
|
* the NetBSD implementation. Provided as versioned nodes in 0.9.1, and
|
||||||
* exposed here explicitly so that we can redirect at compile-time. */
|
* exposed here explicitly so that we can redirect at compile-time. */
|
||||||
strnvis_netbsd;
|
strnvis_netbsd;
|
||||||
strnunvis_netbsd;
|
strnunvis_netbsd;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.9;
|
} LIBBSD_0.9;
|
||||||
|
|
||||||
LIBBSD_0.10.0 {
|
LIBBSD_0.10.0 {
|
||||||
/* These BSD extensions are available on GNU systems, but not on other
|
#if LIBBSD_ABI_ERR
|
||||||
* systems such as Windows or musl libc based ones. */
|
|
||||||
vwarn;
|
vwarn;
|
||||||
vwarnx;
|
vwarnx;
|
||||||
warn;
|
warn;
|
||||||
@@ -184,16 +274,46 @@ LIBBSD_0.10.0 {
|
|||||||
verrx;
|
verrx;
|
||||||
err;
|
err;
|
||||||
errx;
|
errx;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.9.1;
|
} LIBBSD_0.9.1;
|
||||||
|
|
||||||
LIBBSD_0.11.0 {
|
LIBBSD_0.11.0 {
|
||||||
|
#if LIBBSD_ABI_VIS
|
||||||
strnvisx;
|
strnvisx;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_RECALLOCARRAY
|
||||||
recallocarray;
|
recallocarray;
|
||||||
freezero;
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_FREEZERO
|
||||||
|
freezero;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_ID_FROM_NAME
|
||||||
gid_from_group;
|
gid_from_group;
|
||||||
group_from_gid;
|
|
||||||
uid_from_user;
|
uid_from_user;
|
||||||
|
#endif
|
||||||
|
#if LIBBSD_ABI_NAME_FROM_ID
|
||||||
user_from_uid;
|
user_from_uid;
|
||||||
|
group_from_gid;
|
||||||
|
#endif
|
||||||
} LIBBSD_0.10.0;
|
} LIBBSD_0.10.0;
|
||||||
|
|
||||||
|
LIBBSD_0.12.0 {
|
||||||
|
#if LIBBSD_ABI_ASPRINTF
|
||||||
|
vasprintf;
|
||||||
|
asprintf;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_ABI_TIMECONV && LIBBSD_ABI_TIME64
|
||||||
|
_time32_to_time_time64;
|
||||||
|
_time_to_time32_time64;
|
||||||
|
_time64_to_time_time64;
|
||||||
|
_time_to_time64_time64;
|
||||||
|
_time_to_long_time64;
|
||||||
|
_long_to_time_time64;
|
||||||
|
_time_to_int_time64;
|
||||||
|
_int_to_time_time64;
|
||||||
|
#endif
|
||||||
|
} LIBBSD_0.11.0;
|
@@ -38,47 +38,47 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#define libbsd_strong_alias(alias, symbol) \
|
#define libbsd_strong_alias(symbol, alias) \
|
||||||
__asm__(".globl _" #alias); \
|
__asm__(".globl _" #alias); \
|
||||||
__asm__(".set _" #alias ", _" #symbol); \
|
__asm__(".set _" #alias ", _" #symbol); \
|
||||||
extern __typeof(symbol) alias
|
extern __typeof(symbol) alias
|
||||||
#elif !defined(_MSC_VER)
|
#elif !defined(_MSC_VER)
|
||||||
#define libbsd_strong_alias(alias, symbol) \
|
#define libbsd_strong_alias(symbol, alias) \
|
||||||
extern __typeof__(symbol) alias __attribute__((__alias__(#symbol)))
|
extern __typeof__(symbol) alias __attribute__((__alias__(#symbol)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __ELF__
|
#if defined(__ELF__) && !defined(__sun)
|
||||||
# if __has_attribute(symver)
|
# if __has_attribute(symver)
|
||||||
/* The symver attribute is supported since gcc 10.x. */
|
/* The symver attribute is supported since gcc 10.x. */
|
||||||
#define libbsd_symver_default(alias, symbol, version) \
|
#define libbsd_symver_default(symbol, alias, version) \
|
||||||
extern __typeof__(symbol) symbol \
|
extern __typeof__(symbol) symbol \
|
||||||
__attribute__((__symver__(#alias "@@" #version)))
|
__attribute__((__symver__(#alias "@@" #version)))
|
||||||
#define libbsd_symver_variant(alias, symbol, version) \
|
#define libbsd_symver_variant(symbol, alias, version) \
|
||||||
extern __typeof__(symbol) symbol \
|
extern __typeof__(symbol) symbol \
|
||||||
__attribute__((__symver__(#alias "@" #version)))
|
__attribute__((__symver__(#alias "@" #version)))
|
||||||
|
|
||||||
#define libbsd_symver_weak(alias, symbol, version) \
|
#define libbsd_symver_weak(symbol, alias, version) \
|
||||||
extern __typeof__(symbol) symbol \
|
extern __typeof__(symbol) symbol \
|
||||||
__attribute__((__symver__(#alias "@" #version), __weak__))
|
__attribute__((__symver__(#alias "@" #version), __weak__))
|
||||||
# else
|
# else
|
||||||
#define libbsd_symver_default(alias, symbol, version) \
|
#define libbsd_symver_default(symbol, alias, version) \
|
||||||
__asm__(".symver " #symbol "," #alias "@@" #version)
|
__asm__(".symver " #symbol "," #alias "@@" #version)
|
||||||
|
|
||||||
#define libbsd_symver_variant(alias, symbol, version) \
|
#define libbsd_symver_variant(symbol, alias, version) \
|
||||||
__asm__(".symver " #symbol "," #alias "@" #version)
|
__asm__(".symver " #symbol "," #alias "@" #version)
|
||||||
|
|
||||||
#define libbsd_symver_weak(alias, symbol, version) \
|
#define libbsd_symver_weak(symbol, alias, version) \
|
||||||
libbsd_symver_variant(alias, symbol, version); \
|
libbsd_symver_variant(symbol, alias, version); \
|
||||||
extern __typeof__(symbol) alias \
|
extern __typeof__(symbol) alias \
|
||||||
__attribute__((__weak__))
|
__attribute__((__weak__))
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
#define libbsd_symver_default(alias, symbol, version) \
|
#define libbsd_symver_default(symbol, alias, version) \
|
||||||
libbsd_strong_alias(alias, symbol)
|
libbsd_strong_alias(symbol, alias)
|
||||||
|
|
||||||
#define libbsd_symver_variant(alias, symbol, version)
|
#define libbsd_symver_variant(symbol, alias, version)
|
||||||
|
|
||||||
#define libbsd_symver_weak(alias, symbol, version)
|
#define libbsd_symver_weak(symbol, alias, version)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
18
src/md5.c
18
src/md5.c
@@ -37,7 +37,7 @@ libbsd_MD5Init(MD5_CTX *context)
|
|||||||
libbsd_link_warning(MD5Init,
|
libbsd_link_warning(MD5Init,
|
||||||
"The MD5Init() function in libbsd is a deprecated wrapper, "
|
"The MD5Init() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5Init, libbsd_MD5Init, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5Init, MD5Init, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
libbsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
|
libbsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
|
||||||
@@ -47,7 +47,7 @@ libbsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
|
|||||||
libbsd_link_warning(MD5Update,
|
libbsd_link_warning(MD5Update,
|
||||||
"The MD5Update() function in libbsd is a deprecated wrapper, "
|
"The MD5Update() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5Update, libbsd_MD5Update, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5Update, MD5Update, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
libbsd_MD5Pad(MD5_CTX *context)
|
libbsd_MD5Pad(MD5_CTX *context)
|
||||||
@@ -57,7 +57,7 @@ libbsd_MD5Pad(MD5_CTX *context)
|
|||||||
libbsd_link_warning(MD5Pad,
|
libbsd_link_warning(MD5Pad,
|
||||||
"The MD5Pad() function in libbsd is a deprecated wrapper, "
|
"The MD5Pad() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5Pad, libbsd_MD5Pad, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5Pad, MD5Pad, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
libbsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
|
libbsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
|
||||||
@@ -67,7 +67,7 @@ libbsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
|
|||||||
libbsd_link_warning(MD5Final,
|
libbsd_link_warning(MD5Final,
|
||||||
"The MD5Final() function in libbsd is a deprecated wrapper, "
|
"The MD5Final() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5Final, libbsd_MD5Final, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5Final, MD5Final, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
libbsd_MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
|
libbsd_MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
|
||||||
@@ -77,7 +77,7 @@ libbsd_MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
|
|||||||
libbsd_link_warning(MD5Transform,
|
libbsd_link_warning(MD5Transform,
|
||||||
"The MD5Transform() function in libbsd is a deprecated wrapper, "
|
"The MD5Transform() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5Transform, libbsd_MD5Transform, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5Transform, MD5Transform, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
libbsd_MD5End(MD5_CTX *context, char *buf)
|
libbsd_MD5End(MD5_CTX *context, char *buf)
|
||||||
@@ -87,7 +87,7 @@ libbsd_MD5End(MD5_CTX *context, char *buf)
|
|||||||
libbsd_link_warning(MD5End,
|
libbsd_link_warning(MD5End,
|
||||||
"The MD5End() function in libbsd is a deprecated wrapper, "
|
"The MD5End() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5End, libbsd_MD5End, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5End, MD5End, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
libbsd_MD5File(const char *filename, char *buf)
|
libbsd_MD5File(const char *filename, char *buf)
|
||||||
@@ -97,7 +97,7 @@ libbsd_MD5File(const char *filename, char *buf)
|
|||||||
libbsd_link_warning(MD5File,
|
libbsd_link_warning(MD5File,
|
||||||
"The MD5File() function in libbsd is a deprecated wrapper, "
|
"The MD5File() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5File, libbsd_MD5File, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5File, MD5File, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
libbsd_MD5FileChunk(const char *filename, char *buf, off_t offset, off_t length)
|
libbsd_MD5FileChunk(const char *filename, char *buf, off_t offset, off_t length)
|
||||||
@@ -107,7 +107,7 @@ libbsd_MD5FileChunk(const char *filename, char *buf, off_t offset, off_t length)
|
|||||||
libbsd_link_warning(MD5FileChunk,
|
libbsd_link_warning(MD5FileChunk,
|
||||||
"The MD5FileChunk() function in libbsd is a deprecated wrapper, "
|
"The MD5FileChunk() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5FileChunk, libbsd_MD5FileChunk, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5FileChunk, MD5FileChunk, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
libbsd_MD5Data(const uint8_t *data, size_t len, char *buf)
|
libbsd_MD5Data(const uint8_t *data, size_t len, char *buf)
|
||||||
@@ -117,4 +117,4 @@ libbsd_MD5Data(const uint8_t *data, size_t len, char *buf)
|
|||||||
libbsd_link_warning(MD5Data,
|
libbsd_link_warning(MD5Data,
|
||||||
"The MD5Data() function in libbsd is a deprecated wrapper, "
|
"The MD5Data() function in libbsd is a deprecated wrapper, "
|
||||||
"use libmd instead.");
|
"use libmd instead.");
|
||||||
libbsd_symver_weak(MD5Data, libbsd_MD5Data, LIBBSD_0.0);
|
libbsd_symver_weak(libbsd_MD5Data, MD5Data, LIBBSD_0.0);
|
||||||
|
@@ -289,17 +289,17 @@ setproctitle_impl(const char *fmt, ...)
|
|||||||
*++nul = '\0';
|
*++nul = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5);
|
libbsd_symver_default(setproctitle_impl, setproctitle, LIBBSD_0.5);
|
||||||
|
|
||||||
/* The original function introduced in 0.2 was a stub, it only got implemented
|
/* The original function introduced in 0.2 was a stub, it only got implemented
|
||||||
* in 0.5, make the implementation available in the old version as an alias
|
* in 0.5, make the implementation available in the old version as an alias
|
||||||
* for code linking against that version, and change the default to use the
|
* for code linking against that version, and change the default to use the
|
||||||
* new version, so that new code depends on the implemented version. */
|
* new version, so that new code depends on the implemented version. */
|
||||||
#if defined(libbsd_strong_alias)
|
#if defined(libbsd_strong_alias)
|
||||||
libbsd_strong_alias(setproctitle_stub, setproctitle_impl);
|
libbsd_strong_alias(setproctitle_impl, setproctitle_stub);
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
setproctitle_stub(const char *fmt, ...)
|
setproctitle_stub(const char *fmt, ...)
|
||||||
__attribute__((__alias__("setproctitle_impl")));
|
__attribute__((__alias__("setproctitle_impl")));
|
||||||
#endif
|
#endif
|
||||||
libbsd_symver_variant(setproctitle, setproctitle_stub, LIBBSD_0.2);
|
libbsd_symver_variant(setproctitle_stub, setproctitle, LIBBSD_0.2);
|
||||||
|
16
src/strtoi.c
16
src/strtoi.c
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: _strtoi.h,v 1.2 2015/01/18 17:55:22 christos Exp $ */
|
/* $NetBSD: _strtoi.h,v 1.3 2024/01/20 16:13:39 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
* NetBSD: src/lib/libc/locale/_wcstoul.h,v 1.2 2003/08/07 16:43:03 agc Exp
|
* NetBSD: src/lib/libc/locale/_wcstoul.h,v 1.2 2003/08/07 16:43:03 agc Exp
|
||||||
*
|
*
|
||||||
* Created by Kamil Rytarowski, based on ID:
|
* Created by Kamil Rytarowski, based on ID:
|
||||||
* NetBSD: src/common/lib/libc/stdlib/_strtoul.h,v 1.7 2013/05/17 12:55:56 joe…
|
* NetBSD: src/common/lib/libc/stdlib/_strtoul.h,v 1.7 2013/05/17 12:55:56 joerg Exp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
@@ -73,25 +73,25 @@ strtoi(const char *__restrict nptr,
|
|||||||
*rstatus = errno;
|
*rstatus = errno;
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
|
|
||||||
if (*rstatus == 0) {
|
|
||||||
/* No digits were found */
|
/* No digits were found */
|
||||||
if (nptr == *endptr)
|
if (*rstatus == 0 && nptr == *endptr)
|
||||||
*rstatus = ECANCELED;
|
*rstatus = ECANCELED;
|
||||||
/* There are further characters after number */
|
|
||||||
else if (**endptr != '\0')
|
|
||||||
*rstatus = ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (im < lo) {
|
if (im < lo) {
|
||||||
if (*rstatus == 0)
|
if (*rstatus == 0)
|
||||||
*rstatus = ERANGE;
|
*rstatus = ERANGE;
|
||||||
return lo;
|
return lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (im > hi) {
|
if (im > hi) {
|
||||||
if (*rstatus == 0)
|
if (*rstatus == 0)
|
||||||
*rstatus = ERANGE;
|
*rstatus = ERANGE;
|
||||||
return hi;
|
return hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* There are further characters after number */
|
||||||
|
if (*rstatus == 0 && **endptr != '\0')
|
||||||
|
*rstatus = ENOTSUP;
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: strtonum.c,v 1.5 2018/01/04 20:57:29 kamil Exp $ */
|
/* $NetBSD: strtonum.c,v 1.7 2024/01/20 16:13:39 christos Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@@ -42,21 +42,33 @@ strtonum(const char *nptr, long long minval, long long maxval,
|
|||||||
int e;
|
int e;
|
||||||
long long rv;
|
long long rv;
|
||||||
const char *resp;
|
const char *resp;
|
||||||
|
char *eptr;
|
||||||
|
|
||||||
if (errstr == NULL)
|
if (errstr == NULL)
|
||||||
errstr = &resp;
|
errstr = &resp;
|
||||||
|
|
||||||
rv = (long long)strtoi(nptr, NULL, 10, minval, maxval, &e);
|
if (minval > maxval)
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (e == 0) {
|
rv = (long long)strtoi(nptr, &eptr, 10, minval, maxval, &e);
|
||||||
|
|
||||||
|
switch (e) {
|
||||||
|
case 0:
|
||||||
*errstr = NULL;
|
*errstr = NULL;
|
||||||
return rv;
|
return rv;
|
||||||
|
case ECANCELED:
|
||||||
|
case ENOTSUP:
|
||||||
|
goto out;
|
||||||
|
case ERANGE:
|
||||||
|
if (*eptr)
|
||||||
|
goto out;
|
||||||
|
*errstr = rv == maxval ? "too large" : "too small";
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e == ERANGE)
|
out:
|
||||||
*errstr = (rv == maxval ? "too large" : "too small");
|
|
||||||
else
|
|
||||||
*errstr = "invalid";
|
*errstr = "invalid";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
14
src/strtou.c
14
src/strtou.c
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: _strtoi.h,v 1.2 2015/01/18 17:55:22 christos Exp $ */
|
/* $NetBSD: _strtoi.h,v 1.3 2024/01/20 16:13:39 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
@@ -73,25 +73,25 @@ strtou(const char *__restrict nptr,
|
|||||||
*rstatus = errno;
|
*rstatus = errno;
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
|
|
||||||
if (*rstatus == 0) {
|
|
||||||
/* No digits were found */
|
/* No digits were found */
|
||||||
if (nptr == *endptr)
|
if (*rstatus == 0 && nptr == *endptr)
|
||||||
*rstatus = ECANCELED;
|
*rstatus = ECANCELED;
|
||||||
/* There are further characters after number */
|
|
||||||
else if (**endptr != '\0')
|
|
||||||
*rstatus = ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (im < lo) {
|
if (im < lo) {
|
||||||
if (*rstatus == 0)
|
if (*rstatus == 0)
|
||||||
*rstatus = ERANGE;
|
*rstatus = ERANGE;
|
||||||
return lo;
|
return lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (im > hi) {
|
if (im > hi) {
|
||||||
if (*rstatus == 0)
|
if (*rstatus == 0)
|
||||||
*rstatus = ERANGE;
|
*rstatus = ERANGE;
|
||||||
return hi;
|
return hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* There are further characters after number */
|
||||||
|
if (*rstatus == 0 && **endptr != '\0')
|
||||||
|
*rstatus = ENOTSUP;
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
208
src/timeconv.c
208
src/timeconv.c
@@ -32,17 +32,55 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <timeconv.h>
|
|
||||||
|
#include "local-link.h"
|
||||||
|
|
||||||
|
#if LIBBSD_SYS_TIME_BITS == 64
|
||||||
|
/*
|
||||||
|
* - enable time64 functions
|
||||||
|
* - symver libbsd<func>_time64 -> <func> 0.7
|
||||||
|
*/
|
||||||
|
#define time32_symbol(name)
|
||||||
|
#define time64_symbol(name) \
|
||||||
|
libbsd_strong_alias(libbsd ## name ## _time64, name)
|
||||||
|
#elif LIBBSD_SYS_TIME_BITS == 32 && LIBBSD_SYS_HAS_TIME64
|
||||||
|
/*
|
||||||
|
* - enable time32 functions
|
||||||
|
* - enable time64 functions
|
||||||
|
* - symver libbsd<func>_time32 -> <func> 0.7
|
||||||
|
* - map libbsd<func>_time64 <func>_time64 0.12
|
||||||
|
*/
|
||||||
|
#define time32_symbol(name) \
|
||||||
|
libbsd_strong_alias(libbsd ## name ## _time32, name)
|
||||||
|
#define time64_symbol(name) \
|
||||||
|
libbsd_strong_alias(libbsd ## name ## _time64, name ## _time64)
|
||||||
|
#elif LIBBSD_SYS_TIME_BITS == 32 && !LIBBSD_SYS_HAS_TIME64
|
||||||
|
/*
|
||||||
|
* - enable time32 functions
|
||||||
|
* - symver libbsd<func>_time32 -> <func>
|
||||||
|
*/
|
||||||
|
#define time32_symbol(name) \
|
||||||
|
libbsd_strong_alias(libbsd ## name ## _time32, name)
|
||||||
|
#define time64_symbol(name)
|
||||||
|
#else
|
||||||
|
#error "Unknown time_t support"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_SYS_HAS_TIME64
|
||||||
|
typedef int64_t libbsd_time64_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a 32 bit representation of time_t into time_t. XXX needs to
|
* Convert a 32 bit representation of time_t into time_t. XXX needs to
|
||||||
* implement the 50-year rule to handle post-2038 conversions.
|
* implement the 50-year rule to handle post-2038 conversions.
|
||||||
*/
|
*/
|
||||||
time_t
|
libbsd_time64_t
|
||||||
_time32_to_time(int32_t t32)
|
libbsd_time32_to_time_time64(int32_t t32);
|
||||||
|
libbsd_time64_t
|
||||||
|
libbsd_time32_to_time_time64(int32_t t32)
|
||||||
{
|
{
|
||||||
return((time_t)t32);
|
return((libbsd_time64_t)t32);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_time32_to_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert time_t to a 32 bit representation. If time_t is 64 bits we can
|
* Convert time_t to a 32 bit representation. If time_t is 64 bits we can
|
||||||
@@ -50,68 +88,196 @@ _time32_to_time(int32_t t32)
|
|||||||
* converted back to a temporally local 64 bit time_t using time32_to_time.
|
* converted back to a temporally local 64 bit time_t using time32_to_time.
|
||||||
*/
|
*/
|
||||||
int32_t
|
int32_t
|
||||||
_time_to_time32(time_t t)
|
libbsd_time_to_time32_time64(libbsd_time64_t t);
|
||||||
|
int32_t
|
||||||
|
libbsd_time_to_time32_time64(libbsd_time64_t t)
|
||||||
{
|
{
|
||||||
return((int32_t)t);
|
return((int32_t)t);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_time_to_time32);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a 64 bit representation of time_t into time_t. If time_t is
|
* Convert a 64 bit representation of time_t into time_t. If time_t is
|
||||||
* represented as 32 bits we can simply chop it and not support times
|
* represented as 32 bits we can simply chop it and not support times
|
||||||
* past 2038.
|
* past 2038.
|
||||||
*/
|
*/
|
||||||
time_t
|
libbsd_time64_t
|
||||||
_time64_to_time(int64_t t64)
|
libbsd_time64_to_time_time64(int64_t t64);
|
||||||
|
libbsd_time64_t
|
||||||
|
libbsd_time64_to_time_time64(int64_t t64)
|
||||||
{
|
{
|
||||||
return((time_t)t64);
|
return((libbsd_time64_t)t64);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_time64_to_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert time_t to a 64 bit representation. If time_t is represented
|
* Convert time_t to a 64 bit representation. If time_t is represented
|
||||||
* as 32 bits we simply sign-extend and do not support times past 2038.
|
* as 32 bits we simply sign-extend and do not support times past 2038.
|
||||||
*/
|
*/
|
||||||
int64_t
|
int64_t
|
||||||
_time_to_time64(time_t t)
|
libbsd_time_to_time64_time64(libbsd_time64_t t);
|
||||||
|
int64_t
|
||||||
|
libbsd_time_to_time64_time64(libbsd_time64_t t)
|
||||||
{
|
{
|
||||||
return((int64_t)t);
|
return((int64_t)t);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_time_to_time64);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert to/from 'long'. Depending on the sizeof(long) this may or
|
* Convert to/from 'long'. Depending on the sizeof(long) this may or
|
||||||
* may not require using the 50-year rule.
|
* may not require using the 50-year rule.
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
_time_to_long(time_t t)
|
libbsd_time_to_long_time64(libbsd_time64_t t);
|
||||||
|
long
|
||||||
|
libbsd_time_to_long_time64(libbsd_time64_t t)
|
||||||
{
|
{
|
||||||
if (sizeof(long) == sizeof(int64_t))
|
if (sizeof(long) == sizeof(int64_t))
|
||||||
return(_time_to_time64(t));
|
return(libbsd_time_to_time64_time64(t));
|
||||||
return((long)t);
|
return((long)t);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_time_to_long);
|
||||||
|
|
||||||
time_t
|
libbsd_time64_t
|
||||||
_long_to_time(long tlong)
|
libbsd_long_to_time_time64(long tlong);
|
||||||
|
libbsd_time64_t
|
||||||
|
libbsd_long_to_time_time64(long tlong)
|
||||||
{
|
{
|
||||||
if (sizeof(long) == sizeof(int32_t))
|
if (sizeof(long) == sizeof(int32_t))
|
||||||
return(_time32_to_time(tlong));
|
return(libbsd_time32_to_time_time64(tlong));
|
||||||
return((time_t)tlong);
|
return((libbsd_time64_t)tlong);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_long_to_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert to/from 'int'. Depending on the sizeof(int) this may or
|
* Convert to/from 'int'. Depending on the sizeof(int) this may or
|
||||||
* may not require using the 50-year rule.
|
* may not require using the 50-year rule.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
_time_to_int(time_t t)
|
libbsd_time_to_int_time64(time_t t);
|
||||||
|
int
|
||||||
|
libbsd_time_to_int_time64(time_t t)
|
||||||
{
|
{
|
||||||
if (sizeof(int) == sizeof(int64_t))
|
if (sizeof(int) == sizeof(int64_t))
|
||||||
return(_time_to_time64(t));
|
return(libbsd_time_to_time64_time64(t));
|
||||||
return((int)t);
|
return((int)t);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_time_to_int);
|
||||||
|
|
||||||
time_t
|
libbsd_time64_t
|
||||||
_int_to_time(int tint)
|
libbsd_int_to_time_time64(int tint);
|
||||||
|
libbsd_time64_t
|
||||||
|
libbsd_int_to_time_time64(int tint)
|
||||||
{
|
{
|
||||||
if (sizeof(int) == sizeof(int32_t))
|
if (sizeof(int) == sizeof(int32_t))
|
||||||
return(_time32_to_time(tint));
|
return(libbsd_time32_to_time_time64(tint));
|
||||||
return((time_t)tint);
|
return((libbsd_time64_t)tint);
|
||||||
}
|
}
|
||||||
|
time64_symbol(_int_to_time);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_SYS_TIME_BITS == 32
|
||||||
|
typedef int32_t libbsd_time32_t;
|
||||||
|
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_time32_to_time_time32(int32_t t32);
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_time32_to_time_time32(int32_t t32)
|
||||||
|
{
|
||||||
|
return((libbsd_time32_t)t32);
|
||||||
|
}
|
||||||
|
time32_symbol(_time32_to_time);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert time_t to a 32 bit representation. If time_t is 64 bits we can
|
||||||
|
* simply chop it down. The resulting 32 bit representation can be
|
||||||
|
* converted back to a temporally local 64 bit time_t using time32_to_time.
|
||||||
|
*/
|
||||||
|
int32_t
|
||||||
|
libbsd_time_to_time32_time32(libbsd_time32_t t);
|
||||||
|
int32_t
|
||||||
|
libbsd_time_to_time32_time32(libbsd_time32_t t)
|
||||||
|
{
|
||||||
|
return((int32_t)t);
|
||||||
|
}
|
||||||
|
time32_symbol(_time_to_time32);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a 64 bit representation of time_t into time_t. If time_t is
|
||||||
|
* represented as 32 bits we can simply chop it and not support times
|
||||||
|
* past 2038.
|
||||||
|
*/
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_time64_to_time_time32(int64_t t64);
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_time64_to_time_time32(int64_t t64)
|
||||||
|
{
|
||||||
|
return((libbsd_time32_t)t64);
|
||||||
|
}
|
||||||
|
time32_symbol(_time64_to_time);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert time_t to a 64 bit representation. If time_t is represented
|
||||||
|
* as 32 bits we simply sign-extend and do not support times past 2038.
|
||||||
|
*/
|
||||||
|
int64_t
|
||||||
|
libbsd_time_to_time64_time32(libbsd_time32_t t);
|
||||||
|
int64_t
|
||||||
|
libbsd_time_to_time64_time32(libbsd_time32_t t)
|
||||||
|
{
|
||||||
|
return((int64_t)t);
|
||||||
|
}
|
||||||
|
time32_symbol(_time_to_time64);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert to/from 'long'. Depending on the sizeof(long) this may or
|
||||||
|
* may not require using the 50-year rule.
|
||||||
|
*/
|
||||||
|
long
|
||||||
|
libbsd_time_to_long_time32(libbsd_time32_t t);
|
||||||
|
long
|
||||||
|
libbsd_time_to_long_time32(libbsd_time32_t t)
|
||||||
|
{
|
||||||
|
if (sizeof(long) == sizeof(int64_t))
|
||||||
|
return(libbsd_time_to_time64_time32(t));
|
||||||
|
return((long)t);
|
||||||
|
}
|
||||||
|
time32_symbol(_time_to_long);
|
||||||
|
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_long_to_time_time32(long tlong);
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_long_to_time_time32(long tlong)
|
||||||
|
{
|
||||||
|
if (sizeof(long) == sizeof(int32_t))
|
||||||
|
return(libbsd_time32_to_time_time32(tlong));
|
||||||
|
return((libbsd_time32_t)tlong);
|
||||||
|
}
|
||||||
|
time32_symbol(_long_to_time);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert to/from 'int'. Depending on the sizeof(int) this may or
|
||||||
|
* may not require using the 50-year rule.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
libbsd_time_to_int_time32(libbsd_time32_t t);
|
||||||
|
int
|
||||||
|
libbsd_time_to_int_time32(libbsd_time32_t t)
|
||||||
|
{
|
||||||
|
if (sizeof(int) == sizeof(int64_t))
|
||||||
|
return(libbsd_time_to_time64_time32(t));
|
||||||
|
return((int)t);
|
||||||
|
}
|
||||||
|
time32_symbol(_time_to_int);
|
||||||
|
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_int_to_time_time32(int tint);
|
||||||
|
libbsd_time32_t
|
||||||
|
libbsd_int_to_time_time32(int tint)
|
||||||
|
{
|
||||||
|
if (sizeof(int) == sizeof(int32_t))
|
||||||
|
return(libbsd_time32_to_time_time32(tint));
|
||||||
|
return((libbsd_time32_t)tint);
|
||||||
|
}
|
||||||
|
time32_symbol(_int_to_time);
|
||||||
|
#endif
|
||||||
|
@@ -554,7 +554,7 @@ strunvis(char *dst, const char *src)
|
|||||||
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
||||||
* for over ten years). Despite this incompatibility being reported during
|
* for over ten years). Despite this incompatibility being reported during
|
||||||
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
||||||
* Even more unfortunately FreeBSD and later MacOS picked up this incompatible
|
* Even more unfortunately FreeBSD and later macOS picked up this incompatible
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* Provide both implementations and default for now on the historical one to
|
* Provide both implementations and default for now on the historical one to
|
||||||
@@ -570,7 +570,7 @@ strnunvis_openbsd(char *dst, const char *src, size_t dlen)
|
|||||||
{
|
{
|
||||||
return strnunvisx(dst, dlen, src, 0);
|
return strnunvisx(dst, dlen, src, 0);
|
||||||
}
|
}
|
||||||
libbsd_symver_default(strnunvis, strnunvis_openbsd, LIBBSD_0.2);
|
libbsd_symver_default(strnunvis_openbsd, strnunvis, LIBBSD_0.2);
|
||||||
|
|
||||||
int
|
int
|
||||||
strnunvis_netbsd(char *, size_t, const char *);
|
strnunvis_netbsd(char *, size_t, const char *);
|
||||||
@@ -579,4 +579,4 @@ strnunvis_netbsd(char *dst, size_t dlen, const char *src)
|
|||||||
{
|
{
|
||||||
return strnunvisx(dst, dlen, src, 0);
|
return strnunvisx(dst, dlen, src, 0);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(strnunvis, strnunvis_netbsd, LIBBSD_0.9.1);
|
libbsd_symver_variant(strnunvis_netbsd, strnunvis, LIBBSD_0.9.1);
|
||||||
|
64
src/vasprintf.c
Normal file
64
src/vasprintf.c
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2010-2024 Guillem Jover <guillem@hadrons.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
vasprintf(char **strp, char const *fmt, va_list args)
|
||||||
|
{
|
||||||
|
va_list args_copy;
|
||||||
|
int needed, n;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
va_copy(args_copy, args);
|
||||||
|
needed = vsnprintf(NULL, 0, fmt, args_copy);
|
||||||
|
va_end(args_copy);
|
||||||
|
|
||||||
|
if (needed < 0) {
|
||||||
|
*strp = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = malloc(needed + 1);
|
||||||
|
if (str == NULL) {
|
||||||
|
*strp = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = vsnprintf(str, needed + 1, fmt, args);
|
||||||
|
if (n < 0) {
|
||||||
|
free(str);
|
||||||
|
str = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*strp = str;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
@@ -723,7 +723,7 @@ strvis(char *mbdst, const char *mbsrc, int flags)
|
|||||||
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
||||||
* for over ten years). Despite this incompatibility being reported during
|
* for over ten years). Despite this incompatibility being reported during
|
||||||
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
||||||
* Even more unfortunately FreeBSD and later MacOS picked up this incompatible
|
* Even more unfortunately FreeBSD and later macOS picked up this incompatible
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* Provide both implementations and default for now on the historical one to
|
* Provide both implementations and default for now on the historical one to
|
||||||
@@ -739,7 +739,7 @@ strnvis_openbsd(char *mbdst, const char *mbsrc, size_t dlen, int flags)
|
|||||||
{
|
{
|
||||||
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
|
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
|
||||||
}
|
}
|
||||||
libbsd_symver_default(strnvis, strnvis_openbsd, LIBBSD_0.2);
|
libbsd_symver_default(strnvis_openbsd, strnvis, LIBBSD_0.2);
|
||||||
|
|
||||||
int
|
int
|
||||||
strnvis_netbsd(char *, size_t, const char *, int);
|
strnvis_netbsd(char *, size_t, const char *, int);
|
||||||
@@ -748,7 +748,7 @@ strnvis_netbsd(char *mbdst, size_t dlen, const char *mbsrc, int flags)
|
|||||||
{
|
{
|
||||||
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
|
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(strnvis, strnvis_netbsd, LIBBSD_0.9.1);
|
libbsd_symver_variant(strnvis_netbsd, strnvis, LIBBSD_0.9.1);
|
||||||
|
|
||||||
int
|
int
|
||||||
stravis(char **mbdstp, const char *mbsrc, int flags)
|
stravis(char **mbdstp, const char *mbsrc, int flags)
|
||||||
|
2
test/.gitignore
vendored
2
test/.gitignore
vendored
@@ -22,5 +22,7 @@ strl
|
|||||||
strmode
|
strmode
|
||||||
strnstr
|
strnstr
|
||||||
strtonum
|
strtonum
|
||||||
|
timeconv32
|
||||||
|
timeconv64
|
||||||
vis
|
vis
|
||||||
vis-openbsd
|
vis-openbsd
|
||||||
|
171
test/Makefile.am
171
test/Makefile.am
@@ -33,78 +33,161 @@ check_SCRIPTS = \
|
|||||||
|
|
||||||
check_PROGRAMS = \
|
check_PROGRAMS = \
|
||||||
overlay \
|
overlay \
|
||||||
bzero \
|
|
||||||
closefrom \
|
|
||||||
endian \
|
endian \
|
||||||
explicit_bzero \
|
|
||||||
humanize \
|
|
||||||
fgetln \
|
|
||||||
fparseln \
|
|
||||||
proctitle-init \
|
|
||||||
pwcache \
|
|
||||||
setmode \
|
|
||||||
strnstr \
|
|
||||||
strtonum \
|
|
||||||
vis \
|
|
||||||
vis-openbsd \
|
|
||||||
# EOL
|
# EOL
|
||||||
|
|
||||||
if NEED_PROGNAME
|
if ABI_ACCMODE
|
||||||
check_PROGRAMS += progname
|
check_PROGRAMS += \
|
||||||
|
setmode \
|
||||||
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_NLIST
|
if ABI_ARC4RANDOM
|
||||||
check_PROGRAMS += nlist
|
if HAVE_LIBTESTU01
|
||||||
|
check_PROGRAMS += arc4random
|
||||||
|
|
||||||
|
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_STRL
|
if ABI_CLOSEFROM
|
||||||
check_PROGRAMS += strl
|
check_PROGRAMS += \
|
||||||
|
closefrom \
|
||||||
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_STRMODE
|
if ABI_EXPLICIT_BZERO
|
||||||
check_PROGRAMS += strmode
|
check_PROGRAMS += \
|
||||||
|
bzero \
|
||||||
|
explicit_bzero \
|
||||||
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_FPURGE
|
if ABI_FGETLN
|
||||||
|
check_PROGRAMS += \
|
||||||
|
fgetln \
|
||||||
|
fparseln \
|
||||||
|
# EOL
|
||||||
|
|
||||||
|
fgetln_SOURCES = \
|
||||||
|
test-stream.c \
|
||||||
|
test-stream.h \
|
||||||
|
fgetln.c \
|
||||||
|
# EOL
|
||||||
|
|
||||||
|
fgetln_CFLAGS = -Wno-deprecated-declarations
|
||||||
|
|
||||||
|
fparseln_SOURCES = \
|
||||||
|
test-stream.c \
|
||||||
|
test-stream.h \
|
||||||
|
fparseln.c \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_FPURGE
|
||||||
check_PROGRAMS += fpurge
|
check_PROGRAMS += fpurge
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_FUNOPEN
|
if ABI_FUNOPEN
|
||||||
check_PROGRAMS += funopen
|
check_PROGRAMS += funopen
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_ARC4RANDOM
|
if ABI_HUMANIZE_NUMBER
|
||||||
if HAVE_LIBTESTU01
|
check_PROGRAMS += \
|
||||||
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)
|
humanize \
|
||||||
|
|
||||||
check_PROGRAMS += arc4random
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if BUILD_LIBBSD_CTOR
|
|
||||||
proctitle_LDFLAGS = \
|
|
||||||
-Wl,-u,libbsd_init_func \
|
|
||||||
$(top_builddir)/src/libbsd-ctor.a \
|
|
||||||
$(top_builddir)/src/libbsd.la \
|
|
||||||
# EOL
|
# EOL
|
||||||
|
|
||||||
check_PROGRAMS += proctitle
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if NEED_MD5
|
if ABI_FPURGE
|
||||||
|
check_PROGRAMS += fpurge
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_FUNOPEN
|
||||||
|
check_PROGRAMS += funopen
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_MD5
|
||||||
check_PROGRAMS += md5
|
check_PROGRAMS += md5
|
||||||
|
|
||||||
if NEED_TRANSPARENT_LIBMD
|
if ABI_TRANSPARENT_LIBMD
|
||||||
# On the installed system this is handled via the ld script.
|
# On the installed system this is handled via the ld script.
|
||||||
md5_LDADD = $(LDADD) $(MD5_LIBS)
|
md5_LDADD = $(LDADD) $(MD5_LIBS)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
fgetln_SOURCES = test-stream.c test-stream.h fgetln.c
|
if ABI_NLIST
|
||||||
fgetln_CFLAGS = -Wno-deprecated-declarations
|
check_PROGRAMS += nlist
|
||||||
fparseln_SOURCES = test-stream.c test-stream.h fparseln.c
|
endif
|
||||||
|
|
||||||
|
if ABI_PROGNAME
|
||||||
|
check_PROGRAMS += progname
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_PROCTITLE
|
||||||
|
check_PROGRAMS += \
|
||||||
|
proctitle-init \
|
||||||
|
# EOL
|
||||||
|
|
||||||
|
proctitle_init_SOURCES = \
|
||||||
|
proctitle.c \
|
||||||
|
# EOL
|
||||||
|
|
||||||
proctitle_init_SOURCES = proctitle.c
|
|
||||||
proctitle_init_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_USE_SETPROCTITLE_INIT=1
|
proctitle_init_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_USE_SETPROCTITLE_INIT=1
|
||||||
|
|
||||||
|
if BUILD_LIBBSD_CTOR
|
||||||
|
check_PROGRAMS += proctitle
|
||||||
|
|
||||||
|
proctitle_LDFLAGS = \
|
||||||
|
-Wl,-u,libbsd_init_func \
|
||||||
|
$(top_builddir)/src/libbsd-ctor.a \
|
||||||
|
$(top_builddir)/src/libbsd.la \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_PWCACHE
|
||||||
|
check_PROGRAMS += \
|
||||||
|
pwcache \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_PROGNAME
|
||||||
|
check_PROGRAMS += progname
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ABI_STRL
|
||||||
|
check_PROGRAMS += strl
|
||||||
|
endif
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if LIBBSD_SYS_IS_TIME32
|
||||||
|
check_PROGRAMS += timeconv32
|
||||||
|
endif
|
||||||
|
|
||||||
|
if LIBBSD_SYS_HAS_TIME64
|
||||||
|
check_PROGRAMS += timeconv64
|
||||||
|
endif
|
||||||
|
|
||||||
TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
|
TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
|
||||||
|
43
test/timeconv32.c
Normal file
43
test/timeconv32.c
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2024 Guillem Jover <guillem@hadrons.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef _TIME_BITS
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <timeconv.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
time_t t;
|
||||||
|
|
||||||
|
t = _time64_to_time(INT64_MAX);
|
||||||
|
assert(t < INT64_MAX);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
40
test/timeconv64.c
Normal file
40
test/timeconv64.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2024 Guillem Jover <guillem@hadrons.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <timeconv.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
time_t t;
|
||||||
|
|
||||||
|
t = _time64_to_time(INT64_MAX);
|
||||||
|
assert(t == INT64_MAX);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user