mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-19 21:16:55 +02:00
Compare commits
430 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1fb25b7dca | ||
![]() |
31f034e386 | ||
![]() |
2374f409de | ||
![]() |
a4e0db2b97 | ||
![]() |
43d34c9d3b | ||
![]() |
1c3ff61699 | ||
![]() |
edea268ce9 | ||
![]() |
e832b7687e | ||
![]() |
c4fca5bb4f | ||
![]() |
a1f79978e8 | ||
![]() |
4676026286 | ||
![]() |
25f9b30678 | ||
![]() |
18ebabf223 | ||
![]() |
4ab11c7f48 | ||
![]() |
766c883e30 | ||
![]() |
a4de4d95a6 | ||
![]() |
233cab9d64 | ||
![]() |
2462cd8888 | ||
![]() |
d54ceb37ce | ||
![]() |
847e682f8d | ||
![]() |
68f980c90d | ||
![]() |
37a9b56c05 | ||
![]() |
45dd5229ea | ||
![]() |
01f0d1ea1e | ||
![]() |
9c85d828a1 | ||
![]() |
eac4ce0c67 | ||
![]() |
5ecff0c903 | ||
![]() |
8c5a83d678 | ||
![]() |
d5b04ab19c | ||
![]() |
cfeafeabad | ||
![]() |
3d6b6ead64 | ||
![]() |
eb445425ff | ||
![]() |
59f6a95609 | ||
![]() |
3548c5f6bf | ||
![]() |
a11c98a6b5 | ||
![]() |
5745ca0362 | ||
![]() |
9628798d7d | ||
![]() |
f34a5f71d9 | ||
![]() |
72c68868c8 | ||
![]() |
a4323f2b16 | ||
![]() |
4997efa59a | ||
![]() |
96202c6c14 | ||
![]() |
61d378f5e9 | ||
![]() |
9d917aad37 | ||
![]() |
18662cadfc | ||
![]() |
ce53f7c25f | ||
![]() |
24d1f4dd34 | ||
![]() |
e9529d9b4a | ||
![]() |
3aaedb1208 | ||
![]() |
2c754f435b | ||
![]() |
ee4d24970a | ||
![]() |
8d2afa3a9f | ||
![]() |
e9f6faf3aa | ||
![]() |
99320b9168 | ||
![]() |
71c710e9a8 | ||
![]() |
21f4052c5b | ||
![]() |
1899e2c5ab | ||
![]() |
4803340802 | ||
![]() |
f99b8ea527 | ||
![]() |
4bed48398f | ||
![]() |
2e071c3cc1 | ||
![]() |
890699a78b | ||
![]() |
b0ebb0d4c2 | ||
![]() |
73aea4f808 | ||
![]() |
7cfa2d4530 | ||
![]() |
574c7a1365 | ||
![]() |
c2d9d84088 | ||
![]() |
2ebe6d5a02 | ||
![]() |
aeea1f4083 | ||
![]() |
0500a1bd08 | ||
![]() |
3d9c6c08ed | ||
![]() |
b9dee9f69a | ||
![]() |
81c3c3e405 | ||
![]() |
5e0998fa4f | ||
![]() |
8e2d55047c | ||
![]() |
13c32916b4 | ||
![]() |
8e834cd068 | ||
![]() |
e354f9b1d0 | ||
![]() |
4c5e9b478e | ||
![]() |
005b509061 | ||
![]() |
a8531ad051 | ||
![]() |
c4b0fd2c9f | ||
![]() |
1ca09c18f7 | ||
![]() |
e4e15ed286 | ||
![]() |
bf697b900c | ||
![]() |
f1966385b3 | ||
![]() |
e007233cf0 | ||
![]() |
3cabf46bb0 | ||
![]() |
6eebc1f264 | ||
![]() |
a1730c1063 | ||
![]() |
6f68c93076 | ||
![]() |
e13b1a337a | ||
![]() |
ef5faeb575 | ||
![]() |
2d7de186e9 | ||
![]() |
3efad64155 | ||
![]() |
a6f407ab0d | ||
![]() |
21edbb4f22 | ||
![]() |
e3979d1a7c | ||
![]() |
facbddb652 | ||
![]() |
3d88c999b4 | ||
![]() |
e42381dc51 | ||
![]() |
993828d84e | ||
![]() |
30b4d50754 | ||
![]() |
f6ed7c278b | ||
![]() |
1f8a3f7bcc | ||
![]() |
b20272f5a9 | ||
![]() |
11ec8f1e5d | ||
![]() |
5ba8c5bab0 | ||
![]() |
0093ca2b0e | ||
![]() |
0b65d43963 | ||
![]() |
0b61c5ffed | ||
![]() |
9ceac74e91 | ||
![]() |
9afc7100a1 | ||
![]() |
22fbd62368 | ||
![]() |
b4f7c065ba | ||
![]() |
bbf90ac3cd | ||
![]() |
2a8514d8a5 | ||
![]() |
3b2b7938f7 | ||
![]() |
415e3cb266 | ||
![]() |
9532cb39f4 | ||
![]() |
a4dd754c8d | ||
![]() |
b480b7a3f8 | ||
![]() |
4cc20e23f5 | ||
![]() |
c4e58c0950 | ||
![]() |
736e12e8d8 | ||
![]() |
8bff4b1fab | ||
![]() |
0071b97958 | ||
![]() |
cdbb9d0555 | ||
![]() |
0365d0efda | ||
![]() |
10b1328570 | ||
![]() |
922eff5c5e | ||
![]() |
8e8834d8e5 | ||
![]() |
7938619254 | ||
![]() |
ec5d9a685a | ||
![]() |
47013bc92a | ||
![]() |
e8d340de9e | ||
![]() |
7aede6a999 | ||
![]() |
ab5db68bae | ||
![]() |
5a46e4867d | ||
![]() |
7a75f550e8 | ||
![]() |
f1dd5f2e71 | ||
![]() |
c8a1b08b74 | ||
![]() |
4fec871c79 | ||
![]() |
3945693ebe | ||
![]() |
c253365d65 | ||
![]() |
8248e5f7a6 | ||
![]() |
c74ca09916 | ||
![]() |
ba9e2a5a9c | ||
![]() |
6a5a515820 | ||
![]() |
934b7a0ccb | ||
![]() |
f20e6972b3 | ||
![]() |
07c76b666d | ||
![]() |
e4475738fe | ||
![]() |
d6c35f618c | ||
![]() |
db7470b048 | ||
![]() |
368af99f55 | ||
![]() |
337e620275 | ||
![]() |
088f147ec8 | ||
![]() |
b2b1020d8e | ||
![]() |
9bed430ee3 | ||
![]() |
cbfe0ebca9 | ||
![]() |
f3b566bd7c | ||
![]() |
e86c1b5f43 | ||
![]() |
b7ce33cf51 | ||
![]() |
ed84bec5aa | ||
![]() |
cbe3057703 | ||
![]() |
5a32ea0a72 | ||
![]() |
2fb148a290 | ||
![]() |
c8f0723d2b | ||
![]() |
008316aa29 | ||
![]() |
e4ab2c62cd | ||
![]() |
bf5573f86c | ||
![]() |
229f85794f | ||
![]() |
7a75687541 | ||
![]() |
f84004baf2 | ||
![]() |
cdf998a056 | ||
![]() |
2c77ad593c | ||
![]() |
48ac79b188 | ||
![]() |
290a1ce8f2 | ||
![]() |
6bcb1312f4 | ||
![]() |
da137a0921 | ||
![]() |
d2f59a23d5 | ||
![]() |
01b77f0dcf | ||
![]() |
75729394af | ||
![]() |
8493c7f27d | ||
![]() |
2b030da016 | ||
![]() |
330e211142 | ||
![]() |
874a0e51d3 | ||
![]() |
9a9a8b2dba | ||
![]() |
5f9265f816 | ||
![]() |
1f77cdb40a | ||
![]() |
f3b115540c | ||
![]() |
877732ef4d | ||
![]() |
02bccb0a01 | ||
![]() |
58bef83f41 | ||
![]() |
6e074a2bdc | ||
![]() |
0871daf7b0 | ||
![]() |
02c33d5022 | ||
![]() |
45443583df | ||
![]() |
8641d8aed7 | ||
![]() |
0982dcd98b | ||
![]() |
ee26e59e72 | ||
![]() |
151bc71d64 | ||
![]() |
41ff37bbcc | ||
![]() |
53d989a223 | ||
![]() |
f50b197ea5 | ||
![]() |
54f153414a | ||
![]() |
9688ab26b9 | ||
![]() |
025b44800e | ||
![]() |
a6a101effa | ||
![]() |
32388fe59f | ||
![]() |
30e328cbf1 | ||
![]() |
4cc43915f2 | ||
![]() |
34df142665 | ||
![]() |
3881c4fc68 | ||
![]() |
3a3d87d730 | ||
![]() |
d62f7d8fac | ||
![]() |
cfb4d462a9 | ||
![]() |
205827a2dd | ||
![]() |
c7e01e9884 | ||
![]() |
3267114483 | ||
![]() |
0e4e3ab269 | ||
![]() |
a6fe103c1b | ||
![]() |
02b55488c5 | ||
![]() |
6378351169 | ||
![]() |
e390651b64 | ||
![]() |
e8d3d04177 | ||
![]() |
faa005cb32 | ||
![]() |
36aca8c06e | ||
![]() |
e8f9300355 | ||
![]() |
a88bb8380d | ||
![]() |
8d16c3df67 | ||
![]() |
f41fdcf186 | ||
![]() |
86cbff385a | ||
![]() |
ee04e8de14 | ||
![]() |
61b2dbb8f5 | ||
![]() |
119417462e | ||
![]() |
948bcf1db8 | ||
![]() |
c5b9590287 | ||
![]() |
3077d2fffc | ||
![]() |
1bf0a55579 | ||
![]() |
ad613d9d09 | ||
![]() |
e084ce3fa7 | ||
![]() |
50e4c55afd | ||
![]() |
6faea4d2a0 | ||
![]() |
367e036537 | ||
![]() |
dc8b09783f | ||
![]() |
4663364783 | ||
![]() |
df5aebd7e1 | ||
![]() |
9587882316 | ||
![]() |
01f146c28e | ||
![]() |
509841b533 | ||
![]() |
06f0585c48 | ||
![]() |
7c4caa679a | ||
![]() |
30349f8922 | ||
![]() |
96a2dae352 | ||
![]() |
a4812cdf24 | ||
![]() |
d3a09e1cf4 | ||
![]() |
330b569fe3 | ||
![]() |
8c26c40ad2 | ||
![]() |
e9933255d4 | ||
![]() |
c984dacd65 | ||
![]() |
35785f8dd1 | ||
![]() |
2a0260d08c | ||
![]() |
f8d52ead5e | ||
![]() |
cf683a275a | ||
![]() |
7196b4dcca | ||
![]() |
a97ce513e0 | ||
![]() |
ee0489eb2b | ||
![]() |
cb7bc0d85e | ||
![]() |
1be0bdb2c9 | ||
![]() |
ff0d700df0 | ||
![]() |
3862764872 | ||
![]() |
918a4dba4a | ||
![]() |
444bd1fbb8 | ||
![]() |
1d69ae1cd5 | ||
![]() |
14524b545d | ||
![]() |
c21d788fea | ||
![]() |
fdcae57707 | ||
![]() |
e9e4a60d7e | ||
![]() |
309c82a016 | ||
![]() |
cd67cb1417 | ||
![]() |
1b5b1cd52a | ||
![]() |
ddefaae330 | ||
![]() |
e7f3976088 | ||
![]() |
e59ac2c96c | ||
![]() |
7cfa7e4304 | ||
![]() |
7620fef70b | ||
![]() |
08139dd50e | ||
![]() |
d90ce079f7 | ||
![]() |
c1d086c224 | ||
![]() |
e37293a18a | ||
![]() |
34bf1068a2 | ||
![]() |
4eab0cc351 | ||
![]() |
752997462a | ||
![]() |
d5d9186937 | ||
![]() |
f8e8063079 | ||
![]() |
786d143920 | ||
![]() |
866f73af91 | ||
![]() |
f71d8e0501 | ||
![]() |
0b96e1a218 | ||
![]() |
109cafb393 | ||
![]() |
6434858314 | ||
![]() |
943939d0e5 | ||
![]() |
3d614131b5 | ||
![]() |
8723226040 | ||
![]() |
b5cc17d664 | ||
![]() |
abf14c3940 | ||
![]() |
23973e2221 | ||
![]() |
980f04f77b | ||
![]() |
8d2f12d7f0 | ||
![]() |
88004b30ff | ||
![]() |
dcaa93d984 | ||
![]() |
0aa777f47e | ||
![]() |
540ab03b18 | ||
![]() |
93321224f6 | ||
![]() |
2fb7200d45 | ||
![]() |
0acd86f6eb | ||
![]() |
901ed630fc | ||
![]() |
059f89ca95 | ||
![]() |
4a6303ba3b | ||
![]() |
7446f029b5 | ||
![]() |
e80d338b18 | ||
![]() |
b891772ad6 | ||
![]() |
b0eb19970a | ||
![]() |
0bf3d3913f | ||
![]() |
913cdd91b1 | ||
![]() |
200eeb1265 | ||
![]() |
fbd622971d | ||
![]() |
755d86be01 | ||
![]() |
cd4996cebe | ||
![]() |
a7dd4457f5 | ||
![]() |
8be40010ce | ||
![]() |
e1f2a6f869 | ||
![]() |
87dd203c26 | ||
![]() |
de2062873f | ||
![]() |
71e5db4cde | ||
![]() |
9d04217174 | ||
![]() |
17a9a8472e | ||
![]() |
94fe901eda | ||
![]() |
28585a58bd | ||
![]() |
b36c59c0ed | ||
![]() |
8b6a74775b | ||
![]() |
c594192bac | ||
![]() |
8478e57463 | ||
![]() |
f7caf2b30d | ||
![]() |
520682e596 | ||
![]() |
4c01261f39 | ||
![]() |
8a99226f16 | ||
![]() |
1497d34760 | ||
![]() |
741eb58763 | ||
![]() |
9baf9640b9 | ||
![]() |
4b95e82a32 | ||
![]() |
c766e58acf | ||
![]() |
be6ab54986 | ||
![]() |
5b19adfa82 | ||
![]() |
acb7c42d7c | ||
![]() |
06a60a166a | ||
![]() |
51863b6cf9 | ||
![]() |
08afd5d4c9 | ||
![]() |
1f0b0b23cd | ||
![]() |
32d79b0310 | ||
![]() |
cd730a02c3 | ||
![]() |
11f2c32df2 | ||
![]() |
30c794083f | ||
![]() |
ddebbd6792 | ||
![]() |
abe0a4a7e6 | ||
![]() |
2872bfa151 | ||
![]() |
e544a41f62 | ||
![]() |
7b3873bc1e | ||
![]() |
8103fe1486 | ||
![]() |
d63e081303 | ||
![]() |
3fed78e5b0 | ||
![]() |
2a81893cc0 | ||
![]() |
98a2479f0b | ||
![]() |
57cc5326cf | ||
![]() |
9e4adc4633 | ||
![]() |
db406fe24c | ||
![]() |
9396cc62cf | ||
![]() |
7a70f1b019 | ||
![]() |
ca28f28046 | ||
![]() |
dd2756e000 | ||
![]() |
3c9182b85e | ||
![]() |
4d17a18db5 | ||
![]() |
7da57b293f | ||
![]() |
254808d9ef | ||
![]() |
183cc3cbf1 | ||
![]() |
c17c7e13c3 | ||
![]() |
a5dbef45e7 | ||
![]() |
27842d7f77 | ||
![]() |
c5398adfe2 | ||
![]() |
538bc87998 | ||
![]() |
04250f6a7c | ||
![]() |
5c078ce2f5 | ||
![]() |
614eb0402a | ||
![]() |
b6e8469059 | ||
![]() |
d3e14ea99e | ||
![]() |
e51be45c40 | ||
![]() |
56ddcfe65a | ||
![]() |
1bf8b96ac8 | ||
![]() |
16e6ac99fe | ||
![]() |
56f2e55b7a | ||
![]() |
5ac14531b5 | ||
![]() |
2543c5a78b | ||
![]() |
33ef70b9e1 | ||
![]() |
8ef0ecdf44 | ||
![]() |
6660397589 | ||
![]() |
391c75b427 | ||
![]() |
45783ae4ca | ||
![]() |
5902730a03 | ||
![]() |
42601170ac | ||
![]() |
0bd48c4a4d | ||
![]() |
d03b2b07fc | ||
![]() |
cb1346e5b3 | ||
![]() |
61fa98ea9e | ||
![]() |
931e043430 | ||
![]() |
f984a7006b | ||
![]() |
326a3a7619 | ||
![]() |
e4aff3d9fc | ||
![]() |
c3feeb0092 | ||
![]() |
80c3954e3c | ||
![]() |
4c3e03efeb | ||
![]() |
9b30dae909 | ||
![]() |
25dd60b9cc | ||
![]() |
5b16707e95 | ||
![]() |
1f0b016e97 | ||
![]() |
dcaec44a6f | ||
![]() |
8dbfb3529b | ||
![]() |
74ae34e792 | ||
![]() |
deb9f56ceb |
18
.gitignore
vendored
18
.gitignore
vendored
@@ -1,6 +1,22 @@
|
||||
ChangeLog
|
||||
libbsd.pc
|
||||
*.pc
|
||||
*.la
|
||||
*.lo
|
||||
*.o
|
||||
*.so*
|
||||
*.a
|
||||
*.log
|
||||
*.trs
|
||||
.dirstamp
|
||||
.deps/
|
||||
.libs/
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
build-aux/
|
||||
configure
|
||||
config.*
|
||||
libtool
|
||||
m4/
|
||||
stamp-h1
|
||||
|
9
.gitlab-ci.yml
Normal file
9
.gitlab-ci.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
image: debian:buster
|
||||
|
||||
test:
|
||||
before_script:
|
||||
- apt update -qq
|
||||
- apt install -qq -y --no-install-recommends git gcc make autoconf automake libtool libmd-dev
|
||||
script:
|
||||
- ./autogen && ./configure
|
||||
- make check
|
613
COPYING
Normal file
613
COPYING
Normal file
@@ -0,0 +1,613 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
|
||||
Files:
|
||||
*
|
||||
Copyright:
|
||||
Copyright © 2004-2006, 2008-2021 Guillem Jover <guillem@hadrons.org>
|
||||
License: BSD-3-clause
|
||||
|
||||
Files:
|
||||
man/arc4random.3bsd
|
||||
man/tree.3bsd
|
||||
Copyright:
|
||||
Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
|
||||
All rights reserved.
|
||||
License: BSD-4-clause-Niels-Provos
|
||||
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 by Niels Provos.
|
||||
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:
|
||||
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:
|
||||
include/bsd/err.h
|
||||
include/bsd/stdlib.h
|
||||
include/bsd/sys/param.h
|
||||
include/bsd/unistd.h
|
||||
src/bsd_getopt.c
|
||||
src/err.c
|
||||
src/fgetln.c
|
||||
src/progname.c
|
||||
Copyright:
|
||||
Copyright © 2005, 2008-2012, 2019 Guillem Jover <guillem@hadrons.org>
|
||||
Copyright © 2005 Hector Garcia Alvarez
|
||||
Copyright © 2005 Aurelien Jarno
|
||||
Copyright © 2006 Robert Millan
|
||||
Copyright © 2018 Facebook, Inc.
|
||||
License: BSD-3-clause
|
||||
|
||||
Files:
|
||||
include/bsd/netinet/ip_icmp.h
|
||||
include/bsd/sys/bitstring.h
|
||||
include/bsd/sys/queue.h
|
||||
include/bsd/sys/time.h
|
||||
include/bsd/timeconv.h
|
||||
include/bsd/vis.h
|
||||
man/bitstring.3bsd
|
||||
man/errc.3bsd
|
||||
man/explicit_bzero.3bsd
|
||||
man/fgetln.3bsd
|
||||
man/fgetwln.3bsd
|
||||
man/fpurge.3bsd
|
||||
man/funopen.3bsd
|
||||
man/getbsize.3bsd
|
||||
man/heapsort.3bsd
|
||||
man/nlist.3bsd
|
||||
man/pwcache.3bsd
|
||||
man/queue.3bsd
|
||||
man/radixsort.3bsd
|
||||
man/reallocarray.3bsd
|
||||
man/reallocf.3bsd
|
||||
man/setmode.3bsd
|
||||
man/strmode.3bsd
|
||||
man/strnstr.3bsd
|
||||
man/strtoi.3bsd
|
||||
man/strtou.3bsd
|
||||
man/unvis.3bsd
|
||||
man/vis.3bsd
|
||||
man/wcslcpy.3bsd
|
||||
src/getbsize.c
|
||||
src/heapsort.c
|
||||
src/merge.c
|
||||
src/nlist.c
|
||||
src/pwcache.c
|
||||
src/radixsort.c
|
||||
src/setmode.c
|
||||
src/strmode.c
|
||||
src/strnstr.c
|
||||
src/strtoi.c
|
||||
src/strtou.c
|
||||
src/unvis.c
|
||||
Copyright:
|
||||
Copyright © 1980, 1982, 1986, 1989-1994
|
||||
The Regents of the University of California. All rights reserved.
|
||||
Copyright © 1992 Keith Muller.
|
||||
Copyright © 2001 Mike Barcroft <mike@FreeBSD.org>
|
||||
.
|
||||
Some code is derived from software contributed to Berkeley by
|
||||
the American National Standards Committee X3, on Information
|
||||
Processing Systems.
|
||||
.
|
||||
Some code is derived from software contributed to Berkeley by
|
||||
Peter McIlroy.
|
||||
.
|
||||
Some code is derived from software contributed to Berkeley by
|
||||
Ronnie Kon at Mindcraft Inc., Kevin Lew and Elmer Yglesias.
|
||||
.
|
||||
Some code is derived from software contributed to Berkeley by
|
||||
Dave Borman at Cray Research, Inc.
|
||||
.
|
||||
Some code is derived from software contributed to Berkeley by
|
||||
Paul Vixie.
|
||||
.
|
||||
Some code is derived from software contributed to Berkeley by
|
||||
Chris Torek.
|
||||
.
|
||||
Copyright © UNIX System Laboratories, Inc.
|
||||
All or some portions of this file are derived from material licensed
|
||||
to the University of California by American Telephone and Telegraph
|
||||
Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
the permission of UNIX System Laboratories, Inc.
|
||||
License: BSD-3-clause-Regents
|
||||
|
||||
Files:
|
||||
src/vis.c
|
||||
Copyright:
|
||||
Copyright © 1989, 1993
|
||||
The Regents of the University of California. All rights reserved.
|
||||
.
|
||||
Copyright © 1999, 2005 The NetBSD Foundation, Inc.
|
||||
All rights reserved.
|
||||
License: BSD-3-clause-Regents and BSD-2-clause-NetBSD
|
||||
|
||||
Files:
|
||||
include/bsd/libutil.h
|
||||
Copyright:
|
||||
Copyright © 1996 Peter Wemm <peter@FreeBSD.org>.
|
||||
All rights reserved.
|
||||
Copyright © 2002 Networks Associates Technology, Inc.
|
||||
All rights reserved.
|
||||
License: BSD-3-clause-author
|
||||
|
||||
Files:
|
||||
man/timeradd.3bsd
|
||||
Copyright:
|
||||
Copyright © 2009 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
Copyright © 1999 Kelly Yancey <kbyanc@posi.net>
|
||||
All rights reserved.
|
||||
License: BSD-3-clause-John-Birrell
|
||||
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. Neither the name of the author nor the names of any co-contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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:
|
||||
man/setproctitle.3bsd
|
||||
Copyright:
|
||||
Copyright © 1995 Peter Wemm <peter@FreeBSD.org>
|
||||
All rights reserved.
|
||||
License: BSD-5-clause-Peter-Wemm
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, is permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice immediately at the beginning of the file, without modification,
|
||||
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. This work was done expressly for inclusion into FreeBSD. Other use
|
||||
is permitted provided this notation is included.
|
||||
4. Absolutely no warranty of function or purpose is made by the author
|
||||
Peter Wemm.
|
||||
5. Modifications may be freely made to this file providing the above
|
||||
conditions are met.
|
||||
|
||||
Files:
|
||||
include/bsd/stringlist.h
|
||||
man/fmtcheck.3bsd
|
||||
man/humanize_number.3bsd
|
||||
man/stringlist.3bsd
|
||||
man/timeval.3bsd
|
||||
src/fmtcheck.c
|
||||
src/humanize_number.c
|
||||
src/stringlist.c
|
||||
src/strtonum.c
|
||||
Copyright:
|
||||
Copyright © 1994, 1997-2000, 2002, 2008, 2010, 2014
|
||||
The NetBSD Foundation, Inc.
|
||||
Copyright © 2013 John-Mark Gurney <jmg@FreeBSD.org>
|
||||
All rights reserved.
|
||||
.
|
||||
Some code was contributed to The NetBSD Foundation by Allen Briggs.
|
||||
.
|
||||
Some code was contributed to The NetBSD Foundation by Luke Mewburn.
|
||||
.
|
||||
Some code is derived from software contributed to The NetBSD Foundation
|
||||
by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
NASA Ames Research Center, by Luke Mewburn and by Tomas Svensson.
|
||||
.
|
||||
Some code is derived from software contributed to The NetBSD Foundation
|
||||
by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
2005 program.
|
||||
.
|
||||
Some code is derived from software contributed to The NetBSD Foundation
|
||||
by Christos Zoulas.
|
||||
.
|
||||
Some code is derived from software contributed to The NetBSD Foundation
|
||||
by Jukka Ruohonen.
|
||||
License: BSD-2-clause-NetBSD
|
||||
|
||||
Files:
|
||||
include/bsd/sys/endian.h
|
||||
man/byteorder.3bsd
|
||||
man/closefrom.3bsd
|
||||
man/expand_number.3bsd
|
||||
man/flopen.3bsd
|
||||
man/getpeereid.3bsd
|
||||
man/pidfile.3bsd
|
||||
src/expand_number.c
|
||||
src/pidfile.c
|
||||
src/reallocf.c
|
||||
src/timeconv.c
|
||||
Copyright:
|
||||
Copyright © 1998, M. Warner Losh <imp@freebsd.org>
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2001 Dima Dorfman.
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2001 FreeBSD Inc.
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2002 Thomas Moestl <tmm@FreeBSD.org>
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2002 Mike Barcroft <mike@FreeBSD.org>
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2005 Colin Percival
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2007 Eric Anderson <anderson@FreeBSD.org>
|
||||
Copyright © 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2007 Dag-Erling Coïdan Smørgrav
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2009 Advanced Computing Technologies LLC
|
||||
Written by: John H. Baldwin <jhb@FreeBSD.org>
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2011 Guillem Jover <guillem@hadrons.org>
|
||||
License: BSD-2-clause
|
||||
|
||||
Files:
|
||||
src/flopen.c
|
||||
Copyright:
|
||||
Copyright © 2007-2009 Dag-Erling Coïdan Smørgrav
|
||||
All rights reserved.
|
||||
License: BSD-2-clause-verbatim
|
||||
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
|
||||
in this position and unchanged.
|
||||
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.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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:
|
||||
include/bsd/sys/tree.h
|
||||
man/fparseln.3bsd
|
||||
src/fparseln.c
|
||||
Copyright:
|
||||
Copyright © 1997 Christos Zoulas.
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 2002 Niels Provos <provos@citi.umich.edu>
|
||||
All rights reserved.
|
||||
License: BSD-2-clause-author
|
||||
|
||||
Files:
|
||||
include/bsd/readpassphrase.h
|
||||
man/readpassphrase.3bsd
|
||||
man/strlcpy.3bsd
|
||||
man/strtonum.3bsd
|
||||
src/arc4random.c
|
||||
src/arc4random_linux.h
|
||||
src/arc4random_openbsd.h
|
||||
src/arc4random_uniform.c
|
||||
src/arc4random_unix.h
|
||||
src/arc4random_win.h
|
||||
src/closefrom.c
|
||||
src/freezero.c
|
||||
src/getentropy_aix.c
|
||||
src/getentropy_bsd.c
|
||||
src/getentropy_hpux.c
|
||||
src/getentropy_hurd.c
|
||||
src/getentropy_linux.c
|
||||
src/getentropy_osx.c
|
||||
src/getentropy_solaris.c
|
||||
src/getentropy_win.c
|
||||
src/readpassphrase.c
|
||||
src/reallocarray.c
|
||||
src/recallocarray.c
|
||||
src/strlcat.c
|
||||
src/strlcpy.c
|
||||
Copyright:
|
||||
Copyright © 2004 Ted Unangst and Todd Miller
|
||||
All rights reserved.
|
||||
.
|
||||
Copyright © 1996 David Mazieres <dm@uun.org>
|
||||
Copyright © 1998, 2000-2002, 2004-2005, 2007, 2010, 2012-2015
|
||||
Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
Copyright © 2004 Ted Unangst
|
||||
Copyright © 2008 Damien Miller <djm@openbsd.org>
|
||||
Copyright © 2008, 2010-2011, 2016-2017 Otto Moerbeek <otto@drijf.net>
|
||||
Copyright © 2013 Markus Friedl <markus@openbsd.org>
|
||||
Copyright © 2014 Bob Beck <beck@obtuse.com>
|
||||
Copyright © 2014 Brent Cook <bcook@openbsd.org>
|
||||
Copyright © 2014 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
||||
Copyright © 2014 Theo de Raadt <deraadt@openbsd.org>
|
||||
Copyright © 2015 Michael Felt <aixtools@gmail.com>
|
||||
Copyright © 2015 Guillem Jover <guillem@hadrons.org>
|
||||
License: ISC
|
||||
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.
|
||||
|
||||
Files:
|
||||
src/inet_net_pton.c
|
||||
Copyright:
|
||||
Copyright © 1996 by Internet Software Consortium.
|
||||
License: ISC-Original
|
||||
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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
CONSORTIUM 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.
|
||||
|
||||
Files:
|
||||
src/setproctitle.c
|
||||
Copyright:
|
||||
Copyright © 2010 William Ahern
|
||||
Copyright © 2012 Guillem Jover <guillem@hadrons.org>
|
||||
License: Expat
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
.
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Files:
|
||||
src/explicit_bzero.c
|
||||
src/chacha_private.h
|
||||
Copyright:
|
||||
None
|
||||
License: public-domain
|
||||
Public domain.
|
||||
|
||||
Files:
|
||||
man/mdX.3bsd
|
||||
Copyright:
|
||||
None
|
||||
License: Beerware
|
||||
"THE BEER-WARE LICENSE" (Revision 42):
|
||||
<phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
|
||||
can do whatever you want with this stuff. If we meet some day, and you think
|
||||
this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
|
||||
License: BSD-3-clause-Regents
|
||||
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. Neither the name of the University nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
|
||||
License: BSD-3-clause-author
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, is permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
||||
|
||||
License: BSD-3-clause
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
License: BSD-2-clause-NetBSD
|
||||
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.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
``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 FOUNDATION OR CONTRIBUTORS
|
||||
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.
|
||||
|
||||
License: BSD-2-clause-author
|
||||
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.
|
||||
.
|
||||
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.
|
||||
|
||||
License: BSD-2-clause
|
||||
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.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
162
Makefile
162
Makefile
@@ -1,162 +0,0 @@
|
||||
LIB_NAME := libbsd
|
||||
LIB_VERSION_MAJOR := 0
|
||||
LIB_VERSION_MINOR := 0
|
||||
LIB_VERSION_MICRO := 1
|
||||
LIB_VERSION := $(LIB_VERSION_MAJOR).$(LIB_VERSION_MINOR).$(LIB_VERSION_MICRO)
|
||||
|
||||
LIB_PKGCONFIG := $(LIB_NAME).pc
|
||||
LIB_STATIC := $(LIB_NAME).a
|
||||
LIB_SHARED_SO := $(LIB_NAME).so
|
||||
LIB_SONAME := $(LIB_SHARED_SO).$(LIB_VERSION_MAJOR)
|
||||
LIB_SHARED := $(LIB_SONAME).$(LIB_VERSION_MINOR).$(LIB_VERSION_MICRO)
|
||||
|
||||
TAR_NAME := $(LIB_NAME)-$(LIB_VERSION)
|
||||
TAR_FILE := $(TAR_NAME).tar.gz
|
||||
|
||||
LIB_DIST := \
|
||||
Makefile \
|
||||
README \
|
||||
ChangeLog \
|
||||
Versions \
|
||||
$(LIB_PKGCONFIG).in
|
||||
|
||||
LIB_SRCS := \
|
||||
arc4random.c \
|
||||
bsd_getopt.c \
|
||||
err.c \
|
||||
fgetln.c \
|
||||
heapsort.c \
|
||||
humanize_number.c \
|
||||
inet_net_pton.c \
|
||||
hash/md5.c hash/md5hl.c \
|
||||
setmode.c \
|
||||
strlcat.c strlcpy.c \
|
||||
fmtcheck.c \
|
||||
progname.c \
|
||||
vis.c unvis.c
|
||||
LIB_SRCS := $(patsubst %,src/%,$(LIB_SRCS))
|
||||
|
||||
LIB_GEN_SRCS := \
|
||||
man/md5.3bsd \
|
||||
src/hash/md5hl.c
|
||||
|
||||
LIB_INCLUDES := \
|
||||
bsd/err.h \
|
||||
bsd/getopt.h \
|
||||
bsd/inet.h \
|
||||
bsd/ip_icmp.h \
|
||||
bsd/random.h \
|
||||
bsd/queue.h \
|
||||
bsd/md5.h \
|
||||
bsd/string.h \
|
||||
bsd/bsd.h \
|
||||
bsd/cdefs.h \
|
||||
bsd/stdlib.h \
|
||||
vis.h \
|
||||
libutil.h
|
||||
|
||||
LIB_MANS := \
|
||||
arc4random.3 \
|
||||
strlcpy.3 \
|
||||
fgetln.3 \
|
||||
fmtcheck.3 \
|
||||
setmode.3 \
|
||||
md5.3bsd
|
||||
LIB_MANS := $(patsubst %,man/%,$(LIB_MANS))
|
||||
|
||||
LIB_STATIC_OBJS := $(LIB_SRCS:%.c=%.o)
|
||||
LIB_SHARED_OBJS := $(LIB_SRCS:%.c=%.lo)
|
||||
|
||||
# Set default value for compilation
|
||||
CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
|
||||
|
||||
MK_CFLAGS := -Iinclude/ -include bsd/bsd.h -D_GNU_SOURCE -D__REENTRANT
|
||||
|
||||
prefix := /usr
|
||||
exec_prefix :=
|
||||
libdir := ${exec_prefix}/lib
|
||||
usrlibdir := ${prefix}/lib
|
||||
includedir := ${prefix}/include
|
||||
pkgconfigdir := ${usrlibdir}/pkgconfig
|
||||
mandir := ${prefix}/share/man
|
||||
|
||||
.PHONY: libs
|
||||
libs: $(LIB_STATIC) $(LIB_SHARED_SO) $(LIB_PKGCONFIG)
|
||||
|
||||
.PHONY: man
|
||||
man: $(LIB_MANS)
|
||||
|
||||
%.lo: %.c
|
||||
$(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -DPIC -fPIC -c $<
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
man/md5.3bsd: man/mdX.3
|
||||
sed -e 's/mdX/md5/g' -e 's/mdY/md4/g' -e 's/MDX/MD5/g' $< > $@
|
||||
|
||||
src/hash/md5hl.c: src/hash/helper.c
|
||||
sed -e 's:hashinc:bsd/md5.h:g' -e 's:HASH:MD5:g' $< > $@
|
||||
|
||||
# FIXME: the variables should be preserved unexpanded in the .pc file
|
||||
$(LIB_PKGCONFIG): $(LIB_PKGCONFIG).in
|
||||
sed -e 's:@VERSION@:$(LIB_VERSION):' \
|
||||
-e 's:@prefix@:$(prefix):' \
|
||||
-e 's:@exec_prefix@:$(exec_prefix):' \
|
||||
-e 's:@libdir@:$(libdir):' \
|
||||
-e 's:@includedir@:$(includedir):' \
|
||||
$< > $@
|
||||
|
||||
$(LIB_STATIC): $(LIB_STATIC_OBJS)
|
||||
ar rcs $@ $^
|
||||
|
||||
$(LIB_SHARED_SO): $(LIB_SONAME)
|
||||
ln -fs $^ $@
|
||||
|
||||
$(LIB_SONAME): $(LIB_SHARED)
|
||||
ln -fs $^ $@
|
||||
|
||||
$(LIB_SHARED): $(LIB_SHARED_OBJS)
|
||||
gcc -shared \
|
||||
-Wl,-soname -Wl,$(LIB_SONAME) \
|
||||
-Wl,--version-script=Versions \
|
||||
-o $@ $^
|
||||
|
||||
.PHONY: ChangeLog
|
||||
ChangeLog:
|
||||
-git log --stat -C >$@
|
||||
|
||||
.PHONY: dist
|
||||
dist: ChangeLog
|
||||
mkdir $(TAR_NAME)
|
||||
cp -a include src man $(LIB_DIST) $(TAR_NAME)
|
||||
tar czf $(TAR_FILE) --exclude=.gitignore $(TAR_NAME)
|
||||
rm -rf $(TAR_NAME)
|
||||
gpg -a -b $(TAR_FILE)
|
||||
|
||||
.PHONY: install
|
||||
install: libs man
|
||||
mkdir -p $(DESTDIR)/$(libdir)
|
||||
mkdir -p $(DESTDIR)/$(usrlibdir)
|
||||
mkdir -p $(DESTDIR)/$(includedir)/bsd/
|
||||
mkdir -p $(DESTDIR)/$(mandir)/man3
|
||||
mkdir -p $(DESTDIR)/$(pkgconfigdir)
|
||||
install -m644 $(LIB_STATIC) $(DESTDIR)/$(usrlibdir)
|
||||
install -m644 $(LIB_SHARED) $(DESTDIR)/$(libdir)
|
||||
for i in $(LIB_INCLUDES); do \
|
||||
install -m644 include/$$i $(DESTDIR)/$(includedir)/$$i; \
|
||||
done
|
||||
install -m644 $(LIB_MANS) $(DESTDIR)/$(mandir)/man3
|
||||
install -m644 $(LIB_PKGCONFIG) $(DESTDIR)/$(pkgconfigdir)
|
||||
ln -sf $(libdir)/$(LIB_SHARED) $(DESTDIR)/$(usrlibdir)/$(LIB_SHARED_SO)
|
||||
ln -sf $(LIB_SHARED) $(DESTDIR)/$(libdir)/$(LIB_SONAME)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(LIB_PKGCONFIG)
|
||||
rm -f $(LIB_GEN_SRCS)
|
||||
rm -f $(LIB_STATIC_OBJS)
|
||||
rm -f $(LIB_STATIC)
|
||||
rm -f $(LIB_SHARED_OBJS)
|
||||
rm -f $(LIB_SHARED) $(LIB_SONAME) $(LIB_SHARED_SO)
|
||||
|
16
Makefile.am
Normal file
16
Makefile.am
Normal file
@@ -0,0 +1,16 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = include man src test
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
EXTRA_DIST = \
|
||||
autogen \
|
||||
get-version \
|
||||
$(nil)
|
||||
|
||||
dist-hook:
|
||||
echo $(VERSION) >$(distdir)/.dist-version
|
||||
if [ -d .git ]; then \
|
||||
XDG_CONFIG_HOME= HOME= git log --stat -C >$(distdir)/ChangeLog; \
|
||||
fi
|
15
README
15
README
@@ -5,11 +5,14 @@ and lacking on others like GNU systems, thus making it easier to port
|
||||
projects with strong BSD origins, without needing to embed the same
|
||||
code over and over again on each project.
|
||||
|
||||
A BSD compatible message-digest library is required, on systems where
|
||||
this is not provided by its libc or libmd libraries, the canonical
|
||||
implementation to use is <https://www.hadrons.org/software/libmd/>.
|
||||
|
||||
Releases
|
||||
--------
|
||||
|
||||
<http://libbsd.freedesktop.org/releases/>
|
||||
<https://libbsd.freedesktop.org/releases/>
|
||||
|
||||
|
||||
Mailing List
|
||||
@@ -17,7 +20,7 @@ Mailing List
|
||||
|
||||
The subscription interface and web archives can be found at:
|
||||
|
||||
<http://lists.freedesktop.org/mailman/listinfo/libbsd>
|
||||
<https://lists.freedesktop.org/mailman/listinfo/libbsd>
|
||||
|
||||
The mail address is:
|
||||
|
||||
@@ -27,6 +30,10 @@ The mail address is:
|
||||
Source Repository
|
||||
-----------------
|
||||
|
||||
<http://gitweb.freedesktop.org/?p=libbsd.git>
|
||||
<git://anongit.freedesktop.org/git/libbsd>
|
||||
The master repository can be browsed at:
|
||||
|
||||
<https://cgit.freedesktop.org/libbsd>
|
||||
|
||||
and cloned from:
|
||||
|
||||
<https://anongit.freedesktop.org/git/libbsd>
|
||||
|
12
TODO
12
TODO
@@ -1,4 +1,14 @@
|
||||
* Migrate portable functions from GNU/kFreeBSD's libfreebsd.
|
||||
* Add more functions used by ported packages (check openssh).
|
||||
* Fix includes on man pages.
|
||||
* Add more unit tests.
|
||||
* Add missing man pages.
|
||||
- bsd_getopt.
|
||||
- timeconv?
|
||||
* Add a README.import file.
|
||||
* Update man pages:
|
||||
- Document when each interface was added on every BSD, and libbsd.
|
||||
* Handle LFS properly. By default the library emits LFS objects, but might
|
||||
be used by non-LFS objects. We should either provide foo and foo64
|
||||
functions and appropriate mappings on _FILE_OFFSET_BITS=64,
|
||||
_LARGEFILE_SOURCE and _LARGEFILE64_SOURCE. Or error out when the off_t
|
||||
used by the code including us does not match a 64-bit type.
|
||||
|
36
Versions
36
Versions
@@ -1,36 +0,0 @@
|
||||
LIBBSD_0.0 {
|
||||
global:
|
||||
arc4random;
|
||||
arc4random_stir;
|
||||
arc4random_addrandom;
|
||||
bsd_getopt; optreset;
|
||||
errc; warnc; verrc; vwarnc;
|
||||
fgetln;
|
||||
fgetwln;
|
||||
fmtcheck;
|
||||
heapsort;
|
||||
humanize_number;
|
||||
inet_net_pton;
|
||||
|
||||
getprogname; setprogname;
|
||||
strlcpy;
|
||||
strlcat;
|
||||
|
||||
setmode;
|
||||
getmode;
|
||||
|
||||
vis; strvis; strvisx;
|
||||
unvis; strunvis; strunvisx;
|
||||
MD5Init;
|
||||
MD5Update;
|
||||
MD5Pad;
|
||||
MD5Final;
|
||||
MD5Transform;
|
||||
MD5End;
|
||||
MD5File;
|
||||
MD5FileChunk;
|
||||
MD5Data;
|
||||
|
||||
local:
|
||||
*;
|
||||
};
|
5
autogen
Executable file
5
autogen
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p m4
|
||||
autoreconf -f -i
|
||||
rm -rf autom4te.cache
|
229
configure.ac
Normal file
229
configure.ac
Normal file
@@ -0,0 +1,229 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.67])
|
||||
AC_INIT([libbsd], m4_esyscmd([./get-version]), [libbsd@lists.freedesktop.org])
|
||||
AC_CONFIG_SRCDIR([src/strlcpy.c])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.9 foreign nostdinc subdir-objects no-dist-gzip dist-xz])
|
||||
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
|
||||
[AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
|
||||
|
||||
LIBBSD_ABI_MAJOR=0
|
||||
LIBBSD_ABI_MINOR=11
|
||||
LIBBSD_ABI_PATCH=3
|
||||
|
||||
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
||||
AC_SUBST([LIBBSD_ABI])
|
||||
|
||||
# Check and store if we got user supplied variables
|
||||
user_CFLAGS=${CFLAGS-unset}
|
||||
|
||||
# Checks for operating system services and capabilities.
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
LT_INIT
|
||||
|
||||
AC_CACHE_CHECK([if ld supports --version-script flag],
|
||||
[libbsd_cv_version_script], [
|
||||
echo "{ global: symbol; local: *; };" >conftest.map
|
||||
save_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([], [])
|
||||
], [
|
||||
libbsd_cv_version_script=yes
|
||||
], [
|
||||
libbsd_cv_version_script=no
|
||||
])
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
rm -f conftest.map
|
||||
]
|
||||
)
|
||||
AM_CONDITIONAL([HAVE_LINKER_VERSION_SCRIPT],
|
||||
[test "x$libbsd_cv_version_script" = "xyes"])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
||||
# Set default compiler variables
|
||||
if test "$user_CFLAGS" = unset && test "$GCC" = yes; then
|
||||
CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter"
|
||||
fi
|
||||
|
||||
# Checks for libraries.
|
||||
AC_CHECK_LIB([testu01], [unif01_CreateExternGenBits],
|
||||
[TESTU01_LIBS="-ltestu01"])
|
||||
AC_SUBST([TESTU01_LIBS])
|
||||
AM_CONDITIONAL([HAVE_LIBTESTU01],
|
||||
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
||||
|
||||
saved_LIBS="$LIBS"
|
||||
AC_SEARCH_LIBS([dlsym], [dl], [
|
||||
AS_IF([test "x$ac_cv_search_dlsym" != "xnone required"], [
|
||||
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_dlsym"
|
||||
])
|
||||
], [
|
||||
AC_MSG_ERROR([cannot find required dlsym function])
|
||||
])
|
||||
AC_SEARCH_LIBS([MD5Update], [md], [
|
||||
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
|
||||
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_MD5Update"
|
||||
])
|
||||
], [
|
||||
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])
|
||||
])
|
||||
LIBS="$saved_LIBS"
|
||||
|
||||
is_windows=no
|
||||
AS_CASE([$host_os],
|
||||
[*-gnu*], [
|
||||
# In old glibc versions (< 2.17) clock_gettime() is in librt.
|
||||
saved_LIBS="$LIBS"
|
||||
AC_SEARCH_LIBS([clock_gettime], [rt], [
|
||||
AS_IF([test "x$ac_cv_search_clock_gettime" != "xnone required"], [
|
||||
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_clock_gettime"
|
||||
])
|
||||
])
|
||||
LIBS="$saved_LIBS"
|
||||
],
|
||||
[*-musl*], [
|
||||
# Upstream refuses to define this, we will do it ourselves then.
|
||||
AC_DEFINE([__MUSL__], [1], [Define to 1 if we are building for musl])
|
||||
],
|
||||
[mingw*], [
|
||||
is_windows=yes
|
||||
],
|
||||
)
|
||||
AM_CONDITIONAL([OS_WINDOWS], [test "x$is_windows" = "xyes"])
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h pwd.h grp.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_INLINE
|
||||
AC_C_TYPEOF
|
||||
AC_TYPE_INT64_T
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_UID_T
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_SSIZE_T
|
||||
|
||||
AC_CHECK_DECL([F_CLOSEM],
|
||||
[AC_DEFINE([HAVE_FCNTL_CLOSEM], [1],
|
||||
[Define to 1 if you have fcntl(F_CLOSEM)])],
|
||||
[],
|
||||
[#include <limits.h>
|
||||
#include <fcntl.h>])
|
||||
|
||||
AC_CACHE_CHECK(
|
||||
[for GNU .init_array section support],
|
||||
[libbsd_cv_gnu_init_array_support],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE(
|
||||
[[
|
||||
static int rc = 1;
|
||||
static void init(int argc) { if (argc == 1) rc = 0; }
|
||||
void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
|
||||
int main() { return rc; }
|
||||
]]
|
||||
)],
|
||||
[libbsd_cv_gnu_init_array_support=yes],
|
||||
[libbsd_cv_gnu_init_array_support=no],
|
||||
[AC_PREPROC_IFELSE(
|
||||
[AC_LANG_SOURCE(
|
||||
[[
|
||||
/* Look for a known libc that supports .init_array with the GNU extension
|
||||
* to pass main() arguments to the init functions. */
|
||||
#include <stdlib.h>
|
||||
#if defined __GLIBC_PREREQ
|
||||
# if __GLIBC_PREREQ(2, 4)
|
||||
/* glibc supports GNU .init_array since 2.4. */
|
||||
# else
|
||||
# error glibc does not support GNU .init_array
|
||||
# endif
|
||||
#else
|
||||
/*
|
||||
* Basic SysV ABI .init_array support, init functions do not get arguments:
|
||||
* - Bionic since its inception.
|
||||
* - uClibc since 0.9.29.
|
||||
*/
|
||||
# error unknown whether libc supports GNU .init_array
|
||||
#endif
|
||||
]]
|
||||
)],
|
||||
[libbsd_cv_gnu_init_array_support=yes],
|
||||
[libbsd_cv_gnu_init_array_support=no])
|
||||
]
|
||||
)]
|
||||
)
|
||||
AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
|
||||
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_MSG_CHECKING([for program_invocation_short_name])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <errno.h>]],
|
||||
[[const char *p = program_invocation_short_name;]])],
|
||||
[AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
|
||||
[Define to 1 if you have program_invocation_short_name])
|
||||
AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_RESULT([no])])
|
||||
|
||||
AC_MSG_CHECKING([for __progname])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[extern char *__progname;]],
|
||||
[[printf("%s", __progname);]])],
|
||||
[AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
|
||||
AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_RESULT([no])])
|
||||
|
||||
AC_MSG_CHECKING([for __register_atfork])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <stddef.h>
|
||||
extern void *__dso_handle;
|
||||
extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void *);
|
||||
]], [[
|
||||
__register_atfork(NULL, NULL, NULL, __dso_handle);
|
||||
]])],
|
||||
[AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
||||
[Define to 1 if you have __register_atfork])
|
||||
AC_MSG_RESULT([yes])],
|
||||
[LIBBSD_LIBS="$LIBBSD_LIBS -pthread"
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
|
||||
AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
|
||||
getauxval getentropy getexecname getline \
|
||||
pstat_getproc sysconf])
|
||||
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
|
||||
|
||||
AC_SUBST([LIBBSD_LIBS])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
include/Makefile
|
||||
man/Makefile
|
||||
src/Makefile
|
||||
src/libbsd.pc
|
||||
src/libbsd-ctor.pc
|
||||
src/libbsd-overlay.pc
|
||||
test/Makefile
|
||||
])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_OUTPUT
|
48
get-version
Executable file
48
get-version
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# get-version
|
||||
#
|
||||
# Copyright © 2009 Guillem Jover <guillem@hadrons.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
# THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
if [ -f .dist-version ]; then
|
||||
# Get the version from the file distributed in the tarball.
|
||||
version=$(cat .dist-version)
|
||||
elif [ -d .git ]; then
|
||||
# Ger the version from the git repository.
|
||||
version=$(git describe --abbrev=4 HEAD 2>/dev/null)
|
||||
|
||||
# Check if we are on a dirty checkout.
|
||||
git update-index --refresh -q >/dev/null
|
||||
dirty=$(git diff-index --name-only HEAD 2>/dev/null)
|
||||
if [ -n "$dirty" ]; then
|
||||
version="$version-dirty"
|
||||
fi
|
||||
else
|
||||
echo "error: cannot get project version." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use printf to avoid the trailing new line that m4_esyscmd would not handle.
|
||||
printf "$version"
|
32
include/Makefile.am
Normal file
32
include/Makefile.am
Normal file
@@ -0,0 +1,32 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
nobase_include_HEADERS = \
|
||||
bsd/sys/bitstring.h \
|
||||
bsd/sys/cdefs.h \
|
||||
bsd/sys/endian.h \
|
||||
bsd/sys/param.h \
|
||||
bsd/sys/poll.h \
|
||||
bsd/sys/queue.h \
|
||||
bsd/sys/time.h \
|
||||
bsd/sys/tree.h \
|
||||
bsd/netinet/ip_icmp.h \
|
||||
bsd/bitstring.h \
|
||||
bsd/bsd.h \
|
||||
bsd/err.h \
|
||||
bsd/getopt.h \
|
||||
bsd/grp.h \
|
||||
bsd/inttypes.h \
|
||||
bsd/libutil.h \
|
||||
bsd/md5.h \
|
||||
bsd/nlist.h \
|
||||
bsd/pwd.h \
|
||||
bsd/readpassphrase.h \
|
||||
bsd/stdio.h \
|
||||
bsd/stdlib.h \
|
||||
bsd/string.h \
|
||||
bsd/stringlist.h \
|
||||
bsd/timeconv.h \
|
||||
bsd/unistd.h \
|
||||
bsd/vis.h \
|
||||
bsd/wchar.h \
|
||||
$(nil)
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Guillem Jover
|
||||
* Copyright © 2012 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -24,12 +24,9 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_INET_H
|
||||
#define LIBBSD_INET_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
int inet_net_pton(int af, const char *src, void *dst, siez_t size);
|
||||
|
||||
/* For compatibility with NetBSD and OpenBSD. */
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/bitstring.h>
|
||||
#else
|
||||
#include <bsd/sys/bitstring.h>
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2006 Guillem Jover
|
||||
* Copyright © 2004, 2005, 2006 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -27,19 +27,21 @@
|
||||
#ifndef LIBBSD_H
|
||||
#define LIBBSD_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#warning "This header is meant to be used w/o the libbsd overlay."
|
||||
#else
|
||||
/*
|
||||
* Include all bsd compat headers.
|
||||
*/
|
||||
|
||||
#include <bsd/cdefs.h>
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#include <bsd/sys/queue.h>
|
||||
#include <bsd/sys/tree.h>
|
||||
#include <bsd/netinet/ip_icmp.h>
|
||||
#include <bsd/stdlib.h>
|
||||
#include <bsd/string.h>
|
||||
#include <bsd/err.h>
|
||||
#include <bsd/getopt.h>
|
||||
#include <bsd/random.h>
|
||||
#include <bsd/md5.h>
|
||||
#include <bsd/queue.h>
|
||||
#include <bsd/ip_icmp.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Robert Millan
|
||||
* Copyright © 2006 Robert Millan
|
||||
* Copyright © 2009, 2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -24,14 +25,57 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#if __has_include_next(<err.h>)
|
||||
#include_next <err.h>
|
||||
#else
|
||||
#define LIBBSD_NEED_ERR_H_FUNCS
|
||||
#endif
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<err.h>)
|
||||
#include <err.h>
|
||||
#else
|
||||
#define LIBBSD_NEED_ERR_H_FUNCS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_ERR_H
|
||||
#define LIBBSD_ERR_H
|
||||
|
||||
#include <err.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern void warnc (int code, const char *format, ...);
|
||||
extern void vwarnc (int code, const char *format, va_list ap);
|
||||
extern void errc (int status, int code, const char *format, ...);
|
||||
extern void verrc (int status, int code, const char *format, va_list ap);
|
||||
__BEGIN_DECLS
|
||||
void vwarnc(int code, const char *format, va_list ap)
|
||||
__printflike(2, 0);
|
||||
void warnc(int code, const char *format, ...)
|
||||
__printflike(2, 3);
|
||||
|
||||
void verrc(int status, int code, const char *format, va_list ap)
|
||||
__printflike(3, 0) __dead2;
|
||||
void errc(int status, int code, const char *format, ...)
|
||||
__printflike(3, 4) __dead2;
|
||||
|
||||
#ifdef LIBBSD_NEED_ERR_H_FUNCS
|
||||
void vwarn(const char *format, va_list ap)
|
||||
__printflike(1, 0);
|
||||
void vwarnx(const char *format, va_list ap)
|
||||
__printflike(1, 0);
|
||||
void warn(const char *format, ...)
|
||||
__printflike(1, 2);
|
||||
void warnx(const char *format, ...)
|
||||
__printflike(1, 2);
|
||||
|
||||
void verr(int status, const char *format, va_list ap)
|
||||
__printflike(2, 0) __dead2;
|
||||
void verrx(int status, const char *format, va_list ap)
|
||||
__printflike(2, 0) __dead2;
|
||||
void err(int status, const char *format, ...)
|
||||
__printflike(2, 3) __dead2;
|
||||
void errx(int status, const char *format, ...)
|
||||
__printflike(2, 3) __dead2;
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Robert Millan
|
||||
* Copyright © 2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -24,13 +24,16 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_GETOPT_H
|
||||
#define LIBBSD_GETOPT_H
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
extern int optreset;
|
||||
|
||||
int bsd_getopt (int, char **, char *);
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#if __has_include_next(<getopt.h>)
|
||||
#include_next <getopt.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<getopt.h>)
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
#include <bsd/unistd.h>
|
||||
#endif
|
||||
|
51
include/bsd/grp.h
Normal file
51
include/bsd/grp.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright © 2021 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#if __has_include_next(<grp.h>)
|
||||
#include_next <grp.h>
|
||||
#endif
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<grp.h>)
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_GRP_H
|
||||
#define LIBBSD_GRP_H
|
||||
|
||||
#define _GR_BUF_LEN (1024 + 200 * sizeof(char *))
|
||||
|
||||
__BEGIN_DECLS
|
||||
int
|
||||
gid_from_group(const char *, gid_t *);
|
||||
const char *
|
||||
group_from_gid(gid_t, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
49
include/bsd/inttypes.h
Normal file
49
include/bsd/inttypes.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright © 2018 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include_next <inttypes.h>
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_INTTYPES_H
|
||||
#define LIBBSD_INTTYPES_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
intmax_t strtoi(const char *__restrict nptr, char **__restrict endptr,
|
||||
int base, intmax_t lo, intmax_t hi, int *rstatus);
|
||||
uintmax_t strtou(const char *__restrict nptr, char **__restrict endptr,
|
||||
int base, uintmax_t lo, uintmax_t hi, int *rstatus);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
@@ -36,25 +36,55 @@
|
||||
* $FreeBSD: src/lib/libutil/libutil.h,v 1.47 2008/04/23 00:49:12 scf Exp $
|
||||
*/
|
||||
|
||||
#ifndef _LIBUTIL_H_
|
||||
#define _LIBUTIL_H_
|
||||
#ifndef LIBBSD_LIBUTIL_H
|
||||
#define LIBBSD_LIBUTIL_H
|
||||
|
||||
#include <features.h>
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct pidfh;
|
||||
|
||||
__BEGIN_DECLS
|
||||
int humanize_number(char *buf, size_t len, int64_t bytes,
|
||||
const char *suffix, int scale, int flags);
|
||||
int expand_number(const char *_buf, uint64_t *_num);
|
||||
|
||||
int flopen(const char *_path, int _flags, ...);
|
||||
int flopenat(int dirfd, const char *path, int flags, ...);
|
||||
|
||||
struct pidfh *pidfile_open(const char *path, mode_t mode, pid_t *pidptr);
|
||||
int pidfile_fileno(const struct pidfh *pfh);
|
||||
int pidfile_write(struct pidfh *pfh);
|
||||
int pidfile_close(struct pidfh *pfh);
|
||||
int pidfile_remove(struct pidfh *pfh);
|
||||
|
||||
char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
|
||||
__END_DECLS
|
||||
|
||||
/* humanize_number(3) */
|
||||
#define HN_DECIMAL 0x01
|
||||
#define HN_NOSPACE 0x02
|
||||
#define HN_B 0x04
|
||||
#define HN_DIVISOR_1000 0x08
|
||||
/* Values for humanize_number(3)'s flags parameter. */
|
||||
#define HN_DECIMAL 0x01
|
||||
#define HN_NOSPACE 0x02
|
||||
#define HN_B 0x04
|
||||
#define HN_DIVISOR_1000 0x08
|
||||
#define HN_IEC_PREFIXES 0x10
|
||||
|
||||
#define HN_GETSCALE 0x10
|
||||
#define HN_AUTOSCALE 0x20
|
||||
/* Values for humanize_number(3)'s scale parameter. */
|
||||
#define HN_GETSCALE 0x10
|
||||
#define HN_AUTOSCALE 0x20
|
||||
|
||||
#endif /* !_LIBUTIL_H_ */
|
||||
/*
|
||||
* fparseln() specific operation flags.
|
||||
*/
|
||||
#define FPARSELN_UNESCESC 0x01
|
||||
#define FPARSELN_UNESCCONT 0x02
|
||||
#define FPARSELN_UNESCCOMM 0x04
|
||||
#define FPARSELN_UNESCREST 0x08
|
||||
#define FPARSELN_UNESCALL 0x0f
|
||||
|
||||
#endif /* !LIBBSD_LIBUTIL_H */
|
@@ -1,51 +1,31 @@
|
||||
/* $OpenBSD: md5.h,v 1.16 2004/06/22 01:57:30 jfb Exp $ */
|
||||
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
* Copyright © 2021 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _MD5_H_
|
||||
#define _MD5_H_
|
||||
|
||||
#define MD5_BLOCK_LENGTH 64
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
|
||||
|
||||
typedef struct MD5Context {
|
||||
u_int32_t state[4]; /* state */
|
||||
u_int64_t count; /* number of bits, mod 2^64 */
|
||||
u_int8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */
|
||||
} MD5_CTX;
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
void MD5Init(MD5_CTX *);
|
||||
void MD5Update(MD5_CTX *, const u_int8_t *, size_t)
|
||||
__attribute__((__bounded__(__string__,2,3)));
|
||||
void MD5Pad(MD5_CTX *);
|
||||
void MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *)
|
||||
__attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH)));
|
||||
void MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH])
|
||||
__attribute__((__bounded__(__minbytes__,1,4)))
|
||||
__attribute__((__bounded__(__minbytes__,2,MD5_BLOCK_LENGTH)));
|
||||
char *MD5End(MD5_CTX *, char *)
|
||||
__attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH)));
|
||||
char *MD5File(const char *, char *)
|
||||
__attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH)));
|
||||
char *MD5FileChunk(const char *, char *, off_t, off_t)
|
||||
__attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH)));
|
||||
char *MD5Data(const u_int8_t *, size_t, char *)
|
||||
__attribute__((__bounded__(__string__,1,2)))
|
||||
__attribute__((__bounded__(__minbytes__,3,MD5_DIGEST_STRING_LENGTH)));
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _MD5_H_ */
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include_next <md5.h>
|
||||
#else
|
||||
#include <md5.h>
|
||||
#endif
|
||||
|
@@ -30,10 +30,10 @@
|
||||
* $FreeBSD: src/sys/netinet/ip_icmp.h,v 1.22 2004/04/07 20:46:13 imp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_IP_ICMP_H_
|
||||
#define _NETINET_IP_ICMP_H_
|
||||
#ifndef LIBBSD_NETINET_IP_ICMP_H
|
||||
#define LIBBSD_NETINET_IP_ICMP_H
|
||||
|
||||
#include <sys/types.h> /* u_int32_t, u_char */
|
||||
#include <sys/types.h> /* uint32_t */
|
||||
#include <netinet/in.h> /* in_addr */
|
||||
#include <netinet/in_systm.h> /* n_short */
|
||||
#include <netinet/ip.h> /* idi_ip */
|
||||
@@ -47,19 +47,19 @@
|
||||
* Internal of an ICMP Router Advertisement
|
||||
*/
|
||||
struct icmp_ra_addr {
|
||||
u_int32_t ira_addr;
|
||||
u_int32_t ira_preference;
|
||||
uint32_t ira_addr;
|
||||
uint32_t ira_preference;
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure of an icmp header.
|
||||
*/
|
||||
struct icmp {
|
||||
u_char icmp_type; /* type of message, see below */
|
||||
u_char icmp_code; /* type sub code */
|
||||
u_short icmp_cksum; /* ones complement cksum of struct */
|
||||
unsigned char icmp_type; /* type of message, see below */
|
||||
unsigned char icmp_code; /* type sub code */
|
||||
unsigned short icmp_cksum; /* ones complement cksum of struct */
|
||||
union {
|
||||
u_char ih_pptr; /* ICMP_PARAMPROB */
|
||||
unsigned char ih_pptr; /* ICMP_PARAMPROB */
|
||||
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
|
||||
struct ih_idseq {
|
||||
n_short icd_id;
|
||||
@@ -74,9 +74,9 @@ struct icmp {
|
||||
} ih_pmtu;
|
||||
|
||||
struct ih_rtradv {
|
||||
u_char irt_num_addrs;
|
||||
u_char irt_wpa;
|
||||
u_int16_t irt_lifetime;
|
||||
unsigned char irt_num_addrs;
|
||||
unsigned char irt_wpa;
|
||||
uint16_t irt_lifetime;
|
||||
} ih_rtradv;
|
||||
} icmp_hun;
|
||||
#define icmp_pptr icmp_hun.ih_pptr
|
||||
@@ -100,7 +100,7 @@ struct icmp {
|
||||
/* options and then 64 bits of data */
|
||||
} id_ip;
|
||||
struct icmp_ra_addr id_radv;
|
||||
u_int32_t id_mask;
|
||||
uint32_t id_mask;
|
||||
char id_data[1];
|
||||
} icmp_dun;
|
||||
#define icmp_otime icmp_dun.id_ts.its_otime
|
102
include/bsd/nlist.h
Normal file
102
include/bsd/nlist.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright © 2009 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_NLIST_H
|
||||
#define LIBBSD_NLIST_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
struct nlist {
|
||||
union {
|
||||
char *n_name;
|
||||
union {
|
||||
char *n_name;
|
||||
struct n_list *n_next;
|
||||
long n_strx;
|
||||
} n_un;
|
||||
};
|
||||
unsigned char n_type;
|
||||
char n_other;
|
||||
short n_desc;
|
||||
unsigned long n_value;
|
||||
};
|
||||
|
||||
#define n_hash n_desc /* used internally by ld(1); XXX */
|
||||
|
||||
/*
|
||||
* Defines for n_type.
|
||||
*/
|
||||
#define N_UNDF 0x00 /* Undefined */
|
||||
#define N_ABS 0x02 /* Absolute address */
|
||||
#define N_TEXT 0x04 /* Text segment */
|
||||
#define N_DATA 0x06 /* Data segment */
|
||||
#define N_BSS 0x08 /* Bss segment */
|
||||
#define N_INDR 0x0a /* Alias definition */
|
||||
#define N_SIZE 0x0c /* Pseudo type, defines a symbol's size */
|
||||
#define N_COMM 0x12 /* Common reference */
|
||||
/* GNU extensions */
|
||||
#define N_SETA 0x14 /* Absolute set element symbol */
|
||||
#define N_SETT 0x16 /* Text set element symbol */
|
||||
#define N_SETD 0x18 /* Data set element symbol */
|
||||
#define N_SETB 0x1a /* Bss set element symbol */
|
||||
#define N_SETV 0x1c /* Set vector symbol */
|
||||
/* end GNU extensions */
|
||||
#define N_FN 0x1e /* File name (N_EXT on) */
|
||||
#define N_WARN 0x1e /* Warning message (N_EXT off) */
|
||||
|
||||
#define N_EXT 0x01 /* External (global) bit, OR'ed in */
|
||||
#define N_TYPE 0x1e /* Mask for all the type bits */
|
||||
#define N_STAB 0xe0 /* Mask for debugger symbols -- stab(5) */
|
||||
|
||||
#define N_NAME(p) ((p)->n_un.n_name)
|
||||
|
||||
/*
|
||||
* Defines for n_other. It contains the ".type" (AUX) field in the least
|
||||
* significant 4 bits, and the binding (for weak symbols) in the most
|
||||
* significant 4 bits.
|
||||
*/
|
||||
#define N_AUX(p) ((p)->n_other & 0xf)
|
||||
#define N_BIND(p) (((unsigned int)(p)->n_other >> 4) & 0xf)
|
||||
#define N_OTHER(r, v) (((unsigned int)(r) << 4) | ((v) & 0xf))
|
||||
|
||||
#define AUX_OBJECT 1 /* Data object */
|
||||
#define AUX_FUNC 2 /* Function */
|
||||
|
||||
/*#define BIND_LOCAL 0 Not used */
|
||||
/*#define BIND_GLOBAL 1 Not used */
|
||||
#define BIND_WEAK 2 /* Weak binding */
|
||||
|
||||
#define N_FORMAT "%08x" /* namelist value format; XXX */
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern int nlist(const char *filename, struct nlist *list);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
51
include/bsd/pwd.h
Normal file
51
include/bsd/pwd.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright © 2021 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#if __has_include_next(<pwd.h>)
|
||||
#include_next <pwd.h>
|
||||
#endif
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<pwd.h>)
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_PWD_H
|
||||
#define LIBBSD_PWD_H
|
||||
|
||||
#define _PW_BUF_LEN 1024 /* length of getpw*_r buffer */
|
||||
|
||||
__BEGIN_DECLS
|
||||
int
|
||||
uid_from_user(const char *, uid_t *);
|
||||
const char *
|
||||
user_from_uid(uid_t, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
45
include/bsd/readpassphrase.h
Normal file
45
include/bsd/readpassphrase.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* $OpenBSD: readpassphrase.h,v 1.4 2003/06/03 01:52:39 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Sponsored in part by the Defense Advanced Research Projects
|
||||
* Agency (DARPA) and Air Force Research Laboratory, Air Force
|
||||
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_READPASSPHRASE_H
|
||||
#define LIBBSD_READPASSPHRASE_H
|
||||
|
||||
#define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */
|
||||
#define RPP_ECHO_ON 0x01 /* Leave echo on. */
|
||||
#define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */
|
||||
#define RPP_FORCELOWER 0x04 /* Force input to lower case. */
|
||||
#define RPP_FORCEUPPER 0x08 /* Force input to upper case. */
|
||||
#define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */
|
||||
#define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
char * readpassphrase(const char *, char *, size_t, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !LIBBSD_READPASSPHRASE_H */
|
80
include/bsd/stdio.h
Normal file
80
include/bsd/stdio.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright © 2004-2005, 2009, 2011-2013 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(__need_FILE) || defined(__need___FILE)
|
||||
#define LIBBSD_STDIO_H_SKIP
|
||||
#endif
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include_next <stdio.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_STDIO_H_SKIP
|
||||
#ifndef LIBBSD_STDIO_H
|
||||
#define LIBBSD_STDIO_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
const char *fmtcheck(const char *, const char *);
|
||||
|
||||
/* XXX: The function requires cooperation from the system libc to store the
|
||||
* line buffer in the FILE struct itself. */
|
||||
char *fgetln(FILE *fp, size_t *lenp)
|
||||
LIBBSD_DEPRECATED("This functions cannot be safely ported, "
|
||||
"use getline(3) instead, as it is supported "
|
||||
"by GNU and POSIX.1-2008.");
|
||||
|
||||
/*
|
||||
* Note: We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations,
|
||||
* because seekfn() there wrongly uses fpos_t, assuming it's an integral
|
||||
* type, and any code using that on a system where fpos_t is a struct
|
||||
* (such as GNU-based systems or NetBSD) will fail to build. In which case,
|
||||
* as the code has to be modified anyway, we might just as well use the
|
||||
* correct declaration here.
|
||||
*/
|
||||
FILE *funopen(const void *cookie,
|
||||
int (*readfn)(void *cookie, char *buf, int size),
|
||||
int (*writefn)(void *cookie, const char *buf, int size),
|
||||
off_t (*seekfn)(void *cookie, off_t offset, int whence),
|
||||
int (*closefn)(void *cookie));
|
||||
|
||||
#define fropen(cookie, fn) funopen(cookie, fn, NULL, NULL, NULL)
|
||||
#define fwopen(cookie, fn) funopen(cookie, NULL, fn, NULL, NULL)
|
||||
|
||||
int fpurge(FILE *fp);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#undef LIBBSD_STDIO_H_SKIP
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Aurelien Jarno
|
||||
* Copyright (C) 2006 Robert Millan
|
||||
* Copyright (C) 2008 Guillem Jover
|
||||
* Copyright © 2005 Aurelien Jarno
|
||||
* Copyright © 2006 Robert Millan
|
||||
* Copyright © 2008-2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -26,24 +26,62 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include_next <stdlib.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* For compatibility with NetBSD, which defines humanize_number here. */
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <libutil.h>
|
||||
#else
|
||||
#include <bsd/libutil.h>
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_STDLIB_H
|
||||
#define LIBBSD_STDLIB_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
const char *fmtcheck (const char *, const char *);
|
||||
__BEGIN_DECLS
|
||||
uint32_t arc4random(void);
|
||||
void arc4random_stir(void);
|
||||
void arc4random_addrandom(unsigned char *dat, int datlen);
|
||||
void arc4random_buf(void *_buf, size_t n);
|
||||
uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||
|
||||
char *getprogname ();
|
||||
void setprogname (char *);
|
||||
int dehumanize_number(const char *str, int64_t *size);
|
||||
|
||||
int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
const char *getprogname(void);
|
||||
void setprogname(const char *);
|
||||
|
||||
#ifndef S_ISTXT
|
||||
#define S_ISTXT S_ISVTX
|
||||
int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
int mergesort(void *base, size_t nmemb, size_t size,
|
||||
int (*cmp)(const void *, const void *));
|
||||
int radixsort(const unsigned char **base, int nmemb,
|
||||
const unsigned char *table, unsigned endbyte);
|
||||
int sradixsort(const unsigned char **base, int nmemb,
|
||||
const unsigned char *table, unsigned endbyte);
|
||||
|
||||
void *reallocf(void *ptr, size_t size);
|
||||
#if !defined(__GLIBC__) || \
|
||||
(defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 26) || !defined(_GNU_SOURCE)))
|
||||
void *reallocarray(void *ptr, size_t nmemb, size_t size);
|
||||
#endif
|
||||
void *recallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size);
|
||||
void freezero(void *ptr, size_t size);
|
||||
|
||||
mode_t getmode(const void *set, mode_t mode);
|
||||
void *setmode(const char *mode_str);
|
||||
long long strtonum(const char *nptr, long long minval, long long maxval,
|
||||
const char **errstr);
|
||||
|
||||
char *getbsize(int *headerlenp, long *blocksizep);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005 Guillem Jover
|
||||
* Copyright © 2004, 2005, 2009, 2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -24,16 +24,32 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include_next <string.h>
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_STRING_H
|
||||
#define LIBBSD_STRING_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||
size_t strlcat(char *dst, const char *src, size_t siz);
|
||||
char *fgetln(FILE *fp, size_t *lenp);
|
||||
wchar_t *fgetwln(FILE * __restrict fp, size_t *lenp);
|
||||
char *strnstr(const char *str, const char *find, size_t str_len);
|
||||
void strmode(mode_t mode, char *str);
|
||||
|
||||
#if !defined(__GLIBC__) || \
|
||||
(defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE)))
|
||||
void explicit_bzero(void *buf, size_t len);
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
59
include/bsd/stringlist.h
Normal file
59
include/bsd/stringlist.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* $NetBSD: stringlist.h,v 1.6 2006/07/27 15:37:19 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_STRINGLIST_H
|
||||
#define LIBBSD_STRINGLIST_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Simple string list
|
||||
*/
|
||||
typedef struct _stringlist {
|
||||
char **sl_str;
|
||||
size_t sl_max;
|
||||
size_t sl_cur;
|
||||
} StringList;
|
||||
|
||||
__BEGIN_DECLS
|
||||
StringList *sl_init(void);
|
||||
int sl_add(StringList *, char *);
|
||||
void sl_free(StringList *, int);
|
||||
char *sl_find(StringList *, const char *);
|
||||
int sl_delete(StringList *, const char *, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* LIBBSD_STRINGLIST_H */
|
146
include/bsd/sys/bitstring.h
Normal file
146
include/bsd/sys/bitstring.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/*-
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Paul Vixie.
|
||||
*
|
||||
* 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.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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$
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_SYS_BITSTRING_H
|
||||
#define LIBBSD_SYS_BITSTRING_H
|
||||
|
||||
typedef unsigned char bitstr_t;
|
||||
|
||||
/* internal macros */
|
||||
/* byte of the bitstring bit is in */
|
||||
#define _bit_byte(bit) \
|
||||
((bit) >> 3)
|
||||
|
||||
/* mask for the bit within its byte */
|
||||
#define _bit_mask(bit) \
|
||||
(1 << ((bit)&0x7))
|
||||
|
||||
/* external macros */
|
||||
/* bytes in a bitstring of nbits bits */
|
||||
#define bitstr_size(nbits) \
|
||||
(((nbits) + 7) >> 3)
|
||||
|
||||
/* allocate a bitstring */
|
||||
#define bit_alloc(nbits) \
|
||||
(bitstr_t *)calloc((size_t)bitstr_size(nbits), sizeof(bitstr_t))
|
||||
|
||||
/* allocate a bitstring on the stack */
|
||||
#define bit_decl(name, nbits) \
|
||||
((name)[bitstr_size(nbits)])
|
||||
|
||||
/* is bit N of bitstring name set? */
|
||||
#define bit_test(name, bit) \
|
||||
((name)[_bit_byte(bit)] & _bit_mask(bit))
|
||||
|
||||
/* set bit N of bitstring name */
|
||||
#define bit_set(name, bit) \
|
||||
((name)[_bit_byte(bit)] |= _bit_mask(bit))
|
||||
|
||||
/* clear bit N of bitstring name */
|
||||
#define bit_clear(name, bit) \
|
||||
((name)[_bit_byte(bit)] &= ~_bit_mask(bit))
|
||||
|
||||
/* clear bits start ... stop in bitstring */
|
||||
#define bit_nclear(name, start, stop) do { \
|
||||
register bitstr_t *_name = (name); \
|
||||
register int _start = (start), _stop = (stop); \
|
||||
register int _startbyte = _bit_byte(_start); \
|
||||
register int _stopbyte = _bit_byte(_stop); \
|
||||
if (_startbyte == _stopbyte) { \
|
||||
_name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
|
||||
(0xff << ((_stop&0x7) + 1))); \
|
||||
} else { \
|
||||
_name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
|
||||
while (++_startbyte < _stopbyte) \
|
||||
_name[_startbyte] = 0; \
|
||||
_name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* set bits start ... stop in bitstring */
|
||||
#define bit_nset(name, start, stop) do { \
|
||||
register bitstr_t *_name = (name); \
|
||||
register int _start = (start), _stop = (stop); \
|
||||
register int _startbyte = _bit_byte(_start); \
|
||||
register int _stopbyte = _bit_byte(_stop); \
|
||||
if (_startbyte == _stopbyte) { \
|
||||
_name[_startbyte] |= ((0xff << (_start&0x7)) & \
|
||||
(0xff >> (7 - (_stop&0x7)))); \
|
||||
} else { \
|
||||
_name[_startbyte] |= 0xff << ((_start)&0x7); \
|
||||
while (++_startbyte < _stopbyte) \
|
||||
_name[_startbyte] = 0xff; \
|
||||
_name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* find first bit clear in name */
|
||||
#define bit_ffc(name, nbits, value) do { \
|
||||
register bitstr_t *_name = (name); \
|
||||
register int _byte, _nbits = (nbits); \
|
||||
register int _stopbyte = _bit_byte(_nbits - 1), _value = -1; \
|
||||
if (_nbits > 0) \
|
||||
for (_byte = 0; _byte <= _stopbyte; ++_byte) \
|
||||
if (_name[_byte] != 0xff) { \
|
||||
bitstr_t _lb; \
|
||||
_value = _byte << 3; \
|
||||
for (_lb = _name[_byte]; (_lb&0x1); \
|
||||
++_value, _lb >>= 1); \
|
||||
break; \
|
||||
} \
|
||||
if (_value >= nbits) \
|
||||
_value = -1; \
|
||||
*(value) = _value; \
|
||||
} while (0)
|
||||
|
||||
/* find first bit set in name */
|
||||
#define bit_ffs(name, nbits, value) do { \
|
||||
register bitstr_t *_name = (name); \
|
||||
register int _byte, _nbits = (nbits); \
|
||||
register int _stopbyte = _bit_byte(_nbits - 1), _value = -1; \
|
||||
if (_nbits > 0) \
|
||||
for (_byte = 0; _byte <= _stopbyte; ++_byte) \
|
||||
if (_name[_byte]) { \
|
||||
bitstr_t _lb; \
|
||||
_value = _byte << 3; \
|
||||
for (_lb = _name[_byte]; !(_lb&0x1); \
|
||||
++_value, _lb >>= 1); \
|
||||
break; \
|
||||
} \
|
||||
if (_value >= nbits) \
|
||||
_value = -1; \
|
||||
*(value) = _value; \
|
||||
} while (0)
|
||||
|
||||
#endif /* !LIBBSD_SYS_BITSTRING_H */
|
257
include/bsd/sys/cdefs.h
Normal file
257
include/bsd/sys/cdefs.h
Normal file
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright © 2004-2006, 2009-2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(x) 1
|
||||
#endif
|
||||
#ifndef __has_include_next
|
||||
#define __has_include_next(x) 1
|
||||
#endif
|
||||
#ifndef __has_attribute
|
||||
#define __has_attribute(x) 0
|
||||
#endif
|
||||
/* Clang expands this to 1 if an identifier is *not* reserved. */
|
||||
#ifndef __is_identifier
|
||||
#define __is_identifier(x) 1
|
||||
#endif
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
/*
|
||||
* Some libc implementations do not have a <sys/cdefs.h>, in particular
|
||||
* musl, try to handle this gracefully.
|
||||
*/
|
||||
#if __has_include_next(<sys/cdefs.h>)
|
||||
#include_next <sys/cdefs.h>
|
||||
#endif
|
||||
#else
|
||||
#if __has_include(<sys/cdefs.h>)
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_SYS_CDEFS_H
|
||||
#define LIBBSD_SYS_CDEFS_H
|
||||
|
||||
#ifndef __BEGIN_DECLS
|
||||
#ifdef __cplusplus
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* On non-glibc based systems, we cannot unconditionally use the
|
||||
* __GLIBC_PREREQ macro as it gets expanded before evaluation.
|
||||
*/
|
||||
#ifndef __GLIBC_PREREQ
|
||||
#define __GLIBC_PREREQ(maj, min) 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some kFreeBSD headers expect those macros to be set for sanity checks.
|
||||
*/
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#define _SYS_CDEFS_H_
|
||||
#endif
|
||||
#ifndef _SYS_CDEFS_H
|
||||
#define _SYS_CDEFS_H
|
||||
#endif
|
||||
|
||||
#define LIBBSD_CONCAT(x, y) x ## y
|
||||
#define LIBBSD_STRING(x) #x
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define LIBBSD_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__)
|
||||
#else
|
||||
#define LIBBSD_GCC_VERSION 0
|
||||
#endif
|
||||
|
||||
#if LIBBSD_GCC_VERSION >= 0x0405 || __has_attribute(__deprecated__)
|
||||
#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x)))
|
||||
#elif LIBBSD_GCC_VERSION >= 0x0301
|
||||
#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__))
|
||||
#else
|
||||
#define LIBBSD_DEPRECATED(x)
|
||||
#endif
|
||||
|
||||
#if LIBBSD_GCC_VERSION >= 0x0200 || defined(__clang__)
|
||||
#define LIBBSD_REDIRECT(name, proto, alias) name proto __asm__(LIBBSD_ASMNAME(#alias))
|
||||
#endif
|
||||
#define LIBBSD_ASMNAME(cname) LIBBSD_ASMNAME_PREFIX(__USER_LABEL_PREFIX__, cname)
|
||||
#define LIBBSD_ASMNAME_PREFIX(prefix, cname) LIBBSD_STRING(prefix) cname
|
||||
|
||||
#ifndef __dead2
|
||||
# if LIBBSD_GCC_VERSION >= 0x0207 || __has_attribute(__noreturn__)
|
||||
# define __dead2 __attribute__((__noreturn__))
|
||||
# else
|
||||
# define __dead2
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __pure2
|
||||
# if LIBBSD_GCC_VERSION >= 0x0207 || __has_attribute(__const__)
|
||||
# define __pure2 __attribute__((__const__))
|
||||
# else
|
||||
# define __pure2
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __packed
|
||||
# if LIBBSD_GCC_VERSION >= 0x0207 || __has_attribute(__packed__)
|
||||
# define __packed __attribute__((__packed__))
|
||||
# else
|
||||
# define __packed
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __aligned
|
||||
# if LIBBSD_GCC_VERSION >= 0x0207 || __has_attribute(__aligned__)
|
||||
# define __aligned(x) __attribute__((__aligned__(x)))
|
||||
# else
|
||||
# define __aligned(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Linux headers define a struct with a member names __unused.
|
||||
* Debian bugs: #522773 (linux), #522774 (libc).
|
||||
* Disable for now. */
|
||||
#if 0
|
||||
#ifndef __unused
|
||||
# if LIBBSD_GCC_VERSION >= 0x0300
|
||||
# define __unused __attribute__((__unused__))
|
||||
# else
|
||||
# define __unused
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __printflike
|
||||
# if LIBBSD_GCC_VERSION >= 0x0300 || __has_attribute(__format__)
|
||||
# define __printflike(x, y) __attribute((__format__(__printf__, (x), (y))))
|
||||
# else
|
||||
# define __printflike(x, y)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __nonnull
|
||||
# if LIBBSD_GCC_VERSION >= 0x0302 || __has_attribute(__nonnull__)
|
||||
# define __nonnull(x) __attribute__((__nonnull__(x)))
|
||||
# else
|
||||
# define __nonnull(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __bounded__
|
||||
# define __bounded__(x, y, z)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Return the number of elements in a statically-allocated array,
|
||||
* __x.
|
||||
*/
|
||||
#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
|
||||
|
||||
/*
|
||||
* We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
|
||||
* require it.
|
||||
*/
|
||||
#ifndef __offsetof
|
||||
# if LIBBSD_GCC_VERSION >= 0x0401 || !__is_identifier(__builtin_offsetof)
|
||||
# define __offsetof(type, field) __builtin_offsetof(type, field)
|
||||
# else
|
||||
# ifndef __cplusplus
|
||||
# define __offsetof(type, field) \
|
||||
((size_t)(uintptr_t)((const volatile void *)&((type *)0)->field))
|
||||
# else
|
||||
# define __offsetof(type, field) \
|
||||
(__offsetof__ (reinterpret_cast <size_t> \
|
||||
(&reinterpret_cast <const volatile char &> \
|
||||
(static_cast<type *> (0)->field))))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define __rangeof(type, start, end) \
|
||||
(__offsetof(type, end) - __offsetof(type, start))
|
||||
|
||||
/*
|
||||
* Given the pointer x to the member m of the struct s, return
|
||||
* a pointer to the containing structure. When using GCC, we first
|
||||
* assign pointer x to a local variable, to check that its type is
|
||||
* compatible with member m.
|
||||
*/
|
||||
#ifndef __containerof
|
||||
# if LIBBSD_GCC_VERSION >= 0x0301 || !__is_identifier(__typeof__)
|
||||
# define __containerof(x, s, m) ({ \
|
||||
const volatile __typeof__(((s *)0)->m) *__x = (x); \
|
||||
__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m)); \
|
||||
})
|
||||
# else
|
||||
# define __containerof(x, s, m) \
|
||||
__DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __RCSID
|
||||
# define __RCSID(x)
|
||||
#endif
|
||||
|
||||
#ifndef __FBSDID
|
||||
# define __FBSDID(x)
|
||||
#endif
|
||||
|
||||
#ifndef __RCSID
|
||||
# define __RCSID(x)
|
||||
#endif
|
||||
|
||||
#ifndef __RCSID_SOURCE
|
||||
# define __RCSID_SOURCE(x)
|
||||
#endif
|
||||
|
||||
#ifndef __SCCSID
|
||||
# define __SCCSID(x)
|
||||
#endif
|
||||
|
||||
#ifndef __COPYRIGHT
|
||||
# define __COPYRIGHT(x)
|
||||
#endif
|
||||
|
||||
#ifndef __DECONST
|
||||
#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
|
||||
#endif
|
||||
|
||||
#ifndef __DEVOLATILE
|
||||
#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
|
||||
#endif
|
||||
|
||||
#ifndef __DEQUALIFY
|
||||
#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
|
||||
#endif
|
||||
|
||||
#endif
|
170
include/bsd/sys/endian.h
Normal file
170
include/bsd/sys/endian.h
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright © 2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Copyright © 2002 Thomas Moestl <tmm@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#if __has_include_next(<endian.h>)
|
||||
#include_next <endian.h>
|
||||
#endif
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<endian.h>)
|
||||
#include <endian.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_SYS_ENDIAN_H
|
||||
#define LIBBSD_SYS_ENDIAN_H
|
||||
|
||||
#ifndef _BYTE_ORDER
|
||||
#define _BYTE_ORDER __BYTE_ORDER
|
||||
#endif
|
||||
|
||||
#ifndef _LITTLE_ENDIAN
|
||||
#define _LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifndef _BIG_ENDIAN
|
||||
#define _BIG_ENDIAN __BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifndef _PDP_ENDIAN
|
||||
#define _PDP_ENDIAN __PDP_ENDIAN
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
|
||||
|
||||
static __inline uint16_t
|
||||
be16dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return ((p[0] << 8) | p[1]);
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
be32dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||
}
|
||||
|
||||
static __inline uint64_t
|
||||
be64dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
|
||||
}
|
||||
|
||||
static __inline uint16_t
|
||||
le16dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return ((p[1] << 8) | p[0]);
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
le32dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
|
||||
}
|
||||
|
||||
static __inline uint64_t
|
||||
le64dec(const void *pp)
|
||||
{
|
||||
uint8_t const *p = (uint8_t const *)pp;
|
||||
|
||||
return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
be16enc(void *pp, uint16_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = (u >> 8) & 0xff;
|
||||
p[1] = u & 0xff;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
be32enc(void *pp, uint32_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = (u >> 24) & 0xff;
|
||||
p[1] = (u >> 16) & 0xff;
|
||||
p[2] = (u >> 8) & 0xff;
|
||||
p[3] = u & 0xff;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
be64enc(void *pp, uint64_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
be32enc(p, (uint32_t)(u >> 32));
|
||||
be32enc(p + 4, (uint32_t)(u & 0xffffffffU));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
le16enc(void *pp, uint16_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = u & 0xff;
|
||||
p[1] = (u >> 8) & 0xff;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
le32enc(void *pp, uint32_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
p[0] = u & 0xff;
|
||||
p[1] = (u >> 8) & 0xff;
|
||||
p[2] = (u >> 16) & 0xff;
|
||||
p[3] = (u >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
le64enc(void *pp, uint64_t u)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
||||
le32enc(p, (uint32_t)(u & 0xffffffffU));
|
||||
le32enc(p + 4, (uint32_t)(u >> 32));
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2006 Guillem Jover
|
||||
* Copyright © 2018 Facebook, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -24,45 +24,26 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_CDEFS_H
|
||||
#define LIBBSD_CDEFS_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifndef setproctitle
|
||||
# define setproctitle(fmt, args...)
|
||||
#if __has_include_next(<sys/param.h>)
|
||||
#include_next <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifndef __dead2
|
||||
# define __dead2
|
||||
#endif
|
||||
|
||||
/* Linux headers define a struct with a member names __unused.
|
||||
* Disable for now. */
|
||||
#if 0
|
||||
#ifndef __unused
|
||||
# ifdef __GNUC__
|
||||
# define __unused __attribute__((unused))
|
||||
# else
|
||||
# define __unused
|
||||
# endif
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<sys/param.h>)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __printflike
|
||||
# ifdef __GNUC__
|
||||
# define __printflike(x, y) __attribute((format(printf, (x), (y))))
|
||||
# else
|
||||
# define __printflike(x, y)
|
||||
# endif
|
||||
#endif
|
||||
#ifndef LIBBSD_SYS_PARAM_H
|
||||
#define LIBBSD_SYS_PARAM_H
|
||||
|
||||
#ifndef __bounded__
|
||||
# define __bounded__(x, y, z)
|
||||
#ifndef MIN
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef __FBSDID
|
||||
# define __FBSDID(x)
|
||||
#ifndef MAX
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#endif
|
40
include/bsd/sys/poll.h
Normal file
40
include/bsd/sys/poll.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright © 2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include_next <sys/poll.h>
|
||||
#else
|
||||
#include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_SYS_POLL_H
|
||||
#define LIBBSD_SYS_POLL_H
|
||||
|
||||
#ifndef INFTIM
|
||||
#define INFTIM (-1)
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
@@ -27,13 +29,17 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)queue.h 8.5 (Berkeley) 8/20/94
|
||||
* $FreeBSD: src/sys/sys/queue.h,v 1.58 2004/04/07 04:19:49 imp Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _SYS_QUEUE_H
|
||||
#define _SYS_QUEUE_H
|
||||
#ifndef LIBBSD_SYS_QUEUE_H
|
||||
#define LIBBSD_SYS_QUEUE_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This file defines four types of data structures: singly-linked lists,
|
||||
@@ -65,7 +71,7 @@
|
||||
* so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before
|
||||
* or after an existing element or at the head of the list. A list
|
||||
* may only be traversed in the forward direction.
|
||||
* may be traversed in either direction.
|
||||
*
|
||||
* A tail queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
@@ -76,42 +82,61 @@
|
||||
*
|
||||
* For details on the use of these macros, see the queue(3) manual page.
|
||||
*
|
||||
* Below is a summary of implemented functions where:
|
||||
* + means the macro is available
|
||||
* - means the macro is not available
|
||||
* s means the macro is available but is slow (runs in O(n) time)
|
||||
*
|
||||
* SLIST LIST STAILQ TAILQ
|
||||
* _HEAD + + + +
|
||||
* _CLASS_HEAD + + + +
|
||||
* _HEAD_INITIALIZER + + + +
|
||||
* _ENTRY + + + +
|
||||
* _CLASS_ENTRY + + + +
|
||||
* _INIT + + + +
|
||||
* _EMPTY + + + +
|
||||
* _END + + + +
|
||||
* _FIRST + + + +
|
||||
* _NEXT + + + +
|
||||
* _PREV - - - +
|
||||
* _PREV - + - +
|
||||
* _LAST - - + +
|
||||
* _LAST_FAST - - - +
|
||||
* _FOREACH + + + +
|
||||
* _FOREACH_FROM + + + +
|
||||
* _FOREACH_SAFE + + + +
|
||||
* _FOREACH_FROM_SAFE + + + +
|
||||
* _FOREACH_REVERSE - - - +
|
||||
* _FOREACH_REVERSE_FROM - - - +
|
||||
* _FOREACH_REVERSE_SAFE - - - +
|
||||
* _FOREACH_REVERSE_FROM_SAFE - - - +
|
||||
* _INSERT_HEAD + + + +
|
||||
* _INSERT_BEFORE - + - +
|
||||
* _INSERT_AFTER + + + +
|
||||
* _INSERT_TAIL - - + +
|
||||
* _CONCAT - - + +
|
||||
* _CONCAT s s + +
|
||||
* _REMOVE_AFTER + - + -
|
||||
* _REMOVE_HEAD + - + -
|
||||
* _REMOVE + + + +
|
||||
* _REMOVE s + s +
|
||||
* _SWAP + + + +
|
||||
*
|
||||
*/
|
||||
#define QUEUE_MACRO_DEBUG 0
|
||||
#if QUEUE_MACRO_DEBUG
|
||||
#ifdef QUEUE_MACRO_DEBUG
|
||||
#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH
|
||||
#define QUEUE_MACRO_DEBUG_TRACE
|
||||
#define QUEUE_MACRO_DEBUG_TRASH
|
||||
#endif
|
||||
|
||||
#ifdef QUEUE_MACRO_DEBUG_TRACE
|
||||
/* Store the last 2 places the queue element or head was altered */
|
||||
struct qm_trace {
|
||||
char * lastfile;
|
||||
int lastline;
|
||||
char * prevfile;
|
||||
int prevline;
|
||||
unsigned long lastline;
|
||||
unsigned long prevline;
|
||||
const char *lastfile;
|
||||
const char *prevfile;
|
||||
};
|
||||
|
||||
#define TRACEBUF struct qm_trace trace;
|
||||
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
|
||||
#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
|
||||
|
||||
#define QMD_TRACE_HEAD(head) do { \
|
||||
(head)->trace.prevline = (head)->trace.lastline; \
|
||||
@@ -127,12 +152,31 @@ struct qm_trace {
|
||||
(elem)->trace.lastfile = __FILE__; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#else /* !QUEUE_MACRO_DEBUG_TRACE */
|
||||
#define QMD_TRACE_ELEM(elem)
|
||||
#define QMD_TRACE_HEAD(head)
|
||||
#define TRACEBUF
|
||||
#define TRACEBUF_INITIALIZER
|
||||
#endif /* QUEUE_MACRO_DEBUG_TRACE */
|
||||
|
||||
#ifdef QUEUE_MACRO_DEBUG_TRASH
|
||||
#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
|
||||
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
|
||||
#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1)
|
||||
#else /* !QUEUE_MACRO_DEBUG_TRASH */
|
||||
#define QMD_SAVELINK(name, link)
|
||||
#define TRASHIT(x)
|
||||
#endif /* QUEUE_MACRO_DEBUG */
|
||||
#define QMD_IS_TRASHED(x) 0
|
||||
#endif /* QUEUE_MACRO_DEBUG_TRASH */
|
||||
|
||||
#ifdef __cplusplus
|
||||
/*
|
||||
* In C++ there can be structure lists and class lists:
|
||||
*/
|
||||
#define QUEUE_TYPEOF(type) type
|
||||
#else
|
||||
#define QUEUE_TYPEOF(type) struct type
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Singly-linked List declarations.
|
||||
@@ -142,6 +186,11 @@ struct name { \
|
||||
struct type *slh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define SLIST_CLASS_HEAD(name, type) \
|
||||
struct name { \
|
||||
class type *slh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define SLIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
@@ -150,9 +199,37 @@ struct { \
|
||||
struct type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
#define SLIST_CLASS_ENTRY(type) \
|
||||
struct { \
|
||||
class type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#if (defined(_KERNEL) && defined(INVARIANTS))
|
||||
#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) do { \
|
||||
if (*(prevp) != (elm)) \
|
||||
panic("Bad prevptr *(%p) == %p != %p", \
|
||||
(prevp), *(prevp), (elm)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define QMD_SLIST_CHECK_PREVPTR(prevp, elm)
|
||||
#endif
|
||||
|
||||
#define SLIST_CONCAT(head1, head2, type, field) do { \
|
||||
QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \
|
||||
if (curelm == NULL) { \
|
||||
if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \
|
||||
SLIST_INIT(head2); \
|
||||
} else if (SLIST_FIRST(head2) != NULL) { \
|
||||
while (SLIST_NEXT(curelm, field) != NULL) \
|
||||
curelm = SLIST_NEXT(curelm, field); \
|
||||
SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \
|
||||
SLIST_INIT(head2); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
|
||||
|
||||
#define SLIST_FIRST(head) ((head)->slh_first)
|
||||
@@ -162,11 +239,21 @@ struct { \
|
||||
(var); \
|
||||
(var) = SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_FOREACH_FROM(var, head, field) \
|
||||
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
|
||||
(var); \
|
||||
(var) = SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
||||
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
||||
for ((varp) = &SLIST_FIRST((head)); \
|
||||
((var) = *(varp)) != NULL; \
|
||||
@@ -189,22 +276,42 @@ struct { \
|
||||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.sle_next); \
|
||||
if (SLIST_FIRST((head)) == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = SLIST_FIRST((head)); \
|
||||
QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \
|
||||
while (SLIST_NEXT(curelm, field) != (elm)) \
|
||||
curelm = SLIST_NEXT(curelm, field); \
|
||||
SLIST_NEXT(curelm, field) = \
|
||||
SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
|
||||
SLIST_REMOVE_AFTER(curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_AFTER(elm, field) do { \
|
||||
SLIST_NEXT(elm, field) = \
|
||||
SLIST_NEXT(SLIST_NEXT(elm, field), field); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \
|
||||
QMD_SLIST_CHECK_PREVPTR(prevp, elm); \
|
||||
*(prevp) = SLIST_NEXT(elm, field); \
|
||||
TRASHIT((elm)->field.sle_next); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_SWAP(head1, head2, type) do { \
|
||||
QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \
|
||||
SLIST_FIRST(head1) = SLIST_FIRST(head2); \
|
||||
SLIST_FIRST(head2) = swap_first; \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_END(head) NULL
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue declarations.
|
||||
*/
|
||||
@@ -214,6 +321,12 @@ struct name { \
|
||||
struct type **stqh_last;/* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define STAILQ_CLASS_HEAD(name, type) \
|
||||
struct name { \
|
||||
class type *stqh_first; /* first element */ \
|
||||
class type **stqh_last; /* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define STAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).stqh_first }
|
||||
|
||||
@@ -222,6 +335,11 @@ struct { \
|
||||
struct type *stqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
#define STAILQ_CLASS_ENTRY(type) \
|
||||
struct { \
|
||||
class type *stqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue functions.
|
||||
*/
|
||||
@@ -242,12 +360,21 @@ struct { \
|
||||
(var); \
|
||||
(var) = STAILQ_NEXT((var), field))
|
||||
|
||||
#define STAILQ_FOREACH_FROM(var, head, field) \
|
||||
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
|
||||
(var); \
|
||||
(var) = STAILQ_NEXT((var), field))
|
||||
|
||||
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
||||
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define STAILQ_INIT(head) do { \
|
||||
STAILQ_FIRST((head)) = NULL; \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
@@ -271,26 +398,31 @@ struct { \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? \
|
||||
NULL : \
|
||||
((struct type *)(void *) \
|
||||
((char *)((head)->stqh_last) - __offsetof(struct type, field))))
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? NULL : \
|
||||
__containerof((head)->stqh_last, \
|
||||
QUEUE_TYPEOF(type), field.stqe_next))
|
||||
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
|
||||
#define STAILQ_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
|
||||
if (STAILQ_FIRST((head)) == (elm)) { \
|
||||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = STAILQ_FIRST((head)); \
|
||||
QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \
|
||||
while (STAILQ_NEXT(curelm, field) != (elm)) \
|
||||
curelm = STAILQ_NEXT(curelm, field); \
|
||||
if ((STAILQ_NEXT(curelm, field) = \
|
||||
STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
|
||||
(head)->stqh_last = &STAILQ_NEXT((curelm), field);\
|
||||
STAILQ_REMOVE_AFTER(head, curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
|
||||
if ((STAILQ_NEXT(elm, field) = \
|
||||
STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_HEAD(head, field) do { \
|
||||
@@ -299,11 +431,22 @@ struct { \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \
|
||||
if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
#define STAILQ_SWAP(head1, head2, type) do { \
|
||||
QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \
|
||||
QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \
|
||||
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_FIRST(head2) = swap_first; \
|
||||
(head2)->stqh_last = swap_last; \
|
||||
if (STAILQ_EMPTY(head1)) \
|
||||
(head1)->stqh_last = &STAILQ_FIRST(head1); \
|
||||
if (STAILQ_EMPTY(head2)) \
|
||||
(head2)->stqh_last = &STAILQ_FIRST(head2); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_END(head) NULL
|
||||
|
||||
|
||||
/*
|
||||
* List declarations.
|
||||
*/
|
||||
@@ -312,6 +455,11 @@ struct name { \
|
||||
struct type *lh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define LIST_CLASS_HEAD(name, type) \
|
||||
struct name { \
|
||||
class type *lh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define LIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
@@ -321,10 +469,75 @@ struct { \
|
||||
struct type **le_prev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
#define LIST_CLASS_ENTRY(type) \
|
||||
struct { \
|
||||
class type *le_next; /* next element */ \
|
||||
class type **le_prev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* List functions.
|
||||
*/
|
||||
|
||||
#if (defined(_KERNEL) && defined(INVARIANTS))
|
||||
/*
|
||||
* QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME)
|
||||
*
|
||||
* If the list is non-empty, validates that the first element of the list
|
||||
* points back at 'head.'
|
||||
*/
|
||||
#define QMD_LIST_CHECK_HEAD(head, field) do { \
|
||||
if (LIST_FIRST((head)) != NULL && \
|
||||
LIST_FIRST((head))->field.le_prev != \
|
||||
&LIST_FIRST((head))) \
|
||||
panic("Bad list head %p first->prev != head", (head)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME)
|
||||
*
|
||||
* If an element follows 'elm' in the list, validates that the next element
|
||||
* points back at 'elm.'
|
||||
*/
|
||||
#define QMD_LIST_CHECK_NEXT(elm, field) do { \
|
||||
if (LIST_NEXT((elm), field) != NULL && \
|
||||
LIST_NEXT((elm), field)->field.le_prev != \
|
||||
&((elm)->field.le_next)) \
|
||||
panic("Bad link elm %p next->prev != elm", (elm)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME)
|
||||
*
|
||||
* Validates that the previous element (or head of the list) points to 'elm.'
|
||||
*/
|
||||
#define QMD_LIST_CHECK_PREV(elm, field) do { \
|
||||
if (*(elm)->field.le_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (elm)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define QMD_LIST_CHECK_HEAD(head, field)
|
||||
#define QMD_LIST_CHECK_NEXT(elm, field)
|
||||
#define QMD_LIST_CHECK_PREV(elm, field)
|
||||
#endif /* (_KERNEL && INVARIANTS) */
|
||||
|
||||
#define LIST_CONCAT(head1, head2, type, field) do { \
|
||||
QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \
|
||||
if (curelm == NULL) { \
|
||||
if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \
|
||||
LIST_FIRST(head2)->field.le_prev = \
|
||||
&LIST_FIRST((head1)); \
|
||||
LIST_INIT(head2); \
|
||||
} \
|
||||
} else if (LIST_FIRST(head2) != NULL) { \
|
||||
while (LIST_NEXT(curelm, field) != NULL) \
|
||||
curelm = LIST_NEXT(curelm, field); \
|
||||
LIST_NEXT(curelm, field) = LIST_FIRST(head2); \
|
||||
LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \
|
||||
LIST_INIT(head2); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
|
||||
|
||||
#define LIST_FIRST(head) ((head)->lh_first)
|
||||
@@ -334,16 +547,27 @@ struct { \
|
||||
(var); \
|
||||
(var) = LIST_NEXT((var), field))
|
||||
|
||||
#define LIST_FOREACH_FROM(var, head, field) \
|
||||
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
|
||||
(var); \
|
||||
(var) = LIST_NEXT((var), field))
|
||||
|
||||
#define LIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = LIST_FIRST((head)); \
|
||||
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
||||
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
|
||||
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define LIST_INIT(head) do { \
|
||||
LIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
||||
QMD_LIST_CHECK_NEXT(listelm, field); \
|
||||
if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
|
||||
LIST_NEXT((listelm), field)->field.le_prev = \
|
||||
&LIST_NEXT((elm), field); \
|
||||
@@ -352,6 +576,7 @@ struct { \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QMD_LIST_CHECK_PREV(listelm, field); \
|
||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||
LIST_NEXT((elm), field) = (listelm); \
|
||||
*(listelm)->field.le_prev = (elm); \
|
||||
@@ -359,6 +584,7 @@ struct { \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
||||
QMD_LIST_CHECK_HEAD((head), field); \
|
||||
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
|
||||
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
|
||||
LIST_FIRST((head)) = (elm); \
|
||||
@@ -367,13 +593,36 @@ struct { \
|
||||
|
||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
||||
|
||||
#define LIST_PREV(elm, head, type, field) \
|
||||
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
|
||||
__containerof((elm)->field.le_prev, \
|
||||
QUEUE_TYPEOF(type), field.le_next))
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.le_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
|
||||
QMD_LIST_CHECK_NEXT(elm, field); \
|
||||
QMD_LIST_CHECK_PREV(elm, field); \
|
||||
if (LIST_NEXT((elm), field) != NULL) \
|
||||
LIST_NEXT((elm), field)->field.le_prev = \
|
||||
(elm)->field.le_prev; \
|
||||
*(elm)->field.le_prev = LIST_NEXT((elm), field); \
|
||||
TRASHIT(*oldnext); \
|
||||
TRASHIT(*oldprev); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_SWAP(head1, head2, type, field) do { \
|
||||
QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \
|
||||
LIST_FIRST((head1)) = LIST_FIRST((head2)); \
|
||||
LIST_FIRST((head2)) = swap_tmp; \
|
||||
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
|
||||
swap_tmp->field.le_prev = &LIST_FIRST((head1)); \
|
||||
if ((swap_tmp = LIST_FIRST((head2))) != NULL) \
|
||||
swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_END(head) NULL
|
||||
|
||||
/*
|
||||
* Tail queue declarations.
|
||||
*/
|
||||
@@ -384,8 +633,15 @@ struct name { \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
#define TAILQ_CLASS_HEAD(name, type) \
|
||||
struct name { \
|
||||
class type *tqh_first; /* first element */ \
|
||||
class type **tqh_last; /* addr of last next element */ \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
#define TAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).tqh_first }
|
||||
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
|
||||
|
||||
#define TAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
@@ -394,9 +650,69 @@ struct { \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
#define TAILQ_CLASS_ENTRY(type) \
|
||||
struct { \
|
||||
class type *tqe_next; /* next element */ \
|
||||
class type **tqe_prev; /* address of previous next element */ \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#if (defined(_KERNEL) && defined(INVARIANTS))
|
||||
/*
|
||||
* QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
|
||||
*
|
||||
* If the tailq is non-empty, validates that the first element of the tailq
|
||||
* points back at 'head.'
|
||||
*/
|
||||
#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
|
||||
if (!TAILQ_EMPTY(head) && \
|
||||
TAILQ_FIRST((head))->field.tqe_prev != \
|
||||
&TAILQ_FIRST((head))) \
|
||||
panic("Bad tailq head %p first->prev != head", (head)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
|
||||
*
|
||||
* Validates that the tail of the tailq is a pointer to pointer to NULL.
|
||||
*/
|
||||
#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
|
||||
if (*(head)->tqh_last != NULL) \
|
||||
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME)
|
||||
*
|
||||
* If an element follows 'elm' in the tailq, validates that the next element
|
||||
* points back at 'elm.'
|
||||
*/
|
||||
#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
|
||||
if (TAILQ_NEXT((elm), field) != NULL && \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev != \
|
||||
&((elm)->field.tqe_next)) \
|
||||
panic("Bad link elm %p next->prev != elm", (elm)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME)
|
||||
*
|
||||
* Validates that the previous element (or head of the tailq) points to 'elm.'
|
||||
*/
|
||||
#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
|
||||
if (*(elm)->field.tqe_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (elm)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define QMD_TAILQ_CHECK_HEAD(head, field)
|
||||
#define QMD_TAILQ_CHECK_TAIL(head, headname)
|
||||
#define QMD_TAILQ_CHECK_NEXT(elm, field)
|
||||
#define QMD_TAILQ_CHECK_PREV(elm, field)
|
||||
#endif /* (_KERNEL && INVARIANTS) */
|
||||
|
||||
#define TAILQ_CONCAT(head1, head2, field) do { \
|
||||
if (!TAILQ_EMPTY(head2)) { \
|
||||
*(head1)->tqh_last = (head2)->tqh_first; \
|
||||
@@ -417,21 +733,41 @@ struct { \
|
||||
(var); \
|
||||
(var) = TAILQ_NEXT((var), field))
|
||||
|
||||
#define TAILQ_FOREACH_FROM(var, head, field) \
|
||||
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
|
||||
(var); \
|
||||
(var) = TAILQ_NEXT((var), field))
|
||||
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
||||
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
|
||||
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var); \
|
||||
(var) = TAILQ_PREV((var), headname, field))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
|
||||
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
|
||||
(var); \
|
||||
(var) = TAILQ_PREV((var), headname, field))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \
|
||||
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
|
||||
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_INIT(head) do { \
|
||||
TAILQ_FIRST((head)) = NULL; \
|
||||
(head)->tqh_last = &TAILQ_FIRST((head)); \
|
||||
@@ -439,6 +775,7 @@ struct { \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_NEXT(listelm, field); \
|
||||
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
||||
&TAILQ_NEXT((elm), field); \
|
||||
@@ -449,19 +786,21 @@ struct { \
|
||||
TAILQ_NEXT((listelm), field) = (elm); \
|
||||
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
QMD_TRACE_ELEM(&(listelm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_PREV(listelm, field); \
|
||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||
TAILQ_NEXT((elm), field) = (listelm); \
|
||||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
QMD_TRACE_ELEM(&(listelm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_HEAD(head, field); \
|
||||
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
|
||||
TAILQ_FIRST((head))->field.tqe_prev = \
|
||||
&TAILQ_NEXT((elm), field); \
|
||||
@@ -474,6 +813,7 @@ struct { \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_TAIL(head, field); \
|
||||
TAILQ_NEXT((elm), field) = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
@@ -485,12 +825,30 @@ struct { \
|
||||
#define TAILQ_LAST(head, headname) \
|
||||
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
||||
|
||||
/*
|
||||
* The FAST function is fast in that it causes no data access other
|
||||
* then the access to the head. The standard LAST function above
|
||||
* will cause a data access of both the element you want and
|
||||
* the previous element. FAST is very useful for instances when
|
||||
* you may want to prefetch the last data element.
|
||||
*/
|
||||
#define TAILQ_LAST_FAST(head, type, field) \
|
||||
(TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next))
|
||||
|
||||
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
||||
|
||||
#define TAILQ_PREV(elm, headname, field) \
|
||||
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
||||
|
||||
#define TAILQ_PREV_FAST(elm, head, type, field) \
|
||||
((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \
|
||||
__containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next))
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
|
||||
QMD_TAILQ_CHECK_NEXT(elm, field); \
|
||||
QMD_TAILQ_CHECK_PREV(elm, field); \
|
||||
if ((TAILQ_NEXT((elm), field)) != NULL) \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
@@ -499,55 +857,28 @@ struct { \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
} \
|
||||
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
|
||||
TRASHIT((elm)->field.tqe_next); \
|
||||
TRASHIT((elm)->field.tqe_prev); \
|
||||
TRASHIT(*oldnext); \
|
||||
TRASHIT(*oldprev); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_SWAP(head1, head2, type, field) do { \
|
||||
QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \
|
||||
QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \
|
||||
(head1)->tqh_first = (head2)->tqh_first; \
|
||||
(head1)->tqh_last = (head2)->tqh_last; \
|
||||
(head2)->tqh_first = swap_first; \
|
||||
(head2)->tqh_last = swap_last; \
|
||||
if ((swap_first = (head1)->tqh_first) != NULL) \
|
||||
swap_first->field.tqe_prev = &(head1)->tqh_first; \
|
||||
else \
|
||||
(head1)->tqh_last = &(head1)->tqh_first; \
|
||||
if ((swap_first = (head2)->tqh_first) != NULL) \
|
||||
swap_first->field.tqe_prev = &(head2)->tqh_first; \
|
||||
else \
|
||||
(head2)->tqh_last = &(head2)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define TAILQ_END(head) NULL
|
||||
|
||||
/*
|
||||
* XXX insque() and remque() are an old way of handling certain queues.
|
||||
* They bogusly assumes that all queue heads look alike.
|
||||
*/
|
||||
|
||||
struct quehead {
|
||||
struct quehead *qh_link;
|
||||
struct quehead *qh_rlink;
|
||||
};
|
||||
|
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||
|
||||
static __inline void
|
||||
insque(void *a, void *b)
|
||||
{
|
||||
struct quehead *element = (struct quehead *)a,
|
||||
*head = (struct quehead *)b;
|
||||
|
||||
element->qh_link = head->qh_link;
|
||||
element->qh_rlink = head;
|
||||
head->qh_link = element;
|
||||
element->qh_link->qh_rlink = element;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
remque(void *a)
|
||||
{
|
||||
struct quehead *element = (struct quehead *)a;
|
||||
|
||||
element->qh_link->qh_rlink = element->qh_rlink;
|
||||
element->qh_rlink->qh_link = element->qh_link;
|
||||
element->qh_rlink = 0;
|
||||
}
|
||||
|
||||
#else /* !(__GNUC__ || __INTEL_COMPILER) */
|
||||
|
||||
void insque(void *a, void *b);
|
||||
void remque(void *a);
|
||||
|
||||
#endif /* __GNUC__ || __INTEL_COMPILER */
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_SYS_QUEUE_H */
|
||||
#endif /* !LIBBSD_SYS_QUEUE_H */
|
144
include/bsd/sys/time.h
Normal file
144
include/bsd/sys/time.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/* $OpenBSD: time.h,v 1.36 2016/09/12 19:41:20 guenther Exp $ */
|
||||
/* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
*
|
||||
* @(#)time.h 8.2 (Berkeley) 7/10/94
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#if __has_include_next(<sys/time.h>)
|
||||
#include_next <sys/time.h>
|
||||
#endif
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<sys/time.h>)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_SYS_TIME_H
|
||||
#define LIBBSD_SYS_TIME_H
|
||||
|
||||
#ifndef TIMEVAL_TO_TIMESPEC
|
||||
#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
|
||||
(ts)->tv_sec = (tv)->tv_sec; \
|
||||
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIMESPEC_TO_TIMEVAL
|
||||
#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
|
||||
(tv)->tv_sec = (ts)->tv_sec; \
|
||||
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Operations on timevals. */
|
||||
#ifndef timerclear
|
||||
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
||||
#endif
|
||||
|
||||
#ifndef timerisset
|
||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||
#endif
|
||||
|
||||
#ifndef timercmp
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
||||
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
||||
#endif
|
||||
|
||||
#ifndef timeradd
|
||||
#define timeradd(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec >= 1000000) { \
|
||||
(vvp)->tv_sec++; \
|
||||
(vvp)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef timersub
|
||||
#define timersub(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) { \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* Operations on timespecs. */
|
||||
#ifndef timespecclear
|
||||
#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
|
||||
#endif
|
||||
|
||||
#ifndef timespecisset
|
||||
#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
|
||||
#endif
|
||||
|
||||
#ifndef timespeccmp
|
||||
#define timespeccmp(tsp, usp, cmp) \
|
||||
(((tsp)->tv_sec == (usp)->tv_sec) ? \
|
||||
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
|
||||
((tsp)->tv_sec cmp (usp)->tv_sec))
|
||||
#endif
|
||||
|
||||
#ifndef timespecadd
|
||||
#define timespecadd(tsp, usp, vsp) \
|
||||
do { \
|
||||
(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
|
||||
(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
|
||||
if ((vsp)->tv_nsec >= 1000000000L) { \
|
||||
(vsp)->tv_sec++; \
|
||||
(vsp)->tv_nsec -= 1000000000L; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef timespecsub
|
||||
#define timespecsub(tsp, usp, vsp) \
|
||||
do { \
|
||||
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
|
||||
(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
|
||||
if ((vsp)->tv_nsec < 0) { \
|
||||
(vsp)->tv_sec--; \
|
||||
(vsp)->tv_nsec += 1000000000L; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
769
include/bsd/sys/tree.h
Normal file
769
include/bsd/sys/tree.h
Normal file
@@ -0,0 +1,769 @@
|
||||
/* $NetBSD: tree.h,v 1.8 2004/03/28 19:38:30 provos Exp $ */
|
||||
/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*-
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_SYS_TREE_H
|
||||
#define LIBBSD_SYS_TREE_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This file defines data structures for different types of trees:
|
||||
* splay trees and red-black trees.
|
||||
*
|
||||
* A splay tree is a self-organizing data structure. Every operation
|
||||
* on the tree causes a splay to happen. The splay moves the requested
|
||||
* node to the root of the tree and partly rebalances it.
|
||||
*
|
||||
* This has the benefit that request locality causes faster lookups as
|
||||
* the requested nodes move to the top of the tree. On the other hand,
|
||||
* every lookup causes memory writes.
|
||||
*
|
||||
* The Balance Theorem bounds the total access time for m operations
|
||||
* and n inserts on an initially empty tree as O((m + n)lg n). The
|
||||
* amortized cost for a sequence of m accesses to a splay tree is O(lg n);
|
||||
*
|
||||
* A red-black tree is a binary search tree with the node color as an
|
||||
* extra attribute. It fulfills a set of conditions:
|
||||
* - every search path from the root to a leaf consists of the
|
||||
* same number of black nodes,
|
||||
* - each red node (except for the root) has a black parent,
|
||||
* - each leaf node is black.
|
||||
*
|
||||
* Every operation on a red-black tree is bounded as O(lg n).
|
||||
* The maximum height of a red-black tree is 2lg (n+1).
|
||||
*/
|
||||
|
||||
#define SPLAY_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *sph_root; /* root of the tree */ \
|
||||
}
|
||||
|
||||
#define SPLAY_INITIALIZER(root) \
|
||||
{ NULL }
|
||||
|
||||
#define SPLAY_INIT(root) do { \
|
||||
(root)->sph_root = NULL; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *spe_left; /* left element */ \
|
||||
struct type *spe_right; /* right element */ \
|
||||
}
|
||||
|
||||
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
|
||||
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
|
||||
#define SPLAY_ROOT(head) (head)->sph_root
|
||||
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
|
||||
|
||||
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
|
||||
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
|
||||
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
|
||||
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
||||
(head)->sph_root = tmp; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
|
||||
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
||||
(head)->sph_root = tmp; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_LINKLEFT(head, tmp, field) do { \
|
||||
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
||||
tmp = (head)->sph_root; \
|
||||
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_LINKRIGHT(head, tmp, field) do { \
|
||||
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
||||
tmp = (head)->sph_root; \
|
||||
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
|
||||
SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
|
||||
SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
|
||||
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
/* Generates prototypes and inline functions */
|
||||
|
||||
#define SPLAY_PROTOTYPE(name, type, field, cmp) \
|
||||
void name##_SPLAY(struct name *, struct type *); \
|
||||
void name##_SPLAY_MINMAX(struct name *, int); \
|
||||
struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
|
||||
struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
|
||||
\
|
||||
/* Finds the node with the same key as elm */ \
|
||||
static __inline struct type * \
|
||||
name##_SPLAY_FIND(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
if (SPLAY_EMPTY(head)) \
|
||||
return(NULL); \
|
||||
name##_SPLAY(head, elm); \
|
||||
if ((cmp)(elm, (head)->sph_root) == 0) \
|
||||
return (head->sph_root); \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
static __inline struct type * \
|
||||
name##_SPLAY_NEXT(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
name##_SPLAY(head, elm); \
|
||||
if (SPLAY_RIGHT(elm, field) != NULL) { \
|
||||
elm = SPLAY_RIGHT(elm, field); \
|
||||
while (SPLAY_LEFT(elm, field) != NULL) { \
|
||||
elm = SPLAY_LEFT(elm, field); \
|
||||
} \
|
||||
} else \
|
||||
elm = NULL; \
|
||||
return (elm); \
|
||||
} \
|
||||
\
|
||||
static __inline struct type * \
|
||||
name##_SPLAY_MIN_MAX(struct name *head, int val) \
|
||||
{ \
|
||||
name##_SPLAY_MINMAX(head, val); \
|
||||
return (SPLAY_ROOT(head)); \
|
||||
}
|
||||
|
||||
/* Main splay operation.
|
||||
* Moves node close to the key of elm to top
|
||||
*/
|
||||
#define SPLAY_GENERATE(name, type, field, cmp) \
|
||||
struct type * \
|
||||
name##_SPLAY_INSERT(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
if (SPLAY_EMPTY(head)) { \
|
||||
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
|
||||
} else { \
|
||||
int __comp; \
|
||||
name##_SPLAY(head, elm); \
|
||||
__comp = (cmp)(elm, (head)->sph_root); \
|
||||
if(__comp < 0) { \
|
||||
SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
|
||||
SPLAY_RIGHT(elm, field) = (head)->sph_root; \
|
||||
SPLAY_LEFT((head)->sph_root, field) = NULL; \
|
||||
} else if (__comp > 0) { \
|
||||
SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
|
||||
SPLAY_LEFT(elm, field) = (head)->sph_root; \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = NULL; \
|
||||
} else \
|
||||
return ((head)->sph_root); \
|
||||
} \
|
||||
(head)->sph_root = (elm); \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
struct type * \
|
||||
name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *__tmp; \
|
||||
if (SPLAY_EMPTY(head)) \
|
||||
return (NULL); \
|
||||
name##_SPLAY(head, elm); \
|
||||
if ((cmp)(elm, (head)->sph_root) == 0) { \
|
||||
if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
|
||||
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
|
||||
} else { \
|
||||
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
|
||||
name##_SPLAY(head, elm); \
|
||||
SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
|
||||
} \
|
||||
return (elm); \
|
||||
} \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
void \
|
||||
name##_SPLAY(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type __node, *__left, *__right, *__tmp; \
|
||||
int __comp; \
|
||||
\
|
||||
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
|
||||
__left = __right = &__node; \
|
||||
\
|
||||
while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \
|
||||
if (__comp < 0) { \
|
||||
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if ((cmp)(elm, __tmp) < 0){ \
|
||||
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
||||
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKLEFT(head, __right, field); \
|
||||
} else if (__comp > 0) { \
|
||||
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if ((cmp)(elm, __tmp) > 0){ \
|
||||
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
||||
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKRIGHT(head, __left, field); \
|
||||
} \
|
||||
} \
|
||||
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
|
||||
} \
|
||||
\
|
||||
/* Splay with either the minimum or the maximum element \
|
||||
* Used to find minimum or maximum element in tree. \
|
||||
*/ \
|
||||
void name##_SPLAY_MINMAX(struct name *head, int __comp) \
|
||||
{ \
|
||||
struct type __node, *__left, *__right, *__tmp; \
|
||||
\
|
||||
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
|
||||
__left = __right = &__node; \
|
||||
\
|
||||
while (1) { \
|
||||
if (__comp < 0) { \
|
||||
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if (__comp < 0){ \
|
||||
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
||||
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKLEFT(head, __right, field); \
|
||||
} else if (__comp > 0) { \
|
||||
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
||||
if (__tmp == NULL) \
|
||||
break; \
|
||||
if (__comp > 0) { \
|
||||
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
||||
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
|
||||
break; \
|
||||
} \
|
||||
SPLAY_LINKRIGHT(head, __left, field); \
|
||||
} \
|
||||
} \
|
||||
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
|
||||
}
|
||||
|
||||
#define SPLAY_NEGINF -1
|
||||
#define SPLAY_INF 1
|
||||
|
||||
#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
|
||||
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
|
||||
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
|
||||
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
|
||||
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
|
||||
: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
|
||||
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
|
||||
: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
|
||||
|
||||
#define SPLAY_FOREACH(x, name, head) \
|
||||
for ((x) = SPLAY_MIN(name, head); \
|
||||
(x) != NULL; \
|
||||
(x) = SPLAY_NEXT(name, head, x))
|
||||
|
||||
/* Macros that define a red-black tree */
|
||||
#define RB_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *rbh_root; /* root of the tree */ \
|
||||
}
|
||||
|
||||
#define RB_INITIALIZER(root) \
|
||||
{ NULL }
|
||||
|
||||
#define RB_INIT(root) do { \
|
||||
(root)->rbh_root = NULL; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define RB_BLACK 0
|
||||
#define RB_RED 1
|
||||
#define RB_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *rbe_left; /* left element */ \
|
||||
struct type *rbe_right; /* right element */ \
|
||||
struct type *rbe_parent; /* parent element */ \
|
||||
int rbe_color; /* node color */ \
|
||||
}
|
||||
|
||||
#define RB_LEFT(elm, field) (elm)->field.rbe_left
|
||||
#define RB_RIGHT(elm, field) (elm)->field.rbe_right
|
||||
#define RB_PARENT(elm, field) (elm)->field.rbe_parent
|
||||
#define RB_COLOR(elm, field) (elm)->field.rbe_color
|
||||
#define RB_ROOT(head) (head)->rbh_root
|
||||
#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
|
||||
|
||||
#define RB_SET(elm, parent, field) do { \
|
||||
RB_PARENT(elm, field) = parent; \
|
||||
RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
|
||||
RB_COLOR(elm, field) = RB_RED; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define RB_SET_BLACKRED(black, red, field) do { \
|
||||
RB_COLOR(black, field) = RB_BLACK; \
|
||||
RB_COLOR(red, field) = RB_RED; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#ifndef RB_AUGMENT
|
||||
#define RB_AUGMENT(x) do {} while (0)
|
||||
#endif
|
||||
|
||||
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
|
||||
(tmp) = RB_RIGHT(elm, field); \
|
||||
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \
|
||||
RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
|
||||
} \
|
||||
RB_AUGMENT(elm); \
|
||||
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
|
||||
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
|
||||
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
else \
|
||||
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
} else \
|
||||
(head)->rbh_root = (tmp); \
|
||||
RB_LEFT(tmp, field) = (elm); \
|
||||
RB_PARENT(elm, field) = (tmp); \
|
||||
RB_AUGMENT(tmp); \
|
||||
if ((RB_PARENT(tmp, field))) \
|
||||
RB_AUGMENT(RB_PARENT(tmp, field)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
|
||||
(tmp) = RB_LEFT(elm, field); \
|
||||
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \
|
||||
RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
|
||||
} \
|
||||
RB_AUGMENT(elm); \
|
||||
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
|
||||
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
|
||||
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
else \
|
||||
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
|
||||
} else \
|
||||
(head)->rbh_root = (tmp); \
|
||||
RB_RIGHT(tmp, field) = (elm); \
|
||||
RB_PARENT(elm, field) = (tmp); \
|
||||
RB_AUGMENT(tmp); \
|
||||
if ((RB_PARENT(tmp, field))) \
|
||||
RB_AUGMENT(RB_PARENT(tmp, field)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
/* Generates prototypes and inline functions */
|
||||
#define RB_PROTOTYPE(name, type, field, cmp) \
|
||||
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
|
||||
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
|
||||
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
|
||||
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
|
||||
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
|
||||
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
|
||||
attr struct type *name##_RB_REMOVE(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_INSERT(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_FIND(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_NFIND(struct name *, struct type *); \
|
||||
attr struct type *name##_RB_NEXT(struct type *); \
|
||||
attr struct type *name##_RB_PREV(struct type *); \
|
||||
attr struct type *name##_RB_MINMAX(struct name *, int); \
|
||||
\
|
||||
|
||||
/* Main rb operation.
|
||||
* Moves node close to the key of elm to top
|
||||
*/
|
||||
#define RB_GENERATE(name, type, field, cmp) \
|
||||
RB_GENERATE_INTERNAL(name, type, field, cmp,)
|
||||
#define RB_GENERATE_STATIC(name, type, field, cmp) \
|
||||
RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
|
||||
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
|
||||
attr void \
|
||||
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *parent, *gparent, *tmp; \
|
||||
while ((parent = RB_PARENT(elm, field)) != NULL && \
|
||||
RB_COLOR(parent, field) == RB_RED) { \
|
||||
gparent = RB_PARENT(parent, field); \
|
||||
if (parent == RB_LEFT(gparent, field)) { \
|
||||
tmp = RB_RIGHT(gparent, field); \
|
||||
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_COLOR(tmp, field) = RB_BLACK; \
|
||||
RB_SET_BLACKRED(parent, gparent, field);\
|
||||
elm = gparent; \
|
||||
continue; \
|
||||
} \
|
||||
if (RB_RIGHT(parent, field) == elm) { \
|
||||
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
||||
tmp = parent; \
|
||||
parent = elm; \
|
||||
elm = tmp; \
|
||||
} \
|
||||
RB_SET_BLACKRED(parent, gparent, field); \
|
||||
RB_ROTATE_RIGHT(head, gparent, tmp, field); \
|
||||
} else { \
|
||||
tmp = RB_LEFT(gparent, field); \
|
||||
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_COLOR(tmp, field) = RB_BLACK; \
|
||||
RB_SET_BLACKRED(parent, gparent, field);\
|
||||
elm = gparent; \
|
||||
continue; \
|
||||
} \
|
||||
if (RB_LEFT(parent, field) == elm) { \
|
||||
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
||||
tmp = parent; \
|
||||
parent = elm; \
|
||||
elm = tmp; \
|
||||
} \
|
||||
RB_SET_BLACKRED(parent, gparent, field); \
|
||||
RB_ROTATE_LEFT(head, gparent, tmp, field); \
|
||||
} \
|
||||
} \
|
||||
RB_COLOR(head->rbh_root, field) = RB_BLACK; \
|
||||
} \
|
||||
\
|
||||
attr void \
|
||||
name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp; \
|
||||
while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
|
||||
elm != RB_ROOT(head)) { \
|
||||
if (RB_LEFT(parent, field) == elm) { \
|
||||
tmp = RB_RIGHT(parent, field); \
|
||||
if (RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_SET_BLACKRED(tmp, parent, field); \
|
||||
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
||||
tmp = RB_RIGHT(parent, field); \
|
||||
} \
|
||||
if ((RB_LEFT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
|
||||
(RB_RIGHT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
elm = parent; \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
} else { \
|
||||
if (RB_RIGHT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
|
||||
struct type *oleft; \
|
||||
if ((oleft = RB_LEFT(tmp, field)) \
|
||||
!= NULL) \
|
||||
RB_COLOR(oleft, field) = RB_BLACK;\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
RB_ROTATE_RIGHT(head, tmp, oleft, field);\
|
||||
tmp = RB_RIGHT(parent, field); \
|
||||
} \
|
||||
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
|
||||
RB_COLOR(parent, field) = RB_BLACK; \
|
||||
if (RB_RIGHT(tmp, field)) \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
|
||||
RB_ROTATE_LEFT(head, parent, tmp, field);\
|
||||
elm = RB_ROOT(head); \
|
||||
break; \
|
||||
} \
|
||||
} else { \
|
||||
tmp = RB_LEFT(parent, field); \
|
||||
if (RB_COLOR(tmp, field) == RB_RED) { \
|
||||
RB_SET_BLACKRED(tmp, parent, field); \
|
||||
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
||||
tmp = RB_LEFT(parent, field); \
|
||||
} \
|
||||
if ((RB_LEFT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
|
||||
(RB_RIGHT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
elm = parent; \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
} else { \
|
||||
if (RB_LEFT(tmp, field) == NULL || \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
|
||||
struct type *oright; \
|
||||
if ((oright = RB_RIGHT(tmp, field)) \
|
||||
!= NULL) \
|
||||
RB_COLOR(oright, field) = RB_BLACK;\
|
||||
RB_COLOR(tmp, field) = RB_RED; \
|
||||
RB_ROTATE_LEFT(head, tmp, oright, field);\
|
||||
tmp = RB_LEFT(parent, field); \
|
||||
} \
|
||||
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
|
||||
RB_COLOR(parent, field) = RB_BLACK; \
|
||||
if (RB_LEFT(tmp, field)) \
|
||||
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
|
||||
RB_ROTATE_RIGHT(head, parent, tmp, field);\
|
||||
elm = RB_ROOT(head); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
if (elm) \
|
||||
RB_COLOR(elm, field) = RB_BLACK; \
|
||||
} \
|
||||
\
|
||||
attr struct type * \
|
||||
name##_RB_REMOVE(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *child, *parent, *old = elm; \
|
||||
int color; \
|
||||
if (RB_LEFT(elm, field) == NULL) \
|
||||
child = RB_RIGHT(elm, field); \
|
||||
else if (RB_RIGHT(elm, field) == NULL) \
|
||||
child = RB_LEFT(elm, field); \
|
||||
else { \
|
||||
struct type *left; \
|
||||
elm = RB_RIGHT(elm, field); \
|
||||
while ((left = RB_LEFT(elm, field)) != NULL) \
|
||||
elm = left; \
|
||||
child = RB_RIGHT(elm, field); \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
color = RB_COLOR(elm, field); \
|
||||
if (child) \
|
||||
RB_PARENT(child, field) = parent; \
|
||||
if (parent) { \
|
||||
if (RB_LEFT(parent, field) == elm) \
|
||||
RB_LEFT(parent, field) = child; \
|
||||
else \
|
||||
RB_RIGHT(parent, field) = child; \
|
||||
RB_AUGMENT(parent); \
|
||||
} else \
|
||||
RB_ROOT(head) = child; \
|
||||
if (RB_PARENT(elm, field) == old) \
|
||||
parent = elm; \
|
||||
(elm)->field = (old)->field; \
|
||||
if (RB_PARENT(old, field)) { \
|
||||
if (RB_LEFT(RB_PARENT(old, field), field) == old)\
|
||||
RB_LEFT(RB_PARENT(old, field), field) = elm;\
|
||||
else \
|
||||
RB_RIGHT(RB_PARENT(old, field), field) = elm;\
|
||||
RB_AUGMENT(RB_PARENT(old, field)); \
|
||||
} else \
|
||||
RB_ROOT(head) = elm; \
|
||||
RB_PARENT(RB_LEFT(old, field), field) = elm; \
|
||||
if (RB_RIGHT(old, field)) \
|
||||
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
|
||||
if (parent) { \
|
||||
left = parent; \
|
||||
do { \
|
||||
RB_AUGMENT(left); \
|
||||
} while ((left = RB_PARENT(left, field)) != NULL); \
|
||||
} \
|
||||
goto color; \
|
||||
} \
|
||||
parent = RB_PARENT(elm, field); \
|
||||
color = RB_COLOR(elm, field); \
|
||||
if (child) \
|
||||
RB_PARENT(child, field) = parent; \
|
||||
if (parent) { \
|
||||
if (RB_LEFT(parent, field) == elm) \
|
||||
RB_LEFT(parent, field) = child; \
|
||||
else \
|
||||
RB_RIGHT(parent, field) = child; \
|
||||
RB_AUGMENT(parent); \
|
||||
} else \
|
||||
RB_ROOT(head) = child; \
|
||||
color: \
|
||||
if (color == RB_BLACK) \
|
||||
name##_RB_REMOVE_COLOR(head, parent, child); \
|
||||
return (old); \
|
||||
} \
|
||||
\
|
||||
/* Inserts a node into the RB tree */ \
|
||||
attr struct type * \
|
||||
name##_RB_INSERT(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp; \
|
||||
struct type *parent = NULL; \
|
||||
int comp = 0; \
|
||||
tmp = RB_ROOT(head); \
|
||||
while (tmp) { \
|
||||
parent = tmp; \
|
||||
comp = (cmp)(elm, parent); \
|
||||
if (comp < 0) \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
else if (comp > 0) \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
else \
|
||||
return (tmp); \
|
||||
} \
|
||||
RB_SET(elm, parent, field); \
|
||||
if (parent != NULL) { \
|
||||
if (comp < 0) \
|
||||
RB_LEFT(parent, field) = elm; \
|
||||
else \
|
||||
RB_RIGHT(parent, field) = elm; \
|
||||
RB_AUGMENT(parent); \
|
||||
} else \
|
||||
RB_ROOT(head) = elm; \
|
||||
name##_RB_INSERT_COLOR(head, elm); \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
/* Finds the node with the same key as elm */ \
|
||||
attr struct type * \
|
||||
name##_RB_FIND(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp = RB_ROOT(head); \
|
||||
int comp; \
|
||||
while (tmp) { \
|
||||
comp = cmp(elm, tmp); \
|
||||
if (comp < 0) \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
else if (comp > 0) \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
else \
|
||||
return (tmp); \
|
||||
} \
|
||||
return (NULL); \
|
||||
} \
|
||||
\
|
||||
/* Finds the first node greater than or equal to the search key */ \
|
||||
attr struct type * \
|
||||
name##_RB_NFIND(struct name *head, struct type *elm) \
|
||||
{ \
|
||||
struct type *tmp = RB_ROOT(head); \
|
||||
struct type *res = NULL; \
|
||||
int comp; \
|
||||
while (tmp) { \
|
||||
comp = cmp(elm, tmp); \
|
||||
if (comp < 0) { \
|
||||
res = tmp; \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
} \
|
||||
else if (comp > 0) \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
else \
|
||||
return (tmp); \
|
||||
} \
|
||||
return (res); \
|
||||
} \
|
||||
\
|
||||
/* ARGSUSED */ \
|
||||
attr struct type * \
|
||||
name##_RB_NEXT(struct type *elm) \
|
||||
{ \
|
||||
if (RB_RIGHT(elm, field)) { \
|
||||
elm = RB_RIGHT(elm, field); \
|
||||
while (RB_LEFT(elm, field)) \
|
||||
elm = RB_LEFT(elm, field); \
|
||||
} else { \
|
||||
if (RB_PARENT(elm, field) && \
|
||||
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
else { \
|
||||
while (RB_PARENT(elm, field) && \
|
||||
(elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
|
||||
elm = RB_PARENT(elm, field); \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
} \
|
||||
} \
|
||||
return (elm); \
|
||||
} \
|
||||
\
|
||||
/* ARGSUSED */ \
|
||||
attr struct type * \
|
||||
name##_RB_PREV(struct type *elm) \
|
||||
{ \
|
||||
if (RB_LEFT(elm, field)) { \
|
||||
elm = RB_LEFT(elm, field); \
|
||||
while (RB_RIGHT(elm, field)) \
|
||||
elm = RB_RIGHT(elm, field); \
|
||||
} else { \
|
||||
if (RB_PARENT(elm, field) && \
|
||||
(elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
else { \
|
||||
while (RB_PARENT(elm, field) && \
|
||||
(elm == RB_LEFT(RB_PARENT(elm, field), field)))\
|
||||
elm = RB_PARENT(elm, field); \
|
||||
elm = RB_PARENT(elm, field); \
|
||||
} \
|
||||
} \
|
||||
return (elm); \
|
||||
} \
|
||||
\
|
||||
attr struct type * \
|
||||
name##_RB_MINMAX(struct name *head, int val) \
|
||||
{ \
|
||||
struct type *tmp = RB_ROOT(head); \
|
||||
struct type *parent = NULL; \
|
||||
while (tmp) { \
|
||||
parent = tmp; \
|
||||
if (val < 0) \
|
||||
tmp = RB_LEFT(tmp, field); \
|
||||
else \
|
||||
tmp = RB_RIGHT(tmp, field); \
|
||||
} \
|
||||
return (parent); \
|
||||
}
|
||||
|
||||
#define RB_NEGINF -1
|
||||
#define RB_INF 1
|
||||
|
||||
#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
|
||||
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
|
||||
#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
|
||||
#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y)
|
||||
#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
|
||||
#define RB_PREV(name, x, y) name##_RB_PREV(y)
|
||||
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
|
||||
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
|
||||
|
||||
#define RB_FOREACH(x, name, head) \
|
||||
for ((x) = RB_MIN(name, head); \
|
||||
(x) != NULL; \
|
||||
(x) = name##_RB_NEXT(x))
|
||||
|
||||
#define RB_FOREACH_FROM(x, name, y) \
|
||||
for ((x) = (y); \
|
||||
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
|
||||
(x) = (y))
|
||||
|
||||
#define RB_FOREACH_SAFE(x, name, head, y) \
|
||||
for ((x) = RB_MIN(name, head); \
|
||||
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
|
||||
(x) = (y))
|
||||
|
||||
#define RB_FOREACH_REVERSE(x, name, head) \
|
||||
for ((x) = RB_MAX(name, head); \
|
||||
(x) != NULL; \
|
||||
(x) = name##_RB_PREV(x))
|
||||
|
||||
#define RB_FOREACH_REVERSE_FROM(x, name, y) \
|
||||
for ((x) = (y); \
|
||||
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
|
||||
(x) = (y))
|
||||
|
||||
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \
|
||||
for ((x) = RB_MAX(name, head); \
|
||||
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
|
||||
(x) = (y))
|
||||
|
||||
#endif /* LIBBSD_SYS_TREE_H */
|
61
include/bsd/timeconv.h
Normal file
61
include/bsd/timeconv.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* 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. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
*
|
||||
* @(#)time.h 8.3 (Berkeley) 1/21/94
|
||||
*/
|
||||
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_TIMECONV_H
|
||||
#define LIBBSD_TIMECONV_H
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
time_t _time32_to_time(int32_t t32);
|
||||
int32_t _time_to_time32(time_t t);
|
||||
time_t _time64_to_time(int64_t t64);
|
||||
int64_t _time_to_time64(time_t t);
|
||||
long _time_to_long(time_t t);
|
||||
time_t _long_to_time(long tlong);
|
||||
int _time_to_int(time_t t);
|
||||
time_t _int_to_time(int tint);
|
||||
|
||||
#endif /* LIBBSD_TIMECONV_H */
|
74
include/bsd/unistd.h
Normal file
74
include/bsd/unistd.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright © 2006 Robert Millan
|
||||
* Copyright © 2008-2011 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#if __has_include_next(<unistd.h>)
|
||||
#include_next <unistd.h>
|
||||
#endif
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#if __has_include(<unistd.h>)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_UNISTD_H
|
||||
#define LIBBSD_UNISTD_H
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if !defined(S_ISTXT) && defined(S_ISVTX)
|
||||
#define S_ISTXT S_ISVTX
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern int optreset;
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#undef getopt
|
||||
#define getopt(argc, argv, optstr) bsd_getopt(argc, argv, optstr)
|
||||
#endif
|
||||
|
||||
int bsd_getopt(int argc, char * const argv[], const char *shortopts);
|
||||
|
||||
mode_t getmode(const void *set, mode_t mode);
|
||||
void *setmode(const char *mode_str);
|
||||
|
||||
void closefrom(int lowfd);
|
||||
|
||||
/* Compatibility with sendmail implementations. */
|
||||
#define initsetproctitle(c, a, e) setproctitle_init((c), (a), (e))
|
||||
|
||||
void setproctitle_init(int argc, char *argv[], char *envp[]);
|
||||
void setproctitle(const char *fmt, ...)
|
||||
__printflike(1, 2);
|
||||
|
||||
int getpeereid(int s, uid_t *euid, gid_t *egid);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
156
include/bsd/vis.h
Normal file
156
include/bsd/vis.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/* $NetBSD: vis.h,v 1.25 2017/04/23 01:57:36 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
*
|
||||
* @(#)vis.h 8.1 (Berkeley) 6/2/93
|
||||
*/
|
||||
|
||||
#ifndef LIBBSD_VIS_H
|
||||
#define LIBBSD_VIS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* to select alternate encoding format
|
||||
*/
|
||||
#define VIS_OCTAL 0x0001 /* use octal \ddd format */
|
||||
#define VIS_CSTYLE 0x0002 /* use \[nrft0..] where appropriate */
|
||||
|
||||
/*
|
||||
* to alter set of characters encoded (default is to encode all
|
||||
* non-graphic except space, tab, and newline).
|
||||
*/
|
||||
#define VIS_SP 0x0004 /* also encode space */
|
||||
#define VIS_TAB 0x0008 /* also encode tab */
|
||||
#define VIS_NL 0x0010 /* also encode newline */
|
||||
#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
|
||||
#define VIS_SAFE 0x0020 /* only encode "unsafe" characters */
|
||||
#define VIS_DQ 0x8000 /* also encode double quotes */
|
||||
|
||||
/*
|
||||
* other
|
||||
*/
|
||||
#define VIS_NOSLASH 0x0040 /* inhibit printing '\' */
|
||||
#define VIS_HTTP1808 0x0080 /* http-style escape % hex hex */
|
||||
#define VIS_HTTPSTYLE 0x0080 /* http-style escape % hex hex */
|
||||
#define VIS_MIMESTYLE 0x0100 /* mime-style escape = HEX HEX */
|
||||
#define VIS_HTTP1866 0x0200 /* http-style &#num; or &string; */
|
||||
#define VIS_NOESCAPE 0x0400 /* don't decode `\' */
|
||||
#define _VIS_END 0x0800 /* for unvis */
|
||||
#define VIS_GLOB 0x1000 /* encode glob(3) magic characters */
|
||||
#define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */
|
||||
#define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL)
|
||||
#define VIS_NOLOCALE 0x4000 /* encode using the C locale */
|
||||
|
||||
/*
|
||||
* unvis return codes
|
||||
*/
|
||||
#define UNVIS_VALID 1 /* character valid */
|
||||
#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
|
||||
#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
|
||||
#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
|
||||
#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
|
||||
|
||||
/*
|
||||
* unvis flags
|
||||
*/
|
||||
#define UNVIS_END _VIS_END /* no more characters */
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NetBSD added an strnvis and unfortunately made it incompatible with the
|
||||
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
||||
* for over ten years). Despite this incompatibility being reported during
|
||||
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
||||
* Even more unfortunately FreeBSD and later MacOS picked up this incompatible
|
||||
* implementation.
|
||||
*
|
||||
* Provide both implementations and default for now on the historical one to
|
||||
* avoid breakage, we will switch to the NetBSD one in libbsd 0.10.0 or so.
|
||||
* Define LIBBSD_NETBSD_VIS to switch to the NetBSD one now.
|
||||
* Define LIBBSD_OPENBSD_VIS to keep using the OpenBSD one.
|
||||
*/
|
||||
#if defined(LIBBSD_OPENBSD_VIS)
|
||||
#undef LIBBSD_NETBSD_VIS
|
||||
#elif !defined(LIBBSD_NETBSD_VIS)
|
||||
#warning "NetBSD added incompatible strnvis() and strnunvis(), please see <bsd/vis.h> for more detils."
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
char *vis(char *, int, int, int);
|
||||
char *nvis(char *, size_t, int, int, int);
|
||||
|
||||
char *svis(char *, int, int, int, const char *);
|
||||
char *snvis(char *, size_t, int, int, int, const char *);
|
||||
|
||||
int strvis(char *, const char *, int);
|
||||
int stravis(char **, const char *, int);
|
||||
#ifdef LIBBSD_NETBSD_VIS
|
||||
/* NetBSD prototype. */
|
||||
int LIBBSD_REDIRECT(strnvis, (char *, size_t, const char *, int),
|
||||
strnvis_netbsd);
|
||||
#else
|
||||
/* OpenBSD prototype (current default). */
|
||||
int strnvis(char *, const char *, size_t, int);
|
||||
#endif
|
||||
|
||||
int strsvis(char *, const char *, int, const char *);
|
||||
int strsnvis(char *, size_t, const char *, int, const char *);
|
||||
|
||||
int strvisx(char *, const char *, size_t, int);
|
||||
int strnvisx(char *, size_t, const char *, size_t, int);
|
||||
int strenvisx(char *, size_t, const char *, size_t, int, int *);
|
||||
|
||||
int strsvisx(char *, const char *, size_t, int, const char *);
|
||||
int strsnvisx(char *, size_t, const char *, size_t, int, const char *);
|
||||
int strsenvisx(char *, size_t, const char *, size_t , int, const char *,
|
||||
int *);
|
||||
|
||||
int strunvis(char *, const char *);
|
||||
#ifdef LIBBSD_NETBSD_VIS
|
||||
/* NetBSD prototype. */
|
||||
int LIBBSD_REDIRECT(strnunvis, (char *, size_t, const char *),
|
||||
strnunvis_netbsd);
|
||||
#else
|
||||
/* OpenBSD prototype (current default). */
|
||||
ssize_t strnunvis(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
int strunvisx(char *, const char *, int);
|
||||
int strnunvisx(char *, size_t, const char *, int);
|
||||
|
||||
int unvis(char *, int, int *, int);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !LIBBSD_VIS_H */
|
59
include/bsd/wchar.h
Normal file
59
include/bsd/wchar.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright © 2012-2013 Guillem Jover <guillem@hadrons.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(__need_wchar_t) || defined(__need_wint_t) || \
|
||||
defined(__need_mbstate_t)
|
||||
#define LIBBSD_WCHAR_H_SKIP
|
||||
#endif
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include_next <wchar.h>
|
||||
#else
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifndef LIBBSD_WCHAR_H_SKIP
|
||||
#ifndef LIBBSD_WCHAR_H
|
||||
#define LIBBSD_WCHAR_H
|
||||
|
||||
#include <stddef.h>
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <bsd/sys/cdefs.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
wchar_t *fgetwln(FILE *stream, size_t *len);
|
||||
|
||||
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
|
||||
size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#undef LIBBSD_WCHAR_H_SKIP
|
2
man/.gitignore
vendored
2
man/.gitignore
vendored
@@ -1 +1 @@
|
||||
md5.3
|
||||
md5.3bsd
|
||||
|
1
man/LIST_CLASS_ENTRY.3bsd
Normal file
1
man/LIST_CLASS_ENTRY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_CLASS_HEAD.3bsd
Normal file
1
man/LIST_CLASS_HEAD.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_EMPTY.3bsd
Normal file
1
man/LIST_EMPTY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_ENTRY.3bsd
Normal file
1
man/LIST_ENTRY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_FIRST.3bsd
Normal file
1
man/LIST_FIRST.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_FOREACH.3bsd
Normal file
1
man/LIST_FOREACH.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_FOREACH_FROM.3bsd
Normal file
1
man/LIST_FOREACH_FROM.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_FOREACH_FROM_SAFE.3bsd
Normal file
1
man/LIST_FOREACH_FROM_SAFE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_FOREACH_SAFE.3bsd
Normal file
1
man/LIST_FOREACH_SAFE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_HEAD.3bsd
Normal file
1
man/LIST_HEAD.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_HEAD_INITIALIZER.3bsd
Normal file
1
man/LIST_HEAD_INITIALIZER.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_INIT.3bsd
Normal file
1
man/LIST_INIT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_INSERT_AFTER.3bsd
Normal file
1
man/LIST_INSERT_AFTER.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_INSERT_BEFORE.3bsd
Normal file
1
man/LIST_INSERT_BEFORE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_INSERT_HEAD.3bsd
Normal file
1
man/LIST_INSERT_HEAD.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_NEXT.3bsd
Normal file
1
man/LIST_NEXT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_PREV.3bsd
Normal file
1
man/LIST_PREV.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_REMOVE.3bsd
Normal file
1
man/LIST_REMOVE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/LIST_SWAP.3bsd
Normal file
1
man/LIST_SWAP.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
254
man/Makefile.am
Normal file
254
man/Makefile.am
Normal file
@@ -0,0 +1,254 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = \
|
||||
mdX.3bsd \
|
||||
$(nil)
|
||||
|
||||
CLEANFILES = \
|
||||
md5.3bsd \
|
||||
$(nil)
|
||||
|
||||
SED_MD5_SUBST = -e 's/mdX/md5/g' -e 's/mdY/md4/g' -e 's/MDX/MD5/g'
|
||||
|
||||
md5.3bsd: $(srcdir)/mdX.3bsd
|
||||
$(AM_V_GEN) sed $(SED_MD5_SUBST) $< > $@
|
||||
|
||||
dist_man_MANS = \
|
||||
LIST_CLASS_ENTRY.3bsd \
|
||||
LIST_CLASS_HEAD.3bsd \
|
||||
LIST_EMPTY.3bsd \
|
||||
LIST_ENTRY.3bsd \
|
||||
LIST_FIRST.3bsd \
|
||||
LIST_FOREACH.3bsd \
|
||||
LIST_FOREACH_FROM.3bsd \
|
||||
LIST_FOREACH_FROM_SAFE.3bsd \
|
||||
LIST_FOREACH_SAFE.3bsd \
|
||||
LIST_HEAD.3bsd \
|
||||
LIST_HEAD_INITIALIZER.3bsd \
|
||||
LIST_INIT.3bsd \
|
||||
LIST_INSERT_AFTER.3bsd \
|
||||
LIST_INSERT_BEFORE.3bsd \
|
||||
LIST_INSERT_HEAD.3bsd \
|
||||
LIST_NEXT.3bsd \
|
||||
LIST_PREV.3bsd \
|
||||
LIST_REMOVE.3bsd \
|
||||
LIST_SWAP.3bsd \
|
||||
RB_EMPTY.3bsd \
|
||||
RB_ENTRY.3bsd \
|
||||
RB_FIND.3bsd \
|
||||
RB_FOREACH.3bsd \
|
||||
RB_FOREACH_REVERSE.3bsd \
|
||||
RB_GENERATE.3bsd \
|
||||
RB_GENERATE_STATIC.3bsd \
|
||||
RB_HEAD.3bsd \
|
||||
RB_INIT.3bsd \
|
||||
RB_INITIALIZER.3bsd \
|
||||
RB_INSERT.3bsd \
|
||||
RB_LEFT.3bsd \
|
||||
RB_MAX.3bsd \
|
||||
RB_MIN.3bsd \
|
||||
RB_NEXT.3bsd \
|
||||
RB_NFIND.3bsd \
|
||||
RB_PARENT.3bsd \
|
||||
RB_PREV.3bsd \
|
||||
RB_PROTOTYPE.3bsd \
|
||||
RB_PROTOTYPE_STATIC.3bsd \
|
||||
RB_REMOVE.3bsd \
|
||||
RB_RIGHT.3bsd \
|
||||
RB_ROOT.3bsd \
|
||||
SLIST_CLASS_ENTRY.3bsd \
|
||||
SLIST_CLASS_HEAD.3bsd \
|
||||
SLIST_EMPTY.3bsd \
|
||||
SLIST_ENTRY.3bsd \
|
||||
SLIST_FIRST.3bsd \
|
||||
SLIST_FOREACH.3bsd \
|
||||
SLIST_FOREACH_FROM.3bsd \
|
||||
SLIST_FOREACH_FROM_SAFE.3bsd \
|
||||
SLIST_FOREACH_SAFE.3bsd \
|
||||
SLIST_HEAD.3bsd \
|
||||
SLIST_HEAD_INITIALIZER.3bsd \
|
||||
SLIST_INIT.3bsd \
|
||||
SLIST_INSERT_AFTER.3bsd \
|
||||
SLIST_INSERT_HEAD.3bsd \
|
||||
SLIST_NEXT.3bsd \
|
||||
SLIST_REMOVE.3bsd \
|
||||
SLIST_REMOVE_AFTER.3bsd \
|
||||
SLIST_REMOVE_HEAD.3bsd \
|
||||
SLIST_REMOVE_PREVPTR.3bsd \
|
||||
SLIST_SWAP.3bsd \
|
||||
SPLAY_EMPTY.3bsd \
|
||||
SPLAY_ENTRY.3bsd \
|
||||
SPLAY_FIND.3bsd \
|
||||
SPLAY_FOREACH.3bsd \
|
||||
SPLAY_GENERATE.3bsd \
|
||||
SPLAY_HEAD.3bsd \
|
||||
SPLAY_INIT.3bsd \
|
||||
SPLAY_INITIALIZER.3bsd \
|
||||
SPLAY_INSERT.3bsd \
|
||||
SPLAY_LEFT.3bsd \
|
||||
SPLAY_MAX.3bsd \
|
||||
SPLAY_MIN.3bsd \
|
||||
SPLAY_NEXT.3bsd \
|
||||
SPLAY_PROTOTYPE.3bsd \
|
||||
SPLAY_REMOVE.3bsd \
|
||||
SPLAY_RIGHT.3bsd \
|
||||
SPLAY_ROOT.3bsd \
|
||||
STAILQ_CLASS_ENTRY.3bsd \
|
||||
STAILQ_CLASS_HEAD.3bsd \
|
||||
STAILQ_CONCAT.3bsd \
|
||||
STAILQ_EMPTY.3bsd \
|
||||
STAILQ_ENTRY.3bsd \
|
||||
STAILQ_FIRST.3bsd \
|
||||
STAILQ_FOREACH.3bsd \
|
||||
STAILQ_FOREACH_FROM.3bsd \
|
||||
STAILQ_FOREACH_FROM_SAFE.3bsd \
|
||||
STAILQ_FOREACH_SAFE.3bsd \
|
||||
STAILQ_HEAD.3bsd \
|
||||
STAILQ_HEAD_INITIALIZER.3bsd \
|
||||
STAILQ_INIT.3bsd \
|
||||
STAILQ_INSERT_AFTER.3bsd \
|
||||
STAILQ_INSERT_HEAD.3bsd \
|
||||
STAILQ_INSERT_TAIL.3bsd \
|
||||
STAILQ_LAST.3bsd \
|
||||
STAILQ_NEXT.3bsd \
|
||||
STAILQ_REMOVE.3bsd \
|
||||
STAILQ_REMOVE_AFTER.3bsd \
|
||||
STAILQ_REMOVE_HEAD.3bsd \
|
||||
STAILQ_SWAP.3bsd \
|
||||
TAILQ_CLASS_ENTRY.3bsd \
|
||||
TAILQ_CLASS_HEAD.3bsd \
|
||||
TAILQ_CONCAT.3bsd \
|
||||
TAILQ_EMPTY.3bsd \
|
||||
TAILQ_ENTRY.3bsd \
|
||||
TAILQ_FIRST.3bsd \
|
||||
TAILQ_FOREACH.3bsd \
|
||||
TAILQ_FOREACH_FROM.3bsd \
|
||||
TAILQ_FOREACH_FROM_SAFE.3bsd \
|
||||
TAILQ_FOREACH_REVERSE.3bsd \
|
||||
TAILQ_FOREACH_REVERSE_FROM.3bsd \
|
||||
TAILQ_FOREACH_REVERSE_FROM_SAFE.3bsd \
|
||||
TAILQ_FOREACH_REVERSE_SAFE.3bsd \
|
||||
TAILQ_FOREACH_SAFE.3bsd \
|
||||
TAILQ_HEAD.3bsd \
|
||||
TAILQ_HEAD_INITIALIZER.3bsd \
|
||||
TAILQ_INIT.3bsd \
|
||||
TAILQ_INSERT_AFTER.3bsd \
|
||||
TAILQ_INSERT_BEFORE.3bsd \
|
||||
TAILQ_INSERT_HEAD.3bsd \
|
||||
TAILQ_INSERT_TAIL.3bsd \
|
||||
TAILQ_LAST.3bsd \
|
||||
TAILQ_NEXT.3bsd \
|
||||
TAILQ_PREV.3bsd \
|
||||
TAILQ_REMOVE.3bsd \
|
||||
TAILQ_SWAP.3bsd \
|
||||
TIMESPEC_TO_TIMEVAL.3bsd \
|
||||
TIMEVAL_TO_TIMESPEC.3bsd \
|
||||
arc4random.3bsd \
|
||||
arc4random_addrandom.3bsd \
|
||||
arc4random_buf.3bsd \
|
||||
arc4random_stir.3bsd \
|
||||
arc4random_uniform.3bsd \
|
||||
be16dec.3bsd \
|
||||
be16enc.3bsd \
|
||||
be32dec.3bsd \
|
||||
be32enc.3bsd \
|
||||
be64dec.3bsd \
|
||||
be64enc.3bsd \
|
||||
bit_alloc.3bsd \
|
||||
bit_clear.3bsd \
|
||||
bit_decl.3bsd \
|
||||
bit_ffc.3bsd \
|
||||
bit_ffs.3bsd \
|
||||
bit_nclear.3bsd \
|
||||
bit_nset.3bsd \
|
||||
bit_set.3bsd \
|
||||
bit_test.3bsd \
|
||||
bitstr_size.3bsd \
|
||||
bitstring.3bsd \
|
||||
byteorder.3bsd \
|
||||
closefrom.3bsd \
|
||||
dehumanize_number.3bsd \
|
||||
errc.3bsd \
|
||||
expand_number.3bsd \
|
||||
explicit_bzero.3bsd \
|
||||
fgetln.3bsd \
|
||||
fgetwln.3bsd \
|
||||
flopen.3bsd \
|
||||
freezero.3bsd \
|
||||
fmtcheck.3bsd \
|
||||
fparseln.3bsd \
|
||||
fpurge.3bsd \
|
||||
funopen.3bsd \
|
||||
getbsize.3bsd \
|
||||
getmode.3bsd \
|
||||
getpeereid.3bsd \
|
||||
getprogname.3bsd \
|
||||
gid_from_group.3bsd \
|
||||
group_from_gid.3bsd \
|
||||
heapsort.3bsd \
|
||||
humanize_number.3bsd \
|
||||
le16dec.3bsd \
|
||||
le16enc.3bsd \
|
||||
le32dec.3bsd \
|
||||
le32enc.3bsd \
|
||||
le64dec.3bsd \
|
||||
le64enc.3bsd \
|
||||
libbsd.7 \
|
||||
md5.3bsd \
|
||||
mergesort.3bsd \
|
||||
nlist.3bsd \
|
||||
pidfile.3bsd \
|
||||
pidfile_close.3bsd \
|
||||
pidfile_open.3bsd \
|
||||
pidfile_remove.3bsd \
|
||||
pidfile_write.3bsd \
|
||||
pwcache.3bsd \
|
||||
queue.3bsd \
|
||||
radixsort.3bsd \
|
||||
readpassphrase.3bsd \
|
||||
reallocarray.3bsd \
|
||||
reallocf.3bsd \
|
||||
recallocarray.3bsd \
|
||||
setmode.3bsd \
|
||||
setproctitle.3bsd \
|
||||
setproctitle_init.3bsd \
|
||||
setprogname.3bsd \
|
||||
sl_add.3bsd \
|
||||
sl_delete.3bsd \
|
||||
sl_find.3bsd \
|
||||
sl_free.3bsd \
|
||||
sl_init.3bsd \
|
||||
sradixsort.3bsd \
|
||||
stringlist.3bsd \
|
||||
strlcat.3bsd \
|
||||
strlcpy.3bsd \
|
||||
strmode.3bsd \
|
||||
strnstr.3bsd \
|
||||
strnunvis.3bsd \
|
||||
strnvis.3bsd \
|
||||
strtoi.3bsd \
|
||||
strtonum.3bsd \
|
||||
strtou.3bsd \
|
||||
strunvis.3bsd \
|
||||
strvis.3bsd \
|
||||
strvisx.3bsd \
|
||||
timeradd.3bsd \
|
||||
timerclear.3bsd \
|
||||
timercmp.3bsd \
|
||||
timerisset.3bsd \
|
||||
timersub.3bsd \
|
||||
timespec.3bsd \
|
||||
timespecadd.3bsd \
|
||||
timespecclear.3bsd \
|
||||
timespeccmp.3bsd \
|
||||
timespecisset.3bsd \
|
||||
timespecsub.3bsd \
|
||||
timeval.3bsd \
|
||||
tree.3bsd \
|
||||
uid_from_user.3bsd \
|
||||
unvis.3bsd \
|
||||
user_from_uid.3bsd \
|
||||
vis.3bsd \
|
||||
wcslcat.3bsd \
|
||||
wcslcpy.3bsd \
|
||||
$(nil)
|
1
man/RB_EMPTY.3bsd
Normal file
1
man/RB_EMPTY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_ENTRY.3bsd
Normal file
1
man/RB_ENTRY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_FIND.3bsd
Normal file
1
man/RB_FIND.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_FOREACH.3bsd
Normal file
1
man/RB_FOREACH.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_FOREACH_REVERSE.3bsd
Normal file
1
man/RB_FOREACH_REVERSE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_GENERATE.3bsd
Normal file
1
man/RB_GENERATE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_GENERATE_STATIC.3bsd
Normal file
1
man/RB_GENERATE_STATIC.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_HEAD.3bsd
Normal file
1
man/RB_HEAD.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_INIT.3bsd
Normal file
1
man/RB_INIT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_INITIALIZER.3bsd
Normal file
1
man/RB_INITIALIZER.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_INSERT.3bsd
Normal file
1
man/RB_INSERT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_LEFT.3bsd
Normal file
1
man/RB_LEFT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_MAX.3bsd
Normal file
1
man/RB_MAX.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_MIN.3bsd
Normal file
1
man/RB_MIN.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_NEXT.3bsd
Normal file
1
man/RB_NEXT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_NFIND.3bsd
Normal file
1
man/RB_NFIND.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_PARENT.3bsd
Normal file
1
man/RB_PARENT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_PREV.3bsd
Normal file
1
man/RB_PREV.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_PROTOTYPE.3bsd
Normal file
1
man/RB_PROTOTYPE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_PROTOTYPE_STATIC.3bsd
Normal file
1
man/RB_PROTOTYPE_STATIC.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_REMOVE.3bsd
Normal file
1
man/RB_REMOVE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_RIGHT.3bsd
Normal file
1
man/RB_RIGHT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/RB_ROOT.3bsd
Normal file
1
man/RB_ROOT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/tree.3bsd
|
1
man/SLIST_CLASS_ENTRY.3bsd
Normal file
1
man/SLIST_CLASS_ENTRY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_CLASS_HEAD.3bsd
Normal file
1
man/SLIST_CLASS_HEAD.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_EMPTY.3bsd
Normal file
1
man/SLIST_EMPTY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_ENTRY.3bsd
Normal file
1
man/SLIST_ENTRY.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_FIRST.3bsd
Normal file
1
man/SLIST_FIRST.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_FOREACH.3bsd
Normal file
1
man/SLIST_FOREACH.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_FOREACH_FROM.3bsd
Normal file
1
man/SLIST_FOREACH_FROM.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_FOREACH_FROM_SAFE.3bsd
Normal file
1
man/SLIST_FOREACH_FROM_SAFE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_FOREACH_SAFE.3bsd
Normal file
1
man/SLIST_FOREACH_SAFE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_HEAD.3bsd
Normal file
1
man/SLIST_HEAD.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_HEAD_INITIALIZER.3bsd
Normal file
1
man/SLIST_HEAD_INITIALIZER.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_INIT.3bsd
Normal file
1
man/SLIST_INIT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_INSERT_AFTER.3bsd
Normal file
1
man/SLIST_INSERT_AFTER.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_INSERT_HEAD.3bsd
Normal file
1
man/SLIST_INSERT_HEAD.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_NEXT.3bsd
Normal file
1
man/SLIST_NEXT.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
1
man/SLIST_REMOVE.3bsd
Normal file
1
man/SLIST_REMOVE.3bsd
Normal file
@@ -0,0 +1 @@
|
||||
.so man3/queue.3bsd
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user