mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-20 14:02:43 +02:00
Compare commits
75 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
084911ce87 | ||
![]() |
3538d38fe7 | ||
![]() |
03fccd1505 | ||
![]() |
6b6e686b23 | ||
![]() |
da1f45ac71 | ||
![]() |
2f9eddc277 | ||
![]() |
28298ac037 | ||
![]() |
ef981f930b | ||
![]() |
6928d7895e | ||
![]() |
d5865759f8 | ||
![]() |
be327c6ebe | ||
![]() |
a14612d968 | ||
![]() |
f4baceb82c | ||
![]() |
f35c545847 | ||
![]() |
b466b14afb | ||
![]() |
1f6a48b209 | ||
![]() |
873639ebb5 | ||
![]() |
c9c78fdfd0 | ||
![]() |
5f21307570 | ||
![]() |
84acf21568 | ||
![]() |
15200ec7ac | ||
![]() |
f7465b93ec | ||
![]() |
e5ed5fdd62 | ||
![]() |
abb1a6b1a7 | ||
![]() |
c9ff83687c | ||
![]() |
62e67bb49e | ||
![]() |
87b1307040 | ||
![]() |
ba3c46b30f | ||
![]() |
091097e062 | ||
![]() |
5f9608c775 | ||
![]() |
eef07993c9 | ||
![]() |
c6d589bc71 | ||
![]() |
2975d809a0 | ||
![]() |
f11ab67223 | ||
![]() |
54796231c7 | ||
![]() |
7aed0edf73 | ||
![]() |
fafcc397ac | ||
![]() |
48107fc8c4 | ||
![]() |
e7cf8c5785 | ||
![]() |
25d35625eb | ||
![]() |
500b3080a2 | ||
![]() |
1eba406021 | ||
![]() |
8ad7570c20 | ||
![]() |
43a8270317 | ||
![]() |
6a71b24b63 | ||
![]() |
7389fe8d24 | ||
![]() |
2716dfd0b7 | ||
![]() |
54f8745657 | ||
![]() |
428be9e030 | ||
![]() |
c7a5d780ae | ||
![]() |
1808d64b77 | ||
![]() |
beafad2657 | ||
![]() |
6145b56178 | ||
![]() |
731b0a7739 | ||
![]() |
50b50a4330 | ||
![]() |
25e88f6479 | ||
![]() |
04a8fb2469 | ||
![]() |
4f68a88f55 | ||
![]() |
8f59221c4f | ||
![]() |
72a82ee262 | ||
![]() |
3c305f2873 | ||
![]() |
25278891d8 | ||
![]() |
e35d9141dc | ||
![]() |
4feda87049 | ||
![]() |
d563a17430 | ||
![]() |
785cf9d1e9 | ||
![]() |
15bd284b29 | ||
![]() |
a9fc285988 | ||
![]() |
c0d86a6412 | ||
![]() |
1fb25b7dca | ||
![]() |
31f034e386 | ||
![]() |
2374f409de | ||
![]() |
a4e0db2b97 | ||
![]() |
43d34c9d3b | ||
![]() |
1c3ff61699 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
ChangeLog
|
ChangeLog
|
||||||
|
*~
|
||||||
*.pc
|
*.pc
|
||||||
*.la
|
*.la
|
||||||
*.lo
|
*.lo
|
||||||
@@ -7,6 +8,8 @@ ChangeLog
|
|||||||
*.a
|
*.a
|
||||||
*.log
|
*.log
|
||||||
*.trs
|
*.trs
|
||||||
|
*.gcda
|
||||||
|
*.gcno
|
||||||
.dirstamp
|
.dirstamp
|
||||||
.deps/
|
.deps/
|
||||||
.libs/
|
.libs/
|
||||||
@@ -17,6 +20,6 @@ autom4te.cache/
|
|||||||
build-aux/
|
build-aux/
|
||||||
configure
|
configure
|
||||||
config.*
|
config.*
|
||||||
|
format.ld
|
||||||
libtool
|
libtool
|
||||||
m4/
|
|
||||||
stamp-h1
|
stamp-h1
|
||||||
|
@@ -1,9 +1,37 @@
|
|||||||
image: debian:buster
|
.unit-tests:
|
||||||
|
|
||||||
test:
|
|
||||||
before_script:
|
|
||||||
- apt update -qq
|
|
||||||
- apt install -qq -y --no-install-recommends git gcc make autoconf automake libtool libmd-dev
|
|
||||||
script:
|
script:
|
||||||
- ./autogen && ./configure
|
- ./autogen && ./configure
|
||||||
- make check
|
- make check
|
||||||
|
|
||||||
|
.coverage:
|
||||||
|
script:
|
||||||
|
- ./autogen && ./configure --disable-static
|
||||||
|
- make check CFLAGS="--coverage -O0 -ggdb" LDFLAGS="--coverage -O0 -ggdb"
|
||||||
|
- gcovr -s -e test/
|
||||||
|
|
||||||
|
.debian:
|
||||||
|
image: debian:buster
|
||||||
|
stage: test
|
||||||
|
before_script:
|
||||||
|
- apt-get update -qq
|
||||||
|
- apt-get install -qq -y --no-install-recommends
|
||||||
|
git gcc make autoconf automake libtool libmd-dev gcovr
|
||||||
|
|
||||||
|
.alpine:
|
||||||
|
image: alpine:latest
|
||||||
|
stage: test
|
||||||
|
before_script:
|
||||||
|
- apk add --no-cache git gcc make autoconf automake libtool
|
||||||
|
bsd-compat-headers linux-headers libmd-dev musl-dev gcovr
|
||||||
|
|
||||||
|
unit-tests:debian:
|
||||||
|
extends: [.debian, .unit-tests]
|
||||||
|
|
||||||
|
coverage:debian:
|
||||||
|
extends: [.debian, .coverage]
|
||||||
|
|
||||||
|
unit-tests:alpine:
|
||||||
|
extends: [.alpine, .unit-tests]
|
||||||
|
|
||||||
|
coverage:alpine:
|
||||||
|
extends: [.alpine, .coverage]
|
||||||
|
44
COPYING
44
COPYING
@@ -3,12 +3,11 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|||||||
Files:
|
Files:
|
||||||
*
|
*
|
||||||
Copyright:
|
Copyright:
|
||||||
Copyright © 2004-2006, 2008-2021 Guillem Jover <guillem@hadrons.org>
|
Copyright © 2004-2006, 2008-2022 Guillem Jover <guillem@hadrons.org>
|
||||||
License: BSD-3-clause
|
License: BSD-3-clause
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
man/arc4random.3bsd
|
man/arc4random.3bsd
|
||||||
man/tree.3bsd
|
|
||||||
Copyright:
|
Copyright:
|
||||||
Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
|
Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
@@ -38,39 +37,6 @@ License: BSD-4-clause-Niels-Provos
|
|||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
Files:
|
|
||||||
man/getprogname.3bsd
|
|
||||||
Copyright:
|
|
||||||
Copyright © 2001 Christopher G. Demetriou
|
|
||||||
All rights reserved.
|
|
||||||
License: BSD-4-clause-Christopher-G-Demetriou
|
|
||||||
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. All advertising materials mentioning features or use of this software
|
|
||||||
must display the following acknowledgement:
|
|
||||||
This product includes software developed for the
|
|
||||||
NetBSD Project. See http://www.netbsd.org/ for
|
|
||||||
information about NetBSD.
|
|
||||||
4. 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 BY THE AUTHOR ``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.
|
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
include/bsd/err.h
|
include/bsd/err.h
|
||||||
include/bsd/stdlib.h
|
include/bsd/stdlib.h
|
||||||
@@ -348,6 +314,7 @@ License: BSD-2-clause-verbatim
|
|||||||
Files:
|
Files:
|
||||||
include/bsd/sys/tree.h
|
include/bsd/sys/tree.h
|
||||||
man/fparseln.3bsd
|
man/fparseln.3bsd
|
||||||
|
man/tree.3bsd
|
||||||
src/fparseln.c
|
src/fparseln.c
|
||||||
Copyright:
|
Copyright:
|
||||||
Copyright © 1997 Christos Zoulas.
|
Copyright © 1997 Christos Zoulas.
|
||||||
@@ -364,7 +331,6 @@ Files:
|
|||||||
man/strtonum.3bsd
|
man/strtonum.3bsd
|
||||||
src/arc4random.c
|
src/arc4random.c
|
||||||
src/arc4random_linux.h
|
src/arc4random_linux.h
|
||||||
src/arc4random_openbsd.h
|
|
||||||
src/arc4random_uniform.c
|
src/arc4random_uniform.c
|
||||||
src/arc4random_unix.h
|
src/arc4random_unix.h
|
||||||
src/arc4random_win.h
|
src/arc4random_win.h
|
||||||
@@ -383,6 +349,8 @@ Files:
|
|||||||
src/recallocarray.c
|
src/recallocarray.c
|
||||||
src/strlcat.c
|
src/strlcat.c
|
||||||
src/strlcpy.c
|
src/strlcpy.c
|
||||||
|
test/explicit_bzero.c
|
||||||
|
test/strtonum.c
|
||||||
Copyright:
|
Copyright:
|
||||||
Copyright © 2004 Ted Unangst and Todd Miller
|
Copyright © 2004 Ted Unangst and Todd Miller
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
@@ -391,6 +359,7 @@ Copyright:
|
|||||||
Copyright © 1998, 2000-2002, 2004-2005, 2007, 2010, 2012-2015
|
Copyright © 1998, 2000-2002, 2004-2005, 2007, 2010, 2012-2015
|
||||||
Todd C. Miller <Todd.Miller@courtesan.com>
|
Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
Copyright © 2004 Ted Unangst
|
Copyright © 2004 Ted Unangst
|
||||||
|
Copyright © 2004 Otto Moerbeek <otto@drijf.net>
|
||||||
Copyright © 2008 Damien Miller <djm@openbsd.org>
|
Copyright © 2008 Damien Miller <djm@openbsd.org>
|
||||||
Copyright © 2008, 2010-2011, 2016-2017 Otto Moerbeek <otto@drijf.net>
|
Copyright © 2008, 2010-2011, 2016-2017 Otto Moerbeek <otto@drijf.net>
|
||||||
Copyright © 2013 Markus Friedl <markus@openbsd.org>
|
Copyright © 2013 Markus Friedl <markus@openbsd.org>
|
||||||
@@ -398,8 +367,9 @@ Copyright:
|
|||||||
Copyright © 2014 Brent Cook <bcook@openbsd.org>
|
Copyright © 2014 Brent Cook <bcook@openbsd.org>
|
||||||
Copyright © 2014 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
Copyright © 2014 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
||||||
Copyright © 2014 Theo de Raadt <deraadt@openbsd.org>
|
Copyright © 2014 Theo de Raadt <deraadt@openbsd.org>
|
||||||
|
Copyright © 2014 Google Inc.
|
||||||
Copyright © 2015 Michael Felt <aixtools@gmail.com>
|
Copyright © 2015 Michael Felt <aixtools@gmail.com>
|
||||||
Copyright © 2015 Guillem Jover <guillem@hadrons.org>
|
Copyright © 2015, 2022 Guillem Jover <guillem@hadrons.org>
|
||||||
License: ISC
|
License: ISC
|
||||||
Permission to use, copy, modify, and distribute this software for any
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
37
README
37
README
@@ -9,6 +9,7 @@ A BSD compatible message-digest library is required, on systems where
|
|||||||
this is not provided by its libc or libmd libraries, the canonical
|
this is not provided by its libc or libmd libraries, the canonical
|
||||||
implementation to use is <https://www.hadrons.org/software/libmd/>.
|
implementation to use is <https://www.hadrons.org/software/libmd/>.
|
||||||
|
|
||||||
|
|
||||||
Releases
|
Releases
|
||||||
--------
|
--------
|
||||||
|
|
||||||
@@ -30,10 +31,44 @@ The mail address is:
|
|||||||
Source Repository
|
Source Repository
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
The master repository can be browsed at:
|
The primary repository can be browsed at:
|
||||||
|
|
||||||
<https://cgit.freedesktop.org/libbsd>
|
<https://cgit.freedesktop.org/libbsd>
|
||||||
|
|
||||||
and cloned from:
|
and cloned from:
|
||||||
|
|
||||||
<https://anongit.freedesktop.org/git/libbsd>
|
<https://anongit.freedesktop.org/git/libbsd>
|
||||||
|
|
||||||
|
|
||||||
|
Building from git source
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
To prepare the libbsd source tree from git before starting the build process
|
||||||
|
some required software needs to be installed:
|
||||||
|
|
||||||
|
GNU autoconf >= 2.67
|
||||||
|
GNU automake >= 1.9
|
||||||
|
GNU libtool >= 2.0
|
||||||
|
|
||||||
|
After installing the needed software, and running the following command on
|
||||||
|
the git tree:
|
||||||
|
|
||||||
|
$ ./autogen
|
||||||
|
|
||||||
|
the source should be roughly equivalent to the distributed tar source.
|
||||||
|
|
||||||
|
|
||||||
|
Building from tar source
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
The minimum software required to configure and build dpkg from a tarball is:
|
||||||
|
|
||||||
|
C89 compiler
|
||||||
|
make
|
||||||
|
|
||||||
|
The following software might be required depending on the system:
|
||||||
|
|
||||||
|
libmd (whenever the libc does not provide the needed digest functions)
|
||||||
|
|
||||||
|
The build process is done by running the usual «./configure; make». To
|
||||||
|
see all available configuration options please run «./configure --help».
|
||||||
|
75
configure.ac
75
configure.ac
@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
|
|||||||
|
|
||||||
LIBBSD_ABI_MAJOR=0
|
LIBBSD_ABI_MAJOR=0
|
||||||
LIBBSD_ABI_MINOR=11
|
LIBBSD_ABI_MINOR=11
|
||||||
LIBBSD_ABI_PATCH=2
|
LIBBSD_ABI_PATCH=7
|
||||||
|
|
||||||
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
||||||
AC_SUBST([LIBBSD_ABI])
|
AC_SUBST([LIBBSD_ABI])
|
||||||
@@ -47,14 +47,52 @@ AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
|
|||||||
[test "x$libbsd_cv_version_script" = "xyes"])
|
[test "x$libbsd_cv_version_script" = "xyes"])
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
|
AC_CHECK_TOOL([OBJDUMP], [objdump])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
AC_PROG_SED
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_LN_S
|
AC_PROG_LN_S
|
||||||
|
|
||||||
# Set default compiler variables
|
# Set default compiler variables
|
||||||
if test "$user_CFLAGS" = unset && test "$GCC" = yes; then
|
AS_IF([test "$user_CFLAGS" = unset], [
|
||||||
CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter"
|
LIBBSD_CHECK_COMPILER_FLAG([-Wall])
|
||||||
fi
|
LIBBSD_CHECK_COMPILER_FLAG([-Wextra])
|
||||||
|
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wbad-function-cast])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wc99-c11-compat])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wcast-align])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wdeclaration-after-statement])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wdocumentation])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wduplicated-branches])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wduplicated-cond])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wformat -Wformat-security])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wformat=2])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Winit-self])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wlogical-not-parentheses])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wlogical-op])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wmissing-declarations])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wmissing-format-attribute])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wmissing-prototypes])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wnested-externs])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-missing-field-initializers])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-nonnull-compare])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-tautological-constant-out-of-range-compare])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wno-unused-parameter])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wnull-dereference])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wold-style-definition])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wpointer-arith])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wregister])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wrestrict])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wshadow])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wshift-negative-value])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wsizeof-array-argument])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wstrict-prototypes])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wswitch-bool])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wvla])
|
||||||
|
LIBBSD_CHECK_COMPILER_FLAG([-Wwrite-strings])
|
||||||
|
|
||||||
|
CFLAGS="$CFLAGS $LIBBSD_COMPILER_FLAGS"
|
||||||
|
])
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
AC_CHECK_LIB([testu01], [unif01_CreateExternGenBits],
|
AC_CHECK_LIB([testu01], [unif01_CreateExternGenBits],
|
||||||
@@ -65,15 +103,25 @@ AM_CONDITIONAL([HAVE_LIBTESTU01],
|
|||||||
|
|
||||||
saved_LIBS="$LIBS"
|
saved_LIBS="$LIBS"
|
||||||
AC_SEARCH_LIBS([MD5Update], [md], [
|
AC_SEARCH_LIBS([MD5Update], [md], [
|
||||||
AC_SEARCH_LIBS([SHA512Update], [md], [
|
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
|
||||||
MD_LIBS="-lmd"
|
MD5_LIBS="$MD5_LIBS $ac_cv_search_MD5Update"
|
||||||
|
need_transparent_libmd=yes
|
||||||
])
|
])
|
||||||
], [
|
], [
|
||||||
AC_MSG_ERROR([cannot find required message digest functions in libc or libmd])
|
AC_MSG_ERROR([cannot find required MD5 functions in libc or libmd])
|
||||||
|
])
|
||||||
|
AC_SEARCH_LIBS([SHA512Update], [md], [
|
||||||
|
AS_IF([test "x$ac_cv_search_SHA512Update" != "xnone required"], [
|
||||||
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_SHA512Update"
|
||||||
|
])
|
||||||
|
], [
|
||||||
|
AC_MSG_ERROR([cannot find required SHA-2 functions in libc or libmd])
|
||||||
])
|
])
|
||||||
AC_SUBST([MD_LIBS])
|
|
||||||
LIBS="$saved_LIBS"
|
LIBS="$saved_LIBS"
|
||||||
|
|
||||||
|
AM_CONDITIONAL([NEED_TRANSPARENT_LIBMD],
|
||||||
|
[test "x$need_transparent_libmd" = "xyes"])
|
||||||
|
|
||||||
is_windows=no
|
is_windows=no
|
||||||
AS_CASE([$host_os],
|
AS_CASE([$host_os],
|
||||||
[*-gnu*], [
|
[*-gnu*], [
|
||||||
@@ -81,10 +129,9 @@ AS_CASE([$host_os],
|
|||||||
saved_LIBS="$LIBS"
|
saved_LIBS="$LIBS"
|
||||||
AC_SEARCH_LIBS([clock_gettime], [rt], [
|
AC_SEARCH_LIBS([clock_gettime], [rt], [
|
||||||
AS_IF([test "x$ac_cv_search_clock_gettime" != "xnone required"], [
|
AS_IF([test "x$ac_cv_search_clock_gettime" != "xnone required"], [
|
||||||
CLOCK_GETTIME_LIBS="$ac_cv_search_clock_gettime"
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_clock_gettime"
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
AC_SUBST([CLOCK_GETTIME_LIBS])
|
|
||||||
LIBS="$saved_LIBS"
|
LIBS="$saved_LIBS"
|
||||||
],
|
],
|
||||||
[*-musl*], [
|
[*-musl*], [
|
||||||
@@ -126,7 +173,7 @@ AC_CACHE_CHECK(
|
|||||||
[[
|
[[
|
||||||
static int rc = 1;
|
static int rc = 1;
|
||||||
static void init(int argc) { if (argc == 1) rc = 0; }
|
static void init(int argc) { if (argc == 1) rc = 0; }
|
||||||
void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
|
void (*init_func)(int argc) __attribute__((__section__(".init_array"), __used__)) = init;
|
||||||
int main() { return rc; }
|
int main() { return rc; }
|
||||||
]]
|
]]
|
||||||
)],
|
)],
|
||||||
@@ -192,8 +239,7 @@ AC_LINK_IFELSE(
|
|||||||
[AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
[AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
||||||
[Define to 1 if you have __register_atfork])
|
[Define to 1 if you have __register_atfork])
|
||||||
AC_MSG_RESULT([yes])],
|
AC_MSG_RESULT([yes])],
|
||||||
[ARC4RANDOM_ATFORK_LIBS="-pthread"
|
[LIBBSD_LIBS="$LIBBSD_LIBS -pthread"
|
||||||
AC_SUBST([ARC4RANDOM_ATFORK_LIBS])
|
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -202,6 +248,9 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
|
|||||||
pstat_getproc sysconf])
|
pstat_getproc sysconf])
|
||||||
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
|
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
|
||||||
|
|
||||||
|
AC_SUBST([MD5_LIBS])
|
||||||
|
AC_SUBST([LIBBSD_LIBS])
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
include/Makefile
|
include/Makefile
|
||||||
|
@@ -51,11 +51,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
#if !defined(__GLIBC__) || \
|
||||||
|
!__GLIBC_PREREQ(2, 36) || \
|
||||||
|
!defined(_DEFAULT_SOURCE)
|
||||||
uint32_t arc4random(void);
|
uint32_t arc4random(void);
|
||||||
void arc4random_stir(void);
|
|
||||||
void arc4random_addrandom(unsigned char *dat, int datlen);
|
|
||||||
void arc4random_buf(void *_buf, size_t n);
|
void arc4random_buf(void *_buf, size_t n);
|
||||||
uint32_t arc4random_uniform(uint32_t upper_bound);
|
uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||||
|
#endif
|
||||||
|
void arc4random_stir(void);
|
||||||
|
void arc4random_addrandom(unsigned char *dat, int datlen);
|
||||||
|
|
||||||
int dehumanize_number(const char *str, int64_t *size);
|
int dehumanize_number(const char *str, int64_t *size);
|
||||||
|
|
||||||
@@ -72,7 +76,9 @@ int sradixsort(const unsigned char **base, int nmemb,
|
|||||||
|
|
||||||
void *reallocf(void *ptr, size_t size);
|
void *reallocf(void *ptr, size_t size);
|
||||||
#if !defined(__GLIBC__) || \
|
#if !defined(__GLIBC__) || \
|
||||||
(defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 26) || !defined(_GNU_SOURCE)))
|
!__GLIBC_PREREQ(2, 26) || \
|
||||||
|
(__GLIBC_PREREQ(2, 26) && !__GLIBC_PREREQ(2, 29) && !defined(_GNU_SOURCE)) || \
|
||||||
|
(__GLIBC_PREREQ(2, 29) && !defined(_DEFAULT_SOURCE))
|
||||||
void *reallocarray(void *ptr, size_t nmemb, size_t size);
|
void *reallocarray(void *ptr, size_t nmemb, size_t size);
|
||||||
#endif
|
#endif
|
||||||
void *recallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size);
|
void *recallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size);
|
||||||
|
@@ -47,7 +47,8 @@ char *strnstr(const char *str, const char *find, size_t str_len);
|
|||||||
void strmode(mode_t mode, char *str);
|
void strmode(mode_t mode, char *str);
|
||||||
|
|
||||||
#if !defined(__GLIBC__) || \
|
#if !defined(__GLIBC__) || \
|
||||||
(defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE)))
|
!__GLIBC_PREREQ(2, 25) || \
|
||||||
|
!defined(_DEFAULT_SOURCE)
|
||||||
void explicit_bzero(void *buf, size_t len);
|
void explicit_bzero(void *buf, size_t len);
|
||||||
#endif
|
#endif
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
@@ -187,10 +187,10 @@
|
|||||||
# else
|
# else
|
||||||
# ifndef __cplusplus
|
# ifndef __cplusplus
|
||||||
# define __offsetof(type, field) \
|
# define __offsetof(type, field) \
|
||||||
((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
|
((size_t)(uintptr_t)((const volatile void *)&((type *)0)->field))
|
||||||
# else
|
# else
|
||||||
# define __offsetof(type, field) \
|
# define __offsetof(type, field) \
|
||||||
(__offsetof__ (reinterpret_cast <__size_t> \
|
(__offsetof__ (reinterpret_cast <size_t> \
|
||||||
(&reinterpret_cast <const volatile char &> \
|
(&reinterpret_cast <const volatile char &> \
|
||||||
(static_cast<type *> (0)->field))))
|
(static_cast<type *> (0)->field))))
|
||||||
# endif
|
# endif
|
||||||
@@ -243,15 +243,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DECONST
|
#ifndef __DECONST
|
||||||
#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
|
#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DEVOLATILE
|
#ifndef __DEVOLATILE
|
||||||
#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
|
#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DEQUALIFY
|
#ifndef __DEQUALIFY
|
||||||
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
|
#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
2
m4/.gitignore
vendored
Normal file
2
m4/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.m4
|
||||||
|
!libbsd*.m4
|
24
m4/libbsd-compiler.m4
Normal file
24
m4/libbsd-compiler.m4
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Copyright © 2021 Guillem Jover <guillem@hadrons.org>
|
||||||
|
|
||||||
|
# LIBBSD_CHECK_COMPILER_FLAG
|
||||||
|
# -------------------------
|
||||||
|
AC_DEFUN([LIBBSD_CHECK_COMPILER_FLAG], [
|
||||||
|
AS_VAR_PUSHDEF([libbsd_varname_cache], [libbsd_cv_cflags_$1])
|
||||||
|
AC_CACHE_CHECK([whether $CC accepts $1], [libbsd_varname_cache], [
|
||||||
|
m4_define([libbsd_check_flag], m4_bpatsubst([$1], [^-Wno-], [-W]))
|
||||||
|
AS_VAR_COPY([libbsd_save_CFLAGS], [CFLAGS])
|
||||||
|
AS_VAR_SET([CFLAGS], ["-Werror libbsd_check_flag"])
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_SOURCE([[]])
|
||||||
|
], [
|
||||||
|
AS_VAR_SET([libbsd_varname_cache], [yes])
|
||||||
|
], [
|
||||||
|
AS_VAR_SET([libbsd_varname_cache], [no])
|
||||||
|
])
|
||||||
|
AS_VAR_COPY([CFLAGS], [libbsd_save_CFLAGS])
|
||||||
|
])
|
||||||
|
AS_VAR_IF([libbsd_varname_cache], [yes], [
|
||||||
|
AS_VAR_APPEND([LIBBSD_COMPILER_FLAGS], [" $1"])
|
||||||
|
])
|
||||||
|
AS_VAR_POPDEF([libbsd_varname_cache])
|
||||||
|
])
|
@@ -11,7 +11,7 @@ CLEANFILES = \
|
|||||||
SED_MD5_SUBST = -e 's/mdX/md5/g' -e 's/mdY/md4/g' -e 's/MDX/MD5/g'
|
SED_MD5_SUBST = -e 's/mdX/md5/g' -e 's/mdY/md4/g' -e 's/MDX/MD5/g'
|
||||||
|
|
||||||
md5.3bsd: $(srcdir)/mdX.3bsd
|
md5.3bsd: $(srcdir)/mdX.3bsd
|
||||||
$(AM_V_GEN) sed $(SED_MD5_SUBST) $< > $@
|
$(AM_V_GEN) $(SED) $(SED_MD5_SUBST) $< > $@
|
||||||
|
|
||||||
dist_man_MANS = \
|
dist_man_MANS = \
|
||||||
LIST_CLASS_ENTRY.3bsd \
|
LIST_CLASS_ENTRY.3bsd \
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
.\" $OpenBSD: arc4random.3,v 1.34 2014/07/19 16:11:16 naddy Exp $
|
.\" $OpenBSD: arc4random.3,v 1.37 2019/09/29 16:30:35 jmc Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
|
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" Manual page, using -mandoc macros
|
.\" Manual page, using -mandoc macros
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: July 19 2014 $
|
.Dd $Mdocdate: September 29 2019 $
|
||||||
.Dt ARC4RANDOM 3bsd
|
.Dt arc4random 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm arc4random ,
|
.Nm arc4random ,
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
.Nm arc4random_uniform ,
|
.Nm arc4random_uniform ,
|
||||||
.Nm arc4random_stir ,
|
.Nm arc4random_stir ,
|
||||||
.Nm arc4random_addrandom
|
.Nm arc4random_addrandom
|
||||||
.Nd arc4 random number generator
|
.Nd random number generator
|
||||||
.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]
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 19, 1993
|
.Dd July 19, 1993
|
||||||
.Dt BITSTRING 3bsd
|
.Dt bitstring 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm bit_alloc ,
|
.Nm bit_alloc ,
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd April 29, 2002
|
.Dd April 29, 2002
|
||||||
.Dt BYTEORDER 3bsd
|
.Dt byteorder 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm be16enc , be16dec , be32enc , be32dec , be64enc , be64dec ,
|
.Nm be16enc , be16dec , be32enc , be32dec , be64enc , be64dec ,
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 12, 2009
|
.Dd June 12, 2009
|
||||||
.Dt CLOSEFROM 3bsd
|
.Dt closefrom 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm closefrom
|
.Nm closefrom
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: April 23 2014 $
|
.Dd $Mdocdate: April 23 2014 $
|
||||||
.Dt ERRC 3bsd
|
.Dt errc 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm errc ,
|
.Nm errc ,
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd August 15, 2010
|
.Dd August 15, 2010
|
||||||
.Dt EXPAND_NUMBER 3bsd
|
.Dt expand_number 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm expand_number
|
.Nm expand_number
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
.\" $OpenBSD: bzero.3,v 1.10 2014/01/22 21:06:45 tedu Exp $
|
.\" $OpenBSD: bzero.3,v 1.10 2014/01/22 21:06:45 tedu Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: January 22 2014 $
|
.Dd $Mdocdate: January 22 2014 $
|
||||||
.Dt EXPLICIT_BZERO 3bsd
|
.Dt explicit_bzero 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm explicit_bzero
|
.Nm explicit_bzero
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/stdio/fgetln.3,v 1.8 2004/07/16 06:07:12 tjr Exp $
|
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/stdio/fgetln.3,v 1.8 2004/07/16 06:07:12 tjr Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd April 19, 1994
|
.Dd April 19, 1994
|
||||||
.Dt FGETLN 3bsd
|
.Dt fgetln 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm fgetln
|
.Nm fgetln
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 16, 2004
|
.Dd July 16, 2004
|
||||||
.Dt FGETWLN 3bsd
|
.Dt fgetwln 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm fgetwln
|
.Nm fgetwln
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 28, 2017
|
.Dd July 28, 2017
|
||||||
.Dt FLOPEN 3bsd
|
.Dt flopen 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm flopen ,
|
.Nm flopen ,
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd June 14, 2014
|
.Dd June 14, 2014
|
||||||
.Dt FMTCHECK 3bsd
|
.Dt fmtcheck 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm fmtcheck
|
.Nm fmtcheck
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd November 30, 2002
|
.Dd November 30, 2002
|
||||||
.Dt FPARSELN 3bsd
|
.Dt fparseln 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm fparseln
|
.Nm fparseln
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: November 4 2015 $
|
.Dd $Mdocdate: November 4 2015 $
|
||||||
.Dt FPURGE 3bsd
|
.Dt fpurge 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm fpurge
|
.Nm fpurge
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd March 19, 2004
|
.Dd March 19, 2004
|
||||||
.Dt FUNOPEN 3bsd
|
.Dt funopen 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm funopen ,
|
.Nm funopen ,
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd November 16, 2012
|
.Dd November 16, 2012
|
||||||
.Dt GETBSIZE 3bsd
|
.Dt getbsize 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm getbsize
|
.Nm getbsize
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 15, 2001
|
.Dd July 15, 2001
|
||||||
.Dt GETPEEREID 3bsd
|
.Dt getpeereid 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm getpeereid
|
.Nm getpeereid
|
||||||
|
@@ -1,6 +1,4 @@
|
|||||||
.\"
|
.\" Copyright (c) 2022 Guillem Jover <guillem@hadrons.org>
|
||||||
.\" Copyright (c) 2001 Christopher G. Demetriou
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
.\"
|
||||||
.\" 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
|
||||||
@@ -10,34 +8,27 @@
|
|||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
.\" 3. All advertising materials mentioning features or use of this software
|
.\" 3. The name of the author may not be used to endorse or promote products
|
||||||
.\" must display the following acknowledgement:
|
|
||||||
.\" This product includes software developed for the
|
|
||||||
.\" NetBSD Project. See http://www.netbsd.org/ for
|
|
||||||
.\" information about NetBSD.
|
|
||||||
.\" 4. The name of the author may not be used to endorse or promote products
|
|
||||||
.\" derived from this software without specific prior written permission.
|
.\" 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.
|
||||||
.\"
|
.\"
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
.Dd August 03, 2022
|
||||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
.Dt getprogname 3bsd
|
||||||
.\" 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.
|
|
||||||
.\"
|
|
||||||
.\" $FreeBSD$
|
|
||||||
.\"
|
|
||||||
.Dd May 1, 2001
|
|
||||||
.Dt GETPROGNAME 3bsd
|
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm getprogname ,
|
.Nm getprogname ,
|
||||||
.Nm setprogname
|
.Nm setprogname
|
||||||
.Nd get or set the program name
|
.Nd get and set program name
|
||||||
.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]
|
||||||
@@ -54,46 +45,39 @@ for include usage.)
|
|||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Fn getprogname
|
.Fn getprogname
|
||||||
and
|
returns a string with the current program name,
|
||||||
.Fn setprogname
|
excluding any directory component.
|
||||||
functions manipulate the name of the current program.
|
The function will return
|
||||||
They are used by error-reporting routines to produce
|
.Dv NULL
|
||||||
consistent output.
|
if it was unable to get the program name from any known source.
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn getprogname
|
|
||||||
function returns the name of the program.
|
|
||||||
If the name has not been set yet, it will return
|
|
||||||
.Dv NULL .
|
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn setprogname
|
.Fn setprogname
|
||||||
function sets the name of the program to be the last component of the
|
function sets the current program name,
|
||||||
.Fa progname
|
stripping any directory component prefix.
|
||||||
argument.
|
The function will keep a reference to the passed string pointer,
|
||||||
Since a pointer to the given string is kept as the program name,
|
so it must not be freed or modified while these functions might
|
||||||
it should not be modified for the rest of the program's lifetime.
|
be called.
|
||||||
.Pp
|
.Pp
|
||||||
In
|
The implementations on most BSDs will try to initialize the program name
|
||||||
.Fx ,
|
at program startup time, and
|
||||||
the name of the program is set by the start-up code that is run before
|
.Nm libbsd
|
||||||
.Fn main ;
|
will try to infer it from various known sources depending on the
|
||||||
thus,
|
target system.
|
||||||
running
|
But it is not a portable assumption that the program name will be set
|
||||||
.Fn setprogname
|
without calling
|
||||||
is not necessary.
|
.Fn setprogname ,
|
||||||
Programs that desire maximum portability should still call it;
|
so portable programs should always call it after starting up.
|
||||||
on another operating system,
|
|
||||||
these functions may be implemented in a portability library.
|
|
||||||
Calling
|
|
||||||
.Fn setprogname
|
|
||||||
allows the aforementioned library to learn the program name without
|
|
||||||
modifications to the start-up code.
|
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr err 3 ,
|
.Xr setproctitle 3bsd .
|
||||||
.Xr setproctitle 3bsd
|
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
These functions first appeared in
|
The
|
||||||
|
.Fn setprogname
|
||||||
|
and
|
||||||
|
.Fn getprogname
|
||||||
|
functions first appeared in
|
||||||
.Nx 1.6 ,
|
.Nx 1.6 ,
|
||||||
and made their way into
|
.Fx 4.4 ,
|
||||||
.Fx 4.4 .
|
.Dx 2.1
|
||||||
|
and
|
||||||
|
.Ox 5.4 .
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd September 30, 2003
|
.Dd September 30, 2003
|
||||||
.Dt HEAPSORT 3bsd
|
.Dt heapsort 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm heapsort , mergesort
|
.Nm heapsort , mergesort
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd February 9, 2008
|
.Dd February 9, 2008
|
||||||
.Dt HUMANIZE_NUMBER 3bsd
|
.Dt humanize_number 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm dehumanize_number ,
|
.Nm dehumanize_number ,
|
||||||
|
41
man/libbsd.7
41
man/libbsd.7
@@ -1,6 +1,6 @@
|
|||||||
.\" libbsd man page
|
.\" libbsd man page
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright © 2017-2018 Guillem Jover <guillem@hadrons.org>
|
.\" Copyright © 2017-2022 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,8 +24,8 @@
|
|||||||
.\" 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 May 21, 2018
|
.Dd August 3, 2022
|
||||||
.Dt LIBBSD 7
|
.Dt libbsd 7
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm libbsd
|
.Nm libbsd
|
||||||
@@ -42,7 +42,7 @@ The library can be used in an overlay mode, which is the preferred way, so
|
|||||||
that the code is portable and requires no modification to the original BSD
|
that the code is portable and requires no modification to the original BSD
|
||||||
code.
|
code.
|
||||||
This can be done easily with the
|
This can be done easily with the
|
||||||
.Xr pkg-config 3
|
.Xr pkgconf 1
|
||||||
library named
|
library named
|
||||||
.Pa libbsd-overlay .
|
.Pa libbsd-overlay .
|
||||||
Or by adding the system-specific include directory with the
|
Or by adding the system-specific include directory with the
|
||||||
@@ -59,12 +59,12 @@ The includes in this case should be the usual system ones, such as
|
|||||||
.In unistd.h .
|
.In unistd.h .
|
||||||
.Pp
|
.Pp
|
||||||
The other way to use the library is to use the namespaced headers,
|
The other way to use the library is to use the namespaced headers,
|
||||||
this is less portable as it makes using
|
which is a discouraged way, being less portable as it makes using
|
||||||
.Nm libbsd
|
.Nm libbsd
|
||||||
mandatory and it will not work on BSD-based systems, and requires
|
mandatory and it will not work on BSD-based systems, and requires
|
||||||
modifying original BSD code.
|
modifying original BSD code.
|
||||||
This can be done with the
|
This can be done with the
|
||||||
.Xr pkg-config 3
|
.Xr pkgconf 1
|
||||||
library named
|
library named
|
||||||
.Pa libbsd .
|
.Pa libbsd .
|
||||||
The includes in this case should be namespaced with
|
The includes in this case should be namespaced with
|
||||||
@@ -73,13 +73,13 @@ such as
|
|||||||
.In bsd/unistd.h .
|
.In bsd/unistd.h .
|
||||||
.Pp
|
.Pp
|
||||||
The package also provides a
|
The package also provides a
|
||||||
.Pa bsd-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
|
||||||
.Fn setproctitle_init 3
|
.Fn setproctitle_init 3
|
||||||
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 pkg-config 3
|
.Xr pkgconf 1
|
||||||
library named
|
library named
|
||||||
.Pa libbsd-ctor .
|
.Pa libbsd-ctor .
|
||||||
.Sh HEADERS
|
.Sh HEADERS
|
||||||
@@ -134,7 +134,8 @@ originated from, and these various implementations provided are selectable
|
|||||||
at build-time.
|
at build-time.
|
||||||
.Pp
|
.Pp
|
||||||
This is the list of functions that provide multiple implementations:
|
This is the list of functions that provide multiple implementations:
|
||||||
.Bl -tag -width 4m
|
.Pp
|
||||||
|
.Bl -tag -width 4m -compact
|
||||||
.It Fn strnvis 3
|
.It Fn strnvis 3
|
||||||
.It Fn strnunvis 3
|
.It Fn strnunvis 3
|
||||||
.Nx
|
.Nx
|
||||||
@@ -160,7 +161,8 @@ functions and is now more widespread.
|
|||||||
Define
|
Define
|
||||||
.Dv LIBBSD_NETBSD_VIS
|
.Dv LIBBSD_NETBSD_VIS
|
||||||
to switch to the
|
to switch to the
|
||||||
.Nx one now.
|
.Nx
|
||||||
|
one now.
|
||||||
Define
|
Define
|
||||||
.Dv LIBBSD_OPENBSD_VIS
|
.Dv LIBBSD_OPENBSD_VIS
|
||||||
to keep using the
|
to keep using the
|
||||||
@@ -229,11 +231,26 @@ companion library, so it is advised to switch to use that directly instead.
|
|||||||
.It Fn explicit_bzero 3
|
.It Fn explicit_bzero 3
|
||||||
This function is provided by
|
This function is provided by
|
||||||
.Nm glibc
|
.Nm glibc
|
||||||
2.25.
|
2.25, and
|
||||||
|
.Nm musl
|
||||||
|
1.1.20.
|
||||||
.It Fn reallocarray 3
|
.It Fn reallocarray 3
|
||||||
This function is provided by
|
This function is provided by
|
||||||
.Nm glibc
|
.Nm glibc
|
||||||
2.26.
|
2.26, and
|
||||||
|
.Nm musl
|
||||||
|
1.2.2.
|
||||||
|
.It Fn arc4random 3
|
||||||
|
.It Fn arc4random_buf 3
|
||||||
|
.It Fn arc4random_uniform 3
|
||||||
|
These functions are provided by
|
||||||
|
.Nm glibc
|
||||||
|
2.36.
|
||||||
|
Note that it does not provide the
|
||||||
|
.Fn arc4random_stir 3
|
||||||
|
and
|
||||||
|
.Fn arc4random_addrandom 3
|
||||||
|
functions.
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr arc4random 3bsd ,
|
.Xr arc4random 3bsd ,
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/nlist.3,v 1.7 2001/10/01 16:08:51 ru Exp $
|
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/nlist.3,v 1.7 2001/10/01 16:08:51 ru Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd April 19, 1994
|
.Dd April 19, 1994
|
||||||
.Dt NLIST 3bsd
|
.Dt nlist 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm nlist
|
.Nm nlist
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd February 8, 2012
|
.Dd February 8, 2012
|
||||||
.Dt PIDFILE 3bsd
|
.Dt pidfile 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm pidfile_open ,
|
.Nm pidfile_open ,
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: September 13 2018 $
|
.Dd $Mdocdate: September 13 2018 $
|
||||||
.Dt USER_FROM_UID 3
|
.Dt user_from_uid 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm user_from_uid ,
|
.Nm user_from_uid ,
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd September 8, 2016
|
.Dd September 8, 2016
|
||||||
.Dt QUEUE 3bsd
|
.Dt queue 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm SLIST_CLASS_ENTRY ,
|
.Nm SLIST_CLASS_ENTRY ,
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
.\" from: @(#)radixsort.3 8.2 (Berkeley) 1/27/94
|
.\" from: @(#)radixsort.3 8.2 (Berkeley) 1/27/94
|
||||||
.\"
|
.\"
|
||||||
.Dd January 27, 1994
|
.Dd January 27, 1994
|
||||||
.Dt RADIXSORT 3bsd
|
.Dt radixsort 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm radixsort ,
|
.Nm radixsort ,
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: March 6 2014 $
|
.Dd $Mdocdate: March 6 2014 $
|
||||||
.Dt READPASSPHRASE 3bsd
|
.Dt readpassphrase 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm readpassphrase
|
.Nm readpassphrase
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
.\" $OpenBSD: malloc.3,v 1.126 2019/09/14 13:16:50 otto Exp $
|
.\" $OpenBSD: malloc.3,v 1.126 2019/09/14 13:16:50 otto Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: September 14 2019 $
|
.Dd $Mdocdate: September 14 2019 $
|
||||||
.Dt REALLOCARRAY 3bsd
|
.Dt reallocarray 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm reallocarray ,
|
.Nm reallocarray ,
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.80.2.2.2.1 2010/06/14 02:09:06 kensmith Exp $
|
.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.80.2.2.2.1 2010/06/14 02:09:06 kensmith Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd September 26, 2009
|
.Dd September 26, 2009
|
||||||
.Dt REALLOCF 3bsd
|
.Dt reallocf 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm reallocf
|
.Nm reallocf
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
.\" $FreeBSD: src/lib/libc/gen/setmode.3,v 1.12 2007/01/09 00:27:55 imp Exp $
|
.\" $FreeBSD: src/lib/libc/gen/setmode.3,v 1.12 2007/01/09 00:27:55 imp Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd January 4, 2009
|
.Dd January 4, 2009
|
||||||
.Dt SETMODE 3bsd
|
.Dt setmode 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm getmode ,
|
.Nm getmode ,
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" The following requests are required for all man pages.
|
.\" The following requests are required for all man pages.
|
||||||
.Dd December 16, 1995
|
.Dd December 16, 1995
|
||||||
.Dt SETPROCTITLE 3bsd
|
.Dt setproctitle 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm setproctitle
|
.Nm setproctitle
|
||||||
@@ -54,7 +54,7 @@ library routine only needs to be called (before any call to
|
|||||||
and with
|
and with
|
||||||
.Fn main
|
.Fn main
|
||||||
arguments), if the automatic constructor support has not
|
arguments), if the automatic constructor support has not
|
||||||
been linked in through the libbsd-ctor pkg-config file.
|
been linked in through the libbsd-ctor pkgconf file.
|
||||||
.Pp
|
.Pp
|
||||||
The title is set from the executable's name, followed by the
|
The title is set from the executable's name, followed by the
|
||||||
result of a
|
result of a
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd May 6, 2010
|
.Dd May 6, 2010
|
||||||
.Dt STRINGLIST 3bsd
|
.Dt stringlist 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm stringlist ,
|
.Nm stringlist ,
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: May 31 2007 $
|
.Dd $Mdocdate: May 31 2007 $
|
||||||
.Dt STRLCPY 3bsd
|
.Dt strlcpy 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strlcpy ,
|
.Nm strlcpy ,
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
.\" $FreeBSD: src/lib/libc/string/strmode.3,v 1.9 2003/07/01 15:28:05 maxim Exp $
|
.\" $FreeBSD: src/lib/libc/string/strmode.3,v 1.9 2003/07/01 15:28:05 maxim Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd July 28, 1994
|
.Dd July 28, 1994
|
||||||
.Dt STRMODE 3bsd
|
.Dt strmode 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strmode
|
.Nm strmode
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd October 11, 2001
|
.Dd October 11, 2001
|
||||||
.Dt STRSTR 3bsd
|
.Dt strstr 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strnstr
|
.Nm strnstr
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
.\" 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 November 13, 2015
|
||||||
.Dt STRTOI 3bsd
|
.Dt strtoi 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strtoi
|
.Nm strtoi
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd January 18, 2015
|
.Dd January 18, 2015
|
||||||
.Dt STRTONUM 3bsd
|
.Dt strtonum 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strtonum
|
.Nm strtonum
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
.\" 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 November 13, 2015
|
||||||
.Dt STRTOU 3bsd
|
.Dt strtou 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm strtou
|
.Nm strtou
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
.\" $FreeBSD: src/share/man/man3/timeradd.3,v 1.3 2003/09/08 19:57:19 ru Exp $
|
.\" $FreeBSD: src/share/man/man3/timeradd.3,v 1.3 2003/09/08 19:57:19 ru Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd June 7, 2010
|
.Dd June 7, 2010
|
||||||
.Dt TIMERADD 3bsd
|
.Dt timeradd 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm timeradd ,
|
.Nm timeradd ,
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd April 12, 2011
|
.Dd April 12, 2011
|
||||||
.Dt TIMEVAL 3bsd
|
.Dt timeval 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm timeval ,
|
.Nm timeval ,
|
||||||
|
393
man/tree.3bsd
393
man/tree.3bsd
@@ -1,37 +1,30 @@
|
|||||||
.\" $OpenBSD: tree.3,v 1.7 2002/06/12 01:09:20 provos Exp $
|
.\" $OpenBSD: tree.3,v 1.30 2019/05/10 13:13:14 florian Exp $
|
||||||
.\"
|
.\"/*
|
||||||
.\" Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
.\" * Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||||
.\" All rights reserved.
|
.\" * All rights reserved.
|
||||||
.\"
|
.\" *
|
||||||
.\" 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
|
||||||
.\" are met:
|
.\" * are met:
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
.\" * 1. Redistributions of source code must retain the above copyright
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
.\" * notice, this list of conditions and the following disclaimer.
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
.\" * 2. Redistributions in binary form must reproduce the above copyright
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
.\" * notice, this list of conditions and the following disclaimer in the
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
.\" * documentation and/or other materials provided with the distribution.
|
||||||
.\" 3. All advertising materials mentioning features or use of this software
|
.\" *
|
||||||
.\" must display the following acknowledgement:
|
.\" * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
.\" This product includes software developed by Niels Provos.
|
.\" * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
.\" 4. The name of the author may not be used to endorse or promote products
|
.\" * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
.\" derived from this software without specific prior written permission.
|
.\" * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
.\"
|
.\" * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
.\" * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
.\" * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
.\" * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
.\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
.\" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
.\" */
|
||||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
.Dd May 10, 2019
|
||||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
.Dt tree 3bsd
|
||||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" $FreeBSD$
|
|
||||||
.\"
|
|
||||||
.Dd December 27, 2007
|
|
||||||
.Dt TREE 3bsd
|
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm SPLAY_PROTOTYPE ,
|
.Nm SPLAY_PROTOTYPE ,
|
||||||
@@ -70,7 +63,9 @@
|
|||||||
.Nm RB_RIGHT ,
|
.Nm RB_RIGHT ,
|
||||||
.Nm RB_PARENT ,
|
.Nm RB_PARENT ,
|
||||||
.Nm RB_FOREACH ,
|
.Nm RB_FOREACH ,
|
||||||
|
.Nm RB_FOREACH_SAFE ,
|
||||||
.Nm RB_FOREACH_REVERSE ,
|
.Nm RB_FOREACH_REVERSE ,
|
||||||
|
.Nm RB_FOREACH_REVERSE_SAFE ,
|
||||||
.Nm RB_INIT ,
|
.Nm RB_INIT ,
|
||||||
.Nm RB_INSERT ,
|
.Nm RB_INSERT ,
|
||||||
.Nm RB_REMOVE
|
.Nm RB_REMOVE
|
||||||
@@ -84,88 +79,92 @@
|
|||||||
(See
|
(See
|
||||||
.Xr libbsd 7
|
.Xr libbsd 7
|
||||||
for include usage.)
|
for include usage.)
|
||||||
.Fn SPLAY_PROTOTYPE NAME TYPE FIELD CMP
|
.Pp
|
||||||
.Fn SPLAY_GENERATE NAME TYPE FIELD CMP
|
.Fn SPLAY_PROTOTYPE "NAME" "TYPE" "FIELD" "CMP"
|
||||||
.Fn SPLAY_ENTRY TYPE
|
.Fn SPLAY_GENERATE "NAME" "TYPE" "FIELD" "CMP"
|
||||||
.Fn SPLAY_HEAD HEADNAME TYPE
|
.Fn SPLAY_ENTRY "TYPE"
|
||||||
|
.Fn SPLAY_HEAD "HEADNAME" "TYPE"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_INITIALIZER "SPLAY_HEAD *head"
|
.Fn SPLAY_INITIALIZER "SPLAY_HEAD *head"
|
||||||
.Fn SPLAY_ROOT "SPLAY_HEAD *head"
|
.Fn SPLAY_ROOT "SPLAY_HEAD *head"
|
||||||
.Ft bool
|
.Ft "int"
|
||||||
.Fn SPLAY_EMPTY "SPLAY_HEAD *head"
|
.Fn SPLAY_EMPTY "SPLAY_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_NEXT NAME "SPLAY_HEAD *head" "struct TYPE *elm"
|
.Fn SPLAY_NEXT "NAME" "SPLAY_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_MIN NAME "SPLAY_HEAD *head"
|
.Fn SPLAY_MIN "NAME" "SPLAY_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_MAX NAME "SPLAY_HEAD *head"
|
.Fn SPLAY_MAX "NAME" "SPLAY_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_FIND NAME "SPLAY_HEAD *head" "struct TYPE *elm"
|
.Fn SPLAY_FIND "NAME" "SPLAY_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_LEFT "struct TYPE *elm" "SPLAY_ENTRY NAME"
|
.Fn SPLAY_LEFT "struct TYPE *elm" "SPLAY_ENTRY NAME"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_RIGHT "struct TYPE *elm" "SPLAY_ENTRY NAME"
|
.Fn SPLAY_RIGHT "struct TYPE *elm" "SPLAY_ENTRY NAME"
|
||||||
.Fn SPLAY_FOREACH VARNAME NAME "SPLAY_HEAD *head"
|
.Fn SPLAY_FOREACH "VARNAME" "NAME" "SPLAY_HEAD *head"
|
||||||
.Ft void
|
.Ft void
|
||||||
.Fn SPLAY_INIT "SPLAY_HEAD *head"
|
.Fn SPLAY_INIT "SPLAY_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_INSERT NAME "SPLAY_HEAD *head" "struct TYPE *elm"
|
.Fn SPLAY_INSERT "NAME" "SPLAY_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn SPLAY_REMOVE NAME "SPLAY_HEAD *head" "struct TYPE *elm"
|
.Fn SPLAY_REMOVE "NAME" "SPLAY_HEAD *head" "struct TYPE *elm"
|
||||||
.Fn RB_PROTOTYPE NAME TYPE FIELD CMP
|
.Pp
|
||||||
.Fn RB_PROTOTYPE_STATIC NAME TYPE FIELD CMP
|
.Fn RB_PROTOTYPE "NAME" "TYPE" "FIELD" "CMP"
|
||||||
.Fn RB_GENERATE NAME TYPE FIELD CMP
|
.Fn RB_PROTOTYPE_STATIC "NAME" "TYPE" "FIELD" "CMP"
|
||||||
.Fn RB_GENERATE_STATIC NAME TYPE FIELD CMP
|
.Fn RB_GENERATE "NAME" "TYPE" "FIELD" "CMP"
|
||||||
.Fn RB_ENTRY TYPE
|
.Fn RB_GENERATE_STATIC "NAME" "TYPE" "FIELD" "CMP"
|
||||||
.Fn RB_HEAD HEADNAME TYPE
|
.Fn RB_ENTRY "TYPE"
|
||||||
|
.Fn RB_HEAD "HEADNAME" "TYPE"
|
||||||
.Fn RB_INITIALIZER "RB_HEAD *head"
|
.Fn RB_INITIALIZER "RB_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_ROOT "RB_HEAD *head"
|
.Fn RB_ROOT "RB_HEAD *head"
|
||||||
.Ft "bool"
|
.Ft "int"
|
||||||
.Fn RB_EMPTY "RB_HEAD *head"
|
.Fn RB_EMPTY "RB_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_NEXT NAME "RB_HEAD *head" "struct TYPE *elm"
|
.Fn RB_NEXT "NAME" "RB_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_PREV NAME "RB_HEAD *head" "struct TYPE *elm"
|
.Fn RB_PREV "NAME" "RB_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_MIN NAME "RB_HEAD *head"
|
.Fn RB_MIN "NAME" "RB_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_MAX NAME "RB_HEAD *head"
|
.Fn RB_MAX "NAME" "RB_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_FIND NAME "RB_HEAD *head" "struct TYPE *elm"
|
.Fn RB_FIND "NAME" "RB_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_NFIND NAME "RB_HEAD *head" "struct TYPE *elm"
|
.Fn RB_NFIND "NAME" "RB_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_LEFT "struct TYPE *elm" "RB_ENTRY NAME"
|
.Fn RB_LEFT "struct TYPE *elm" "RB_ENTRY NAME"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_RIGHT "struct TYPE *elm" "RB_ENTRY NAME"
|
.Fn RB_RIGHT "struct TYPE *elm" "RB_ENTRY NAME"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_PARENT "struct TYPE *elm" "RB_ENTRY NAME"
|
.Fn RB_PARENT "struct TYPE *elm" "RB_ENTRY NAME"
|
||||||
.Fn RB_FOREACH VARNAME NAME "RB_HEAD *head"
|
.Fn RB_FOREACH "VARNAME" "NAME" "RB_HEAD *head"
|
||||||
.Fn RB_FOREACH_REVERSE VARNAME NAME "RB_HEAD *head"
|
.Fn RB_FOREACH_SAFE "VARNAME" "NAME" "RB_HEAD *head" "TEMP_VARNAME"
|
||||||
|
.Fn RB_FOREACH_REVERSE "VARNAME" "NAME" "RB_HEAD *head"
|
||||||
|
.Fn RB_FOREACH_REVERSE_SAFE "VARNAME" "NAME" "RB_HEAD *head" "TEMP_VARNAME"
|
||||||
.Ft void
|
.Ft void
|
||||||
.Fn RB_INIT "RB_HEAD *head"
|
.Fn RB_INIT "RB_HEAD *head"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_INSERT NAME "RB_HEAD *head" "struct TYPE *elm"
|
.Fn RB_INSERT "NAME" "RB_HEAD *head" "struct TYPE *elm"
|
||||||
.Ft "struct TYPE *"
|
.Ft "struct TYPE *"
|
||||||
.Fn RB_REMOVE NAME "RB_HEAD *head" "struct TYPE *elm"
|
.Fn RB_REMOVE "NAME" "RB_HEAD *head" "struct TYPE *elm"
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
These macros define data structures for different types of trees:
|
These macros define data structures for different types of trees:
|
||||||
splay trees and red-black trees.
|
splay trees and red-black trees.
|
||||||
.Pp
|
.Pp
|
||||||
In the macro definitions,
|
In the macro definitions,
|
||||||
.Fa TYPE
|
.Fa TYPE
|
||||||
is the name tag of a user defined structure that must contain a field of type
|
is the name tag of a user defined structure that must contain a field named
|
||||||
.Vt SPLAY_ENTRY ,
|
.Fa FIELD ,
|
||||||
|
of type
|
||||||
|
.Li SPLAY_ENTRY
|
||||||
or
|
or
|
||||||
.Vt RB_ENTRY ,
|
.Li RB_ENTRY .
|
||||||
named
|
|
||||||
.Fa ENTRYNAME .
|
|
||||||
The argument
|
The argument
|
||||||
.Fa HEADNAME
|
.Fa HEADNAME
|
||||||
is the name tag of a user defined structure that must be declared
|
is the name tag of a user defined structure that must be declared
|
||||||
using the macros
|
using the macros
|
||||||
.Fn SPLAY_HEAD ,
|
.Fn SPLAY_HEAD
|
||||||
or
|
or
|
||||||
.Fn RB_HEAD .
|
.Fn RB_HEAD .
|
||||||
The argument
|
The argument
|
||||||
@@ -173,46 +172,38 @@ The argument
|
|||||||
has to be a unique name prefix for every tree that is defined.
|
has to be a unique name prefix for every tree that is defined.
|
||||||
.Pp
|
.Pp
|
||||||
The function prototypes are declared with
|
The function prototypes are declared with
|
||||||
.Fn SPLAY_PROTOTYPE ,
|
.Li SPLAY_PROTOTYPE ,
|
||||||
.Fn RB_PROTOTYPE ,
|
.Li RB_PROTOTYPE ,
|
||||||
or
|
or
|
||||||
.Fn RB_PROTOTYPE_STATIC .
|
.Li RB_PROTOTYPE_STATIC .
|
||||||
The function bodies are generated with
|
The function bodies are generated with
|
||||||
.Fn SPLAY_GENERATE ,
|
.Li SPLAY_GENERATE ,
|
||||||
.Fn RB_GENERATE ,
|
.Li RB_GENERATE ,
|
||||||
or
|
or
|
||||||
.Fn RB_GENERATE_STATIC .
|
.Li RB_GENERATE_STATIC .
|
||||||
See the examples below for further explanation of how these macros are used.
|
See the examples below for further explanation of how these macros are used.
|
||||||
.Sh SPLAY TREES
|
.Sh SPLAY TREES
|
||||||
A splay tree is a self-organizing data structure.
|
A splay tree is a self-organizing data structure.
|
||||||
Every operation on the tree causes a splay to happen.
|
Every operation on the tree causes a splay to happen.
|
||||||
The splay moves the requested
|
The splay moves the requested node to the root of the tree and partly
|
||||||
node to the root of the tree and partly rebalances it.
|
rebalances it.
|
||||||
.Pp
|
.Pp
|
||||||
This has the benefit that request locality causes faster lookups as
|
This has the benefit that request locality causes faster lookups as
|
||||||
the requested nodes move to the top of the tree.
|
the requested nodes move to the top of the tree.
|
||||||
On the other hand, every lookup causes memory writes.
|
On the other hand, every lookup causes memory writes.
|
||||||
.Pp
|
.Pp
|
||||||
The Balance Theorem bounds the total access time for
|
The Balance Theorem bounds the total access time for m operations
|
||||||
.Ar m
|
and n inserts on an initially empty tree as O((m + n)lg n).
|
||||||
operations and
|
The amortized cost for a sequence of m accesses to a splay tree is O(lg n).
|
||||||
.Ar n
|
|
||||||
inserts on an initially empty tree as
|
|
||||||
.Fn O "\*[lp]m + n\*[rp]lg n" .
|
|
||||||
The
|
|
||||||
amortized cost for a sequence of
|
|
||||||
.Ar m
|
|
||||||
accesses to a splay tree is
|
|
||||||
.Fn O "lg n" .
|
|
||||||
.Pp
|
.Pp
|
||||||
A splay tree is headed by a structure defined by the
|
A splay tree is headed by a structure defined by the
|
||||||
.Fn SPLAY_HEAD
|
.Fn SPLAY_HEAD
|
||||||
macro.
|
macro.
|
||||||
A
|
A
|
||||||
|
.Fa SPLAY_HEAD
|
||||||
structure is declared as follows:
|
structure is declared as follows:
|
||||||
.Bd -ragged -offset indent
|
.Bd -literal -offset indent
|
||||||
.Fn SPLAY_HEAD HEADNAME TYPE
|
SPLAY_HEAD(HEADNAME, TYPE) head;
|
||||||
.Va head ;
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
where
|
where
|
||||||
@@ -251,16 +242,15 @@ macro, but should be used only once.
|
|||||||
Finally,
|
Finally,
|
||||||
the
|
the
|
||||||
.Fa CMP
|
.Fa CMP
|
||||||
argument is the name of a function used to compare tree nodes
|
argument is the name of a function used to compare trees' nodes
|
||||||
with each other.
|
with each other.
|
||||||
The function takes two arguments of type
|
The function takes two arguments of type
|
||||||
.Vt "struct TYPE *" .
|
.Fa "struct TYPE *" .
|
||||||
If the first argument is smaller than the second, the function returns a
|
If the first argument is smaller than the second, the function returns a
|
||||||
value smaller than zero.
|
value smaller than zero.
|
||||||
If they are equal, the function returns zero.
|
If they are equal, the function returns zero.
|
||||||
Otherwise, it should return a value greater than zero.
|
Otherwise, it should return a value greater than zero.
|
||||||
The compare
|
The compare function defines the order of the tree elements.
|
||||||
function defines the order of the tree elements.
|
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn SPLAY_INIT
|
.Fn SPLAY_INIT
|
||||||
@@ -270,11 +260,8 @@ macro initializes the tree referenced by
|
|||||||
The splay tree can also be initialized statically by using the
|
The splay tree can also be initialized statically by using the
|
||||||
.Fn SPLAY_INITIALIZER
|
.Fn SPLAY_INITIALIZER
|
||||||
macro like this:
|
macro like this:
|
||||||
.Bd -ragged -offset indent
|
.Bd -literal -offset indent
|
||||||
.Fn SPLAY_HEAD HEADNAME TYPE
|
SPLAY_HEAD(HEADNAME, TYPE) head = SPLAY_INITIALIZER(&head);
|
||||||
.Va head
|
|
||||||
=
|
|
||||||
.Fn SPLAY_INITIALIZER &head ;
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
@@ -282,6 +269,11 @@ The
|
|||||||
macro inserts the new element
|
macro inserts the new element
|
||||||
.Fa elm
|
.Fa elm
|
||||||
into the tree.
|
into the tree.
|
||||||
|
Upon success,
|
||||||
|
.Va NULL
|
||||||
|
is returned.
|
||||||
|
If a matching element already exists in the tree, the insertion is
|
||||||
|
aborted, and a pointer to the existing element is returned.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn SPLAY_REMOVE
|
.Fn SPLAY_REMOVE
|
||||||
@@ -289,6 +281,11 @@ macro removes the element
|
|||||||
.Fa elm
|
.Fa elm
|
||||||
from the tree pointed by
|
from the tree pointed by
|
||||||
.Fa head .
|
.Fa head .
|
||||||
|
Upon success, a pointer to the removed element is returned.
|
||||||
|
.Va NULL
|
||||||
|
is returned if
|
||||||
|
.Fa elm
|
||||||
|
is not present in the tree.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn SPLAY_FIND
|
.Fn SPLAY_FIND
|
||||||
@@ -296,7 +293,7 @@ macro can be used to find a particular element in the tree.
|
|||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
struct TYPE find, *res;
|
struct TYPE find, *res;
|
||||||
find.key = 30;
|
find.key = 30;
|
||||||
res = SPLAY_FIND(NAME, head, &find);
|
res = SPLAY_FIND(NAME, &head, &find);
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
@@ -313,8 +310,8 @@ for (np = SPLAY_MIN(NAME, &head); np != NULL; np = SPLAY_NEXT(NAME, &head, np))
|
|||||||
Or, for simplicity, one can use the
|
Or, for simplicity, one can use the
|
||||||
.Fn SPLAY_FOREACH
|
.Fn SPLAY_FOREACH
|
||||||
macro:
|
macro:
|
||||||
.Bd -ragged -offset indent
|
.Bd -literal -offset indent
|
||||||
.Fn SPLAY_FOREACH np NAME head
|
SPLAY_FOREACH(np, NAME, &head)
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
@@ -324,29 +321,28 @@ macro should be used to check whether a splay tree is empty.
|
|||||||
A red-black tree is a binary search tree with the node color as an
|
A red-black tree is a binary search tree with the node color as an
|
||||||
extra attribute.
|
extra attribute.
|
||||||
It fulfills a set of conditions:
|
It fulfills a set of conditions:
|
||||||
.Bl -enum -offset indent
|
.Pp
|
||||||
|
.Bl -enum -compact -offset indent
|
||||||
.It
|
.It
|
||||||
Every search path from the root to a leaf consists of the same number of
|
every search path from the root to a leaf consists of the same number of
|
||||||
black nodes.
|
black nodes,
|
||||||
.It
|
.It
|
||||||
Each red node (except for the root) has a black parent.
|
each red node (except for the root) has a black parent,
|
||||||
.It
|
.It
|
||||||
Each leaf node is black.
|
each leaf node is black.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Every operation on a red-black tree is bounded as
|
Every operation on a red-black tree is bounded as O(lg n).
|
||||||
.Fn O "lg n" .
|
The maximum height of a red-black tree is 2lg (n+1).
|
||||||
The maximum height of a red-black tree is
|
|
||||||
.Fn 2lg "n + 1" .
|
|
||||||
.Pp
|
.Pp
|
||||||
A red-black tree is headed by a structure defined by the
|
A red-black tree is headed by a structure defined by the
|
||||||
.Fn RB_HEAD
|
.Fn RB_HEAD
|
||||||
macro.
|
macro.
|
||||||
A
|
A
|
||||||
|
.Fa RB_HEAD
|
||||||
structure is declared as follows:
|
structure is declared as follows:
|
||||||
.Bd -ragged -offset indent
|
.Bd -literal -offset indent
|
||||||
.Fn RB_HEAD HEADNAME TYPE
|
RB_HEAD(HEADNAME, TYPE) head;
|
||||||
.Va head ;
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
where
|
where
|
||||||
@@ -364,7 +360,7 @@ their prototypes need to be declared with the
|
|||||||
.Fn RB_PROTOTYPE
|
.Fn RB_PROTOTYPE
|
||||||
or
|
or
|
||||||
.Fn RB_PROTOTYPE_STATIC
|
.Fn RB_PROTOTYPE_STATIC
|
||||||
macro,
|
macros,
|
||||||
where
|
where
|
||||||
.Fa NAME
|
.Fa NAME
|
||||||
is a unique identifier for this particular tree.
|
is a unique identifier for this particular tree.
|
||||||
@@ -381,7 +377,7 @@ The function bodies are generated with the
|
|||||||
.Fn RB_GENERATE
|
.Fn RB_GENERATE
|
||||||
or
|
or
|
||||||
.Fn RB_GENERATE_STATIC
|
.Fn RB_GENERATE_STATIC
|
||||||
macro.
|
macros.
|
||||||
These macros take the same arguments as the
|
These macros take the same arguments as the
|
||||||
.Fn RB_PROTOTYPE
|
.Fn RB_PROTOTYPE
|
||||||
and
|
and
|
||||||
@@ -391,16 +387,15 @@ macros, but should be used only once.
|
|||||||
Finally,
|
Finally,
|
||||||
the
|
the
|
||||||
.Fa CMP
|
.Fa CMP
|
||||||
argument is the name of a function used to compare tree nodes
|
argument is the name of a function used to compare trees' nodes
|
||||||
with each other.
|
with each other.
|
||||||
The function takes two arguments of type
|
The function takes two arguments of type
|
||||||
.Vt "struct TYPE *" .
|
.Fa "struct TYPE *" .
|
||||||
If the first argument is smaller than the second, the function returns a
|
If the first argument is smaller than the second, the function returns a
|
||||||
value smaller than zero.
|
value smaller than zero.
|
||||||
If they are equal, the function returns zero.
|
If they are equal, the function returns zero.
|
||||||
Otherwise, it should return a value greater than zero.
|
Otherwise, it should return a value greater than zero.
|
||||||
The compare
|
The compare function defines the order of the tree elements.
|
||||||
function defines the order of the tree elements.
|
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn RB_INIT
|
.Fn RB_INIT
|
||||||
@@ -410,11 +405,8 @@ macro initializes the tree referenced by
|
|||||||
The red-black tree can also be initialized statically by using the
|
The red-black tree can also be initialized statically by using the
|
||||||
.Fn RB_INITIALIZER
|
.Fn RB_INITIALIZER
|
||||||
macro like this:
|
macro like this:
|
||||||
.Bd -ragged -offset indent
|
.Bd -literal -offset indent
|
||||||
.Fn RB_HEAD HEADNAME TYPE
|
RB_HEAD(HEADNAME, TYPE) head = RB_INITIALIZER(&head);
|
||||||
.Va head
|
|
||||||
=
|
|
||||||
.Fn RB_INITIALIZER &head ;
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
@@ -422,6 +414,11 @@ The
|
|||||||
macro inserts the new element
|
macro inserts the new element
|
||||||
.Fa elm
|
.Fa elm
|
||||||
into the tree.
|
into the tree.
|
||||||
|
Upon success,
|
||||||
|
.Va NULL
|
||||||
|
is returned.
|
||||||
|
If a matching element already exists in the tree, the insertion is
|
||||||
|
aborted, and a pointer to the existing element is returned.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn RB_REMOVE
|
.Fn RB_REMOVE
|
||||||
@@ -429,16 +426,24 @@ macro removes the element
|
|||||||
.Fa elm
|
.Fa elm
|
||||||
from the tree pointed by
|
from the tree pointed by
|
||||||
.Fa head .
|
.Fa head .
|
||||||
|
.Fn RB_REMOVE
|
||||||
|
returns
|
||||||
|
.Fa elm .
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn RB_FIND
|
.Fn RB_FIND
|
||||||
and
|
and
|
||||||
.Fn RB_NFIND
|
.Fn RB_NFIND
|
||||||
macros can be used to find a particular element in the tree.
|
macros can be used to find a particular element in the tree.
|
||||||
|
.Fn RB_FIND
|
||||||
|
finds the node with the same key as
|
||||||
|
.Fa elm .
|
||||||
|
.Fn RB_NFIND
|
||||||
|
finds the first node greater than or equal to the search key.
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
struct TYPE find, *res;
|
struct TYPE find, *res;
|
||||||
find.key = 30;
|
find.key = 30;
|
||||||
res = RB_FIND(NAME, head, &find);
|
res = RB_FIND(NAME, &head, &find);
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
@@ -449,26 +454,119 @@ The
|
|||||||
and
|
and
|
||||||
.Fn RB_PREV
|
.Fn RB_PREV
|
||||||
macros can be used to traverse the tree:
|
macros can be used to traverse the tree:
|
||||||
.Pp
|
.Bd -literal -offset indent
|
||||||
.Dl "for (np = RB_MIN(NAME, &head); np != NULL; np = RB_NEXT(NAME, &head, np))"
|
for (np = RB_MIN(NAME, &head); np != NULL; np = RB_NEXT(NAME, &head, np))
|
||||||
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Or, for simplicity, one can use the
|
Or, for simplicity, one can use the
|
||||||
.Fn RB_FOREACH
|
.Fn RB_FOREACH
|
||||||
or
|
or
|
||||||
.Fn RB_FOREACH_REVERSE
|
.Fn RB_FOREACH_REVERSE
|
||||||
macro:
|
macros:
|
||||||
.Bd -ragged -offset indent
|
.Bd -literal -offset indent
|
||||||
.Fn RB_FOREACH np NAME head
|
RB_FOREACH(np, NAME, &head)
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
|
The macros
|
||||||
|
.Fn RB_FOREACH_SAFE
|
||||||
|
and
|
||||||
|
.Fn RB_FOREACH_REVERSE_SAFE
|
||||||
|
traverse the tree referenced by head
|
||||||
|
in a forward or reverse direction respectively,
|
||||||
|
assigning each element in turn to np.
|
||||||
|
However, unlike their unsafe counterparts,
|
||||||
|
they permit both the removal of np
|
||||||
|
as well as freeing it from within the loop safely
|
||||||
|
without interfering with the traversal.
|
||||||
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn RB_EMPTY
|
.Fn RB_EMPTY
|
||||||
macro should be used to check whether a red-black tree is empty.
|
macro should be used to check whether a red-black tree is empty.
|
||||||
|
.Sh EXAMPLES
|
||||||
|
The following example demonstrates how to declare a red-black tree
|
||||||
|
holding integers.
|
||||||
|
Values are inserted into it and the contents of the tree are printed
|
||||||
|
in order.
|
||||||
|
Lastly, the internal structure of the tree is printed.
|
||||||
|
.Bd -literal -offset 3n
|
||||||
|
#include <sys/tree.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct node {
|
||||||
|
RB_ENTRY(node) entry;
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
int intcmp(struct node *, struct node *);
|
||||||
|
void print_tree(struct node *);
|
||||||
|
|
||||||
|
int
|
||||||
|
intcmp(struct node *e1, struct node *e2)
|
||||||
|
{
|
||||||
|
return (e1->i < e2->i ? -1 : e1->i > e2->i);
|
||||||
|
}
|
||||||
|
|
||||||
|
RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
|
||||||
|
RB_PROTOTYPE(inttree, node, entry, intcmp)
|
||||||
|
RB_GENERATE(inttree, node, entry, intcmp)
|
||||||
|
|
||||||
|
int testdata[] = {
|
||||||
|
20, 16, 17, 13, 3, 6, 1, 8, 2, 4, 10, 19, 5, 9, 12, 15, 18,
|
||||||
|
7, 11, 14
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
print_tree(struct node *n)
|
||||||
|
{
|
||||||
|
struct node *left, *right;
|
||||||
|
|
||||||
|
if (n == NULL) {
|
||||||
|
printf("nil");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
left = RB_LEFT(n, entry);
|
||||||
|
right = RB_RIGHT(n, entry);
|
||||||
|
if (left == NULL && right == NULL)
|
||||||
|
printf("%d", n->i);
|
||||||
|
else {
|
||||||
|
printf("%d(", n->i);
|
||||||
|
print_tree(left);
|
||||||
|
printf(",");
|
||||||
|
print_tree(right);
|
||||||
|
printf(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct node *n;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(testdata) / sizeof(testdata[0]); i++) {
|
||||||
|
if ((n = malloc(sizeof(struct node))) == NULL)
|
||||||
|
err(1, NULL);
|
||||||
|
n->i = testdata[i];
|
||||||
|
RB_INSERT(inttree, &head, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
RB_FOREACH(n, inttree, &head) {
|
||||||
|
printf("%d\en", n->i);
|
||||||
|
}
|
||||||
|
print_tree(RB_ROOT(&head));
|
||||||
|
printf("\en");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
.Ed
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr queue 3bsd
|
||||||
.Sh NOTES
|
.Sh NOTES
|
||||||
Trying to free a tree in the following way is a common error:
|
Trying to free a tree in the following way is a common error:
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
SPLAY_FOREACH(var, NAME, head) {
|
SPLAY_FOREACH(var, NAME, &head) {
|
||||||
SPLAY_REMOVE(NAME, head, var);
|
SPLAY_REMOVE(NAME, &head, var);
|
||||||
free(var);
|
free(var);
|
||||||
}
|
}
|
||||||
free(head);
|
free(head);
|
||||||
@@ -476,36 +574,17 @@ free(head);
|
|||||||
.Pp
|
.Pp
|
||||||
Since
|
Since
|
||||||
.Va var
|
.Va var
|
||||||
is freed, the
|
is free'd, the
|
||||||
.Fn FOREACH
|
.Fn FOREACH
|
||||||
macro refers to a pointer that may have been reallocated already.
|
macro refers to a pointer that may have been reallocated already.
|
||||||
Proper code needs a second variable.
|
Proper code needs a second variable.
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
for (var = SPLAY_MIN(NAME, head); var != NULL; var = nxt) {
|
for (var = SPLAY_MIN(NAME, &head); var != NULL; var = nxt) {
|
||||||
nxt = SPLAY_NEXT(NAME, head, var);
|
nxt = SPLAY_NEXT(NAME, &head, var);
|
||||||
SPLAY_REMOVE(NAME, head, var);
|
SPLAY_REMOVE(NAME, &head, var);
|
||||||
free(var);
|
free(var);
|
||||||
}
|
}
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
|
||||||
Both
|
|
||||||
.Fn RB_INSERT
|
|
||||||
and
|
|
||||||
.Fn SPLAY_INSERT
|
|
||||||
return
|
|
||||||
.Dv NULL
|
|
||||||
if the element was inserted in the tree successfully, otherwise they
|
|
||||||
return a pointer to the element with the colliding key.
|
|
||||||
.Pp
|
|
||||||
Accordingly,
|
|
||||||
.Fn RB_REMOVE
|
|
||||||
and
|
|
||||||
.Fn SPLAY_REMOVE
|
|
||||||
return the pointer to the removed element otherwise they return
|
|
||||||
.Dv NULL
|
|
||||||
to indicate an error.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr queue 3bsd
|
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
The author of the tree macros is
|
The author of the tree macros is
|
||||||
.An Niels Provos .
|
.An Niels Provos .
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93
|
.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93
|
||||||
.\"
|
.\"
|
||||||
.Dd March 12, 2011
|
.Dd March 12, 2011
|
||||||
.Dt UNVIS 3bsd
|
.Dt unvis 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm unvis ,
|
.Nm unvis ,
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
|
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
|
||||||
.\"
|
.\"
|
||||||
.Dd April 22, 2017
|
.Dd April 22, 2017
|
||||||
.Dt VIS 3bsd
|
.Dt vis 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm vis ,
|
.Nm vis ,
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd March 4, 2009
|
.Dd March 4, 2009
|
||||||
.Dt WCSLCPY 3bsd
|
.Dt wcslcpy 3bsd
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm wcslcat ,
|
.Nm wcslcat ,
|
||||||
|
@@ -25,6 +25,7 @@ libbsd_la_included_sources = \
|
|||||||
getentropy_win.c \
|
getentropy_win.c \
|
||||||
$(nil)
|
$(nil)
|
||||||
|
|
||||||
|
CLEANFILES =
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
libbsd.map \
|
libbsd.map \
|
||||||
libbsd.pc.in \
|
libbsd.pc.in \
|
||||||
@@ -52,9 +53,8 @@ libbsd_la_DEPENDENCIES = \
|
|||||||
$(libbsd_la_included_sources) \
|
$(libbsd_la_included_sources) \
|
||||||
libbsd.map
|
libbsd.map
|
||||||
libbsd_la_LIBADD = \
|
libbsd_la_LIBADD = \
|
||||||
$(MD_LIBS) \
|
$(MD5_LIBS) \
|
||||||
$(CLOCK_GETTIME_LIBS) \
|
$(LIBBSD_LIBS) \
|
||||||
$(ARC4RANDOM_ATFORK_LIBS) \
|
|
||||||
$(nil)
|
$(nil)
|
||||||
libbsd_la_LDFLAGS = \
|
libbsd_la_LDFLAGS = \
|
||||||
-version-number $(LIBBSD_ABI)
|
-version-number $(LIBBSD_ABI)
|
||||||
@@ -66,7 +66,6 @@ libbsd_la_SOURCES = \
|
|||||||
arc4random.c \
|
arc4random.c \
|
||||||
arc4random.h \
|
arc4random.h \
|
||||||
arc4random_linux.h \
|
arc4random_linux.h \
|
||||||
arc4random_openbsd.h \
|
|
||||||
arc4random_uniform.c \
|
arc4random_uniform.c \
|
||||||
arc4random_unix.h \
|
arc4random_unix.h \
|
||||||
arc4random_win.h \
|
arc4random_win.h \
|
||||||
@@ -126,22 +125,51 @@ libbsd_la_SOURCES += \
|
|||||||
$(nil)
|
$(nil)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if NEED_TRANSPARENT_LIBMD
|
||||||
|
CLEANFILES += \
|
||||||
|
format.ld \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
libbsd_ctor_a_SOURCES = \
|
libbsd_ctor_a_SOURCES = \
|
||||||
setproctitle_ctor.c \
|
setproctitle_ctor.c \
|
||||||
$(nil)
|
$(nil)
|
||||||
|
|
||||||
|
if NEED_TRANSPARENT_LIBMD
|
||||||
|
TRANSPARENT_LIBMD_DEPENDS = format.ld
|
||||||
|
|
||||||
|
format.ld:
|
||||||
|
$(CC) -shared -nostdlib -nostartfiles -x assembler /dev/null -o $@.so
|
||||||
|
$(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
|
||||||
|
rm -f $@.so
|
||||||
|
endif
|
||||||
|
|
||||||
runtimelibdir = $(libdir)
|
runtimelibdir = $(libdir)
|
||||||
|
|
||||||
install-exec-hook:
|
install-exec-hook: $(TRANSPARENT_LIBMD_DEPENDS)
|
||||||
if [ "$(libdir)" != "$(runtimelibdir)" ]; then \
|
if [ "$(libdir)" != "$(runtimelibdir)" ]; then \
|
||||||
$(MKDIR_P) $(DESTDIR)$(runtimelibdir); \
|
$(MKDIR_P) $(DESTDIR)$(runtimelibdir); \
|
||||||
mv $(DESTDIR)$(libdir)/libbsd*.so.* \
|
mv $(DESTDIR)$(libdir)/libbsd*.so.* \
|
||||||
$(DESTDIR)$(runtimelibdir)/; \
|
$(DESTDIR)$(runtimelibdir)/; \
|
||||||
|
fi
|
||||||
|
if NEED_TRANSPARENT_LIBMD
|
||||||
|
# The "GNU ld script" magic is required so that GNU ldconfig does not complain
|
||||||
|
# about an unknown format file.
|
||||||
soname=`readlink $(DESTDIR)$(libdir)/libbsd.so`; \
|
soname=`readlink $(DESTDIR)$(libdir)/libbsd.so`; \
|
||||||
sorelprefix=`echo $(libdir) | sed -r -e 's:(^/)?[^/]+:..:g'`; \
|
$(RM) $(DESTDIR)$(libdir)/libbsd.so; \
|
||||||
|
(echo '/* GNU ld script'; \
|
||||||
|
echo ' * The MD5 functions are provided by the libmd library. */'; \
|
||||||
|
cat format.ld; \
|
||||||
|
echo "GROUP($(runtimelibdir)/$$soname AS_NEEDED($(MD5_LIBS)))"; \
|
||||||
|
)>$(DESTDIR)$(libdir)/libbsd.so
|
||||||
|
else
|
||||||
|
if [ "$(libdir)" != "$(runtimelibdir)" ]; then \
|
||||||
|
soname=`readlink $(DESTDIR)$(libdir)/libbsd.so`; \
|
||||||
|
sorelprefix=`echo $(libdir) | $(SED) -r -e 's:(^/)?[^/]+:..:g'`; \
|
||||||
ln -sf $$sorelprefix$(runtimelibdir)/$$soname \
|
ln -sf $$sorelprefix$(runtimelibdir)/$$soname \
|
||||||
$(DESTDIR)$(libdir)/libbsd.so; \
|
$(DESTDIR)$(libdir)/libbsd.so; \
|
||||||
fi
|
fi
|
||||||
|
endif
|
||||||
|
|
||||||
uninstall-hook:
|
uninstall-hook:
|
||||||
rm -f $(DESTDIR)$(runtimelibdir)/libbsd*.so*
|
rm -f $(DESTDIR)$(runtimelibdir)/libbsd*.so*
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: arc4random.c,v 1.53 2015/09/10 18:53:50 bcook Exp $ */
|
/* $OpenBSD: arc4random.c,v 1.58 2022/07/31 13:41:45 tb Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, David Mazieres <dm@uun.org>
|
* Copyright (c) 1996, David Mazieres <dm@uun.org>
|
||||||
@@ -50,6 +50,8 @@
|
|||||||
#define BLOCKSZ 64
|
#define BLOCKSZ 64
|
||||||
#define RSBUFSZ (16*BLOCKSZ)
|
#define RSBUFSZ (16*BLOCKSZ)
|
||||||
|
|
||||||
|
#define REKEY_BASE (1024*1024) /* NB. should be a power of 2 */
|
||||||
|
|
||||||
/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */
|
/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */
|
||||||
static struct _rs {
|
static struct _rs {
|
||||||
size_t rs_have; /* valid bytes at end of rs_buf */
|
size_t rs_have; /* valid bytes at end of rs_buf */
|
||||||
@@ -74,10 +76,10 @@ _rs_init(unsigned char *buf, size_t n)
|
|||||||
|
|
||||||
if (rs == NULL) {
|
if (rs == NULL) {
|
||||||
if (_rs_allocate(&rs, &rsx) == -1)
|
if (_rs_allocate(&rs, &rsx) == -1)
|
||||||
abort();
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8, 0);
|
chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8);
|
||||||
chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ);
|
chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +110,7 @@ static void
|
|||||||
_rs_stir(void)
|
_rs_stir(void)
|
||||||
{
|
{
|
||||||
unsigned char rnd[KEYSZ + IVSZ];
|
unsigned char rnd[KEYSZ + IVSZ];
|
||||||
|
uint32_t rekey_fuzz = 0;
|
||||||
|
|
||||||
if (getentropy(rnd, sizeof rnd) == -1)
|
if (getentropy(rnd, sizeof rnd) == -1)
|
||||||
_getentropy_fail();
|
_getentropy_fail();
|
||||||
@@ -122,7 +125,10 @@ _rs_stir(void)
|
|||||||
rs->rs_have = 0;
|
rs->rs_have = 0;
|
||||||
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
|
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
|
||||||
|
|
||||||
rs->rs_count = 1600000;
|
/* rekey interval should not be predictable */
|
||||||
|
chacha_encrypt_bytes(&rsx->rs_chacha, (uint8_t *)&rekey_fuzz,
|
||||||
|
(uint8_t *)&rekey_fuzz, sizeof(rekey_fuzz));
|
||||||
|
rs->rs_count = REKEY_BASE + (rekey_fuzz % REKEY_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@@ -32,9 +32,7 @@
|
|||||||
int
|
int
|
||||||
getentropy(void *buf, size_t len);
|
getentropy(void *buf, size_t len);
|
||||||
|
|
||||||
#if defined(__OpenBSD__)
|
#if defined(__linux__)
|
||||||
#include "arc4random_openbsd.h"
|
|
||||||
#elif defined(__linux__)
|
|
||||||
#include "arc4random_linux.h"
|
#include "arc4random_linux.h"
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include "arc4random_win.h"
|
#include "arc4random_win.h"
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
/* $OpenBSD: arc4random.h,v 1.3 2014/07/20 20:51:13 bcook Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1996, David Mazieres <dm@uun.org>
|
|
||||||
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
|
|
||||||
* Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
|
|
||||||
* Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stub functions for portability.
|
|
||||||
*/
|
|
||||||
#include <sys/mman.h>
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#include "thread_private.h"
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
_getentropy_fail(void)
|
|
||||||
{
|
|
||||||
raise(SIGKILL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
|
|
||||||
{
|
|
||||||
struct {
|
|
||||||
struct _rs rs;
|
|
||||||
struct _rsx rsx;
|
|
||||||
} *p;
|
|
||||||
|
|
||||||
if ((p = mmap(NULL, sizeof(*p), PROT_READ|PROT_WRITE,
|
|
||||||
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
|
|
||||||
return (-1);
|
|
||||||
if (minherit(p, sizeof(*p), MAP_INHERIT_ZERO) == -1) {
|
|
||||||
munmap(p, sizeof(*p));
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
*rsp = &p->rs;
|
|
||||||
*rsxp = &p->rsx;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
_rs_forkdetect(void)
|
|
||||||
{
|
|
||||||
}
|
|
@@ -4,7 +4,7 @@ D. J. Bernstein
|
|||||||
Public domain.
|
Public domain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $OpenBSD: chacha_private.h,v 1.2 2013/10/04 07:02:27 djm Exp $ */
|
/* $OpenBSD: chacha_private.h,v 1.3 2022/02/28 21:56:29 dtucker Exp $ */
|
||||||
|
|
||||||
typedef unsigned char u8;
|
typedef unsigned char u8;
|
||||||
typedef unsigned int u32;
|
typedef unsigned int u32;
|
||||||
@@ -52,7 +52,7 @@ static const char sigma[16] = "expand 32-byte k";
|
|||||||
static const char tau[16] = "expand 16-byte k";
|
static const char tau[16] = "expand 16-byte k";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ivbits)
|
chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)
|
||||||
{
|
{
|
||||||
const char *constants;
|
const char *constants;
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@ sys_close_range(unsigned int fd, unsigned int max_fd, unsigned int flags)
|
|||||||
* Close all file descriptors greater than or equal to lowfd.
|
* Close all file descriptors greater than or equal to lowfd.
|
||||||
* This is the expensive (fallback) method.
|
* This is the expensive (fallback) method.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
closefrom_fallback(int lowfd)
|
closefrom_fallback(int lowfd)
|
||||||
{
|
{
|
||||||
long fd, maxfd;
|
long fd, maxfd;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: explicit_bzero.c,v 1.3 2014/06/21 02:34:26 matthew Exp $ */
|
/* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */
|
||||||
/*
|
/*
|
||||||
* Public domain.
|
* Public domain.
|
||||||
* Written by Matthew Dempsky.
|
* Written by Matthew Dempsky.
|
||||||
@@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
__attribute__((__weak__)) void
|
||||||
|
__explicit_bzero_hook(void *, size_t);
|
||||||
|
|
||||||
__attribute__((__weak__)) void
|
__attribute__((__weak__)) void
|
||||||
__explicit_bzero_hook(void *buf, size_t len)
|
__explicit_bzero_hook(void *buf, size_t len)
|
||||||
{
|
{
|
||||||
|
@@ -76,8 +76,8 @@ fgetln(FILE *stream, size_t *len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
libbsd_link_warning(fgetln,
|
libbsd_link_warning(fgetln,
|
||||||
"This function cannot be safely ported, use getline(3) "
|
"The fgetln() function cannot be safely ported, use getline(3) "
|
||||||
"instead, as it is supported by GNU and POSIX.1-2008.")
|
"instead, as it is supported by GNU and POSIX.1-2008.");
|
||||||
#else
|
#else
|
||||||
#error "Function fgetln() needs to be ported."
|
#error "Function fgetln() needs to be ported."
|
||||||
#endif
|
#endif
|
||||||
|
@@ -87,6 +87,9 @@ fgetwln(FILE *stream, size_t *lenp)
|
|||||||
*lenp = wused;
|
*lenp = wused;
|
||||||
return wused ? fb->wbuf : NULL;
|
return wused ? fb->wbuf : NULL;
|
||||||
}
|
}
|
||||||
|
/* XXX: Ideally we'd recommend getwline(3), but unfortunately even though it
|
||||||
|
* was part of the ISO/IEC TR 24731-2:2010 draft, it did not make it into C11
|
||||||
|
* and is not widely implemented. */
|
||||||
libbsd_link_warning(fgetwln,
|
libbsd_link_warning(fgetwln,
|
||||||
"This function cannot be safely ported, use fgetwc(3) "
|
"The fgetwln() function cannot be safely ported, use fgetwc(3) "
|
||||||
"instead, as it is supported by C99 and POSIX.1-2001.")
|
"instead, as it is supported by C99 and POSIX.1-2001.");
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
int
|
int
|
||||||
fpurge(FILE *fp)
|
fpurge(FILE *fp)
|
||||||
{
|
{
|
||||||
if (fp == NULL || fileno(fp) < 0) {
|
if (fp == NULL) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int getentropy(void *buf, size_t len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Derived from lib/libc/gen/arc4random.c from FreeBSD.
|
* Derived from lib/libc/gen/arc4random.c from FreeBSD.
|
||||||
*/
|
*/
|
||||||
|
@@ -415,17 +415,17 @@ getentropy_fallback(void *buf, size_t len)
|
|||||||
#ifdef HAVE_GETAUXVAL
|
#ifdef HAVE_GETAUXVAL
|
||||||
#ifdef AT_RANDOM
|
#ifdef AT_RANDOM
|
||||||
/* Not as random as you think but we take what we are given */
|
/* Not as random as you think but we take what we are given */
|
||||||
p = (char *) getauxval(AT_RANDOM);
|
p = (char *) ((intptr_t) getauxval(AT_RANDOM));
|
||||||
if (p)
|
if (p)
|
||||||
HR(p, 16);
|
HR(p, 16);
|
||||||
#endif
|
#endif
|
||||||
#ifdef AT_SYSINFO_EHDR
|
#ifdef AT_SYSINFO_EHDR
|
||||||
p = (char *) getauxval(AT_SYSINFO_EHDR);
|
p = (char *) ((intptr_t) getauxval(AT_SYSINFO_EHDR));
|
||||||
if (p)
|
if (p)
|
||||||
HR(p, pgs);
|
HR(p, pgs);
|
||||||
#endif
|
#endif
|
||||||
#ifdef AT_BASE
|
#ifdef AT_BASE
|
||||||
p = (char *) getauxval(AT_BASE);
|
p = (char *) ((intptr_t) getauxval(AT_BASE));
|
||||||
if (p)
|
if (p)
|
||||||
HD(p);
|
HD(p);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -520,17 +520,17 @@ getentropy_fallback(void *buf, size_t len)
|
|||||||
#ifdef HAVE_GETAUXVAL
|
#ifdef HAVE_GETAUXVAL
|
||||||
#ifdef AT_RANDOM
|
#ifdef AT_RANDOM
|
||||||
/* Not as random as you think but we take what we are given */
|
/* Not as random as you think but we take what we are given */
|
||||||
p = (char *) getauxval(AT_RANDOM);
|
p = (char *) ((intptr_t) getauxval(AT_RANDOM));
|
||||||
if (p)
|
if (p)
|
||||||
HR(p, 16);
|
HR(p, 16);
|
||||||
#endif
|
#endif
|
||||||
#ifdef AT_SYSINFO_EHDR
|
#ifdef AT_SYSINFO_EHDR
|
||||||
p = (char *) getauxval(AT_SYSINFO_EHDR);
|
p = (char *) ((intptr_t) getauxval(AT_SYSINFO_EHDR));
|
||||||
if (p)
|
if (p)
|
||||||
HR(p, pgs);
|
HR(p, pgs);
|
||||||
#endif
|
#endif
|
||||||
#ifdef AT_BASE
|
#ifdef AT_BASE
|
||||||
p = (char *) getauxval(AT_BASE);
|
p = (char *) ((intptr_t) getauxval(AT_BASE));
|
||||||
if (p)
|
if (p)
|
||||||
HD(p);
|
HD(p);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -8,4 +8,5 @@ Description: Utility functions from BSD systems (overlay)
|
|||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
URL: https://libbsd.freedesktop.org/
|
URL: https://libbsd.freedesktop.org/
|
||||||
Libs: -L${libdir} -lbsd
|
Libs: -L${libdir} -lbsd
|
||||||
|
Libs.private: @LIBBSD_LIBS@ @MD5_LIBS@
|
||||||
Cflags: -isystem ${includedir}/bsd -DLIBBSD_OVERLAY
|
Cflags: -isystem ${includedir}/bsd -DLIBBSD_OVERLAY
|
||||||
|
@@ -8,4 +8,5 @@ Description: Utility functions from BSD systems
|
|||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
URL: https://libbsd.freedesktop.org/
|
URL: https://libbsd.freedesktop.org/
|
||||||
Libs: -L${libdir} -lbsd
|
Libs: -L${libdir} -lbsd
|
||||||
|
Libs.private: @LIBBSD_LIBS@ @MD5_LIBS@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
@@ -124,6 +124,16 @@
|
|||||||
#define ELF_TARG_CLASS ELFCLASS64
|
#define ELF_TARG_CLASS ELFCLASS64
|
||||||
#define ELF_TARG_DATA ELFDATA2LSB
|
#define ELF_TARG_DATA ELFDATA2LSB
|
||||||
|
|
||||||
|
#elif defined(__loongarch__)
|
||||||
|
|
||||||
|
#define ELF_TARG_MACH EM_LOONGARCH
|
||||||
|
#if defined(__loongarch64)
|
||||||
|
#define ELF_TARG_CLASS ELFCLASS64
|
||||||
|
#else
|
||||||
|
#error Unsupported ELF class
|
||||||
|
#endif
|
||||||
|
#define ELF_TARG_DATA ELFDATA2LSB
|
||||||
|
|
||||||
#elif defined(__m32r__)
|
#elif defined(__m32r__)
|
||||||
|
|
||||||
#define ELF_TARG_MACH EM_M32R
|
#define ELF_TARG_MACH EM_M32R
|
||||||
@@ -220,7 +230,7 @@
|
|||||||
#if defined(__LITTLE_ENDIAN__)
|
#if defined(__LITTLE_ENDIAN__)
|
||||||
#define ELF_TARG_DATA ELFDATA2LSB
|
#define ELF_TARG_DATA ELFDATA2LSB
|
||||||
#elif defined(__BIG_ENDIAN__)
|
#elif defined(__BIG_ENDIAN__)
|
||||||
#define ELF_TARG_DATA ELFDATA2LMSB
|
#define ELF_TARG_DATA ELFDATA2MSB
|
||||||
#else
|
#else
|
||||||
#error Unknown SH endianness
|
#error Unknown SH endianness
|
||||||
#endif
|
#endif
|
||||||
|
@@ -27,21 +27,44 @@
|
|||||||
#ifndef LIBBSD_LOCAL_LINK_H
|
#ifndef LIBBSD_LOCAL_LINK_H
|
||||||
#define LIBBSD_LOCAL_LINK_H
|
#define LIBBSD_LOCAL_LINK_H
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
#define libbsd_link_warning(symbol, msg) \
|
#define libbsd_link_warning(symbol, msg) \
|
||||||
static const char libbsd_emit_link_warning_##symbol[] \
|
static const char libbsd_emit_link_warning_##symbol[] \
|
||||||
__attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg;
|
__attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg
|
||||||
|
|
||||||
#ifdef __ELF__
|
#ifdef __ELF__
|
||||||
|
# if __has_attribute(symver)
|
||||||
|
/* The symver attribute is supported since gcc 10.x. */
|
||||||
|
#define libbsd_symver_default(alias, symbol, version) \
|
||||||
|
extern __typeof__(symbol) symbol \
|
||||||
|
__attribute__((__symver__(#alias "@@" #version)))
|
||||||
|
#define libbsd_symver_variant(alias, symbol, version) \
|
||||||
|
extern __typeof__(symbol) symbol \
|
||||||
|
__attribute__((__symver__(#alias "@" #version)))
|
||||||
|
|
||||||
|
#define libbsd_symver_weak(alias, symbol, version) \
|
||||||
|
extern __typeof__(symbol) symbol \
|
||||||
|
__attribute__((__symver__(#alias "@" #version), __weak__))
|
||||||
|
# else
|
||||||
#define libbsd_symver_default(alias, symbol, version) \
|
#define libbsd_symver_default(alias, symbol, version) \
|
||||||
__asm__(".symver " #symbol "," #alias "@@" #version)
|
__asm__(".symver " #symbol "," #alias "@@" #version)
|
||||||
|
|
||||||
#define libbsd_symver_variant(alias, symbol, version) \
|
#define libbsd_symver_variant(alias, symbol, version) \
|
||||||
__asm__(".symver " #symbol "," #alias "@" #version)
|
__asm__(".symver " #symbol "," #alias "@" #version)
|
||||||
|
|
||||||
|
#define libbsd_symver_weak(alias, symbol, version) \
|
||||||
|
libbsd_symver_variant(alias, symbol, version); \
|
||||||
|
extern __typeof__(symbol) alias \
|
||||||
|
__attribute__((__weak__))
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
#define libbsd_symver_default(alias, symbol, version) \
|
#define libbsd_symver_default(alias, symbol, version) \
|
||||||
extern __typeof(symbol) alias __attribute__((__alias__(#symbol)))
|
extern __typeof__(symbol) alias __attribute__((__alias__(#symbol)))
|
||||||
|
|
||||||
#define libbsd_symver_variant(alias, symbol, version)
|
#define libbsd_symver_variant(alias, symbol, version)
|
||||||
|
|
||||||
|
#define libbsd_symver_weak(alias, symbol, version)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
65
src/md5.c
65
src/md5.c
@@ -27,65 +27,94 @@
|
|||||||
#include <md5.h>
|
#include <md5.h>
|
||||||
#include "local-link.h"
|
#include "local-link.h"
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Init(MD5_CTX *context)
|
libbsd_MD5Init(MD5_CTX *context)
|
||||||
{
|
{
|
||||||
MD5Init(context);
|
MD5Init(context);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Init, bsd_MD5Init, LIBBSD_0.0);
|
libbsd_link_warning(MD5Init,
|
||||||
|
"The MD5Init() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5Init, libbsd_MD5Init, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
|
libbsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
MD5Update(context, data, len);
|
MD5Update(context, data, len);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Update, bsd_MD5Update, LIBBSD_0.0);
|
libbsd_link_warning(MD5Update,
|
||||||
|
"The MD5Update() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5Update, libbsd_MD5Update, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Pad(MD5_CTX *context)
|
libbsd_MD5Pad(MD5_CTX *context)
|
||||||
{
|
{
|
||||||
MD5Pad(context);
|
MD5Pad(context);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Pad, bsd_MD5Pad, LIBBSD_0.0);
|
libbsd_link_warning(MD5Pad,
|
||||||
|
"The MD5Pad() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5Pad, libbsd_MD5Pad, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
|
libbsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
|
||||||
{
|
{
|
||||||
MD5Final(digest, context);
|
MD5Final(digest, context);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Final, bsd_MD5Final, LIBBSD_0.0);
|
libbsd_link_warning(MD5Final,
|
||||||
|
"The MD5Final() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5Final, libbsd_MD5Final, LIBBSD_0.0);
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_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])
|
||||||
{
|
{
|
||||||
MD5Transform(state, block);
|
MD5Transform(state, block);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Transform, bsd_MD5Transform, LIBBSD_0.0);
|
libbsd_link_warning(MD5Transform,
|
||||||
|
"The MD5Transform() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5Transform, libbsd_MD5Transform, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_MD5End(MD5_CTX *context, char *buf)
|
libbsd_MD5End(MD5_CTX *context, char *buf)
|
||||||
{
|
{
|
||||||
return MD5End(context, buf);
|
return MD5End(context, buf);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5End, bsd_MD5End, LIBBSD_0.0);
|
libbsd_link_warning(MD5End,
|
||||||
|
"The MD5End() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5End, libbsd_MD5End, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_MD5File(const char *filename, char *buf)
|
libbsd_MD5File(const char *filename, char *buf)
|
||||||
{
|
{
|
||||||
return MD5File(filename, buf);
|
return MD5File(filename, buf);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5File, bsd_MD5File, LIBBSD_0.0);
|
libbsd_link_warning(MD5File,
|
||||||
|
"The MD5File() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5File, libbsd_MD5File, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_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)
|
||||||
{
|
{
|
||||||
return MD5FileChunk(filename, buf, offset, length);
|
return MD5FileChunk(filename, buf, offset, length);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5FileChunk, bsd_MD5FileChunk, LIBBSD_0.0);
|
libbsd_link_warning(MD5FileChunk,
|
||||||
|
"The MD5FileChunk() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5FileChunk, libbsd_MD5FileChunk, LIBBSD_0.0);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_MD5Data(const uint8_t *data, size_t len, char *buf)
|
libbsd_MD5Data(const uint8_t *data, size_t len, char *buf)
|
||||||
{
|
{
|
||||||
return MD5Data(data, len, buf);
|
return MD5Data(data, len, buf);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Data, bsd_MD5Data, LIBBSD_0.0);
|
libbsd_link_warning(MD5Data,
|
||||||
|
"The MD5Data() function in libbsd is a deprecated wrapper, "
|
||||||
|
"use libmd instead.");
|
||||||
|
libbsd_symver_weak(MD5Data, libbsd_MD5Data, LIBBSD_0.0);
|
||||||
|
@@ -43,10 +43,6 @@
|
|||||||
|
|
||||||
#include "local-elf.h"
|
#include "local-elf.h"
|
||||||
|
|
||||||
#ifndef SIZE_T_MAX
|
|
||||||
#define SIZE_T_MAX 0xffffffffU
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Note: This function is used by libkvm0, so we need to export it.
|
/* Note: This function is used by libkvm0, so we need to export it.
|
||||||
* It is not declared in the include files though. */
|
* It is not declared in the include files though. */
|
||||||
int __fdnlist(int, struct nlist *);
|
int __fdnlist(int, struct nlist *);
|
||||||
@@ -153,7 +149,7 @@ __fdnlist(int fd, struct nlist *list)
|
|||||||
shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
|
shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
|
||||||
|
|
||||||
/* Make sure it's not too big to mmap */
|
/* Make sure it's not too big to mmap */
|
||||||
if (shdr_size > SIZE_T_MAX || shdr_size > st.st_size) {
|
if (shdr_size > st.st_size) {
|
||||||
errno = EFBIG;
|
errno = EFBIG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -186,7 +182,7 @@ __fdnlist(int fd, struct nlist *list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for files too large to mmap. */
|
/* Check for files too large to mmap. */
|
||||||
if (symstrsize > SIZE_T_MAX || symstrsize > st.st_size) {
|
if (symstrsize > st.st_size) {
|
||||||
errno = EFBIG;
|
errno = EFBIG;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -239,7 +235,6 @@ __fdnlist(int fd, struct nlist *list)
|
|||||||
for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) {
|
for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) {
|
||||||
char *name;
|
char *name;
|
||||||
Elf_Word size;
|
Elf_Word size;
|
||||||
struct nlist *p;
|
|
||||||
|
|
||||||
name = strtab + s->st_name;
|
name = strtab + s->st_name;
|
||||||
if (name[0] == '\0')
|
if (name[0] == '\0')
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -144,12 +145,13 @@ common: if (set->cmd2 & CMD2_CLR) {
|
|||||||
|
|
||||||
#define ADDCMD(a, b, c, d) do { \
|
#define ADDCMD(a, b, c, d) do { \
|
||||||
if (set >= endset) { \
|
if (set >= endset) { \
|
||||||
|
ptrdiff_t setdiff = set - saveset; \
|
||||||
BITCMD *newset; \
|
BITCMD *newset; \
|
||||||
setlen += SET_LEN_INCR; \
|
setlen += SET_LEN_INCR; \
|
||||||
newset = reallocarray(saveset, setlen, sizeof(BITCMD)); \
|
newset = reallocarray(saveset, setlen, sizeof(BITCMD)); \
|
||||||
if (newset == NULL) \
|
if (newset == NULL) \
|
||||||
goto out; \
|
goto out; \
|
||||||
set = newset + (set - saveset); \
|
set = newset + setdiff; \
|
||||||
saveset = newset; \
|
saveset = newset; \
|
||||||
endset = newset + (setlen - 2); \
|
endset = newset + (setlen - 2); \
|
||||||
} \
|
} \
|
||||||
|
@@ -222,6 +222,10 @@ setproctitle_init(int argc, char *argv[], char *envp[])
|
|||||||
#define SPT_MAXTITLE 255
|
#define SPT_MAXTITLE 255
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
__printflike(1, 2)
|
||||||
|
void
|
||||||
|
setproctitle_impl(const char *fmt, ...);
|
||||||
|
|
||||||
void
|
void
|
||||||
setproctitle_impl(const char *fmt, ...)
|
setproctitle_impl(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
*
|
*
|
||||||
* To avoid any other possible fallout, the constructor is split into a
|
* To avoid any other possible fallout, the constructor is split into a
|
||||||
* new static library that needs to be linked explicitly into programs
|
* new static library that needs to be linked explicitly into programs
|
||||||
* using setproctitle(). As an additional safety measure the pkg-config
|
* using setproctitle(). As an additional safety measure the pkgconf(1)
|
||||||
* linker flags will mark the program as not allowing to be dlopen()ed
|
* linker flags will mark the program as not allowing to be dlopen()ed
|
||||||
* so that we make sure to avoid the problem described above.
|
* so that we make sure to avoid the problem described above.
|
||||||
*/
|
*/
|
||||||
@@ -49,4 +49,4 @@
|
|||||||
* move them from .ctors to .init_array.
|
* move them from .ctors to .init_array.
|
||||||
*/
|
*/
|
||||||
void (*libbsd_init_func)(int argc, char *argv[], char *envp[])
|
void (*libbsd_init_func)(int argc, char *argv[], char *envp[])
|
||||||
__attribute__((__section__(".init_array"))) = setproctitle_init;
|
__attribute__((__section__(".init_array"), __used__)) = setproctitle_init;
|
||||||
|
@@ -564,12 +564,16 @@ strunvis(char *dst, const char *src)
|
|||||||
* NetBSD: 2012, strnunvis(char *dst, size_t dlen, const char *src);
|
* NetBSD: 2012, strnunvis(char *dst, size_t dlen, const char *src);
|
||||||
*/
|
*/
|
||||||
ssize_t
|
ssize_t
|
||||||
|
strnunvis_openbsd(char *, const char *, size_t);
|
||||||
|
ssize_t
|
||||||
strnunvis_openbsd(char *dst, const char *src, size_t dlen)
|
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, strnunvis_openbsd, LIBBSD_0.2);
|
||||||
|
|
||||||
|
int
|
||||||
|
strnunvis_netbsd(char *, size_t, const char *);
|
||||||
int
|
int
|
||||||
strnunvis_netbsd(char *dst, size_t dlen, const char *src)
|
strnunvis_netbsd(char *dst, size_t dlen, const char *src)
|
||||||
{
|
{
|
||||||
|
@@ -733,12 +733,16 @@ strvis(char *mbdst, const char *mbsrc, int flags)
|
|||||||
* NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
|
* NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
strnvis_openbsd(char *, const char *, size_t, int);
|
||||||
|
int
|
||||||
strnvis_openbsd(char *mbdst, const char *mbsrc, size_t dlen, int flags)
|
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, strnvis_openbsd, LIBBSD_0.2);
|
||||||
|
|
||||||
|
int
|
||||||
|
strnvis_netbsd(char *, size_t, const char *, int);
|
||||||
int
|
int
|
||||||
strnvis_netbsd(char *mbdst, size_t dlen, const char *mbsrc, int flags)
|
strnvis_netbsd(char *mbdst, size_t dlen, const char *mbsrc, int flags)
|
||||||
{
|
{
|
||||||
|
6
test/.gitignore
vendored
6
test/.gitignore
vendored
@@ -2,23 +2,25 @@ arc4random
|
|||||||
bzero
|
bzero
|
||||||
closefrom
|
closefrom
|
||||||
endian
|
endian
|
||||||
|
explicit_bzero
|
||||||
fgetln
|
fgetln
|
||||||
funopen
|
|
||||||
fparseln
|
fparseln
|
||||||
fpurge
|
fpurge
|
||||||
|
funopen
|
||||||
headers-overlay-gen.c
|
headers-overlay-gen.c
|
||||||
headers-system-gen.c
|
headers-system-gen.c
|
||||||
humanize
|
humanize
|
||||||
md5
|
md5
|
||||||
nlist
|
nlist
|
||||||
overlay
|
overlay
|
||||||
proctitle-init
|
|
||||||
proctitle
|
proctitle
|
||||||
|
proctitle-init
|
||||||
progname
|
progname
|
||||||
pwcache
|
pwcache
|
||||||
setmode
|
setmode
|
||||||
strl
|
strl
|
||||||
strmode
|
strmode
|
||||||
strnstr
|
strnstr
|
||||||
|
strtonum
|
||||||
vis
|
vis
|
||||||
vis-openbsd
|
vis-openbsd
|
||||||
|
@@ -34,6 +34,7 @@ check_PROGRAMS = \
|
|||||||
bzero \
|
bzero \
|
||||||
closefrom \
|
closefrom \
|
||||||
endian \
|
endian \
|
||||||
|
explicit_bzero \
|
||||||
humanize \
|
humanize \
|
||||||
fgetln \
|
fgetln \
|
||||||
funopen \
|
funopen \
|
||||||
@@ -48,12 +49,11 @@ check_PROGRAMS = \
|
|||||||
strl \
|
strl \
|
||||||
strmode \
|
strmode \
|
||||||
strnstr \
|
strnstr \
|
||||||
|
strtonum \
|
||||||
vis \
|
vis \
|
||||||
vis-openbsd \
|
vis-openbsd \
|
||||||
$(nil)
|
$(nil)
|
||||||
|
|
||||||
md5_LDADD = $(LDADD) $(MD_LIBS)
|
|
||||||
|
|
||||||
if HAVE_LIBTESTU01
|
if HAVE_LIBTESTU01
|
||||||
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)
|
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)
|
||||||
|
|
||||||
@@ -70,6 +70,11 @@ proctitle_LDFLAGS = \
|
|||||||
check_PROGRAMS += proctitle
|
check_PROGRAMS += proctitle
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if NEED_TRANSPARENT_LIBMD
|
||||||
|
# On the installed system this is handled via the ld script.
|
||||||
|
md5_LDADD = $(LDADD) $(MD5_LIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
fgetln_SOURCES = test-stream.c test-stream.h fgetln.c
|
fgetln_SOURCES = test-stream.c test-stream.h fgetln.c
|
||||||
fgetln_CFLAGS = -Wno-deprecated-declarations
|
fgetln_CFLAGS = -Wno-deprecated-declarations
|
||||||
fparseln_SOURCES = test-stream.c test-stream.h fparseln.c
|
fparseln_SOURCES = test-stream.c test-stream.h fparseln.c
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
unsigned char array[40];
|
unsigned char array[40];
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int fd;
|
int fd;
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
unsigned char decstream[] = {
|
unsigned char decstream[] = {
|
||||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
||||||
|
229
test/explicit_bzero.c
Normal file
229
test/explicit_bzero.c
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
/* $OpenBSD: explicit_bzero.c,v 1.7 2021/03/27 11:17:58 bcook Exp $ */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Google Inc.
|
||||||
|
* Copyright (c) 2022 Guillem Jover <guillem@hadrons.org>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define ASSERT_EQ(a, b) assert((a) == (b))
|
||||||
|
#define ASSERT_NE(a, b) assert((a) != (b))
|
||||||
|
#define ASSERT_GE(a, b) assert((a) >= (b))
|
||||||
|
|
||||||
|
/* 128 bits of random data. */
|
||||||
|
static const char secret[16] = {
|
||||||
|
0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c,
|
||||||
|
0xb0, 0xd6, 0xd4, 0xe3, 0xeb, 0x52, 0x5f, 0x96,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SECRETCOUNT = 64,
|
||||||
|
SECRETBYTES = SECRETCOUNT * sizeof(secret)
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* As of glibc 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is no longer
|
||||||
|
* constant on Linux. SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).
|
||||||
|
*/
|
||||||
|
static char *altstack;
|
||||||
|
#define ALTSTACK_SIZE (SIGSTKSZ + SECRETBYTES)
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_stack(void)
|
||||||
|
{
|
||||||
|
const stack_t sigstk = {
|
||||||
|
.ss_sp = altstack = calloc(1, ALTSTACK_SIZE),
|
||||||
|
.ss_size = ALTSTACK_SIZE
|
||||||
|
};
|
||||||
|
|
||||||
|
ASSERT_NE(NULL, altstack);
|
||||||
|
ASSERT_EQ(0, sigaltstack(&sigstk, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup_stack(void)
|
||||||
|
{
|
||||||
|
free(altstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
assert_on_stack(void)
|
||||||
|
{
|
||||||
|
stack_t cursigstk;
|
||||||
|
ASSERT_EQ(0, sigaltstack(NULL, &cursigstk));
|
||||||
|
ASSERT_EQ(SS_ONSTACK, cursigstk.ss_flags & (SS_DISABLE|SS_ONSTACK));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
call_on_stack(void (*fn)(int))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This is a bit more complicated than strictly necessary, but
|
||||||
|
* it ensures we don't have any flaky test failures due to
|
||||||
|
* inherited signal masks/actions/etc.
|
||||||
|
*
|
||||||
|
* On systems where SA_ONSTACK is not supported, this could
|
||||||
|
* alternatively be implemented using makecontext() or
|
||||||
|
* pthread_attr_setstack().
|
||||||
|
*/
|
||||||
|
|
||||||
|
const struct sigaction sigact = {
|
||||||
|
.sa_handler = fn,
|
||||||
|
.sa_flags = SA_ONSTACK,
|
||||||
|
};
|
||||||
|
struct sigaction oldsigact;
|
||||||
|
sigset_t sigset, oldsigset;
|
||||||
|
|
||||||
|
/* First, block all signals. */
|
||||||
|
ASSERT_EQ(0, sigemptyset(&sigset));
|
||||||
|
ASSERT_EQ(0, sigfillset(&sigset));
|
||||||
|
ASSERT_EQ(0, sigprocmask(SIG_BLOCK, &sigset, &oldsigset));
|
||||||
|
|
||||||
|
/* Next setup the signal handler for SIGUSR1. */
|
||||||
|
ASSERT_EQ(0, sigaction(SIGUSR1, &sigact, &oldsigact));
|
||||||
|
|
||||||
|
/* Raise SIGUSR1 and momentarily unblock it to run the handler. */
|
||||||
|
ASSERT_EQ(0, raise(SIGUSR1));
|
||||||
|
ASSERT_EQ(0, sigdelset(&sigset, SIGUSR1));
|
||||||
|
ASSERT_EQ(-1, sigsuspend(&sigset));
|
||||||
|
ASSERT_EQ(EINTR, errno);
|
||||||
|
|
||||||
|
/* Restore the original signal action, stack, and mask. */
|
||||||
|
ASSERT_EQ(0, sigaction(SIGUSR1, &oldsigact, NULL));
|
||||||
|
ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &oldsigset, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
populate_secret(char *buf, ssize_t len)
|
||||||
|
{
|
||||||
|
int i, fds[2];
|
||||||
|
ASSERT_EQ(0, pipe(fds));
|
||||||
|
|
||||||
|
for (i = 0; i < SECRETCOUNT; i++)
|
||||||
|
ASSERT_EQ(sizeof(secret), write(fds[1], secret, sizeof(secret)));
|
||||||
|
ASSERT_EQ(0, close(fds[1]));
|
||||||
|
|
||||||
|
ASSERT_EQ(len, read(fds[0], buf, len));
|
||||||
|
ASSERT_EQ(0, close(fds[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __attribute__((__noinline__))
|
||||||
|
blank_stack_side_effects(char *buf, size_t len)
|
||||||
|
{
|
||||||
|
char scratch[SECRETBYTES * 4];
|
||||||
|
|
||||||
|
/* If the read(3) in populate_secret() wrote into the stack, as it
|
||||||
|
* might happen on the Hurd for small data, then we might incorrectly
|
||||||
|
* detect the wrong secret on the stack. */
|
||||||
|
memset(scratch, 0xFF, sizeof(scratch));
|
||||||
|
ASSERT_EQ(NULL, memmem(scratch, sizeof(scratch), buf, len));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
count_secrets(const char *buf)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < SECRETCOUNT; i++) {
|
||||||
|
if (memcmp(buf + i * sizeof(secret), secret,
|
||||||
|
sizeof(secret)) == 0)
|
||||||
|
res += 1;
|
||||||
|
}
|
||||||
|
return (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
test_without_bzero(void)
|
||||||
|
{
|
||||||
|
char buf[SECRETBYTES];
|
||||||
|
char *res;
|
||||||
|
assert_on_stack();
|
||||||
|
populate_secret(buf, sizeof(buf));
|
||||||
|
blank_stack_side_effects(buf, sizeof(buf));
|
||||||
|
res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
|
||||||
|
ASSERT_NE(NULL, res);
|
||||||
|
return (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
test_with_bzero(void)
|
||||||
|
{
|
||||||
|
char buf[SECRETBYTES];
|
||||||
|
char *res;
|
||||||
|
assert_on_stack();
|
||||||
|
populate_secret(buf, sizeof(buf));
|
||||||
|
blank_stack_side_effects(buf, sizeof(buf));
|
||||||
|
res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
|
||||||
|
ASSERT_NE(NULL, res);
|
||||||
|
explicit_bzero(buf, sizeof(buf));
|
||||||
|
return (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_test_without_bzero(int signo)
|
||||||
|
{
|
||||||
|
char *buf = test_without_bzero();
|
||||||
|
ASSERT_GE(count_secrets(buf), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_test_with_bzero(int signo)
|
||||||
|
{
|
||||||
|
char *buf = test_with_bzero();
|
||||||
|
ASSERT_EQ(count_secrets(buf), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
setup_stack();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Solaris and OS X clobber the signal stack after returning to the
|
||||||
|
* normal stack, so we need to inspect altstack while we're still
|
||||||
|
* running on it. Unfortunately, this means we risk clobbering the
|
||||||
|
* buffer ourselves.
|
||||||
|
*
|
||||||
|
* To minimize this risk, test_with{,out}_bzero() are responsible for
|
||||||
|
* locating the offset of their buf variable within altstack, and
|
||||||
|
* and returning that address. Then we can simply memcmp() repeatedly
|
||||||
|
* to count how many instances of secret we found.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First, test that if we *don't* call explicit_bzero, that we
|
||||||
|
* *are* able to find at least one instance of the secret data still
|
||||||
|
* on the stack. This sanity checks that call_on_stack() and
|
||||||
|
* populate_secret() work as intended.
|
||||||
|
*/
|
||||||
|
memset(altstack, 0, ALTSTACK_SIZE);
|
||||||
|
call_on_stack(do_test_without_bzero);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now test with a call to explicit_bzero() and check that we
|
||||||
|
* *don't* find any instances of the secret data.
|
||||||
|
*/
|
||||||
|
memset(altstack, 0, ALTSTACK_SIZE);
|
||||||
|
call_on_stack(do_test_with_bzero);
|
||||||
|
|
||||||
|
cleanup_stack();
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
@@ -75,7 +75,7 @@ test_fgetln_single(void)
|
|||||||
size_t len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fp = pipe_feed("%s", (const void **)data_ascii, DATA_LINES);
|
fp = pipe_feed(PIPE_DATA_ASCII, (const void **)data_ascii, DATA_LINES);
|
||||||
for (i = 0; i < DATA_LINES; i++) {
|
for (i = 0; i < DATA_LINES; i++) {
|
||||||
char *str = fgetln(fp, &len);
|
char *str = fgetln(fp, &len);
|
||||||
|
|
||||||
@@ -96,13 +96,14 @@ test_fgetln_multi(void)
|
|||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
str = strdup("A\n");
|
str = strdup("A\n");
|
||||||
|
assert(str);
|
||||||
str[0] += i;
|
str[0] += i;
|
||||||
|
|
||||||
files[i].line_alloc = str;
|
files[i].line_alloc = str;
|
||||||
files[i].lines = reallocarray(NULL, LINE_COUNT, sizeof(char *));
|
files[i].lines = reallocarray(NULL, LINE_COUNT, sizeof(char *));
|
||||||
files[i].lines[0] = str;
|
files[i].lines[0] = str;
|
||||||
files[i].lines[1] = str;
|
files[i].lines[1] = str;
|
||||||
files[i].fp = pipe_feed("%s", files[i].lines, LINE_COUNT);
|
files[i].fp = pipe_feed(PIPE_DATA_ASCII, files[i].lines, LINE_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (l = 0; l < LINE_COUNT; l++) {
|
for (l = 0; l < LINE_COUNT; l++) {
|
||||||
@@ -139,7 +140,7 @@ test_fgetwln_single(void)
|
|||||||
size_t len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fp = pipe_feed("%ls", (const void **)data_wide, DATA_LINES);
|
fp = pipe_feed(PIPE_DATA_WIDE, (const void **)data_wide, DATA_LINES);
|
||||||
for (i = 0; i < DATA_LINES; i++) {
|
for (i = 0; i < DATA_LINES; i++) {
|
||||||
wchar_t *wstr;
|
wchar_t *wstr;
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ test_fgetwln_multi(void)
|
|||||||
files[i].lines = reallocarray(NULL, LINE_COUNT, sizeof(char *));
|
files[i].lines = reallocarray(NULL, LINE_COUNT, sizeof(char *));
|
||||||
files[i].lines[0] = wstr;
|
files[i].lines[0] = wstr;
|
||||||
files[i].lines[1] = wstr;
|
files[i].lines[1] = wstr;
|
||||||
files[i].fp = pipe_feed("%ls", files[i].lines, LINE_COUNT);
|
files[i].fp = pipe_feed(PIPE_DATA_WIDE, files[i].lines, LINE_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (l = 0; l < LINE_COUNT; l++) {
|
for (l = 0; l < LINE_COUNT; l++) {
|
||||||
|
@@ -68,7 +68,7 @@ test_fparseln(const char **data_expect, int flags)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
size_t i, len, lineno = 0;
|
size_t i, len, lineno = 0;
|
||||||
|
|
||||||
fp = pipe_feed("%s", (const void **)data_test, TEST_LINES);
|
fp = pipe_feed(PIPE_DATA_ASCII, (const void **)data_test, TEST_LINES);
|
||||||
for (i = 0; i < EXPECT_LINES; i++) {
|
for (i = 0; i < EXPECT_LINES; i++) {
|
||||||
char *str = fparseln(fp, &len, &lineno, NULL, flags);
|
char *str = fparseln(fp, &len, &lineno, NULL, flags);
|
||||||
|
|
||||||
|
@@ -25,24 +25,33 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
static FILE fp_bad;
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t bufsz = 0;
|
||||||
|
|
||||||
if (fpurge(NULL) == 0)
|
if (fpurge(NULL) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (fpurge(&fp_bad) == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
fp = fopen("/dev/zero", "r");
|
fp = fopen("/dev/zero", "r");
|
||||||
if (fpurge(fp) < 0)
|
if (fpurge(fp) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
|
fp = open_memstream(&buf, &bufsz);
|
||||||
|
fputs("World", fp);
|
||||||
|
if (fpurge(fp) < 0)
|
||||||
|
return 1;
|
||||||
|
fflush(fp);
|
||||||
|
if (bufsz != 0)
|
||||||
|
return 1;
|
||||||
|
free(buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ struct test_cookie {
|
|||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
static int
|
||||||
test_readfn(void *cookie, char *buf, int size)
|
test_readfn(void *cookie, char *buf, int size)
|
||||||
{
|
{
|
||||||
struct test_cookie *tc = cookie;
|
struct test_cookie *tc = cookie;
|
||||||
@@ -56,7 +56,7 @@ test_readfn(void *cookie, char *buf, int size)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
test_writefn(void *cookie, const char *buf, int size)
|
test_writefn(void *cookie, const char *buf, int size)
|
||||||
{
|
{
|
||||||
struct test_cookie *tc = cookie;
|
struct test_cookie *tc = cookie;
|
||||||
@@ -75,7 +75,7 @@ test_writefn(void *cookie, const char *buf, int size)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t
|
static off_t
|
||||||
test_seekfn(void *cookie, off_t offset, int whence)
|
test_seekfn(void *cookie, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
struct test_cookie *tc = cookie;
|
struct test_cookie *tc = cookie;
|
||||||
@@ -95,7 +95,7 @@ test_seekfn(void *cookie, off_t offset, int whence)
|
|||||||
return tc->index;
|
return tc->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
test_closefn(void *cookie)
|
test_closefn(void *cookie)
|
||||||
{
|
{
|
||||||
struct test_cookie *tc = cookie;
|
struct test_cookie *tc = cookie;
|
||||||
@@ -114,7 +114,7 @@ main(int argc, char **argv)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
/* Test invalid hooks. */
|
/* Test invalid hooks. */
|
||||||
fp = funopen(&tc, NULL, NULL, NULL, NULL);
|
fp = funopen(NULL, NULL, NULL, NULL, NULL);
|
||||||
assert(fp == NULL);
|
assert(fp == NULL);
|
||||||
assert(errno == EINVAL);
|
assert(errno == EINVAL);
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include <md5.h>
|
#include <md5.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void
|
static void
|
||||||
test_md5(const char *digest, const char *string)
|
test_md5(const char *digest, const char *string)
|
||||||
{
|
{
|
||||||
char result[MD5_DIGEST_STRING_LENGTH];
|
char result[MD5_DIGEST_STRING_LENGTH];
|
||||||
@@ -37,7 +37,7 @@ test_md5(const char *digest, const char *string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
test_md5("d41d8cd98f00b204e9800998ecf8427e", "");
|
test_md5("d41d8cd98f00b204e9800998ecf8427e", "");
|
||||||
test_md5("900150983cd24fb0d6963f7d28e17f72", "abc");
|
test_md5("900150983cd24fb0d6963f7d28e17f72", "abc");
|
||||||
|
16
test/nlist.c
16
test/nlist.c
@@ -39,11 +39,11 @@ extern int data_pub_uninit[2048];
|
|||||||
extern int *data_pub_ptr;
|
extern int *data_pub_ptr;
|
||||||
|
|
||||||
int *data_pub_ptr = &data_prv_init;
|
int *data_pub_ptr = &data_prv_init;
|
||||||
int data_pub_init = 10;
|
int data_pub_init __attribute__((__used__)) = 10;
|
||||||
int data_pub_uninit[2048];
|
int data_pub_uninit[2048] __attribute__((__used__));
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
func_pub(void);
|
func_pub(void) __attribute__((__used__)) ;
|
||||||
|
|
||||||
int
|
int
|
||||||
func_pub(void)
|
func_pub(void)
|
||||||
@@ -55,11 +55,11 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct nlist nl[] = {
|
struct nlist nl[] = {
|
||||||
{ .n_un.n_name = "main" },
|
{ .n_un.n_name = (char *)"main" },
|
||||||
{ .n_un.n_name = "func_pub" },
|
{ .n_un.n_name = (char *)"func_pub" },
|
||||||
{ .n_un.n_name = "data_pub_uninit" },
|
{ .n_un.n_name = (char *)"data_pub_uninit" },
|
||||||
{ .n_un.n_name = "data_pub_init" },
|
{ .n_un.n_name = (char *)"data_pub_init" },
|
||||||
{ .n_un.n_name = "data_prv_init" },
|
{ .n_un.n_name = (char *)"data_prv_init" },
|
||||||
{ .n_un.n_name = NULL },
|
{ .n_un.n_name = NULL },
|
||||||
};
|
};
|
||||||
int rc;
|
int rc;
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
/* Test that we do not get partial definitions. */
|
/* Test that we do not get partial definitions. */
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
64
test/strtonum.c
Normal file
64
test/strtonum.c
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/* $OpenBSD: strtonumtest.c,v 1.1 2004/08/03 20:38:36 otto Exp $ */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004 Otto Moerbeek <otto@drijf.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int fail;
|
||||||
|
|
||||||
|
static void
|
||||||
|
test(const char *p, long long lb, long long ub, int ok)
|
||||||
|
{
|
||||||
|
long long val;
|
||||||
|
const char *q;
|
||||||
|
|
||||||
|
val = strtonum(p, lb, ub, &q);
|
||||||
|
if (ok && q != NULL) {
|
||||||
|
fprintf(stderr, "%s [%lld-%lld] ", p, lb, ub);
|
||||||
|
fprintf(stderr, "NUMBER NOT ACCEPTED %s\n", q);
|
||||||
|
fail = 1;
|
||||||
|
} else if (!ok && q == NULL) {
|
||||||
|
fprintf(stderr, "%s [%lld-%lld] %lld ", p, lb, ub, val);
|
||||||
|
fprintf(stderr, "NUMBER ACCEPTED\n");
|
||||||
|
fail = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
test("1", 0, 10, 1);
|
||||||
|
test("0", -2, 5, 1);
|
||||||
|
test("0", 2, 5, 0);
|
||||||
|
test("0", 2, LLONG_MAX, 0);
|
||||||
|
test("-2", 0, LLONG_MAX, 0);
|
||||||
|
test("0", -5, LLONG_MAX, 1);
|
||||||
|
test("-3", -3, LLONG_MAX, 1);
|
||||||
|
test("-9223372036854775808", LLONG_MIN, LLONG_MAX, 1);
|
||||||
|
test("9223372036854775807", LLONG_MIN, LLONG_MAX, 1);
|
||||||
|
test("-9223372036854775809", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("9223372036854775808", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("-1000000000000000000000000", LLONG_MIN, LLONG_MAX, 0);
|
||||||
|
test("-2", 10, -1, 0);
|
||||||
|
test("-2", -10, -1, 1);
|
||||||
|
test("-20", -10, -1, 0);
|
||||||
|
test("20", -10, -1, 0);
|
||||||
|
|
||||||
|
return (fail);
|
||||||
|
}
|
||||||
|
|
@@ -27,12 +27,13 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "test-stream.h"
|
#include "test-stream.h"
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
pipe_feed(const char *fmt, const void **buf, int buf_nmemb)
|
pipe_feed(enum pipe_data_mode mode, const void **buf, int buf_nmemb)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -56,7 +57,10 @@ pipe_feed(const char *fmt, const void **buf, int buf_nmemb)
|
|||||||
assert(fp);
|
assert(fp);
|
||||||
|
|
||||||
for (line = 0; line < buf_nmemb; line++) {
|
for (line = 0; line < buf_nmemb; line++) {
|
||||||
rc = fprintf(fp, fmt, buf[line]);
|
if (mode == PIPE_DATA_ASCII)
|
||||||
|
rc = fprintf(fp, "%s", (const char *)buf[line]);
|
||||||
|
else
|
||||||
|
rc = fprintf(fp, "%ls", (const wchar_t *)buf[line]);
|
||||||
assert(rc >= 0);
|
assert(rc >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,8 +29,13 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
enum pipe_data_mode {
|
||||||
|
PIPE_DATA_ASCII,
|
||||||
|
PIPE_DATA_WIDE,
|
||||||
|
};
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
pipe_feed(const char *fmt, const void **buf, int buf_nmemb);
|
pipe_feed(enum pipe_data_mode mode, const void **buf, int buf_nmemb);
|
||||||
void
|
void
|
||||||
pipe_close(FILE *fp);
|
pipe_close(FILE *fp);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user